DiskStats.hpp 3.65 KB
Newer Older
1
2
3
4
5
6
7
/*
 * @project        The CERN Tape Archive (CTA)
 * @copyright      Copyright(C) 2021 CERN
 * @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
23
24
25
26
27
28
29
30
31

#pragma once

namespace castor {
namespace tape {
namespace tapeserver {
namespace daemon {
  /**
   * 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.
   */
  struct DiskStats {
    /** Mounting time, in seconds */
    double openingTime;
    
32
    /** Closing time, in seconds */
33
34
35
36
37
    double closingTime;
    
    /** Cumulated time spent computing checksums */
    double checksumingTime;
    
38
39
    /** Cumulated time spent calling read/write methods on the disk client */
    double readWriteTime;
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    
    /** Cumulated time spent waiting for data blocks. */
    double waitDataTime;
    
    /** Cumulated time spent waiting for free memory. */
    double waitFreeMemoryTime;
    
    /** Cumulated time spent by the tape thread waiting for a task. */
    double waitInstructionsTime;
    
    /** Cumulated time spent reporting */
    double waitReportingTime;
  
    /** Cumulated time spent reporting */
    double checkingErrorTime;
    
56
57
58
    /** Time spent between the opening of the file and the completion of the transfer */
    double transferTime;
    
59
60
61
    /** Total real time spent by the thread/pool. */
    double totalTime;
    
62
63
64
65
66
67
    /** Cumulated data volume (actual payload), in bytes. */
    uint64_t dataVolume;
    
    /** Count of files actually transfered in the session. */
    uint64_t filesCount;
    
68
69
70
71
72
73
    /** Archive file ID of the current file */
    uint64_t fileId;

    /** Destination URL for the current file */
    std::string dstURL;

74
75
    /** Constructor: all defaults are zero */
    DiskStats():  openingTime(0.0), 
76
    closingTime(0.0),
77
    checksumingTime(0.0),
78
    readWriteTime(0.0),
79
80
81
82
    waitDataTime(0.0), 
    waitFreeMemoryTime(0.0),
    waitInstructionsTime(0.0),
    waitReportingTime(0.0), 
83
    checkingErrorTime(0.0),
84
    transferTime(0.0),
85
    totalTime(0.0),
86
    dataVolume(0),
87
88
89
    filesCount(0),
    fileId(0),
    dstURL("") {}
90
91
92
93
94
95
96
    
    /** Accumulate contents of another stats block */

    void operator+=(const DiskStats& other) {
      openingTime += other.openingTime;
      closingTime += other.closingTime;
      checksumingTime += other.checksumingTime;
97
      readWriteTime += other.readWriteTime;
98
99
100
101
102
      waitDataTime += other.waitDataTime;
      waitFreeMemoryTime += other.waitFreeMemoryTime;
      waitInstructionsTime += other.waitInstructionsTime;
      waitReportingTime += other.waitReportingTime;
      checkingErrorTime += other.checkingErrorTime;
103
104
      transferTime += other.transferTime; // Transfer times can be cumulated and used to compute the average file bandwidth over a disk pool
      // total time is not a cumulative member. It is used to represent real time.
105
106
107
108
109
110
111
      filesCount += other.filesCount;
      dataVolume += other.dataVolume;
    }
  };
  
}}}}