Changeset 11308
- Timestamp:
- 07/10/11 13:49:31 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/datalogger.cc
r11292 r11308 42 42 //**************************************************************** 43 43 #include <unistd.h> //for getting stat of opened files 44 #include <sys/statvfs.h> //for getting disk free space45 #include <sys/stat.h> //for getting files sizes44 //#include <sys/statvfs.h> //for getting disk free space 45 //#include <sys/stat.h> //for getting files sizes 46 46 #include <fstream> 47 47 … … 51 51 #include "Dim.h" 52 52 #include "Event.h" 53 #include "Time.h"54 53 #include "StateMachineDim.h" 55 #include "WindowLog.h"56 54 #include "Configuration.h" 57 #include "ServiceList.h"58 55 #include "Converter.h" 59 #include "MessageImp.h" 60 #include "DimDescriptionService.h" 56 #include "DimWriteStatistics.h" 61 57 62 58 #include "Description.h" 63 64 //#include "DimServiceInfoList.h"65 59 #include "DimNetwork.h" 66 60 … … 68 62 #include "Fits.h" 69 63 #endif 70 71 #include "FilesStatisticsService.h"72 64 73 65 //Dim structures … … 217 209 list<RunNumberType> fRunNumber; 218 210 ///old run numbers time-out delay (in seconds) 219 longfRunNumberTimeout;211 uint32_t fRunNumberTimeout; 220 212 ///previous run number. to check if changed while logging 221 213 int fPreviousRunNumber; … … 238 230 ///boolean to know whether we should close and reopen daily files or not 239 231 bool fDailyFileDayChangedAlready; 240 FilesStatisticsService fFilesStats; 232 233 DimWriteStatistics fFilesStats; 241 234 private: 242 235 /*************************************************** … … 907 900 // 908 901 DataLogger::DataLogger(ostream &out) : StateMachineDim(out, "DATA_LOGGER"), 909 fFilesStats("DATA_LOGGER", this)902 fFilesStats("DATA_LOGGER", *this) 910 903 { 911 904 //initialize member data … … 1004 997 "|Enable[bool]:Enable of disable debug mode (yes/no)."); 1005 998 1006 AddEvent("SET_STATISTICS_UPDATE_INTERVAL", " F", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)999 AddEvent("SET_STATISTICS_UPDATE_INTERVAL", "S:1", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready) 1007 1000 (boost::bind(&DataLogger::SetStatsPeriod, this, _1)) 1008 1001 ("Interval in which the data-logger statistics service (STATS) is updated." 1009 "|Interval[ s]:Floating point value in seconds.");1002 "|Interval[ms]:Value in milliseconds (<=0: no update)."); 1010 1003 1011 1004 AddEvent("ENABLE_FILENAME_SERVICES", "B:1", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready) … … 1125 1118 const Time cTime = Time(); 1126 1119 1127 if ( (cTime - fPreviousOldRunNumberCheck).total_seconds() < fRunNumberTimeout)1120 if (cTime - fPreviousOldRunNumberCheck < boost::posix_time::milliseconds(fRunNumberTimeout)) 1128 1121 return; 1129 1122 1130 while (fRunNumber.size() > 1 && (cTime - fRunNumber.back().time) > boost::posix_time:: seconds(fRunNumberTimeout))1123 while (fRunNumber.size() > 1 && (cTime - fRunNumber.back().time) > boost::posix_time::milliseconds(fRunNumberTimeout)) 1131 1124 { 1132 1125 RemoveOldestRunNumber(); … … 1594 1587 //timeout value 1595 1588 str.str(""); 1596 str << "Timeout delay for old run numbers: " << fRunNumberTimeout << " seconds";1589 str << "Timeout delay for old run numbers: " << fRunNumberTimeout << " ms"; 1597 1590 Message(str); 1598 1591 … … 1615 1608 } 1616 1609 1617 FileStatisticsData statVar; 1618 fFilesStats.GetTotalSizeWritten(statVar); 1610 const DimWriteStatistics::Stats statVar = fFilesStats.GetTotalSizeWritten(); 1619 1611 // /*const bool statWarning =*/ calculateTotalSizeWritten(statVar, true); 1620 1612 #ifdef HAVE_FITS … … 1738 1730 } 1739 1731 */ 1740 fFilesStats.Set StatPeriod(evt.GetFloat());1732 fFilesStats.SetUpdateInterval(evt.GetShort()); 1741 1733 return GetCurrentState(); 1742 1734 } … … 1798 1790 int DataLogger::SetRunTimeoutDelay(const Event& evt) 1799 1791 { 1800 const long backupTimeout = fRunNumberTimeout; 1801 fRunNumberTimeout = evt.GetXtra(); 1802 1803 if (fRunNumberTimeout == 0) 1804 { 1805 fRunNumberTimeout = backupTimeout; 1806 Error("Timeout delays for old run numbers must be greater than 0. Ignored."); 1792 if (evt.GetUInt() == 0) 1793 { 1794 Error("Timeout delays for old run numbers must be greater than 0... ignored."); 1807 1795 return GetCurrentState(); 1808 1796 } 1809 1797 1810 if (fRunNumberTimeout == backupTimeout)1798 if (fRunNumberTimeout == evt.GetUInt()) 1811 1799 Message("New timeout for old run numbers is same value as previous one."); 1812 1800 1801 fRunNumberTimeout = evt.GetUInt(); 1802 1813 1803 ostringstream str; 1814 str << "Timeout delay for old run numbers is now " << fRunNumberTimeout << " seconds";1804 str << "Timeout delay for old run numbers is now " << fRunNumberTimeout << " ms"; 1815 1805 Message(str); 1816 1806 … … 1959 1949 // fBaseSizeRun = 0; 1960 1950 // fPreviousSize = 0; 1961 fFilesStats.Reset();1951 // fFilesStats.Reset(); 1962 1952 fFilesStats.FileOpened(fFullNightlyLogFileName); 1963 1953 fFilesStats.FileOpened(fFullNightlyReportFileName); … … 2538 2528 { 2539 2529 const vector<string> vec = conf.Get<vector<string>>("block"); 2540 2541 2530 fBlackList.insert(vec.begin(), vec.end()); 2542 2531 } … … 2557 2546 2558 2547 //set the old run numbers timeout delay 2559 if (conf.Has("run timeout"))2560 { 2561 const long timeout = conf.Get<long>("runtimeout");2562 if (timeout <= 0)2563 { 2564 Error("Time out delay for old run numbers should be greater than 0 minute");2548 if (conf.Has("run-timeout")) 2549 { 2550 const uint32_t timeout = conf.Get<uint32_t>("run-timeout"); 2551 if (timeout == 0) 2552 { 2553 Error("Time out delay for old run numbers must not be 0."); 2565 2554 return 1; 2566 2555 } … … 2569 2558 2570 2559 //configure the run files directory 2571 if (conf.Has(" run_folder"))2560 if (conf.Has("destination-folder")) 2572 2561 { 2573 const string folder = conf.Get<string>("run_folder"); 2574 if (fFilesStats.SetCurrentFolder(folder)) 2575 fRunFilePath = folder; 2576 else 2577 Error("Folder " + folder + " given through configuration seems invalid. Ignoring it"); 2578 } 2579 2580 //configure the nightly files directory 2581 if (conf.Has("nightly_folder")) 2582 { 2583 const string folder = conf.Get<string>("nightly_folder"); 2584 if (fFilesStats.SetCurrentFolder(folder)) 2585 fNightlyFilePath = folder; 2586 else 2587 Error("Folder " + folder + " given through configuration seems invalid. Ignoring it"); 2588 } 2589 2590 //check if we have overwritten badly the directory being watched for free space 2591 if (conf.Has("run_folder") && !conf.Has("nightly_folder")) 2592 {//we've set the run folder for free space. we've decided it should be the nightly one. thus override it 2593 fFilesStats.SetCurrentFolder(fNightlyFilePath); 2562 const string folder = conf.Get<string>("destination-folder"); 2563 if (!fFilesStats.SetCurrentFolder(folder)) 2564 return 2; 2565 2566 fRunFilePath = folder; 2567 fNightlyFilePath = folder; 2594 2568 } 2595 2569 2596 2570 //configure the interval between statistics updates 2597 if (conf.Has("stats_interval")) 2598 { 2599 const float interval = conf.Get<float>("stats_interval"); 2600 fFilesStats.SetStatPeriod(interval); 2601 } 2571 if (conf.Has("stats-interval")) 2572 fFilesStats.SetUpdateInterval(conf.Get<int16_t>("stats-interval")); 2602 2573 2603 2574 //configure if the filenames service is on or off 2604 if (conf.Has("filename_service")) 2605 { 2606 fOpenedFilesIsOn = conf.Get<bool>("filename_service"); 2607 } 2575 fOpenedFilesIsOn = !conf.Get<bool>("no-filename-service"); 2608 2576 2609 2577 //configure if the number of subscriptions and fits files is on or off. 2610 if (conf.Has("numsubs_service")) 2611 { 2612 fNumSubAndFitsIsOn = conf.Get<bool>("numsubs_service"); 2613 } 2578 fNumSubAndFitsIsOn = !conf.Get<bool>("no-numsubs-service"); 2614 2579 2615 2580 return -1; … … 2769 2734 po::options_description configs("DataLogger options"); 2770 2735 configs.add_options() 2771 ("block,b", vars<string>(), "Black-list of services") 2772 ("allow,a", vars<string>(), "White-list of services") 2773 ("debug", po_bool(), "Debug mode. Print clear text of received service reports to log-stream") 2774 ("group,g", vars<string>(), "Grouping of services into a single run-Fits") 2775 ("runtimeout", var<long>(), "Time out delay for old run numbers") 2776 ("nightly_folder", var<string>(), "Base path for the nightly files") 2777 ("run_folder", var<string>(), "Base path for the run files") 2778 ("stats_interval", var<float>(), "Interval in seconds between two files statistics update") 2779 ("filename_service", po_bool(), "Should the filename service be enabled?") 2780 ("numsubs_service", po_bool(), "Should the number of subscriptions service be enabled?") 2736 ("block,b", vars<string>(), "Black-list of services") 2737 ("allow,a", vars<string>(), "White-list of services") 2738 ("debug", po_bool(), "Debug mode. Print clear text of received service reports to log-stream") 2739 ("group,g", vars<string>(), "Grouping of services into a single run-Fits") 2740 ("run-timeout", var<uint32_t>(), "Time out delay for old run numbers in milliseconds") 2741 ("destination-folder", var<string>(), "Base path for the nightly files") 2742 ("stats-interval", var<int16_t>(), "Interval in seconds between two files statistics update") 2743 ("no-filename-service", po_bool(), "Should the filename service be enabled?") 2744 ("no-numsubs-service", po_bool(), "Should the number of subscriptions service be enabled?") 2781 2745 ; 2782 2746
Note:
See TracChangeset
for help on using the changeset viewer.