net.java.btrace.runtime
Class BTraceRuntime

java.lang.Object
  extended by net.java.btrace.runtime.BTraceRuntime

public final class BTraceRuntime
extends Object

Helper class used by BTrace built-in functions and also acts runtime "manager" for a specific BTrace client and sends Commands to the CommandListener passed.

Author:
A. Sundararajan, Christian Glencross (aggregation support), Joachim Skeie (GC MBean support, advanced Deque manipulation), KLynch

Field Summary
static BTraceRuntime NULL
           
static long TIMESTAMP
           
 
Constructor Summary
BTraceRuntime(net.java.btrace.api.server.ShutdownHandler shutdown, String runtimeName, String[] args, net.java.btrace.api.wireio.Channel commChannel, Instrumentation inst, net.java.btrace.api.extensions.ExtensionsRepository extRepository)
          Creates a newly configured BTrace runtime instance Intended to be used only from within the BTrace.
 
Method Summary
 String $(int n)
           
 String[] $$()
           
 int $length()
           
static boolean classNameExists(String name)
           
 void commit(int id)
           
static boolean compare(Object obj1, Object obj2)
          Indicates whether two given objects are "equal to" one another.
 Class defineClass(byte[] code)
           
 Class defineClass(byte[] code, boolean mustBeBootstrap)
           
 void discard(int id)
           
static boolean enter()
           
static boolean enter(BTraceRuntime current)
          Enter method is called by every probed method just before the probe actions start.
static void exit(int exitCode)
           
static BTraceRuntime forClass(Class cl)
          One instance of BTraceRuntime is created per-client.
static String getClassName()
           
static BTraceRuntime getCurrent()
          Get the current thread BTraceRuntime instance if there is one.
static List<GarbageCollectorMXBean> getGarbageCollectionMBeans()
           
static com.sun.management.HotSpotDiagnosticMXBean getHotSpotMBean()
           
static MemoryMXBean getMemoryMBean()
           
static List<MemoryPoolMXBean> getMemoryPoolMXBeans()
           
static double getPerfDouble(String name)
          Return the value of double perf.
static float getPerfFloat(String name)
          Return the value of float perf.
static int getPerfInt(String name)
          Return the value of integer perf.
static long getPerfLong(String name)
          Return the value of long perf.
static net.java.btrace.api.core.PerfReader getPerfReader()
           
static String getPerfString(String name)
          Return the value of String perf.
static RuntimeMXBean getRuntimeMBean()
           
static String getValidTraceClassName(String origClassName)
           
 void handleEvent(String event)
           
static void handleException(Throwable th)
          Handles exception from BTrace probe actions.
static int hash(Object obj)
          Returns a hash code value for the object.
static int identityHashCode(Object obj)
          Returns the same hash code for the given object as would be returned by the default method hashCode(), whether or not the given object's class overrides hashCode().
static String identityStr(Object obj)
          Returns identity string of the form class-name@identity-hash
static void init(net.java.btrace.api.core.PerfReader perfRead, RunnableGenerator runGen)
           
static void leave()
          Leave method is called by every probed method just before the probe actions end (and actual probed method continues).
static void newPerfCounter(String name, String desc, Object value)
          Utility to create a new jvmstat perf counter.
static ThreadLocal newThreadLocal(Object initValue)
          Utility to create a new ThreadLocal object.
static void putPerfDouble(double value, String name)
          write the value of double perf.
static void putPerfFloat(float value, String name)
          Write the value of float perf.
static void putPerfInt(int value, String name)
          Write the value of integer perf.
static void putPerfLong(long value, String name)
          Write the value of float perf.
static void putPerfString(String value, String name)
          Write the value of float perf.
static String resolveFileName(String name)
           
static void retransform(String runtimeName, Class<?> clazz)
           
static
<T extends net.java.btrace.api.wireio.AbstractCommand>
net.java.btrace.api.wireio.Response<T>
send(Class<? extends T> cmdClass, net.java.btrace.api.wireio.AbstractCommand.Initializer<T> init)
           
 void shutdown()
           
 void speculate(int id)
           
 int speculation()
           
static void start()
          start method is called by every BTrace (preprocesed) class just at the end of it's class initializer.
