CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FilesMonitorCollection.cc
Go to the documentation of this file.
1 // $Id: FilesMonitorCollection.cc,v 1.15 2011/07/07 09:22:45 mommsen Exp $
3 
4 #include <string>
5 #include <sstream>
6 #include <iomanip>
7 
10 
11 
12 namespace stor {
13 
15  MonitorCollection(updateInterval),
16  maxFileEntries_(250),
17  entryCounter_(0)
18  {
19  boost::mutex::scoped_lock sl(fileRecordsMutex_);
20  fileRecords_.set_capacity(maxFileEntries_);
21  }
22 
23 
26  {
27  boost::mutex::scoped_lock sl(fileRecordsMutex_);
28 
29  boost::shared_ptr<FileRecord> fileRecord(new FilesMonitorCollection::FileRecord());
30  fileRecord->entryCounter = entryCounter_++;
31  fileRecord->fileSize = 0;
32  fileRecord->eventCount = 0;
33  fileRecord->adler32 = 0;
34  fileRecords_.push_back(fileRecord);
35  return fileRecord;
36  }
37 
39  {
40  boost::mutex::scoped_lock sl(fileRecordsMutex_);
41  fileRecords = fileRecords_;
42  }
43 
44 
46  {
47  // nothing to do
48  }
49 
50 
52  {
53  boost::mutex::scoped_lock sl(fileRecordsMutex_);
54  fileRecords_.clear();
55  entryCounter_ = 0;
56  }
57 
58 
60  {
61  infoSpaceItems.push_back(std::make_pair("openFiles", &openFiles_));
62  infoSpaceItems.push_back(std::make_pair("closedFiles", &closedFiles_));
63  }
64 
65 
67  {
68  boost::mutex::scoped_lock sl(fileRecordsMutex_);
69 
70  openFiles_ = 0;
71 
72  for (
73  FileRecordList::const_iterator it = fileRecords_.begin(),
74  itEnd = fileRecords_.end();
75  it != itEnd;
76  ++it
77  )
78  {
79  if ( (*it)->isOpen )
80  ++openFiles_;
81  }
82 
84  }
85 
86 
88  {
89  switch (whyClosed)
90  {
91  case notClosed: return "open";
92  case runEnded: return "run ended";
93  case LSended: return "LS ended";
94  case timeout: return "timeout";
95  case size: return "file size";
96  case truncated: return "TRUNCATED";
97  case inaccessible:return "INACCESSIBLE";
98  default: return "unknown";
99  }
100  }
101 
102 
104  {
105  switch (status)
106  {
107  case open: return ( baseFilePath + "/open/" );
108  case closed: return ( baseFilePath + "/closed/" );
109  case current: return ( baseFilePath + (isOpen ? "/open/" : "/closed/") );
110  }
111  return "";
112  }
113 
114 
116  {
117  std::ostringstream fileName;
118  fileName << coreFileName
119  << "." << std::setfill('0') << std::setw(4) << fileCounter
120  << ".dat";
121  return fileName.str();
122  }
123 
124 } // namespace stor
125 
FilesMonitorCollection(const utils::Duration_t &updateInterval)
const FileRecordPtr getNewFileRecord()
boost::shared_ptr< FileRecord > FileRecordPtr
virtual void do_appendInfoSpaceItems(InfoSpaceItems &)
boost::posix_time::time_duration Duration_t
Definition: Utils.h:41
std::string filePath(FileStatus status=current)
void getFileRecords(FileRecordList &) const
xdata::UnsignedInteger32 closedFiles_
std::vector< std::pair< std::string, xdata::Serializable * > > InfoSpaceItems
xdata::UnsignedInteger32 openFiles_
boost::circular_buffer< FileRecordPtr > FileRecordList
tuple status
Definition: ntuplemaker.py:245