users@shoal.java.net

Re: [Shoal-Users] RE: Group Leader PB on Glassfish

From: Shreedhar Ganapathy <Shreedhar.Ganapathy_at_Sun.COM>
Date: Tue, 29 Apr 2008 09:13:49 -0700

Hi Olivier
Please see my responses below:

Olivier LAGACHE wrote:
> Hi Shreedhar,
>
>
> It seems that you have found the solution... But I still have some
> questions in order to make it work
> (https://shoal.dev.java.net/servlets/ReadMsg?list=users&msgNo=165).
>
> Our Web application is deployed on Glassfish and we started our own
> instance of Shoal.
> Maybe it's a good solution with Tomcat server or others but not with
> Glassfih which already uses Shoal.
> The question is how we can get a Shoal instance from our web
> application once deployed in Glassfish Cluster ?
Here's a snippet. After the app has loaded, in an appropriate class that
should implement CallBack interface you could do the following :

public class SomeClassThatTheAppDeployedOnAClusterCalls implements CallBack {

    private GroupManagementService getGMSReference(){

        GroupManagementService gms = GMSFactory.getGMSModule(clusterName);

        return gms;

    }

    private void registerForGMSClusterEvents(){

        //register for group events so that your code can do the needful wrt cleaning up references etc.

        gms.addActionFactory(new JoinNotificationActionFactoryImpl(this);

        gms.addActionFactory(new FailureSuspectedActionFactoryImpl(this);

        gms.addActionFactory(new FailureNotificationActionFactoryImpl(this);

        gms.addActionFactory(new PlannedShutdownActionFactoryImpl(this);

    }

    private List<String> getClusterInstances(){

        GroupHandle gh = gms.getGroupHandle();

        return gh.getCurrentCoreMembers();

    }

    public void processNotification(Signal clusterEventSignal) {

        //handle JoinNotificationSignal, FailureSuspectedSignal, FailureNotificationSignal, PlannedShutdownSignal

        //This will allow your app code to react to dynamic changes to the cluster

    }

}

>
> One of your solution is :
> > If your use case is to pick one member of the cluster (and not
> including DAS), then this approach will not work. What you could do is
> to call GroupHandle.getCurrentCoreMembers(). This returns the cluster
> members
> > who join the group as core members (as opposed to DAS which is a
> Spectator member). You can then choose the first or a specific member
> to be the one you are looking for, to perform the one time task.
>
> Do you mean that GroupHandle.getCurrentCoreMembers() return an ordered
> list and if I choose the first, it will be the first on all instances
> of our application ?
Yes. That is correct. If its not let us know as that would be a bug.
>
> Thanks in anticipation,
>
> Best regards
>
> << Olivier >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_shoal.dev.java.net
> For additional commands, e-mail: users-help_at_shoal.dev.java.net
>