Example #1
0
 public void addMessage(LogMessage msg) {
   if (!m_serviceID.equals(msg.getServiceID())) {
     throw new IllegalArgumentException(
         "ServiceID of log message does not match serviceID of ServiceCollector: " + m_serviceID);
   }
   if (msg.isCollectorBeginMessage()) {
     m_lastBegin = msg.getDate().getTime();
     // measure the time between collections
     if (m_lastEnd > 0) {
       m_totalBetweenTime += msg.getDate().getTime() - m_lastEnd;
       m_betweenCount++;
     }
     m_lastEnd = 0;
   }
   if (msg.isErrorMessage()) {
     m_lastErrorBegin = m_lastBegin;
   }
   if (msg.isCollectorEndMessage()) {
     long end = msg.getDate().getTime();
     m_lastEnd = msg.getDate().getTime();
     if (m_lastBegin > 0) {
       m_totalTime += end - m_lastBegin;
       m_collectionCount++;
     }
     m_lastBegin = 0;
     if (m_lastErrorBegin > 0) {
       m_errorTime += end - m_lastErrorBegin;
       m_errorCount++;
     }
     m_lastErrorBegin = 0;
   }
   if (msg.isPersistBeginMessage()) {
     m_lastPersistBegin = msg.getDate().getTime();
   }
   if (msg.isPersistEndMessage()) {
     long end = msg.getDate().getTime();
     msg.getDate().getTime();
     if (m_lastPersistBegin > 0) {
       m_totalPersistTime += end - m_lastPersistBegin;
       m_persistCount++;
     }
     m_lastPersistBegin = 0;
   }
 }