S1ASJVMStatsImplMockpublic class S1ASJVMStatsImplMock extends Object implements S1ASJVMStatsMockMock class for using JVMStats as a component that will register and
unregister with a MonitoringRegistration object which in turn created a
dynamic MBean that will be registered with the MBeanServer using an ObjectName
that has a unique identifier. |
Fields Summary |
---|
private long | initTime | public static final String | LOGGER_NAME | final Logger | logger |
Constructors Summary |
---|
public S1ASJVMStatsImplMock()Creates a new instance of JVMStatsImpl
initTime = System.currentTimeMillis();
logger = Logger.getLogger(LOGGER_NAME);
|
Methods Summary |
---|
public CountStatistic | getAvailableProcessors()
int availProcs = Runtime.getRuntime().availableProcessors();
return StatisticFactory.getCountStatistic(availProcs, "AvailableProcessors",
"Numbers", "Processors Available to the JVM",
System.currentTimeMillis(), initTime);
| public javax.management.j2ee.statistics.BoundedRangeStatistic | getHeapSize()
long heapSize = Runtime.getRuntime().totalMemory();
long upper = Runtime.getRuntime().maxMemory();
return StatisticFactory.getBoundedRangeStatistic(heapSize, heapSize, heapSize,
upper, 0, "HeapSize", "bytes",
"JVM Heap Size", initTime,
System.currentTimeMillis());
| public CountStatistic | getMaxMemory()
long maxMem = Runtime.getRuntime().maxMemory();
return StatisticFactory.getCountStatistic(maxMem, "MaxMemory",
"bytes", "Memory Available to the JVM",
System.currentTimeMillis(), initTime);
| public javax.management.j2ee.statistics.Statistic | getStatistic(java.lang.String statisticName)
if(statisticName != null){
try{
return (Statistic)(this.getClass().getMethod("get"+statisticName, null)).invoke(this,null);
}
catch(Exception e){
e.printStackTrace();
}
}
throw new NullPointerException("Cannot find Statistic as Statistic Name is not provided");
| public java.lang.String[] | getStatisticNames()
return new String[]{"HeapSize","MaxMemory","UpTime", "AvailableProcessors"};
| public javax.management.j2ee.statistics.Statistic[] | getStatistics()
Statistic[] stats = new Statistic[]{};
for(int i=0;i<getStatisticNames().length;i++){
stats[i]=getStatistic(getStatisticNames()[i]);
}
return stats;
| public CountStatistic | getUpTime()
long curTime = System.currentTimeMillis();
long upTime = curTime - initTime;
return StatisticFactory.getCountStatistic(upTime, "UpTime", "milliseconds",
"Amount of time the JVM has been running",
curTime, initTime);
|
|