FACT++  1.0
void DimWriteStatistics::UpdateService ( )
private

Main loop.

Updates the service. This is the function executed by the thread.

Definition at line 154 of file DimWriteStatistics.cc.

References data, MessageImp::Debug(), fBaseSize, fDebug, fDimService, fLog, fOpenedFiles, DimWriteStatistics::Stats::freeSpace, fStats, fUpdateInterval, GetFileSizeOnDisk(), GetFreeSpace(), DimWriteStatistics::Stats::rateWritten, DimDescribedService::setData(), DimWriteStatistics::Stats::sizeWritten, str, DimWriteStatistics::Stats::timeElapsed, and DimDescribedService::Update().

Referenced by DimWriteStatistics().

155 {
156  Time previousTime;
157  uint64_t previousSize = 0;
158 
159  while (1)
160  {
161  if (fUpdateInterval==0)
162  {
163  boost::this_thread::interruption_point();
164  boost::this_thread::yield();
165  continue;
166  }
167 
168  Stats data;
169 
170  for (set<string>::const_iterator it = fOpenedFiles.begin(); it != fOpenedFiles.end(); it++)
171  data.sizeWritten += GetFileSizeOnDisk(*it);
172  data.sizeWritten -= fBaseSize;
173 
174  const Time cTime = Time();
175 
176  data.freeSpace = GetFreeSpace();
177  data.rateWritten = data.sizeWritten-previousSize;
178  data.timeElapsed = (cTime - previousTime).total_milliseconds();
179 
180  previousSize = data.sizeWritten;
181  previousTime = cTime;
182 
183  fDimService.setData(data);
184  fDimService.Update(cTime);
185 
186  fStats = data;
187 
188  if (fDebug)
189  {
190  ostringstream str;
191  str << "Written: " << fStats.sizeWritten/1000 << " kB; writing rate: ";
192  str << fStats.rateWritten/fStats.timeElapsed << " kB/s; free space: ";
193  str << fStats.freeSpace/1000000 << " MB";
194  fLog.Debug(str);
195  }
196 
197  boost::this_thread::sleep(milliseconds(fUpdateInterval));
198  }
199 }
uint16_t fUpdateInterval
Current folder being watched for free space.
int Debug(const std::string &str)
Definition: MessageImp.h:45
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
DimDescribedService fDimService
int64_t GetFreeSpace()
Returns the free space on the disk of the folder being watched (fCurrentFolder)
void setData(const void *ptr, size_t sz)
Stats fStats
The data structure holding the stat data.
std::set< std::string > fOpenedFiles
Total base size of all opened files.
int64_t GetFileSizeOnDisk(const std::string &file)
Returns the size on disk of a given file.
float data[4 *1440]
bool fDebug
List of all opened files. set is used to easily check for entries.
size_t fBaseSize
Duration, in millisecond between two service updates. 0 means no more updates.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: