Changeset 17915 for fact/Evidence
- Timestamp:
- 07/18/14 10:08:12 (10 years ago)
- Location:
- fact/Evidence
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/Evidence/DColl.cc
r12910 r17915 45 45 float DataSizeMB, LogSizeMB; 46 46 int DataSizeLastUpdate, LogSizeLastUpdate; 47 DimService *LogSizeService, *DataSizeService, *DataFilename; 47 DimService *LogSizeService, *DataSizeService, *DataFilename, *SubscriptionService; 48 48 49 int TimeForNextFile; 49 50 … … 113 114 LogCommand = new DimCommand("DColl/Log", (char *) "C", this); 114 115 115 // Subsribe to top-level server list (not via AddService() due to thread issue) 116 // Create services for information about subscribed services 117 SubscriptionService = new DimService(SERVER_NAME "/Subscriptions", "C", NULL, 0); 118 119 // Subscribe to top-level server list (not via AddService() due to thread issue) 116 120 ServerList = new DimInfo((char *) "DIS_DNS/SERVER_LIST", NO_LINK, this); 117 121 } … … 132 136 delete LogSizeService; 133 137 delete DataSizeService; 138 delete SubscriptionService; 134 139 135 140 // Close files … … 151 156 // no mutex is needed to serialize writing to the file 152 157 void DataHandler::infoHandler() { 158 159 static string SubscriptionList; 153 160 154 161 // Check if service available … … 192 199 Name = strtok(NULL, "|"); 193 200 } 201 202 // Update service subscription list 203 stringstream Stream; 204 205 for (unsigned int i=0; i<List.size(); i++) Stream << List[i].DataItem->getName() << '|'; 206 207 SubscriptionList = Stream.str(); 208 SubscriptionService->updateService((void *) SubscriptionList.c_str(), SubscriptionList.size()+1); // Note that Subscription is a static variable 209 194 210 return; 195 211 } -
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.