Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 43771 invoked from network); 3 Sep 2006 04:38:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Sep 2006 04:38:34 -0000 Received: (qmail 65172 invoked by uid 500); 3 Sep 2006 04:38:27 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 65137 invoked by uid 500); 3 Sep 2006 04:38:27 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 65107 invoked by uid 99); 3 Sep 2006 04:38:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Sep 2006 21:38:27 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of deepu.srinivasa@gmail.com designates 64.233.166.179 as permitted sender) Received: from [64.233.166.179] (HELO py-out-1112.google.com) (64.233.166.179) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Sep 2006 21:38:25 -0700 Received: by py-out-1112.google.com with SMTP id x66so3558334pye for ; Sat, 02 Sep 2006 21:38:05 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=BxOezFtukzrkCWb6NiwB4kdDCrVTfh8eqhJ8pFGLMyljfzPJn1AiIxZ2ZZbMA1KRXh/Jp8hztM7OhsMRnCGamakdLa5MI0v6d6V8qlsuNbS7olMVNMaqQDAeX76YkCoIoMQGMevTOyvkOVGXYUFgcDx+TRi6B8qc/jAMiLXNNNw= Received: by 10.35.45.14 with SMTP id x14mr6863925pyj; Sat, 02 Sep 2006 21:38:04 -0700 (PDT) Received: by 10.35.11.14 with HTTP; Sat, 2 Sep 2006 21:38:04 -0700 (PDT) Message-ID: <6eeff4ea0609022138s21f95e5h6a69d015e467bfe5@mail.gmail.com> Date: Sun, 3 Sep 2006 10:08:04 +0530 From: "Deepak Srinivasa" To: dev@geronimo.apache.org Subject: Re: When has the server started? In-Reply-To: <1E373D7E-E9C6-4F5E-BECE-24FA799E2098@planet57.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_25510_20935374.1157258284767" References: <1E373D7E-E9C6-4F5E-BECE-24FA799E2098@planet57.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_25510_20935374.1157258284767 Content-Type: multipart/alternative; boundary="----=_Part_25511_9059130.1157258284767" ------=_Part_25511_9059130.1157258284767 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Jason, I was interested too, in finding out this piece of information from my server... In Geronimo 1.0, the code below 'ServerWhenStart.java' works. It basically gets hold of the Kernel, then gets a KernelManagementHelper object, and then queries for the JVM, to find out its boot time (I am assuming that JVM start time is close to what you are looking for). However, in Geronimo 1.1, this fails. I am able to get the KernelManagementHelper object, and also able to look up the domains. But I cannot get the servers from the first domain. In jconsole, I wish that the VM tab was active. The VM tab gives info about the uptime of VM (I have seen that when I ran jconsole to see JMX info for other software). Then, we could have done currentTime-upTime to get the boot time. If you are successful in getting server configuration information from JMX, please let me know how you did that. Thanks! -Deepu. ------------- ServerWhenStart.java ----------------- import java.util.Date; import javax.management.MBeanServerConnection; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import org.apache.geronimo.console.util.KernelManagementHelper; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.jmx.KernelDelegate; import org.apache.geronimo.management.J2EEDomain; import org.apache.geronimo.management.geronimo.J2EEServer; import org.apache.geronimo.management.geronimo.JVM; public class ServerWhenStart { /** * @param args */ public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub java.util.Map environment = new java.util.HashMap(); String[] credentials = new String[]{"system", "manager"}; environment.put(JMXConnector.CREDENTIALS, credentials); JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/JMXConnector"); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment); MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection(); Kernel kernel = new KernelDelegate(mbServerConnection); KernelManagementHelper mgr = new KernelManagementHelper(kernel); J2EEDomain domain = mgr.getDomains()[0]; //This is where it fails J2EEServer[] server = mgr.getServers(domain)[0]; JVM[] jvms = mgr.getJavaVMs(server); //I am thinking that the first VM is what we are interested in... (is that right??) JVM jvm = jvms[0]; Date bootTime = jvm.getKernelBootTime(); System.out.println(bootTime); } } On 9/2/06, Jason Dillon wrote: > > What is the best way to detect when the server has started using JMX? > > The ServerBehavior class in the deployment plugin has some code that > connects to JMX, then lists the configurations, and then takes he > first configuration and get the "kernelFulltStarted" attribute from > it... but it assumes that ConfigurationManager.listConfigurations() > returns an array of ObjectNames, which it does not. > > I also peeked at the server's JMX tree via jconsole and I don't see > any attribute or operation that matches up to "kernelFullyStarted". > There is also a strange "null" element of the tree, but I will leave > that for another day. > > So, how can I easily check of the server has started by polling a JMX > attribute? > > --jason > ------=_Part_25511_9059130.1157258284767 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Jason,

I was interested too, in finding out this piece of information from my server...

In Geronimo 1.0, the code below 'ServerWhenStart.java' works. It basically gets hold of the Kernel, then gets a KernelManagementHelper object, and then queries for the JVM, to find out its boot time (I am assuming that JVM start time is close to what you are looking for).

However, in Geronimo 1.1, this fails. I am able to get the KernelManagementHelper object, and also able to look up the domains. But I cannot get the servers from the first domain.

In jconsole, I wish that the VM tab was active. The VM tab gives info about the uptime of VM (I have seen that when I ran jconsole to see JMX info for other software). Then, we could have done currentTime-upTime to get the boot time.

