1 4 package com.tc.stats; 5 6 import com.tc.objectserver.api.GCStats; 7 import com.tc.objectserver.api.ObjectManagerMBean; 8 import com.tc.objectserver.api.ObjectManagerStats; 9 import com.tc.objectserver.core.api.DSOGlobalServerStats; 10 import com.tc.objectserver.core.impl.ServerManagementContext; 11 import com.tc.stats.counter.sampled.SampledCounter; 12 import com.tc.stats.statistics.CountStatistic; 13 import com.tc.stats.statistics.DoubleStatistic; 14 import com.tc.stats.statistics.DoubleStatisticImpl; 15 import com.tc.stats.statistics.Statistic; 16 17 import java.lang.reflect.Method ; 18 19 25 26 public class DSOStatsImpl extends StatsSupport implements DSOStats { 27 28 private final DSOGlobalServerStats serverStats; 29 private final SampledCounter faultRate; 30 private final SampledCounter flushRate; 31 private final ObjectManagerStats objMgrStats; 32 private final SampledCounter txnRate; 33 private final ObjectManagerMBean objManager; 34 35 public DSOStatsImpl(ServerManagementContext context) { 36 this.objManager = context.getObjectManager(); 37 this.serverStats = context.getServerStats(); 38 this.objMgrStats = serverStats.getObjectManagerStats(); 39 this.faultRate = serverStats.getObjectFaultCounter(); 40 this.flushRate = serverStats.getObjectFlushCounter(); 41 this.txnRate = serverStats.getTransactionCounter(); 42 } 43 44 public CountStatistic getObjectFaultRate() { 45 return StatsUtil.makeCountStat(faultRate); 46 } 47 48 public CountStatistic getObjectFlushRate() { 49 return StatsUtil.makeCountStat(flushRate); 50 } 51 52 public CountStatistic getTransactionRate() { 53 return StatsUtil.makeCountStat(txnRate); 54 } 55 56 public DoubleStatistic getCacheHitRatio() { 57 double value = objMgrStats.getCacheHitRatio(); 58 DoubleStatisticImpl rv = new DoubleStatisticImpl(System.currentTimeMillis()); 59 rv.setDoubleValue(value); 60 return rv; 61 } 62 63 public CountStatistic getCacheMissRate() { 64 return StatsUtil.makeCountStat( objMgrStats.getCacheMissRate()); 65 } 66 67 68 public Statistic[] getStatistics(String [] names) { 69 int count = names.length; 70 Statistic[] result = new Statistic[count]; 71 Method method; 72 73 for (int i = 0; i < count; i++) { 74 try { 75 method = getClass().getMethod("get" + names[i], new Class [] {}); 76 result[i] = (Statistic) method.invoke(this, new Object [] {}); 77 } catch (Exception e) { 78 e.printStackTrace(); 79 } 80 } 81 82 return result; 83 } 84 85 public GCStats[] getGarbageCollectorStats() { 86 return this.objManager.getGarbageCollectorStats(); 87 } 88 89 } 90 | Popular Tags |