- Timestamp:
- 06/08/11 18:28:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/dataLogger.cc
r10930 r10931 77 77 78 78 //Dim structures 79 ///Distributes the writ ting statistics79 ///Distributes the writing statistics 80 80 struct DataLoggerStats { 81 81 long sizeWritten; … … 129 129 #endif 130 130 runNumber = 0; 131 //give it a meaningless, 0 time to distinguish with actual, valid times132 time = Time(0,0);133 131 } 134 132 ///default destructor … … 138 136 } 139 137 ///copy operator 138 /* 140 139 void operator = (const RunNumberType& other) 141 140 { … … 151 150 runFitsFile = other.runFitsFile; 152 151 #endif 153 } 152 }*/ 153 154 154 ///copy constructor 155 155 RunNumberType(const RunNumberType& other) … … 169 169 170 170 void addServiceToOpenedFits(const string& fileName, const string& serviceName) 171 {//most likely I should add this service name. 172 //the only case for which I should not add it is if a service disapeared, hence the file was closed 173 //and reopened again. Unlikely to happen, but well it may 174 bool found = false; 175 for (vector<string>::iterator it=openedFits[fileName].begin(); it!=openedFits[fileName].end(); it++) 176 if (*it == serviceName) 177 { 178 found = true; 179 break; 180 } 181 if (!found) 171 { 172 //most likely I should add this service name. 173 //the only case for which I should not add it is if a service disapeared, hence the file was closed 174 //and reopened again. Unlikely to happen, but well it may 175 176 if (find(openedFits[fileName].begin(), openedFits[fileName].end(), 177 serviceName)==openedFits[fileName].end()) 182 178 openedFits[fileName].push_back(serviceName); 183 179 } … … 203 199 uint32_t runNumber; 204 200 ///copy operator 201 /* 205 202 void operator = (const SubscriptionType& other) 206 203 { … … 214 211 fConv = other.fConv; 215 212 runNumber = other.runNumber; 216 } 217 ///copy constructor 213 }*/ 214 215 /* ///copy constructor 218 216 SubscriptionType(const SubscriptionType& other) 219 217 { … … 227 225 fConv = other.fConv; 228 226 runNumber = other.runNumber; 229 } 227 }*/ 230 228 ///Dim info constructor 231 SubscriptionType(DimStampedInfo* info )229 SubscriptionType(DimStampedInfo* info=NULL) 232 230 { 233 231 dimInfo = shared_ptr<DimStampedInfo>(info); … … 236 234 } 237 235 ///default constructor 238 SubscriptionType()236 /* SubscriptionType() 239 237 { 240 238 dimInfo = shared_ptr<DimStampedInfo>(); 241 239 fConv = shared_ptr<Converter>(); 242 240 runNumber = 0; 243 } 241 }*/ 244 242 ///default destructor 245 243 ~SubscriptionType() … … 380 378 NumSubAndFitsType fNumSubAndFitsData; 381 379 ///Small function for calculating the total size written so far 382 void calculateTotalSizeWritten(DataLoggerStats& statVar, bool& shouldWarn, bool isPrinting);380 bool calculateTotalSizeWritten(DataLoggerStats& statVar, bool isPrinting); 383 381 384 382 /*************************************************** … … 417 415 void RemoveOldestRunNumber(); 418 416 ///retrieves the size of a file 419 off_t GetFileSize( string&);417 off_t GetFileSize(const string&); 420 418 ///Get the digits of year, month and day for filenames and paths 421 419 void GetYearMonthDayForFiles(unsigned short& year, unsigned short& month, unsigned short& day); … … 616 614 { 617 615 //get the size of the file we're about to open 618 if (fFileSizesMap.find(fileName) == fFileSizesMap.end()) 619 { 620 if (nightly) 621 fBaseSizeNightly += GetFileSize(fileName); 622 else 623 fBaseSizeRun += GetFileSize(fileName); 624 fFileSizesMap[fileName] = 0; 625 return true; 626 } 627 return false; 616 if (fFileSizesMap.find(fileName) != fFileSizesMap.end()) 617 return false; 618 619 if (nightly) 620 fBaseSizeNightly += GetFileSize(fileName); 621 else 622 fBaseSizeRun += GetFileSize(fileName); 623 fFileSizesMap[fileName] = 0; 624 return true; 628 625 } 629 626 … … 754 751 //! @return the size of the file on disk, in bytes. 0 if the file does not exist or if an error occured 755 752 // 756 off_t DataLogger::GetFileSize( string& fileName)753 off_t DataLogger::GetFileSize(const string& fileName) 757 754 { 758 755 errno = 0; … … 784 781 } 785 782 CreateFitsGrouping(fRunNumber.front().openedFits, fRunNumber.front().runNumber); 783 786 784 //crawl through the subscriptions to see if there are still corresponding fits files opened. 787 SubscriptionsListType::iterator x;788 map<string, SubscriptionType>::iterator y;789 for (x=fServiceSubscriptions.begin(); x != fServiceSubscriptions.end(); x++)790 for (y=x->second.begin(); y !=x->second.end(); y++)785 for (SubscriptionsListType::iterator x=fServiceSubscriptions.begin(); 786 x!=fServiceSubscriptions.end(); x++) 787 for (map<string, SubscriptionType>::iterator y=x->second.begin(); 788 y!=x->second.end(); y++) 791 789 if (y->second.runFile.fRunNumber == fRunNumber.front().runNumber && y->second.runFile.IsOpen()) 792 790 { … … 813 811 //! @param isPrinting whether this function was called from the PRINT command or not. If so, displays relevant information 814 812 // 815 void DataLogger::calculateTotalSizeWritten(DataLoggerStats& statVar, bool& shouldWarn, bool isPrinting)813 bool DataLogger::calculateTotalSizeWritten(DataLoggerStats& statVar, bool isPrinting) 816 814 { 817 815 #ifdef HAVE_FITS … … 822 820 Message(str); 823 821 } 824 SubscriptionsListType::iterator x; 825 map<string, SubscriptionType>::iterator y; 826 ///TODO the grouping file is dealt with several times. This should not be a problem but well, better to fix it I guess. 827 for (x=fServiceSubscriptions.begin(); x != fServiceSubscriptions.end(); x++) 828 { 829 for (y=x->second.begin(); y != x->second.end(); y++) 822 823 ///TODO the grouping file is dealt with several times. This should not be a problem but well, better to fix it I guess. 824 for (SubscriptionsListType::const_iterator x=fServiceSubscriptions.begin(); 825 x!=fServiceSubscriptions.end(); x++) 826 { 827 for (map<string, SubscriptionType>::const_iterator y=x->second.begin(); 828 y!=x->second.end(); y++) 830 829 { 831 830 if (y->second.runFile.IsOpen()) … … 861 860 #endif 862 861 } 862 863 bool shouldWarn = false; 863 864 struct statvfs vfs; 864 865 if (!statvfs(fNightlyFilePath.c_str(), &vfs)) 865 {866 866 statVar.freeSpace = vfs.f_bsize*vfs.f_bavail; 867 shouldWarn = false;868 }869 867 else 870 868 { … … 873 871 if (!shouldWarn) 874 872 Error(str); 875 shouldWarn = true;876 873 statVar.freeSpace = -1; 877 874 } 878 875 //sum up all the file sizes. past and present 879 876 statVar.sizeWritten = 0; 880 for (map<string, long>:: iterator it=fFileSizesMap.begin(); it != fFileSizesMap.end(); it++)877 for (map<string, long>::const_iterator it=fFileSizesMap.begin(); it != fFileSizesMap.end(); it++) 881 878 statVar.sizeWritten += it->second; 882 879 statVar.sizeWritten -= fBaseSizeNightly; 883 880 statVar.sizeWritten -= fBaseSizeRun; 881 882 return shouldWarn; 884 883 } 885 884 //static members initialization … … 922 921 DimDescribedService srvc ("DATA_LOGGER/STATS", "X:3", statVar, "Add description here"); 923 922 fPreviousSize = 0; 924 bool statWarning = false;923 //bool statWarning = false; 925 924 bool resetDone = false; 926 925 //loop-wait for broadcast … … 967 966 sleep(fStatsPeriodDuration); 968 967 //update the fits files sizes 969 calculateTotalSizeWritten(statVar, statWarning, false);968 /*statWarning =*/ calculateTotalSizeWritten(statVar, false); 970 969 if (fStatsPeriodDuration == 0.0f) 971 970 continue; … … 979 978 { 980 979 ostringstream str; 981 str << "Size written: " << statVar.sizeWritten/1000 << " kB; writ ting rate: ";980 str << "Size written: " << statVar.sizeWritten/1000 << " kB; writing rate: "; 982 981 str << statVar.writingRate/1000 << " kB/s; free space: "; 983 982 str << statVar.freeSpace/(1000*100) << " MB"; … … 1081 1080 "|NumOpenFiles[int]:number of files currently open by the data logger"); 1082 1081 1083 //black/white list1084 fBlackList.clear();1085 fWhiteList.clear();1086 1082 //services parameters 1087 1083 fDebugIsOn = false; … … 1094 1090 (boost::bind(&DataLogger::SetDebugOnOff, this, _1)) 1095 1091 ("Switch debug mode on off. Debug mode prints ifnormation about every service written to a file." 1096 "|Enable[bool]:Enable of disable debu ig mode (yes/no).");1092 "|Enable[bool]:Enable of disable debug mode (yes/no)."); 1097 1093 1098 1094 AddEvent(fStatsPeriod, "F", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready) … … 1367 1363 { 1368 1364 list<RunNumberType>::reverse_iterator rit; 1369 for (rit=fRunNumber.rbegin(); rit !=fRunNumber.rend(); rit++)1365 for (rit=fRunNumber.rbegin(); rit!=fRunNumber.rend(); rit++) 1370 1366 { 1371 1367 if (rit->time < cTime) //this is the run number that we want to use … … 1497 1493 ostringstream str; 1498 1494 str << "Active Run Numbers:"; 1499 for (list<RunNumberType>:: iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++)1495 for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++) 1500 1496 str << " " << it->runNumber; 1501 1497 if (fRunNumber.size()==0) … … 1511 1507 Message("Nightly report-file: OPEN"); 1512 1508 1513 for (list<RunNumberType>:: iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++)1509 for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++) 1514 1510 { 1515 1511 #ifdef RUN_LOGS … … 1521 1517 } 1522 1518 1523 bool statWarning = false;1524 1519 DataLoggerStats statVar; 1525 calculateTotalSizeWritten(statVar, statWarning, false); 1520 /*const bool statWarning =*/ calculateTotalSizeWritten(statVar, false); 1521 1526 1522 Message("----------------- STATS ------------------"); 1527 1523 str.str(""); … … 1551 1547 1552 1548 Message("--------------- BLOCK LIST ---------------"); 1553 for (set<string>:: iterator it=fBlackList.begin(); it != fBlackList.end(); it++)1549 for (set<string>::const_iterator it=fBlackList.begin(); it != fBlackList.end(); it++) 1554 1550 Message(" -> "+*it); 1555 1551 if (fBlackList.size()==0) … … 1557 1553 1558 1554 Message("--------------- ALLOW LIST ---------------"); 1559 for (set<string>:: iterator it=fWhiteList.begin(); it != fWhiteList.end(); it++)1555 for (set<string>::const_iterator it=fWhiteList.begin(); it != fWhiteList.end(); it++) 1560 1556 Message(" -> "+*it); 1561 1557 if (fWhiteList.size()==0) … … 1565 1561 Message("The following servers and/or services will"); 1566 1562 Message("be grouped into a single fits file:"); 1567 for (set<string>:: iterator it=fGrouping.begin(); it != fGrouping.end(); it++)1563 for (set<string>::const_iterator it=fGrouping.begin(); it != fGrouping.end(); it++) 1568 1564 Message(" -> "+*it); 1569 1565 if (fGrouping.size()==0) … … 1841 1837 if (!sub.runFile.IsOpen() && (GetCurrentState() == kSM_Logging)) 1842 1838 {//will we find this service in the grouping list ? 1843 for (set<string>:: iterator it=fGrouping.begin(); it!=fGrouping.end(); it++)1839 for (set<string>::const_iterator it=fGrouping.begin(); it!=fGrouping.end(); it++) 1844 1840 { 1845 1841 if (serviceName.find(*it) != string::npos) … … 2087 2083 CCfits::FITS* groupFile; 2088 2084 unsigned int numFilesToGroup = 0; 2089 for (map<string, vector<string> >:: iterator it=filesToGroup.begin(); it != filesToGroup.end(); it++)2085 for (map<string, vector<string> >::const_iterator it=filesToGroup.begin(); it != filesToGroup.end(); it++) 2090 2086 { 2091 2087 numFilesToGroup += it->second.size(); … … 2158 2154 2159 2155 int i=1; 2160 for (map<string, vector<string> >:: iterator it=filesToGroup.begin(); it!=filesToGroup.end(); it++)2161 for (vector<string>:: iterator jt=it->second.begin(); jt != it->second.end(); jt++, i++)2156 for (map<string, vector<string> >::const_iterator it=filesToGroup.begin(); it!=filesToGroup.end(); it++) 2157 for (vector<string>::const_iterator jt=it->second.begin(); jt != it->second.end(); jt++, i++) 2162 2158 { 2163 2159 strcpy(startOfLocation, it->first.c_str()); … … 2199 2195 Debug("Stopping Run Logging..."); 2200 2196 } 2201 for (list<RunNumberType>:: iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)2197 for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++) 2202 2198 { 2203 2199 #ifdef RUN_LOGS … … 2300 2296 fWhiteList.clear(); 2301 2297 2298 //Adding entries that should ALWAYS be ignored 2299 //fBlackList.insert("DATA_LOGGER/"); 2300 fBlackList.insert("/SERVICE_LIST"); 2301 fBlackList.insert("DIS_DNS/"); 2302 2302 2303 if (conf.Has("block")) 2303 2304 { … … 2305 2306 2306 2307 fBlackList.insert(vec.begin(), vec.end()); 2307 2308 //Adding entries that should ALWAYS be ignored2309 fBlackList.insert("DATA_LOGGER/");2310 fBlackList.insert("/SERVICE_LIST");2311 fBlackList.insert("DIS_DNS/");2312 2308 } 2313 2309
Note:
See TracChangeset
for help on using the changeset viewer.