Ejemplo n.º 1
0
  StatsGroups createStatsGroup(String providerName, Map providerStatsEvents) {
    StatsGroups sGroup = new StatsGroups(providerName);
    StatEvent event = null;
    if (providerStatsEvents != null && providerStatsEvents.size() > 0) {
      event = (StatEvent) ((SynchronizedMap) providerStatsEvents).getValueByPosition(0);
    } else {
      return null;
    }

    sGroup.setStartTime(event.getTime());
    sGroup.setLastSampleTime(event.getTime());

    return sGroup;
  }
Ejemplo n.º 2
0
 StatsGroups feedGroup(StatsGroups group, Map<String, StatEvent> events) {
   EventCollection eventCollection = null;
   StatEvent event = null;
   if (events != null && events.keySet() != null && events.keySet().iterator() != null) {
     try {
       Iterator<String> it = events.keySet().iterator();
       while (it.hasNext()) {
         String eventCollectionName = it.next();
         event = events.get(eventCollectionName);
         eventCollection = group.getEventCollection(eventCollectionName);
         //	    	    Object value = event.getValue();
         if (Text.isNumeric(event.getValue())) {
           Long value = Text.toLong(event.getValue(), new Long(0));
           eventCollection.setAverageValue(value);
           eventCollection.setMaxValue(value.longValue());
           eventCollection.setMinValue(value.longValue());
           if (eventCollection.getCollection().size() >= 1) {
             event.setDeltaValue(value.longValue() - eventCollection.lastValue);
           } else {
             event.setDeltaValue(0);
           }
         }
         eventCollection.setEvent(event);
         group.setEventCollection(eventCollectionName, eventCollection);
         group.setLastSampleTime(event.getTime());
       }
     } catch (Throwable th) {
       th.printStackTrace();
     }
     return group;
   } else return null;
 }