Skip to main content

Is there a way for code to query what instance it is currently running on?

2 replies [Last post]
schaffer1969
Offline
Joined: 2012-07-12
Points: 0

I'm trying to write some code that needs to be aware of the instance it is running on in a cluster.
I know by using the REST API it is possible to find out the instances that are active and also the hostnames/ip addresses of each instance.

https://DAS:4848/management/domain/clusters/cluster/{cluster id}/get-health
https://DAS:4848/management/domain/servers/server
https://DAS:4848/management/domain/servers/server/{instance id}

but I've no idea if it is possible to get the instance code is currently running on.

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tmueller
Offline
Joined: 2005-10-31
Points: 0

If you don't mind using a non-portable interface,
System.getProperty("com.sun.aas.instanceName") returns the instance name.

Tom

On 8/15/2012 12:44 PM, forums@java.net wrote:
> Is there a way for code to query what instance it is currently running
> on?
> I'm trying to write some code that needs to be aware of the instance
> it is
> running on in a cluster. I know by using the REST API it is possible
> to find
> out the instances that are active and also the hostnames/ip addresses
> of each
> instance. https://DAS:4848/management/domain/clusters/cluster/{cluster
> id}/get-health https://DAS:4848/management/domain/servers/server
> https://DAS:4848/management/domain/servers/server/{instance id} Thanks
>
> --
>
> [Message sent by forum member 'schaffer1969']
>
> View Post: http://forums.java.net/node/889163
>
>

schaffer1969
Offline
Joined: 2012-07-12
Points: 0

Great. Works perfectly!

Thanks