private Number computeDelta(DefaultHashMap statsMap, String name, Number currentValue) { if (name.equals(StatsKey.DISK_READ_BYTES)) { Number prevValue = statsMap.get(StatsKey.DISK_READ_BYTES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.DISK_RECOVERED_BYTES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.DISK_WRITEN_BYTES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.BACKUPS_IN_PROGRESS).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.BACKUPS_COMPLETED).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.FLUSHED_BYTES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.NUM_FLUSHES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue;
private Number computeDelta(DefaultHashMap statsMap, String name, Number currentValue) { if (name.equals(StatsKey.DISK_READ_BYTES)) { Number prevValue = statsMap.get(StatsKey.DISK_READ_BYTES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.DISK_RECOVERED_BYTES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.DISK_WRITEN_BYTES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.BACKUPS_IN_PROGRESS).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.BACKUPS_COMPLETED).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.FLUSHED_BYTES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.NUM_FLUSHES).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue;
Number processCpuTime = statsMap.get(StatsKey.VM_PROCESS_CPU_TIME);
private Number computeDelta(DefaultHashMap statsMap, String name, Number currentValue) { if (name.equals(StatsKey.PRIMARY_BUCKET_COUNT)) { Number prevValue = statsMap.get(StatsKey.PRIMARY_BUCKET_COUNT).intValue(); Number deltaValue = currentValue.intValue() - prevValue.intValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.BUCKET_COUNT).intValue(); Number deltaValue = currentValue.intValue() - prevValue.intValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.TOTAL_BUCKET_SIZE).intValue(); Number deltaValue = currentValue.intValue() - prevValue.intValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.LRU_EVICTIONS).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.LRU_DESTROYS) .longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); Number prevValue = statsMap.get(StatsKey.DISK_SPACE) .longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue();
private Number computeDelta(DefaultHashMap statsMap, String name, Number currentValue) { if (name.equals(StatsKey.PRIMARY_BUCKET_COUNT)) { Number prevValue = statsMap.get(StatsKey.PRIMARY_BUCKET_COUNT).intValue(); Number deltaValue = currentValue.intValue() - prevValue.intValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.BUCKET_COUNT).intValue(); Number deltaValue = currentValue.intValue() - prevValue.intValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.TOTAL_BUCKET_SIZE).intValue(); Number deltaValue = currentValue.intValue() - prevValue.intValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.LRU_EVICTIONS).longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); return deltaValue; Number prevValue = statsMap.get(StatsKey.LRU_DESTROYS) .longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue(); Number prevValue = statsMap.get(StatsKey.DISK_SPACE) .longValue(); Number deltaValue = currentValue.longValue() - prevValue.longValue();
/** * Right now it only refreshes CPU usage in terms of percentage. This method * can be used for any other computation based on Stats in future. * * Returns the time (as a percentage) that this member's process time with * respect to Statistics sample time interval. If process time between two * sample time t1 & t2 is p1 and p2 cpuUsage = ((p2-p1) * 100) / ((t2-t1) */ private void refreshStats() { if (processCPUTimeAvailable) { Number processCpuTime = statsMap.get(StatsKey.VM_PROCESS_CPU_TIME); if (lastSystemTime == 0) { lastSystemTime = System.currentTimeMillis(); return; } long cpuTime = processCpuTime.longValue(); if (lastProcessCpuTime == 0) { lastProcessCpuTime = cpuTime; return; } long systemTime = System.currentTimeMillis(); long denom = (systemTime - lastSystemTime) * 10000; // 10000 = (Nano // conversion factor / // 100 for percentage) float processCpuUsage = (float) (cpuTime - lastProcessCpuTime) / denom; lastSystemTime = systemTime; lastProcessCpuTime = cpuTime; cpuUsage = processCpuUsage; } }
@Override public void handleNotification(StatisticsNotification notification) { synchronized (statsMap) { if(removed){ return; } for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); Number deltaValue = computeDelta(statsMap, name, value); statsMap.put(name, value); increaseStats(name, deltaValue); // fix for bug 46604 } } }
@Override public void handleNotification(StatisticsNotification notification) { synchronized (statsMap) { if(removed){ return; } for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); Number deltaValue = computeDelta(statsMap, name, value); statsMap.put(name, value); increaseStats(name, deltaValue); // fix for bug 46604 } } }
@Override public void handleNotification(StatisticsNotification notification) { synchronized (statsMap) { if(removed){ return; } for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); Number deltaValue = computeDelta(statsMap, name, value); statsMap.put(name, value); increaseStats(name, deltaValue); } } }
@Override public void handleNotification(StatisticsNotification notification) { synchronized (statsMap) { if(removed){ return; } for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); Number deltaValue = computeDelta(statsMap, name, value); statsMap.put(name, value); increaseStats(name, deltaValue); } } }
/** * Only decrease those values which can both increase and decrease and not * values which can only increase like read/writes * * Remove last sample value from the aggregate. Last Sampled value can be * obtained from the DefaultHashMap for the disk * * @param stats */ public void decreaseDiskStoreStats(Statistics stats) { synchronized (statsMap) { queueSize -= statsMap.get(StatsKey.DISK_QUEUE_SIZE).intValue(); backupsInProgress -= statsMap.get(StatsKey.BACKUPS_IN_PROGRESS) .intValue(); ; removed = true; } }
@Override public void handleNotification(StatisticsNotification notification) { decreasePrevValues(statsMap); for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); increaseStats(name, value); statsMap.put(name, value); } }
@Override public void handleNotification(StatisticsNotification notification) { decreasePrevValues(statsMap); for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); increaseStats(name, value); statsMap.put(name, value); } }
/** * Only decrease those values which can both increase and decrease and not * values which can only increase like read/writes * * Remove last sample value from the aggregate. Last Sampled value can be * obtained from the DefaultHashMap for the disk * * @param stats */ public void decreaseParStats(Statistics stats) { synchronized (statsMap) { primaryBucketCount -= statsMap.get(StatsKey.PRIMARY_BUCKET_COUNT).intValue(); bucketCount -= statsMap.get(StatsKey.BUCKET_COUNT).intValue(); totalBucketSize -= statsMap.get(StatsKey.TOTAL_BUCKET_SIZE).intValue(); removed = true; } }
/** * Only decrease those values which can both increase and decrease and not * values which can only increase like read/writes * * Remove last sample value from the aggregate. Last Sampled value can be * obtained from the DefaultHashMap for the disk * * @param stats */ public void decreaseParStats(Statistics stats) { synchronized (statsMap) { primaryBucketCount -= statsMap.get(StatsKey.PRIMARY_BUCKET_COUNT).intValue(); bucketCount -= statsMap.get(StatsKey.BUCKET_COUNT).intValue(); totalBucketSize -= statsMap.get(StatsKey.TOTAL_BUCKET_SIZE).intValue(); removed = true; } }
@Override public void handleNotification(StatisticsNotification notification) { for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); statsMap.put(name, value); } refreshStats(); }
@Override public void handleNotification(StatisticsNotification notification) { for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); statsMap.put(name, value); } refreshStats(); }
/** * Only decrease those values which can both increase and decrease and not * values which can only increase like read/writes * * Remove last sample value from the aggregate. Last Sampled value can be * obtained from the DefaultHashMap for the disk * * @param stats */ public void decreaseDiskStoreStats(Statistics stats) { synchronized (statsMap) { queueSize -= statsMap.get(StatsKey.DISK_QUEUE_SIZE).intValue(); backupsInProgress -= statsMap.get(StatsKey.BACKUPS_IN_PROGRESS) .intValue(); ; removed = true; } }
@Override public void handleNotification(StatisticsNotification notification) { for (StatisticId statId : notification) { StatisticDescriptor descriptor = statId.getStatisticDescriptor(); String name = descriptor.getName(); Number value; try { value = notification.getValue(statId); } catch (StatisticNotFoundException e) { value = 0; } log(name,value); statsMap.put(name, value); } }
public void removeStatisticsFromMonitor(Statistics stats) { statsMap.clear(); }