users@glassfish.java.net

Re: setting node-specific properties

From: Kedar Mhaswade <Kedar.Mhaswade_at_Sun.COM>
Date: Sat, 26 Jul 2008 16:49:48 -0700

Dick Davies wrote:
> On Sat, Jul 26, 2008 at 2:26 PM, Kedar Mhaswade <Kedar.Mhaswade_at_sun.com> wrote:
>> Absolutely.
>>
>> If all you need is a Java system property that is unique for instances
>> in a cluster, you can do the following:
>>
>> - In the cluster, define a Java system property (we call it JVM option
>> for some weird reason) named defaultClientId (e.g.) using command
>> like: asadmin create-jvm-options -- "-DdefaultClientId=${UNIQUE_NAME}"
>>
>> As a result, the cluster's java-config element would have something
>> like: <jvm-options>-DdefaultClientId=${UNIQUE_NAME} </jvm-options>
>>
>> - Define a GlassFish system property (weird name, but that's what it
>> is!) that overrides the value of UNIQUE_NAME per instance:
>> asadmin create-system-properties --target instance1
>> UNIQUE_NAME=cluster1:instance1
>> asadmin create-system-properties --target instance2
>> UNIQUE_NAME=cluster1:instance2
>
> That sounds like what I want, thanks. Glassfish doesn't expose something
> like the instance name by default, by any chance?
> Would be handy for general debugging if we could grab that (we run this
> behind a Netscaler for load balancing, and it's often useful to expose something
> like a node id for troubleshooting).

There is, but it's not a public interface of GlassFish. It's like
the sun.misc.Base64Encoder class ;) which you not supposed to use.

e.g. inside the application code (assuming security manager allows)
do System.getProperty("com.sun.aas.instanceName"). That's your instance's
name which is guaranteed to be unique in given domain.
@Disclaimer:
Again, rely on this name at your own risk.
>
>> I hope this can be easily tied with Roller's properties file.
>
> Hmm, that's the bit I'm worried about :)
>
> Need to Google up a way to do something like
> appspecific.property = ${some-system-property}
> in a general properties file.
> (Feel free to pipe up, developers :) )
>
> Thanks a lot !
>
>> Regards,
>> Kedar
>>
>>
>> Dick Davies wrote:
>>> Hi, we're running a 2 node GFv2 cluster, and we've got the Roller
>>> weblogger running
>>> on both nodes.
>>>
>>> I've been debugging some weird issues the past day or two and think I
>>> found the problem;
>>> the webapp needs a property
>>>
>>> # client identifier. should be unique for each instance in a cluster.
>>> tasks.clientId=defaultClientId
>>>
>>> (in a bundled properties file) to uniquely identify each
>>> instance (to handle concurrent access to parts of the database).
>>>
>>> Since both glassfish instances are running the same WAR file, they
>>> both have the same clientid.
>>>
>>> I really don't want to have to write 2 different WARfiles, so I'm
>>> wondering if there's a way to set
>>> a system property at glassfish instance startup (-Dclientid=$HOSTNAME),
>>> that I could somehow inject into that properties file?
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>
>
>