users@shoal.java.net

GroupLeader's question

From: leehui <leehui70_at_gmail.com>
Date: Tue, 22 Apr 2008 15:32:46 +0800

Hi,

Recently, I wrote a simple class to get GroupLeader. The code is as follows:

import com.sun.enterprise.ee.cms.core.GMSException;
import com.sun.enterprise.ee.cms.core.GMSFactory;
import com.sun.enterprise.ee.cms.core.GroupManagementService;

public class SimpleTest{
        
        public GroupManagementService gms;
        
        public static void main(String[] args) {
                
                try {
                        GroupManagementService gms = (GroupManagementService) GMSFactory.startGMSModule("instance1","DemoGroup", GroupManagementService.MemberType.CORE, null);
                        gms.join();
                        System.out.println(gms.getGroupHandle().getGroupLeader());
                } catch (GMSException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
}

The console print:

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:15)
2008-4-22 15:14:40 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: instance1, MemberType: CORE, Address: urn:jxta:uuid-289CBAB1836A4A009242B36E1509E49A7987FC1134E54090AB24B0C9E01AD7DF03

2008-4-22 15:14:40 com.sun.enterprise.ee.cms.impl.jxta.ViewWindow newViewObserved
ΠΕΟ’: Analyzing new membership snapshot received as part of event : MASTER_CHANGE_EVENT


It seems that I can't invoke gms.getGroupHandle().getGroupLeader() at once after gms.join(). But Shreedhar Ganapathy said,

"The join() call is a blocking call in that it returns only after group join has occurred. So you should be able to call GroupHandle's apis
without any waiting."

How to handle it? When could I invoke gms.getGroupHandle().getGroupLeader()? If there are some callbacks ?

Thank you!

                
--------------
leehui
2008-04-22