Package org.jboss.profiler.jvmti

Examples of org.jboss.profiler.jvmti.JVMTIInterface


      conn.start();
      MessageConsumer cons = sess.createConsumer(queue);

      produceMessages(sess, prod, 100, cons);
     
      JVMTIInterface jvmti = new JVMTIInterface();
      Map inventory1=jvmti.produceInventory();
      log.info("Producing first snapshot");
      produceMessages(sess, prod, NUM_MESSAGES, cons);
      log.info("Producing second snapshot");
      jvmti.forceReleaseOnSoftReferences();
      jvmti.forceGC();
      Map inventory2 = jvmti.produceInventory();
     
      log.info("inventory1.size=" + inventory1.size());
      log.info("inventory2.size=" + inventory2.size());
     
      assertTrue("Test produced unexpected objects",jvmti.compareInventories(System.out, inventory1,inventory2,null, null, new InventoryDataPoint[] {new InventoryDataPoint(Object.class,10)}));
           
      conn.close();
     
      conn = null;
     
View Full Code Here


      MessageConsumer cons1 = sess.createConsumer(queue,"target='1'");
      MessageConsumer cons2 = sess.createConsumer(queue,"target='2'");

      produceMessages(sess, prod, 30, cons1,cons2,payLoad);
     
      JVMTIInterface jvmti = new JVMTIInterface();
      Map inventory1=jvmti.produceInventory();
      log.info("Producing first snapshot");
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      log.info("Producing second snapshot");
      Map inventory2 = jvmti.produceInventory();
     
      log.info("inventory1.size=" + inventory1.size());
      log.info("inventory2.size=" + inventory2.size());
     
      assertTrue("Test produced unexpected objects",jvmti.compareInventories(System.out, inventory1,inventory2,null, null, new InventoryDataPoint[] {new InventoryDataPoint(Object.class,10)}));
     
      conn.close();
     
      conn = null;
     
