users@shoal.java.net

Re: [Shoal-Users] Re: send message after join

From: Shreedhar Ganapathy <Shreedhar.Ganapathy_at_Sun.COM>
Date: Fri, 19 Jun 2009 09:06:14 -0700

Will the following work for you?
> This is the opposite of my problem. In my case, I have two nodes, and the
> following is the order of execution in chronological order:
>
> Node1:
>
t0' : register for joined and ready notification for any future members'
ready state notification
> t0: join()
>
t0.1 : reportJoinedAndReadyState() for self --> goes into ether
(expected) but sets this member's health state from Alive to AliveAndReady
> t1: send() --> goes nowhere, as expected
>
> Node2:
>
t1.1 register for joined and ready notification for any future member's
ready state notification
> t2: join()
>
t2.1 : receive joinNotificationSignal, call
groupHandle.getCurrentCoreMembers() or getAllCurrentMembers() as the
case may be.
For the second member, call getMemberState() and if state is
AliveAndReady, go to t2.2 and t3

t2.2 : reportJoinedAndReadyState() for any members that will send out
messages after this point to this member. Sets my health state to
AliveAndReady
> t3: send() --> goes nowhere, not expected
>
> In this case Node1 can register for a joined and ready notification, but it will
> not help, since node1 is not going to send anything.
>

Let us know if the above works for you.
> -Jerry
>
>
>
>
>>> -Jerry
>>>
>>>
>>>
>>>> Thanks
>>>> Shreedhar
>>>>
>>>>
>>>>
>>>>> The same identical code worked fine with Shoal 1.0.
>>>>>
>>>>> I hope this clarifies the use-case.
>>>>> -Jerry
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> However, there is not enough information in your original post to
>>>>>> confirm or deny this.
>>>>>>
>>>>>> You could delay sending a message to the group until there is certain
>>>>>> number of members joined or
>>>>>> you could wait for all members to have joined via JoinNotification event.
>>>>>>
>>>>>> Pull API:
>>>>>>
>>>>>> List<String> members = gms.getGroupHandle().getAllCurrentMembers();
>>>>>> <wait to send first message until all expected number of members have
>>>>>> joined>
>>>>>>
>>>>>> Event driven API:
>>>>>>
>>>>>> gms.addActionFactory( new JoinNotificationActionFactoryImpl( new
>>>>>> JoinNotificationCallBack( serverName ) ) );
>>>>>> gms.join();
>>>>>> <wait till all expected instances have joined before sending message;
>>>>>> use info calculated from JoinNotificationCallback>
>>>>>>
>>>>>> private class JoinNotificationCallBack implements CallBack {
>>>>>>
>>>>>> private String serverName;
>>>>>>
>>>>>> public JoinNotificationCallBack( String serverName ) {
>>>>>> this.serverName = serverName;
>>>>>> }
>>>>>>
>>>>>> // called for every instance joining the gms group.
>>>>>> public void processNotification( Signal notification ) {
>>>>>> <record instance has joined>;
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> A non-coding way to check this out is to start all your receiving
>>>>>> clients first.
>>>>>> Wait 10 seconds (like your initial test).
>>>>>> Then start your sending gms client.
>>>>>> There is no need a sleep between the join and send since all the other
>>>>>> members
>>>>>> will have already joined. Hope this helps.
>>>>>>
>>>>>> -Joe
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Thanks
>>>>>>> -Jerry
>>>>>>>
>>>>>>> Jerry Raj wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hello,
>>>>>>>> I have code like this:
>>>>>>>> <snip>
>>>>>>>> gms.join();
>>>>>>>> // Commented: Thread.sleep(10000);
>>>>>>>> GroupHandle gh = gms.getGroupHandle();
>>>>>>>>
>>>>>>>> gh.sendMessage(blah);
>>>>>>>>
>>>>>>>> </snip>
>>>>>>>>
>>>>>>>> This used to work fine in Shoal 1.0. The node would join the group
>>>>>>>> and the
>>>>>>>> message would be recd by other members in the group. But this does
>>>>>>>> not happen
>>>>>>>> with Shoal 1.1 unless I uncomment the sleep(10000) between join() and
>>>>>>>> send(). I
>>>>>>>> expect this is because the join operation has not completed
>>>>>>>> successfully when
>>>>>>>> send() is called. Is there a way to be notified when join is
>>>>>>>> complete? I tried
>>>>>>>> looking at JoinedAndReadyNotificationActionImpl but that does not
>>>>>>>> seem to work?
>>>>>>>>
>>>>>>>> I'm using Shoal 1.1 from the download link on the front page of the
>>>>>>>> Shoal website.
>>>>>>>>
>>>>>>>> -Jerry
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe_at_shoal.dev.java.net <mailto:users-unsubscribe_at_shoal.dev.java.net> <mailto:users-unsubscribe_at_shoal.dev.java.net>
>>>>>>> For additional commands, e-mail: users-help_at_shoal.dev.java.net <mailto:users-help_at_shoal.dev.java.net> <mailto:users-help_at_shoal.dev.java.net>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe_at_shoal.dev.java.net <mailto:users-unsubscribe_at_shoal.dev.java.net> <mailto:users-unsubscribe_at_shoal.dev.java.net>
>>>>>> For additional commands, e-mail: users-help_at_shoal.dev.java.net <mailto:users-help_at_shoal.dev.java.net> <mailto:users-help_at_shoal.dev.java.net>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe_at_shoal.dev.java.net <mailto:users-unsubscribe_at_shoal.dev.java.net> <mailto:users-unsubscribe_at_shoal.dev.java.net>
>>>>> For additional commands, e-mail: users-help_at_shoal.dev.java.net <mailto:users-help_at_shoal.dev.java.net> <mailto:users-help_at_shoal.dev.java.net>
>>>>>
>>>>>
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_shoal.dev.java.net <mailto:users-unsubscribe_at_shoal.dev.java.net>
>>> For additional commands, e-mail: users-help_at_shoal.dev.java.net <mailto:users-help_at_shoal.dev.java.net>
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_shoal.dev.java.net
> For additional commands, e-mail: users-help_at_shoal.dev.java.net
>
>