Byteman

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Organizatorium

Byteman Example

In clustered.conf:

BYTEMAN_HOME=/path/to/byteman-download-3.0.6
...
JAVA_OPTS="$JAVA_OPTS -javaagent:${BYTEMAN_HOME}/lib/byteman.jar=sys:${BYTEMAN_HOME}/lib/byteman.jar,script:/path/to/debug-stat.btm"

debug-stat.btm:

RULE debug stat getAverageReadTime
CLASS org.infinispan.interceptors.CacheMgmtInterceptor
METHOD getAverageReadTime
AT EXIT
IF TRUE
DO System.out.println("hitTimes.sum(): " + $this.hitTimes.sum() + ", missTimes.sum(): " + $this.missTimes.sum());
ENDRULE

RULE debug stat getAverageWriteTime
CLASS org.infinispan.interceptors.CacheMgmtInterceptor
METHOD getAverageWriteTime
AT EXIT
IF TRUE
DO System.out.println("stores.sum(): " + $this.stores.sum());
ENDRULE

RULE debug stat getAverageRemoveTime
CLASS org.infinispan.interceptors.CacheMgmtInterceptor
METHOD getAverageRemoveTime
AT EXIT
IF TRUE
DO System.out.println("removeTimes.sum(): " + $this.removeTimes.sum());
ENDRULE