private void refreshStats(){
  if (processCPUTimeAvailable) {
    Number processCpuTime=statsMap.get(StatsKey.VM_PROCESS_CPU_TIME);
    if (processCpuTime == null) {
      cpuUsage=MBeanJMXAdapter.VALUE_NOT_AVAILABLE;
      return;
    }
    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;
    float processCpuUsage=(float)(cpuTime - lastProcessCpuTime) / denom;
    lastSystemTime=systemTime;
    lastProcessCpuTime=cpuTime;
    cpuUsage=processCpuUsage;
  }
}

private void refreshStats ( ) { if ( processCPUTimeAvailable ) { Number processCpuTime = statsMap . get ( StatsKey . VM_PROCESS_CPU_TIME ) ; if ( processCpuTime == null ) { cpuUsage = MBeanJMXAdapter . VALUE_NOT_AVAILABLE ; return ; } 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 ; float processCpuUsage = ( float ) ( cpuTime - lastProcessCpuTime ) / denom ; lastSystemTime = systemTime ; lastProcessCpuTime = cpuTime ; cpuUsage = processCpuUsage ; } }
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 )
