DiskStats.hpp 3.79 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/******************************************************************************
 *
 * This file is part of the Castor project.
 * See http://castor.web.cern.ch/castor
 *
 * Copyright (C) 2014  CERN
 * 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 2
 * of the License, or (at your option) any later version.
 * 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.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * 
 *
 * @author Castor Dev team, castor-dev@cern.ch
 *****************************************************************************/

#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;
    
38
    /** Closing time, in seconds */
39
40
41
42
43
    double closingTime;
    
    /** Cumulated time spent computing checksums */
    double checksumingTime;
    
44
45
    /** Cumulated time spent calling read/write methods on the disk client */
    double readWriteTime;
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    
    /** 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;
    
62
63
64
    /** Time spent between the opening of the file and the completion of the transfer */
    double transferTime;
    
65
66
67
    /** Total real time spent by the thread/pool. */
    double totalTime;
    
68
69
70
71
72
73
    /** Cumulated data volume (actual payload), in bytes. */
    uint64_t dataVolume;
    
    /** Count of files actually transfered in the session. */
    uint64_t filesCount;
    
74
75
76
77
78
79
    /** Archive file ID of the current file */
    uint64_t fileId;

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

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

    void operator+=(const DiskStats& other) {
      openingTime += other.openingTime;
      closingTime += other.closingTime;
      checksumingTime += other.checksumingTime;
103
      readWriteTime += other.readWriteTime;
104
105
106
107
108
      waitDataTime += other.waitDataTime;
      waitFreeMemoryTime += other.waitFreeMemoryTime;
      waitInstructionsTime += other.waitInstructionsTime;
      waitReportingTime += other.waitReportingTime;
      checkingErrorTime += other.checkingErrorTime;
109
110
      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.
111
112
113
114
115
116
117
      filesCount += other.filesCount;
      dataVolume += other.dataVolume;
    }
  };
  
}}}}