If you are successful in getting server configuration information from JMX, please let me know how you did that. Thanks!

-Deepu.

------------- ServerWhenStart.java -----------------
import java.util.Date ;

import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

import org.apache.geronimo.console.util.KernelManagementHelper;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.jmx.KernelDelegate;
import org.apache.geronimo.management.J2EEDomain;
import org.apache.geronimo.management.geronimo.J2EEServer;
import org.apache.geronimo.management.geronimo.JVM;

public class ServerWhenStart {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception{
        // TODO Auto-generated method stub
       
        java.util.Map environment = new java.util.HashMap();
        String[] credentials = new String[]{"system", "manager"};
        environment.put(JMXConnector.CREDENTIALS, credentials);
        JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/JMXConnector");
        JMXConnector jmxConnector = JMXConnectorFactory.connect (address, environment);
        MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection();
        Kernel kernel = new KernelDelegate(mbServerConnection);
       
        KernelManagementHelper mgr = new KernelManagementHelper(kernel);
        J2EEDomain domain = mgr.getDomains()[0];
       
        //This is where it fails
        J2EEServer[] server = mgr.getServers(domain)[0];
        JVM[] jvms = mgr.getJavaVMs(server);
       
        //I am thinking that the first VM is what we are interested in... (is that right??)
        JVM jvm = jvms[0];
        Date bootTime = jvm.getKernelBootTime();
        System.out.println(bootTime);

    }

}



On 9/2/06, Jason Dillon <jason@planet57.com> wrote:
What is the best way to detect when the server has started using JMX?

The ServerBehavior class in the deployment plugin has some code that
connects to JMX, then lists the configurations, and then takes he
first configuration and get the "kernelFulltStarted" attribute from
it... but it assumes that ConfigurationManager.listConfigurations()
returns an array of ObjectNames, which it does not.

I also peeked at the server's JMX tree via jconsole and I don't see
any attribute or operation that matches up to "kernelFullyStarted".
There is also a strange "null" element of the tree, but I will leave
that for another day.

So, how can I easily check of the server has started by polling a JMX
attribute?

--jason

------=_Part_25511_9059130.1157258284767-- ------=_Part_25510_20935374.1157258284767 Content-Type: application/octet-stream; name=ServerWhenStart.java Content-Transfer-Encoding: base64 X-Attachment-Id: f_ermwvo7q Content-Disposition: attachment; filename="ServerWhenStart.java" aW1wb3J0IGphdmEudXRpbC5EYXRlOw0KDQppbXBvcnQgamF2YXgubWFuYWdlbWVudC5NQmVhblNl cnZlckNvbm5lY3Rpb247DQppbXBvcnQgamF2YXgubWFuYWdlbWVudC5yZW1vdGUuSk1YQ29ubmVj dG9yOw0KaW1wb3J0IGphdmF4Lm1hbmFnZW1lbnQucmVtb3RlLkpNWENvbm5lY3RvckZhY3Rvcnk7 DQppbXBvcnQgamF2YXgubWFuYWdlbWVudC5yZW1vdGUuSk1YU2VydmljZVVSTDsNCg0KaW1wb3J0 IG9yZy5hcGFjaGUuZ2Vyb25pbW8uY29uc29sZS51dGlsLktlcm5lbE1hbmFnZW1lbnRIZWxwZXI7 DQppbXBvcnQgb3JnLmFwYWNoZS5nZXJvbmltby5rZXJuZWwuS2VybmVsOw0KaW1wb3J0IG9yZy5h cGFjaGUuZ2Vyb25pbW8ua2VybmVsLmpteC5LZXJuZWxEZWxlZ2F0ZTsNCmltcG9ydCBvcmcuYXBh Y2hlLmdlcm9uaW1vLm1hbmFnZW1lbnQuSjJFRURvbWFpbjsNCmltcG9ydCBvcmcuYXBhY2hlLmdl cm9uaW1vLm1hbmFnZW1lbnQuZ2Vyb25pbW8uSjJFRVNlcnZlcjsNCmltcG9ydCBvcmcuYXBhY2hl Lmdlcm9uaW1vLm1hbmFnZW1lbnQuZ2Vyb25pbW8uSlZNOw0KDQpwdWJsaWMgY2xhc3MgU2VydmVy V2hlblN0YXJ0IHsNCg0KICAgIC8qKg0KICAgICAqIEBwYXJhbSBhcmdzDQogICAgICovDQogICAg cHVibGljIHN0YXRpYyB2b2lkIG1haW4oU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0K ICAgICAgICBKVk1bXSBqdm1zID0gbWdyLmdldEphdmFWTXMoc2VydmVyKTsNCiAgICAgICAgDQog ICAgICAgIC8vSSBhbSB0aGlua2luZyB0aGVyZSBpcyBvbmx5IG9uZSBKVk0gZm9yIHRoaXMgc2Vy dmVyLi4uIChpcyB0aGF0IHJpZ2h0Pz8pDQogICAgICAgIEpWTSBqdm0gPSBqdm1zWzBdOw0KICAg ICAgICBEYXRlIGJvb3RUaW1lID0ganZtLmdldEtlcm5lbEJvb3RUaW1lKCk7DQogICAgICAgIFN5 c3RlbS5vdXQucHJpbnRsbihib290VGltZSk7DQoNCiAgICB9DQoNCn0= ------=_Part_25510_20935374.1157258284767--