Changeset 10974
- Timestamp:
- 06/10/11 09:54:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/dataLogger.cc
r10971 r10974 239 239 string fFullNightlyReportFileName; 240 240 ///variable to track when the statistic were last calculated 241 double fPreviousStatsUpdateTime;242 double fPreviousOldRunNumberCheck;241 Time fPreviousStatsUpdateTime; 242 Time fPreviousOldRunNumberCheck; 243 243 ///boolean to know whether we should close and reopen daily files or not 244 244 bool fDailyFileDayChangedAlready; … … 396 396 ///Checks if a given path exist 397 397 bool DoesPathExist(string path); 398 ///Check if the statistics service should be updated, and if so, do it 399 void UpdateStatisticsService(); 400 ///Check if old run numbers can be trimmed, and if so, do it 401 void TrimOldRunNumbers(); 398 402 public: 399 403 ///Create a given directory … … 1104 1108 } 1105 1109 } 1106 1110 // -------------------------------------------------------------------------- 1111 // 1112 //! checks if the statistic service should be updated, and if so, do it 1113 // 1114 void DataLogger::UpdateStatisticsService() 1115 { 1116 //update the fits files sizes 1117 const Time cTime = Time(); 1118 1119 if ((fStatsPeriodDuration == 0) || ((cTime - fPreviousStatsUpdateTime).total_seconds() < fStatsPeriodDuration)) 1120 return; 1121 1122 calculateTotalSizeWritten(fStatVar, false); 1123 fStatVar.writingRate = (fStatVar.sizeWritten - fPreviousSize)/((cTime - fPreviousStatsUpdateTime).total_seconds()); 1124 fPreviousSize = fStatVar.sizeWritten; 1125 fPreviousStatsUpdateTime = cTime; 1126 //update the service. No need to check if data has been written, because some must have been, otherwise we would not have hit this piece of code 1127 fStatsMonitoring->updateService(); 1128 1129 if(fDebugIsOn) 1130 { 1131 ostringstream str; 1132 str << "Size written: " << fStatVar.sizeWritten/1000 << " kB; writing rate: "; 1133 str << fStatVar.writingRate/1000 << " kB/s; free space: "; 1134 str << fStatVar.freeSpace/(1000*1000) << " MB"; 1135 Debug(str); 1136 } 1137 } 1138 // -------------------------------------------------------------------------- 1139 // 1140 //! checks if old run numbers should be trimmed and if so, do it 1141 // 1142 void DataLogger::TrimOldRunNumbers() 1143 { 1144 const Time cTime = Time(); 1145 1146 if ((cTime - fPreviousOldRunNumberCheck).total_seconds() < fRunNumberTimeout*60) 1147 return; 1148 1149 while (fRunNumber.size() > 1 && (cTime - fRunNumber.back().time) > boost::posix_time::minutes(fRunNumberTimeout)) 1150 { 1151 RemoveOldestRunNumber(); 1152 } 1153 fPreviousOldRunNumberCheck = cTime; 1154 } 1107 1155 // -------------------------------------------------------------------------- 1108 1156 // … … 1154 1202 1155 1203 //update the fits files sizes 1156 const Time cTime = Time(); 1157 if ((fStatsPeriodDuration != 0) && ((cTime.Mjd() - fPreviousStatsUpdateTime)*24*60*60 > fStatsPeriodDuration)) 1158 { 1159 calculateTotalSizeWritten(fStatVar, false); 1160 fStatVar.writingRate = (fStatVar.sizeWritten - fPreviousSize)/((cTime.Mjd() - fPreviousStatsUpdateTime)*24*60*60); 1161 fPreviousSize = fStatVar.sizeWritten; 1162 fPreviousStatsUpdateTime = cTime.Mjd(); 1163 //update the service. No need to check if data has been written, because some must have been, otherwise we would not have hit this piece of code 1164 fStatsMonitoring->updateService(); 1165 1166 if(fDebugIsOn) 1167 { 1168 ostringstream str; 1169 str << "Size written: " << fStatVar.sizeWritten/1000 << " kB; writing rate: "; 1170 str << fStatVar.writingRate/1000 << " kB/s; free space: "; 1171 str << fStatVar.freeSpace/(1000*1000) << " MB"; 1172 Debug(str); 1173 } 1174 } 1175 if ((cTime.Mjd() - fPreviousOldRunNumberCheck)*24*60 >= fRunNumberTimeout) 1176 { 1177 while (fRunNumber.size() > 1 && (cTime - fRunNumber.back().time) > boost::posix_time::minutes(fRunNumberTimeout)) 1178 { 1179 RemoveOldestRunNumber(); 1180 } 1181 fPreviousOldRunNumberCheck = cTime.Mjd(); 1182 } 1204 UpdateStatisticsService(); 1205 1206 //remove old run numbers 1207 TrimOldRunNumbers(); 1183 1208 } 1184 1209 // --------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.