admin@glassfish.java.net

Re: Fwd: Re: A question on getAvailabilityServiceEnabled()

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Thu, 14 Jul 2011 15:16:54 -0500

Interesting. Jerome had raised this exact issue as part of our work to
split off nucleus.
Right now, in the DAS, if you do:

@Inject AvailabilityService ss;

There isn't any guarantee that the AvailabilityService that you get is
the one for the server that you are running. And as you have observed,
if one isn't declared in server-config, then you will get one that is
declared elsewhere. The only reason that you get the one from
server-config for ANY config service is because server-config is first
in the domain.xml file.

To fix this now, you can do the following:

@Inject(name=ServerEnvironment.DEFAULT_INSTANCE_NAME) Config config;

and then somewhere else, do:

AvailabilityService ss = config.getAvailabilityService();

As we refactor config-api.jar, we may move the AvailabilityService out
of nucleus. If that happens, then the 2nd statement would either be:

@Inject(name=ServerEnvironment.DEFAULT_INSTANCE_NAME)
AvailabilityService ss;

or

AvailabilityService ss =
config.getExtensionByType(AvailabilityService.class);

We are still working about the details of this latter design.

Tom


On 7/14/2011 2:22 PM, Shing Wai Chan wrote:
> I have done option c) locally in my machine.
> I notice something that I do not understand.
> 1. There is no availability-service in server-config of domain.xml.
> There is one availability-service in default-config.
> 2. In WebContainer.java, we have the following:
> @Inject(optional = true)
> private AvailabilityService availabilityService;
>
> I find that it will pick up the AvailabilityService from
> default-config, not the null from server-config.
> I confirm this in debugger by changing the attribute of
> availability-service in default-config.
>
> The question is whether it is the correct behavior to get the
> AvailabilityService from default-config if there is none in
> server-config. If not, then can we inject the correct
> AvailabilityService from server-config.
> Or should we create a availability-service with
> availability-enabled=false in server-config?
> Any comment?
>
> Shing Wai Chan
>
>
> On 7/14/11 12:05 PM, Mahesh.Kannan_at_Oracle.Com wrote:
>>
>>
>> -------- Original Message --------
>> Subject: Re: A question on getAvailabilityServiceEnabled()
>> Date: Thu, 14 Jul 2011 12:04:51 -0700
>> From: Mahesh.Kannan_at_Oracle.Com <Mahesh.Kannan_at_Oracle.Com>
>> To: admin_at_glassfish.java.net
>>
>>
>>
>> OK. On second thought, I think it is risky to set the top level
>> availability-enabled to false. Setting the top level to false4 will
>> completely turn off HA which might break a whole lot of QA HA tests.
>>
>> Thanks,
>> --Mahesh
>>
>> On 07/14/2011 10:38 AM,Mahesh.Kannan_at_Oracle.Com wrote:
>> > Agree with Jerome that Option C is the easiest.
>> >
>> > Regarding why there are so many different settings, yes it is possible
>> > to deploy an app that has web container ha 'on' but ejb container ha
>> > 'off'. Its been like this since 8.x days
>> >
>> > Having said that, I looked into the WebContainer.java and it looks
>> > like the call to
>> > habitat.getComponent(WebContainerFeatureFactory.class,
>> > featureFactoryname) may be modified to avoid loading
>> > HAWebContainerFeatureFactoryImpl. I could be wrong here but will
>> > discuss this with Shing Wai.
>> >
>> > Thanks,
>> > --Mahesh
>> >
>> > On 07/14/2011 02:43 AM, Jerome Dochez wrote:
>> >> I think c) is probably the least risky.
>> >>
>> >> Do we know why we have all those different availability settings ?
>> >> It's not like we can have web container in HA mode and ejb container
>> >> not, correct ?
>> >>
>> >> Mahesh, any feedback ?
>> >>
>> >> jerome
>> >> On Jul 13, 2011, at 5:42 PM, Shing Wai Chan wrote:
>> >>
>> >>> While investigatinghttp://java.net/jira/browse/GLASSFISH-17041
>> >>> I notice that
>> >>> serverConfigLookup.getWebContainerAvailabilityEnabledFromConfig() =
>> >>> true
>> >>> out of the box. In other words, we are using HA by default. I don't
>> >>> think this is the desirable behavior.
>> >>>
>> >>> While investigating, I find the following:
>> >>> 1. In domain.xml, we have
>> >>> <availability-service>
>> >>> <web-container-availability></web-container-availability>
>> >>> <ejb-container-availability
>> >>> sfsb-store-pool-name="jdbc/hastore"></ejb-container-availability>
>> >>> <jms-availability></jms-availability>
>> >>> </availability-service>
>> >>>
>> >>> 2. In admin/config-api:
>> >>> For AvailabilityService, WebContainerAvailability,
>> >>> EjbContainerAvailability, getAvailabilityEnabled()
>> >>> has a "true" as default.
>> >>> Note that JmsAvailability.getAvailabilityEnabled() has a "false"
>> >>> as default.
>> >>>
>> >>> There are several possibilities to resolve this issue:
>> >>> a) remove the<availability-service> in the domain.xml
>> >>> I do not know whether there is any side effect in admin / admin
>> >>> console side
>> >>>
>> >>> b) add availability-enabled="false" to availability-service,
>> >>> web-container-availability, ejb-container-availability
>> >>> At least, we have to add it to web-container-availability and
>> >>> ejb-container-availability.
>> >>>
>> >>> c) change the default value of getAvailabilityServiceEnabled() in
>> >>> AvailabilityService, WebContainerAvailability,
>> >>> EjbContainerAvailability of config-api.
>> >>>
>> >>> Any comment?
>> >
>>
>