3 Replies Latest reply: Jun 22, 2014 11:54 AM by Staffan Larsen RSS

    Serviceability API

    Mohan

      Hi,

               I don't know any forum that discusses serviceability  implementation ideas. So I am asking some questions here.

      1. What are the various type serviceability API's that will be supported in the future ? I have used JVMTI and JMX and some more are mentioned in http://hirt.se/blog/. The attach API mentioned here uses diagnostic commands. Is there a list of all such commands ?

      2. I use JVMTI like this.

             VM vm = VM.getVM();

             Universe universe = vm.getUniverse();

              CollectedHeap heap = universe.heap();

              if (heap instanceof ParallelScavengeHeap) {

                  ParallelScavengeHeap psHeap = (ParallelScavengeHeap) heap;

                  PSYoungGen y = psHeap.youngGen();

                  MutableSpace youngObjSpace = y.edenSpace();

                  youngCapacity = youngObjSpace.capacity();

                  l.debug(youngCapacity);

              }

       

           JVM 1 attaches to JVM 2. Which JVM executes this code ? Can I create an agent or JMX bean in JVM 2 that uses this code and call it from JVM 1 using JMX ? I am aware the JMX itself

      can give me memory data separately ?

      3. Is  the JMC code freely available for inclusion in another OSS project ? Is JMC or any other API reactive so that the events produced by the JVM(perf. counters ?) trigger the listeners ?

          

       

       

      Thanks,

      Mohan

        • 1. Re: Serviceability API
          Staffan Larsen

          Mohan,

           

          JVMTI, JMX and the attach API are all supported.

           

          The list of diagnostic commands varies with each version of the JVM, but you can easily query the JVM with "$JAVA_HOME/bin/jcmd <pid> help". This will give you a list of all the commands supported for that JVM. "$JAVA_HOME/bin/jcmd <pid> help <command>" will give you details about that particular command.

           

          You code snippet does not look like JVMTI, but Serviceability Agent code. In your case JVM 1 will execute the code. It will first attach to JVM 2 as if it were a debugger (completely suspending execution in JVM 2 until it detaches).

           

          The JMC code is not currently freely available.

           

          Thanks,

          /Staffan

          • 2. Re: Serviceability API
            Mohan

            Hi Staffan,

                               Ok. I have misunderstood. JVMTI deals with JNI agents(http://www.oracle.com/technetwork/articles/javase/jvmti-136367.html )and serviceability API is Java. Right ? Can the attach API do everything that JVMTI does ? If this has all been explained in an article I will read that first. There are a few such technologies and I found it confusing.

             

             

             

            Thanks,

            Mohan

            • 3. Re: Serviceability API
              Staffan Larsen

              Yes, JVMTI is a native API (C or C++) whereas the Serviceability Agent is in Java. JVMTI is a supported and specified API. The Serviceability agent API is not supported and may change at any time.

               

              JVMTI is a very versatile API which can be used of writing debuggers and profilers. The attach API is very specific and only does a few things, one of which is to load a JVMTI agent. In short: they do different things.

               

              JVMTI: http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html

              Attach API: http://docs.oracle.com/javase/8/docs/jdk/api/attach/spec/

               

              /Staffan