dev@glassfish.java.net

Re: How to get status of cluster instances over AMX or JMX

From: Lloyd Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Mon, 10 Nov 2008 10:36:09 -0800

Peter,

Don't use the com.sun.appserv MBean.

Sreeni, please don't recommend private MBeans which have AMX
equivalents.

Lloyd
..............................................
Lloyd Chambers
lloyd.chambers_at_sun.com
GlassFish team, LSARC member

On Nov 8, 2008, at 10:32 AM, Peter Williams wrote:

>
> Thanks Anissa, Sreeni's comment helped me find "J2EEServer"
> yesterday. That was the bean I was looking for.
>
> Anyway, thanks for the suggestions, all.
>
> -Peter
>
>
> Anissa Lam wrote:
>>
>> Hi Peter,
>>
>> Here is some sample code on how to use AMX API to get the server
>> instance inside a cluster, test if the server instance is running
>> and whether restart is required. Assuming you already has
>> domainRoot, and the clusterName.
>>
>> Map<String, ClusteredServerConfig> serverMap =
>> domainRoot
>> .getDomainConfig
>> ().getClusterConfigMap
>> ().get(clusterName).getClusteredServerConfigMap();
>> //serverMap contains the config of the server instance of
>> this cluster, keyed by the instance name.
>> if (serverMap != null) {
>> for (String serverName : serverMap.keySet()) {
>> J2EEServer j2eeServer =
>> domainRoot.getJ2EEServerMap().get(serverName);
>> int serverState = j2eeServer.getstate();
>> if (serverState == StateManageable.STATE_STOPPING ||
>> serverState == StateManageable.STATE_STOPPED ||
>> serverState == StateManageable.STATE_FAILED) {
>> System.out.println(serverName + " is NOT
>> running");
>> }
>> if (j2eeServer.getRestartRequired() == true) {
>> System.out.println(serverName + " Needs restart");
>> }
>> }
>> }
>>
>> Hope this help.
>>
>> Anissa
>>
>>
>> Sreenivas Munnangi wrote:
>>> Peter Williams wrote:
>>>> I need to know how to get the status (stopped, running, etc.) of
>>>> a server instance inside a cluster using either the AMX api
>>>> (preferable) or JMX calls. I wasn't able to find a JMX field
>>>> that contains this information though. Does anyone know where I
>>>> should be looking?
>>>>
>>>> -Peter
>>>>
>>> I guess, you are referring to v2.
>>>
>>> JSR77 mBeans report the runtime state, for ex.
>>>
>>> * *MBean Name:*
>>>
>>> com.sun.appserv:j2eeType=J2EEServer,name=server,category=runtime
>>>
>>> If the '*stateManageable' is true then you can invoke the
>>> operation '**getRuntimeStatus*
>>> com.sun.enterprise.admin.servermgmt.RuntimeStatus
>>>
>>>
>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>
>>>
>>
>> --------------------------------------------------------------------- To
>> unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net For
>> additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>