dev@glassfish.java.net

Re: getting server-config in an instance

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Fri, 23 Sep 2011 09:20:12 -0500

Bobby,
Currently there isn't any case (AFAIK) of an instance invoking a command
on the DAS. During instance startup, the asadmin command runs
_synchronize-files on the DAS, but that is asadmin doing it, not the
instance itself.

There are many examples in the DAS code when the DAS invokes a command
on an instance. For example, the list-instances command uses the
InstanceInfo class which then uses InstanceCommandExecutor which uses
ServerRemoteAdminCommand. The ServerRemoteAdminCommand class can be
used directly if you don't need to run the command in the background.
InstanceCommandExecutor is a Runnable so that you can run it in a
background thread.

An example of using ServerRemoteAdminCommand directly is the
StopInstanceCommand class.

Tom



On 9/23/2011 8:44 AM, Bobby Bissett wrote:
> Thanks for the info Tom.
>
> Another option I have now is to make a remote call to the DAS to ask
> for the property. The in-code equivalent of:
>
> asadmin --host [hostname] get
> configs.config.server-config.system-property.GMS_LISTENER_PORT-[cluster name].value
>
>
> Can you tell me what the proper way is to do that (if any) from within
> the gms-adapter module? Something with RemoteCommand I guess, but
> you'd know up front if there are any issues with this approach.
>
> I have the DAS host and admin port already at this point in the code.
> I know that it will only work if secure admin is turned on, but I'd at
> least like to provide the option. This is something we'd like to get
> into 3.1.2 also, if possible, in case that makes a difference.
>
> Thanks,
> Bobby
>
> On 9/21/11 4:33 PM, Tom Mueller wrote:
>> Currently no.
>>
>> When an instance reads the domain.xml file, it only reads in its own
>> config, it's own cluster, and the server elements that are in its own
>> cluster. The "server-config" and the "server" <server> element are
>> never read in by an instance.
>>
>> This behavior is implemented by the InstanceReaderFilter which is
>> only used on instances. The DAS uses the DasReaderFilter. The
>> choice between these is made by the DomainXml class. These are all
>> in the admin/config-api module.
>>
>> We have several options for fixing this as we work towards a cluster
>> that includes the DAS and eventually a floating DAS. One is to
>> include the DAS server-ref in the cluster element. Also, we may not
>> want to have the DAS be special (always named "server") and give the
>> DAS a normal instance name.
>>
>> Tom
>>
>> On 9/21/2011 3:16 PM, Bobby Bissett wrote:
>>> Hi all,
>>>
>>> From an instance starting up, I'm trying to get the DAS's host name
>>> and gms port so that the instance can connect to the DAS without
>>> multicast. I can get the host name just fine from the das.properties
>>> file, but can't reach the port info for some reason. The server
>>> config contains this sys prop, which I'm trying to read:
>>>
>>> <configs>
>>> <config name="server-config">
>>> <system-property name="GMS_LISTENER_PORT-clus"
>>> value="9090"></system-property>
>>> etc.
>>>
>>> In the gms adapter, I'm injecting the domain object, and am trying:
>>>
>>> Config serverConf =
>>> domain.getConfigNamed("server-config");
>>>
>>> ...but this is always null. If I iterate over the configs in
>>> domain.getConfigs().getConfig(), the only config that shows up is
>>> the cluster one, "clus-config" in this case.
>>>
>>> Can an instance not read the das's configuration info?
>>>
>>> Thanks,
>>> Bobby
>>>
>