public void update ( boolean needJvmInfo ) { if ( state == VMInfoState . ERROR_DURING_ATTACH || state == VMInfoState . DETACHED ) { return ; } try { int lastJmxErrorCount = jmxUpdateErrorCount ; // 将UPDTATE_ERROR重置开始新一轮循环 state = VMInfoState . ATTACHED ; // 清空JMX内部缓存 jmxClient . flush ( ) ; updateUpTime ( ) ; if ( needJvmInfo ) { if ( isLinux ) { updateProcessStatus ( ) ; updateIO ( ) ; } updateCpu ( ) ; updateThreads ( ) ; updateClassLoader ( ) ; updateMemoryPool ( ) ; updateGC ( ) ; updateSafepoint ( ) ; } // 无新异常，状态重新判定为正常 if ( jmxUpdateErrorCount == lastJmxErrorCount ) { jmxUpdateErrorCount = 0 ; } } catch ( Throwable e ) { // 其他非JMX异常，直接退出 e . printStackTrace ( ) ; System . out . flush ( ) ; state = VMInfoState . DETACHED ; } }
Updates all jvm metrics to the most recent remote values