static RuntimeException translate(Exception exp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static final BTraceRuntime NULL

TIMESTAMP

public static volatile long TIMESTAMP
Constructor Detail

BTraceRuntime

public BTraceRuntime(net.java.btrace.api.server.ShutdownHandler shutdown,
                     String runtimeName,
                     String[] args,
                     net.java.btrace.api.wireio.Channel commChannel,
                     Instrumentation inst,
                     net.java.btrace.api.extensions.ExtensionsRepository extRepository)
Creates a newly configured BTrace runtime instance Intended to be used only from within the BTrace. Trying to instantiate BTraceRuntime from any other class will result in IllegalArgumentException

Parameters:
shutdown - The associated RuntimeShutdownHandler instance
runtimeName - A runtime name - it is taken from the BTrace script used
args - Arguments passed to the BTrace agent
inst - Instrumentation instance
extRepository - ExtensionsRepository instance wrapping access to BTrace extensions
Throws:
IllegalArgumentException - if called from outside of the BTrace core
Method Detail

getClassName

public static String getClassName()

classNameExists

public static boolean classNameExists(String name)

init

public static void init(net.java.btrace.api.core.PerfReader perfRead,
                        RunnableGenerator runGen)

defineClass

public Class defineClass(byte[] code)

defineClass

public Class defineClass(byte[] code,
                         boolean mustBeBootstrap)

enter

public static boolean enter(BTraceRuntime current)
Enter method is called by every probed method just before the probe actions start.


enter

public static boolean enter()

leave

public static void leave()
Leave method is called by every probed method just before the probe actions end (and actual probed method continues).


start

public static void start()
start method is called by every BTrace (preprocesed) class just at the end of it's class initializer.


handleEvent

public void handleEvent(String event)

forClass

public static BTraceRuntime forClass(Class cl)
One instance of BTraceRuntime is created per-client. This forClass method creates it. Class passed is the preprocessed BTrace program of the client.


newThreadLocal

public static ThreadLocal newThreadLocal(Object initValue)
Utility to create a new ThreadLocal object. Called by preprocessed BTrace class to create ThreadLocal for each @TLS variable.

Parameters:
initValue - Initial value. This value must be either a boxed primitive or Cloneable. In case a Cloneable value is provided the value is never used directly - instead, a new clone of the value is created per thread.

newPerfCounter

public static void newPerfCounter(String name,
                                  String desc,
                                  Object value)
Utility to create a new jvmstat perf counter. Called by preprocessed BTrace class to create perf counter for each @Export variable.


getPerfInt

public static int getPerfInt(String name)
Return the value of integer perf. counter of given name.


putPerfInt

public static void putPerfInt(int value,
                              String name)
Write the value of integer perf. counter of given name.


getPerfFloat

public static float getPerfFloat(String name)
Return the value of float perf. counter of given name.


putPerfFloat

public static void putPerfFloat(float value,
                                String name)
Write the value of float perf. counter of given name.


getPerfLong

public static long getPerfLong(String name)
Return the value of long perf. counter of given name.


putPerfLong

public static void putPerfLong(long value,
                               String name)
Write the value of float perf. counter of given name.


getPerfDouble

public static double getPerfDouble(String name)
Return the value of double perf. counter of given name.


putPerfDouble

public static void putPerfDouble(double value,
                                 String name)
write the value of double perf. counter of given name.


getPerfString

public static String getPerfString(String name)
Return the value of String perf. counter of given name.


putPerfString

public static void putPerfString(String value,
                                 String name)
Write the value of float perf. counter of given name.


handleException

public static void handleException(Throwable th)
Handles exception from BTrace probe actions.


exit

public static void exit(int exitCode)

$length

public int $length()

$$

public String[] $$()

$

public String $(int n)

getCurrent

public static BTraceRuntime getCurrent()
Get the current thread BTraceRuntime instance if there is one.


getValidTraceClassName

public static String getValidTraceClassName(String origClassName)

identityStr

public static String identityStr(Object obj)
Returns identity string of the form class-name@identity-hash

Parameters:
obj - object for which identity string is returned
Returns:
identity string

identityHashCode

public static int identityHashCode(Object obj)
Returns the same hash code for the given object as would be returned by the default method hashCode(), whether or not the given object's class overrides hashCode(). The hash code for the null reference is zero.

Parameters:
obj - object for which the hashCode is to be calculated
Returns:
the hashCode

hash

public static int hash(Object obj)
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable. For bootstrap classes, returns the result of calling Object.hashCode() override. For non-bootstrap classes, the identity hash code is returned.

Parameters:
obj - the Object whose hash code is returned.
Returns:
a hash code value for the given object.

compare

public static boolean compare(Object obj1,
                              Object obj2)
Indicates whether two given objects are "equal to" one another. For bootstrap classes, returns the result of calling Object.equals() override. For non-bootstrap classes, the reference identity comparison is done.

Parameters:
obj1 - first object to compare equality
obj2 - second object to compare equality
Returns:
true if the given objects are equal; false otherwise.

getRuntimeMBean

public static RuntimeMXBean getRuntimeMBean()

getMemoryPoolMXBeans

public static List<MemoryPoolMXBean> getMemoryPoolMXBeans()

getHotSpotMBean

public static com.sun.management.HotSpotDiagnosticMXBean getHotSpotMBean()
Returns:
Returns the HotSpotDiagnosticMXBean MBean for the running JVM

getGarbageCollectionMBeans

public static List<GarbageCollectorMXBean> getGarbageCollectionMBeans()
Returns:
Returns a list of GarbageCollectorMXBean instances registered in the running JVM

getPerfReader

public static net.java.btrace.api.core.PerfReader getPerfReader()

send

public static <T extends net.java.btrace.api.wireio.AbstractCommand> net.java.btrace.api.wireio.Response<T> send(Class<? extends T> cmdClass,
                                                                                                                 net.java.btrace.api.wireio.AbstractCommand.Initializer<T> init)

speculation

public int speculation()

speculate

public void speculate(int id)

discard

public void discard(int id)

commit

public void commit(int id)

shutdown

public void shutdown()

retransform

public static void retransform(String runtimeName,
                               Class<?> clazz)

translate

public static RuntimeException translate(Exception exp)

resolveFileName

public static String resolveFileName(String name)

getMemoryMBean

public static MemoryMXBean getMemoryMBean()


Copyright © 2015. All Rights Reserved.