dev@shoal.java.net

Re: Re: [Shoal-Dev] GroupLeader Test

From: leehui <leehui70_at_gmail.com>
Date: Thu, 1 May 2008 10:04:26 +0800

Hi Shreedhar,
        
        Glad to receive your letter.

        I can contribute the test as you said, and I can also file the tracker issue.
        But how to commit my test codes? I have no privilege. If I need to contact to somebody?

        By the way, what NPE respects for?

        Best Regard.
        

------------------
leehui
2008-05-01

-------------------------------------------------------------
发件人:Shreedhar Ganapathy
发送日期:2008-05-01 03:21:27
收件人:dev_at_shoal.dev.java.net
抄送:
主题:Re: [Shoal-Dev] GroupLeader Test

Hi Leehui
Thanks for writing the test.
Can you contribute it into the tests directory with the following
package name?
com.sun.enterprise.shoal.groupleadertest

Also for the NPE, could you file an issue tracker issue?

See below for responses:

leehui wrote:
> Hi,
>
> I write a simple class to test shoal's GroupLeader functions. The codes like this:
>
> import java.util.UUID;
>
> import com.sun.enterprise.ee.cms.core.GMSException;
> import com.sun.enterprise.ee.cms.core.GMSFactory;
> import com.sun.enterprise.ee.cms.core.GroupHandle;
> import com.sun.enterprise.ee.cms.core.GroupManagementService;
> import com.sun.enterprise.ee.cms.core.GroupManagementService.MemberType;
>
>
> public class SimpleTest {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
>
>
> String serverToken = UUID.randomUUID().toString();
> GroupManagementService gms = (GroupManagementService) GMSFactory.startGMSModule(serverToken, "DemoGroup", MemberType.CORE, null);
> try {
> gms.join();
> } catch (GMSException e) {
> e.printStackTrace();
> }
>
> GroupHandle groupHandle = gms.getGroupHandle();
> System.out.println(groupHandle.isGroupLeader());
> System.out.println(groupHandle.getGroupLeader());
>
> try {
> Thread.sleep(2000);
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
>
> System.out.println(groupHandle.isGroupLeader());
> System.out.println(groupHandle.getGroupLeader());
>
>
> }
>
> }
>
> When I run it, the console prints:
>
> false
> e2fed556-ff76-4a38-9645-c1f6160dc07f
> 2008-4-30 14:29:33 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow getMemberTokens
> 信息: GMS View Change Received for group DemoGroup : Members in view for (before change analysis) are :
> 1: MemberId: e2fed556-ff76-4a38-9645-c1f6160dc07f, MemberType: CORE, Address: urn:jxta:uuid-289CBAB1836A4A009242B36E1509E49AE78AB5C0E6B94A499134E1DEA803497203
>
> 2008-4-30 14:29:33 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow newViewObserved
> 信息: Analyzing new membership snapshot received as part of event : MASTER_CHANGE_EVENT
> false
> e2fed556-ff76-4a38-9645-c1f6160dc07f
>
> (1) Why isGroupLeader() returns false? I think it should return true.
>
The process when it initially is in discovery phase only assumes
leadership temporarily. There is a subtle difference between assuming
leadership during master discovery phase and post discovery assignment
of master. During the discovery phase there is no group level master,
only a local placeholder master. Hence false is returned to the query.
>
> Then, I start another instance of SimpleTest, the console prints:
>
> false
> 836f3c91-a20a-4edf-a13c-326028990a8e
> 2008-4-30 14:29:46 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow getMemberTokens
> 信息: GMS View Change Received for group DemoGroup : Members in view for (before change analysis) are :
> 1: MemberId: 836f3c91-a20a-4edf-a13c-326028990a8e, MemberType: CORE, Address: urn:jxta:uuid-289CBAB1836A4A009242B36E1509E49A428F46CA05A349DBA7A9B02FEBDB344803
>
> 2008-4-30 14:29:47 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow newViewObserved
> 信息: Analyzing new membership snapshot received as part of event : MASTER_CHANGE_EVENT
> 2008-4-30 14:29:47 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow getMemberTokens
> 信息: GMS View Change Received for group DemoGroup : Members in view for (before change analysis) are :
> 1: MemberId: 836f3c91-a20a-4edf-a13c-326028990a8e, MemberType: CORE, Address: urn:jxta:uuid-289CBAB1836A4A009242B36E1509E49A428F46CA05A349DBA7A9B02FEBDB344803
> 2: MemberId: e2fed556-ff76-4a38-9645-c1f6160dc07f, MemberType: CORE, Address: urn:jxta:uuid-289CBAB1836A4A009242B36E1509E49AE78AB5C0E6B94A499134E1DEA803497203
>
> 2008-4-30 14:29:47 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow newViewObserved
> 信息: Analyzing new membership snapshot received as part of event : MASTER_CHANGE_EVENT
> 2008-4-30 14:29:47 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow getMemberTokens
> 信息: GMS View Change Received for group DemoGroup : Members in view for (before change analysis) are :
> 1: MemberId: 836f3c91-a20a-4edf-a13c-326028990a8e, MemberType: CORE, Address: urn:jxta:uuid-289CBAB1836A4A009242B36E1509E49A428F46CA05A349DBA7A9B02FEBDB344803
> 2: MemberId: e2fed556-ff76-4a38-9645-c1f6160dc07f, MemberType: CORE, Address: urn:jxta:uuid-289CBAB1836A4A009242B36E1509E49AE78AB5C0E6B94A499134E1DEA803497203
>
> 2008-4-30 14:29:47 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow newViewObserved
> 信息: Analyzing new membership snapshot received as part of event : ADD_EVENT
> false
> e2fed556-ff76-4a38-9645-c1f6160dc07f
>
> (2) The first isGroupLeader() prints false. I think it should be true. Just like my question (1).
> (3) Form above console's info, it seems that every group member first elects himself as group leader, then communicate others to update group leader' info.
> As there is no change notification of group leader, I think it may be better to return the true group leader after gms.join(). Otherwise, the shoal should
> provide some callbacks. Am I right?
>
The correct way to characterize this process is that every member
initially designate themselves as master. During this master discovery
phase though, they are their own master and not the group's. Once
discovery protocol has ended, a group leader has come into being. That
is when a call to isGroupLeader() in the rightfully assigned master
returns true.

