Changeset 17915 for fact/Evidence/History.cc
- Timestamp:
- 07/18/14 10:08:12 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/Evidence/History.cc
r17017 r17915 29 29 using namespace std; 30 30 31 const int MIN_SIZE_KB = 50; // Min and max buffersize in kByte (> 3*sizeof(int) !)32 const string DEFAULT_MAX_SIZE_KB = "2000";33 const string DEFAULT_NUM_ENTRIES = "1000"; // Number of entries in each history buffer34 const double MIN_SAVE_PERDIOD = 0.5; // Minimum period between saving history buffers in hours35 36 31 // 37 32 // Class declaration … … 39 34 class History: public DimRpc, public DimClient, public EvidenceServer { 40 35 36 static const int MIN_SIZE_KB = 50; // Min and max buffersize in kByte (> 3*sizeof(int) !) 37 static const string DEFAULT_MAX_SIZE_KB; 38 static const string DEFAULT_NUM_ENTRIES; // Number of entries in each history buffer 39 41 40 struct Item { 42 41 DimStampedInfo *DataItem; … … 52 51 53 52 DimInfo *ServerList; 54 DimService *S ervice;53 DimService *SubscriptionService; 55 54 char *Directory; 56 55 … … 68 67 }; 69 68 69 // Initialize non-integral constants (cannot be inside class declaration) 70 const string History::DEFAULT_MAX_SIZE_KB = "2000"; 71 const string History::DEFAULT_NUM_ENTRIES = "1000"; 72 static const double MIN_SAVE_PERIOD = 0.5; // Minimum period between saving history buffers in hours 73 70 74 71 75 // Constructor … … 73 77 EvidenceServer(SERVER_NAME), 74 78 Directory(Dir) { 79 75 80 // Get/initialize configuration 76 81 GetConfig("minchange", " "); … … 81 86 82 87 // Create services for information about subscribed services 83 S ervice = new DimService(SERVER_NAME "/Subscriptions", "C", NULL, 0);88 SubscriptionService = new DimService(SERVER_NAME "/Subscriptions", "C", NULL, 0); 84 89 85 90 // Subscribe to top-level server list … … 94 99 while (Map.size() != 0) RemoveService((*Map.begin()).first); 95 100 96 delete S ervice;101 delete SubscriptionService; 97 102 } 98 103 … … 147 152 148 153 // Update service subscription list 149 st atic stringstream Stream;154 stringstream Stream; 150 155 151 156 for (map<string, struct Item>::const_iterator i=Map.begin(); i!=Map.end(); i++) { … … 153 158 } 154 159 List = Stream.str(); 155 S ervice->updateService((void *) List.c_str(), List.size()+1);160 SubscriptionService->updateService((void *) List.c_str(), List.size()+1); // Note that List is a static variable 156 161 157 162 return; … … 166 171 167 172 // Save history buffers periodically (in case of program crash) 168 if (time(NULL)-Map[Service].LastSave > max(atof(GetConfig("saveperiod").c_str()), MIN_SAVE_PERDIOD)*3600) {173 if (time(NULL)-Map[Service].LastSave > max(atof(GetConfig("saveperiod").c_str()), MIN_SAVE_PERIOD)*3600) { 169 174 Map[Service].LastSave = time(NULL); 170 175 SaveHistory(Service);
Note:
See TracChangeset
for help on using the changeset viewer.