TapeSessionStats.hpp 5.54 KB
Newer Older
1
2
/*
 * @project        The CERN Tape Archive (CTA)
3
 * @copyright      Copyright(C) 2003-2021 CERN
4
5
6
7
 * @license        This program is free software: you can redistribute it and/or modify
 *                 it under the terms of the GNU General Public License as published by
 *                 the Free Software Foundation, either version 3 of the License, or
 *                 (at your option) any later version.
8
 *
9
10
11
12
 *                 This program is distributed in the hope that it will be useful,
 *                 but WITHOUT ANY WARRANTY; without even the implied warranty of
 *                 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *                 GNU General Public License for more details.
13
 *
14
15
16
 *                 You should have received a copy of the GNU General Public License
 *                 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
17
18
19
20
21
22

#pragma once

namespace castor {
namespace tape {
namespace tapeserver {
23
namespace daemon {
24
25
26
27
  /**
   * Structure holding the timers and stats for the tape session. We use doubles, 
   * for time and all measurements are in seconds or uint64_t for bytes.
   */
28
  struct TapeSessionStats {
29
30
    /** Mounting time, in seconds */
    double mountTime;
31
    
32
33
    /** Cumulated positioning time, in seconds. */
    double positionTime;
34
    
35
36
    /** Cumulated time spent computing checksums */
    double checksumingTime;
37
    
38
39
    /** Cumulated time spent reading and writing data with the drive (for both data and headers). */
    double readWriteTime;
40
    
41
42
    /** Cumulated time spent flushing */
    double flushTime;
43
    
44
45
    /** Unload time, in seconds. */
    double unloadTime;
46
    
47
48
    /** Unmount time, in seconds. */
    double unmountTime;
49
50
51
52
   
    /** Time spent running encryption control scripts */
    double encryptionControlTime;
 
53
    /** Cumulated time spent waiting for data blocks. */
54
    double waitDataTime;
55
    
56
57
    /** Cumulated time spent waiting for free memory. */
    double waitFreeMemoryTime;
58
    
59
60
    /** Cumulated time spent by the tape thread waiting for a task. */
    double waitInstructionsTime;
61
    
62
63
    /** Cumulated time spent reporting */
    double waitReportingTime;
64
    
65
66
67
68
69
70
71
    /** Time spent during the session, except mounting, positioning and 
     * unloading / unmounting. This a derived value */
    double transferTime() const {
      return checksumingTime + readWriteTime + flushTime + waitDataTime +
              waitFreeMemoryTime + waitInstructionsTime + waitReportingTime;
    }
    
72
73
    /** Total time of the session, computed in parallel */
    double totalTime;
74
75
76
77
78

    /** Time to delivery data to the client equal disk threads totalTime 
     * for recall and the tape thread totalTime for migration
     */
    double deliveryTime;
79
    
80
81
    /** Cumulated data volume (actual payload), in bytes. */
    uint64_t dataVolume;
82
    
83
84
    /** Cumulated space used by file headers. */
    uint64_t headerVolume;
85
    
86
87
    /** Count of files actually transfered in the session. */
    uint64_t filesCount;
88
    
89
90
91
92
93
94
    /** Count of files coming from repack retrieve request transfered in the session.*/
    uint64_t repackFilesCount;
    
    /** Count of files coming from user retrieve request transfered in the session.*/
    uint64_t userFilesCount;
    
Michael Davis's avatar
Michael Davis committed
95
96
97
    /** Count of files coming from verify-only retrieve requests in the session.*/
    uint64_t verifiedFilesCount;
    
98
99
100
101
102
103
    /** Count of bytes coming from repack retrieve request transfered in the session.*/
    uint64_t repackBytesCount;
    
    /** Count of bytes coming from user retrieve request transfered in the session.*/
    uint64_t userBytesCount;
    
Michael Davis's avatar
Michael Davis committed
104
105
106
    /** Count of bytes coming from verify-only retrieve requests in the session.*/
    uint64_t verifiedBytesCount;
    
107
    static const uint64_t headerVolumePerFile = 3*80;
108
    static const uint64_t trailerVolumePerFile = 3*80;
109
    
110
    /** Constructor: all defaults are zero */
111
    TapeSessionStats():  mountTime(0.0), positionTime(0.0), checksumingTime(0.0),
112
    readWriteTime(0.0), flushTime(0.0), unloadTime(0.0), unmountTime(0.0),
113
114
    encryptionControlTime(0.0), waitDataTime(0.0), waitFreeMemoryTime(0.0),
    waitInstructionsTime(0.0), waitReportingTime(0.0), totalTime(0.0),
115
    deliveryTime(0.0), dataVolume(0), headerVolume(0), filesCount(0), repackFilesCount(0), 
Michael Davis's avatar
Michael Davis committed
116
117
    userFilesCount(0), verifiedFilesCount(0), repackBytesCount(0), userBytesCount(0),
    verifiedBytesCount(0) {}
118
    
119
    /** Accumulate contents of another stats block */
120
    void add(const TapeSessionStats& other) {
121
122
123
      mountTime += other.mountTime;
      positionTime += other.positionTime;
      checksumingTime += other.checksumingTime;
124
      readWriteTime += other.readWriteTime;
125
126
127
      flushTime += other.flushTime;
      unloadTime += other.unloadTime;
      unmountTime += other.unmountTime;
128
      encryptionControlTime += other.encryptionControlTime;
129
      waitDataTime += other.waitDataTime;
130
      waitFreeMemoryTime += other.waitFreeMemoryTime;
131
132
      waitInstructionsTime += other.waitInstructionsTime;
      waitReportingTime += other.waitReportingTime;
133
      // totalTime is not cumulative between threads (it's real time)
134
      // deliveryTime is not cumulative between thread
135
136
137
      dataVolume += other.dataVolume;
      headerVolume += other.headerVolume;
      filesCount += other.filesCount;
138
139
      repackFilesCount += other.repackFilesCount;
      userFilesCount += other.userFilesCount;
Michael Davis's avatar
Michael Davis committed
140
      verifiedFilesCount += other.verifiedFilesCount;
141
142
      repackBytesCount += other.repackBytesCount;
      userBytesCount += other.userBytesCount;
Michael Davis's avatar
Michael Davis committed
143
      verifiedBytesCount += other.verifiedBytesCount;
144
145
    }
  };
146
147
  
}}}}