Now we do have an RFE filed by a user recently for exposing changes in
group leadership through an event so that consuming applications can
register for that event be notified. Once we have that implemented
shortly, I think it would be good for consuming applications.
Could you tell me what use case you had in mind for knowing who the
group leader in the group is? It will help all of us understand better.

> When you run SimpleTest serveral times, the console may prints:
>
> false
> Exception in thread "main" java.lang.NullPointerException
> at com.sun.enterprise.ee.cms.impl.jxta.GroupCommunicationProviderImpl.getGroupLeader(GroupCommunicationProviderImpl.java:281)
> at com.sun.enterprise.ee.cms.impl.jxta.GroupHandleImpl.getGroupLeader(GroupHandleImpl.java:398)
> at SimpleTest.main(SimpleTest.java:28)
> 2008-4-30 14:51:16 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow getMemberTokens
> 信息: GMS View Change Received for group DemoGroup : Members in view for (before change analysis) are :
> 1: MemberId: ab6418c9-84bc-49a8-af4c-d6e5b6127de4, MemberType: CORE, Address: urn:jxta:uuid-289CBAB1836A4A009242B36E1509E49A1B75978AE67A4B04A022C83142739EC103
>
> 2008-4-30 14:51:16 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow newViewObserved
> 信息: Analyzing new membership snapshot received as part of event : MASTER_CHANGE_EVENT
>
> (4) This exception occurs occasionally. But I don't know when and why it occurs. How to handle it?
>
We have to fix it. Could you file a P3 issue ?

>
> (5) Does shoal plan to expose MASTER_CHANGE_EVENT callback in future?
>
>
Yes, there is an RFE in the issue tracker (I dont remember the issue
number off hand).

Thanks
Shreedhar
> Thank you in advance for your reply.
>
> --------------
> leehui
> 2008-04-30
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_shoal.dev.java.net
For additional commands, e-mail: dev-help_at_shoal.dev.java.net

.