View Full Code Here

    * @param reportHTMLFile the report file
    * @throws Exception
    */
   protected void checkUnload(WeakReference weakReferenceOnLoader, String className, String reportHTMLFile) throws Exception
   {
      JVMTIInterface jvmti = new JVMTIInterface();
      if (jvmti.isActive())
      {
         jvmti.forceGC();
         Class clazz = jvmti.getClassByName(className);
         if (clazz!=null)
         {
            jvmti.heapSnapshot("snapshot", "mem");
            clazz=null;
           
            String report =jvmti.exploreClassReferences(className, 10, true, false, false, false, false);
           
            System.out.println(report);
            File outputfile = new File(reportHTMLFile);
            FileOutputStream outfile = new FileOutputStream(outputfile);
            PrintStream realoutput = new PrintStream(outfile);
            realoutput.println(report);
            realoutput.close();
           
           
            jvmti.forceGC();
           
            clazz = jvmti.getClassByName(className);
           
            if (clazz==null)
            {
                System.out.println("Attention: After clearing every field on AspectManager, GC could release the classLoader");
            }
View Full Code Here

    * @param className the class name
    */
   protected void clearEverySingleFieldOnInstances(String className)
   {
      System.out.println("Clearing " + className);
      JVMTIInterface jvmti = new JVMTIInterface();
      Class classes[] = jvmti.getLoadedClasses();
      Object objects[] = null;
     
      for (int i=0;i<classes.length;i++)
      {
         if (classes[i].getName().equals(className))
         {
            Field fields[] = getDeclaredFields(classes[i]);
            objects = jvmti.getAllObjects(classes[i]);
            for (int j=0;j<objects.length;j++)
            {
               resetObject(objects[j], fields);
            }
            if (objects.length==0)
View Full Code Here

   public void testValidateFailover() throws Exception
   {
      Connection conn = null;

      JVMTIInterface jvmti = new JVMTIInterface();

      try
      {
         conn = cf.createConnection();
         conn.close();
         conn = cf.createConnection();
         conn.start();

         // make sure we're connecting to node 1

         int nodeID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn).
            getDelegate()).getState()).getServerID();

         assertEquals(1, nodeID);

         Session s1 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer c1 = s1.createConsumer(queue[1]);
         JBossMessageProducer p1 = (JBossMessageProducer)s1.createProducer(queue[1]);
         p1.setDeliveryMode(DeliveryMode.PERSISTENT);

         // send a message

         p1.send(s1.createTextMessage("blip"));
         assertNotNull(c1.receive());
         p1.send(s1.createTextMessage("blip again"));

         log.info("Producing inventory");

         Map inventory1 = jvmti.produceInventory();

         // kill node 1

         ServerManagement.killAndWait(1);
         log.info("########");
         log.info("######## KILLED NODE 1");
         log.info("########");

         try
         {
            ic[1].lookup("queue"); // looking up anything
            fail("The server still alive, kill didn't work yet");
         }
         catch (Exception e)
         {
         }

         // we must receive the message

         TextMessage tm = (TextMessage)c1.receive(1000);
         assertEquals("blip again", tm.getText());

         log.info("Forcing release on SoftReferences");
         jvmti.forceReleaseOnSoftReferences();
         jvmti.forceGC();

         Map inventory2 = jvmti.produceInventory();

         InventoryDataPoint dataPoint = (InventoryDataPoint) inventory2.get(ProducerState.class);
         if (dataPoint.getInstances() > 1)
         {
            // We should only have this producerState... we will look for where are the
            // other references
            ProducerState originalState = (ProducerState )
                ((DelegateSupport)p1.getDelegate()).getState();
            Object obj[] = jvmti.getAllObjects(ProducerState.class);

            for (int i = 0; i < obj.length; i++)
            {
               if (obj[i] != originalState)
               {
                  log.info("Exploring references on " + obj[i]);
                  Object[] holders = jvmti.getReferenceHolders(new Object[]{obj[i]});

                  for (int j = 0; j < holders.length; j++)
                  {
                     log.info("Holder[" + j + "] = " + holders[j]);
                  }

               }
            }

         }

         assertTrue("Test produced unexpected objects", jvmti.compareInventories(System.out,
            inventory1, inventory2, null, null,
            new InventoryDataPoint[]{new InventoryDataPoint(Object.class, 10)}));

      }
      finally
View Full Code Here

   // Public ---------------------------------------------------------------------------------------

   public void testValidateOpening() throws Exception
   {
      JVMTIInterface jvmti = new JVMTIInterface();


      Map inventory1 = null;
      Connection conn = null;
      for (int i=0;i<100;i++)
      {
         log.info("Creating connection " + i);
         conn = cf.createConnection();
         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer producer = session.createProducer(queue[0]);
         MessageConsumer consumer = session.createConsumer(queue[0]);
         conn.start();
         Thread.sleep(100);
         conn.close();

         if (i==10)
         {
            inventory1 = jvmti.produceInventory();
         }
      }

      conn = null;


      jvmti.forceReleaseOnSoftReferences();
      jvmti.forceGC();

      Map inventory2 = jvmti.produceInventory();

      validateInstances(jvmti, FailoverValve2.class, inventory2, 1);
      validateInstances(jvmti, ClientConsumer.class, inventory2, 1);

      assertTrue("Test produced unexpected objects", jvmti.compareInventories(System.out,
          inventory1, inventory2, null, null,
          new InventoryDataPoint[]{new InventoryDataPoint(java.lang.ref.SoftReference.class, 10),
                                   new InventoryDataPoint(jvmti.getClassByName("java.io.ObjectStreamClass$WeakClassKey"), 100),
             new InventoryDataPoint(jvmti.getClassByName("java.util.concurrent.ConcurrentHashMap$HashEntry"), 100),
             new InventoryDataPoint(jvmti.getClassByName("java.util.WeakHashMap$Entry"), 500)

                                   }));

   }
View Full Code Here

   public void testValidateFailover() throws Exception
   {
      Connection conn = null;

      JVMTIInterface jvmti = new JVMTIInterface();

      try
      {
         conn = cf.createConnection();
         conn.close();
         conn = cf.createConnection();
         conn.start();

         // make sure we're connecting to node 1

         int nodeID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn).
            getDelegate()).getState()).getServerID();

         assertEquals(1, nodeID);

         Session s1 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer c1 = s1.createConsumer(queue[1]);
         JBossMessageProducer p1 = (JBossMessageProducer)s1.createProducer(queue[1]);
         p1.setDeliveryMode(DeliveryMode.PERSISTENT);

         // send a message

         p1.send(s1.createTextMessage("blip"));
         assertNotNull(c1.receive());
         p1.send(s1.createTextMessage("blip again"));

         log.info("Producing inventory");

         Map inventory1 = jvmti.produceInventory();

         // kill node 1

         ServerManagement.kill(1);
         log.info("########");
         log.info("######## KILLED NODE 1");
         log.info("########");

         try
         {
            ic[1].lookup("queue"); // looking up anything
            fail("The server still alive, kill didn't work yet");
         }
         catch (Exception e)
         {
         }

         // we must receive the message

         TextMessage tm = (TextMessage)c1.receive(1000);
         assertEquals("blip again", tm.getText());

         log.info("Forcing release on SoftReferences");
         jvmti.forceReleaseOnSoftReferences();
         jvmti.forceGC();

         Map inventory2 = jvmti.produceInventory();

         validateInstances(jvmti, ClientConnectionDelegate.class, inventory2, 1);
         validateInstances(jvmti, ConnectionState.class, inventory2, 1);
         validateInstances(jvmti, MessageConsumer.class, inventory2, 1);
         validateInstances(jvmti, ProducerState.class, inventory2, 1);
View Full Code Here

    assertSame(a,objects[0]);
  }
 
  public void testGetObjects()
    {
        JVMTIInterface interfaceJVMTI = new JVMTIInterface();
        Object[] result = interfaceJVMTI.getAllObjects(java.lang.String.class);

        for (int i = 0; i < result.length; i++)
        {
            System.out.println("String result[" + i + "]=" + result[i]);
        }

        result = interfaceJVMTI.getAllObjects(java.lang.Class.class);
        assertTrue(result.length>0);

        for (int i = 0; i < result.length; i++)
        {
            System.out.println("class result[" + i + "]=" + result[i]);
View Full Code Here

        }
    }
   
    public void testHolders() throws Exception
    {
        JVMTIInterface interfaceJVMTI = new JVMTIInterface();
       
      Object holders[] = interfaceJVMTI.getReferenceHolders(new Object[]{this});
     
      System.out.println("There are " + holders.length + " holding a reference");
    }
View Full Code Here

      System.out.println("There are " + holders.length + " holding a reference");
    }

    public void testNavigation() throws Exception
    {
        JVMTIInterface interfaceJVMTI = new JVMTIInterface();
        Class classes[] = interfaceJVMTI.getLoadedClasses();
        System.out.println("length=" + classes.length);
        ArrayList stringVer = new ArrayList();
        stringVer.add(new String("tst"));
        try
        {
            Thread.sleep(1000);
        } catch (Exception e)
        {
            e.printStackTrace();
        }

        Holder holder = new Holder();
        holder.addInstance(new UsedByHolder());
        holder.addInstance(new UsedByHolder());

        Holder holder2 = new Holder();
        holder2.addInstance(new UsedByHolder());
        holder2.addInstance(new UsedByHolder());
       
        Holder holder3 = new Holder();
        holder3=null;
       
        local.set(holder3);
       
       

        JVMTIInterface jvmti = new JVMTIInterface();
        jvmti.forceGC();
       
        //File tmpFile = File.createTempFile("profiler","");
        File tmpFile = new File("tst","");
       
        System.out.println("Generating data to " + tmpFile.getAbsolutePath());
       
        jvmti.heapSnapshot(tmpFile.getAbsolutePath(), "log");
        holder.print();
        holder2.print();
       
        MemorySnapshotEngine engine = new MemorySnapshotEngine();
        engine.processFiles(tmpFile.getAbsolutePath(),"log");
View Full Code Here

TOP

Related Classes of org.jboss.profiler.jvmti.JVMTIInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.