Skip to main content

Accessing GF cluster health programmatically?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
lprimak
Offline
Joined: 2006-08-22

I would like to know programmatically which instances in the cluster are running.
Preferably form one of the instances itself,
i.e. asadmin get-health but only programmatically.

Is this possible?

And more generically, can I get access to Project Shoal that's running behind the scenes there?
I would like to know the goodies like when replication happens, etc.

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jfialli
Offline
Joined: 2003-06-16

On 11/7/12 4:32 AM, forums@java.net wrote:
> I would like to know programmatically which instances in the cluster are
> running. Preferably form one of the instances itself, i.e. asadmin
> get-health
> but only programmatically. Is this possible?
As a restful web service.

You can access the asadmin get-health command as a restful web service
as of glassfish 3.1.2 and greater versions.

Here is an example url to access info for cluster /***myCluster*/
running on machine /*hostname-running-DAS*/ with 3 clustered instances.

http:///*hostname-running-DAS*/:4848/management/domain/clusters/cluster/...

{
"extraProperties": {
"commandLog": ["get-health --DEFAULT myCluster --clusterName myCluster"],
"instances": [
{
"status": "RUNNING",
"name": "instance01",
"time": "1352306126796"
},
{
"status": "RUNNING",
"name": "instance02",
"time": "1352306127034"
},
{
"status": "RUNNING",
"name": "instance03",
"time": "1352306126744"
}
]
},
"properties": {},
"message": "instance01 started since Wed Nov 07 11:35:26 EST 2012\ninstance02 started since Wed Nov 07 11:35:27 EST 2012\ninstance03 started since Wed Nov 07 11:35:26 EST 2012"
}

-Joe Fialli

>
> --
>
> [Message sent by forum member 'lprimak']
>
> View Post: http://forums.java.net/node/892052
>
>

lprimak
Offline
Joined: 2006-08-22

Thanks, I will try that.

I want to do this from a web/JEE app that runs on one of the cluster node.

Is there a way to do this from JMX? Or something local to the cluster node?
Configuring the location of DAS for my webapp and introducing localhost REST service
seems like an overkill. Also, I am looking for more than just health-check.
health-check is a bear minimum.

THanks a lot for all your answers!

tmueller
Offline
Joined: 2005-10-31

From what programming environment? Web app? HK2 module? Embedded server?

The APIs that are available depend on the programming environment where
your code is running.

Tom