Hi.
I suddenly have another opinions about this.
I think that if users already know Shoal's JoinedAndReadyNotification meaning, they will implement JoinedAndReadyNotification's callback function generally.
So I think that if they have an important work which should be executed once when they join the cluster initially, they will suppose that only implementing JoinedAndReadyNotification's callback function is enough.
But at this case, actually users should implement two callback functions. please see the following examples
1. About JoinNotification
MemberStates state = ((JoinNotificationSignal)notification).getMemberState();
if ( !booleanInit && ( state == MemberStates.READY || state == MemberStates.ALIVEANDREADY ) ) {
// execute some initialization
...
booleanInit = true;
}
2. About JoinedAndReadyNotification
if ( !booleanInit ) {
// execute some initialization
...
booleanInit = true;
}
So I think it would be better that the Joined and Ready Notification should be sent though a member joins a group late.
If changes are possible about the Joined and Ready Notification, implementing new design is maybe simple.
When a member receives a join notification and a joined and ready notification in ViewWindow.java,
We just determine whether we should call addJoinedAndReadyNotificationSignal() or not.
The following code is example about this.
--------------------------------------------------------------------------------
[In ViewWindow.java]
private final HashSet<String> joinedAndReadyMembers = new HashSet<String>();
private void determineAndAddReadyMember( String token, String groupName, long startTime ) {
if( joinedAndReadyMembers.contains( token ) )
return; // joined and ready event is already notified.
// todo if we can know whether current member has JoinedAndReadyNotificationActionFactory or not, skip this for reducing unnecessary network's traffic
MemberStates state = ctx.getGroupCommunicationProvider().getMemberState( token );
if( state == MemberStates.STARTING ) {
// after waiting for a while
// ...
state = ctx.getGroupCommunicationProvider().getMemberState( token );
}
if( state == MemberStates.READY || state == MemberStates.ALIVEANDREADY ) {
addJoinedAndReadyNotificationSignal( token, groupName, startTime );
joinedAndReadyMembers.add( token );
}
}
--------------------------------------------------------------------------------
We always call above determineAndAddReadyMember() after calling addJoinNotificationSignal() and in addReadyMemers().
In addition, we maybe should add the removing logic of joinedAndReadyMembers.
Actually, this example just fulfilled annoying implementing logic of users in internal SHOAL.
I would like to receive other opinions and please point out my mistakes.
Or if you have better choice about this case, please advice me.
Thanks.
--
Bongjae Chang
----- Original Message -----
From: Bongjae Chang
To: dev_at_shoal.dev.java.net
Sent: Saturday, June 14, 2008 1:40 AM
Subject: Re: [Shoal-Dev] a question about JoinedAndReadyNotification
Hi Shreedhar.
Thanks to you, I understood that.
Thanks!
--
Bongjae Chang
----- Original Message -----
From: Shreedhar Ganapathy
To: dev_at_shoal.dev.java.net
Sent: Saturday, June 14, 2008 1:05 AM
Subject: Re: [Shoal-Dev] a question about JoinedAndReadyNotification
Bongjae Chang wrote:
Hi.
I have a question about JoinedAndReadyNotification.
Assuming that "A" and "B" are members of "TestGroup".
"A" joins the group and "A" calls gms.reportJoinedAndReadyState( "TestGroup" ).
Then "A" receives own JoinedAndReadyNotification. Of course "A" receives own JoinNotication.
When "A" already joined the group, new "B" joins the group. Then I know that "B" receives "A"'s JoinNotification and own JoinNotification.
At that time, I don't know whether "B" should receive "A"'s JoinedAndReadyNotification or not. This is my question.
At this time, the way it is designed is that B does not have to receive the Joined and Ready Notification wrt A.
Now though "A" reported JoinedAndReady's state as well as joined the group, "B" only receives "A"'s join notification if "B" joins the group later.
Yes, when a member joins a group late after other members have joined and indicated their ready state, then the Joined and Ready Notification is not sent. However, the J&R member's state will be Ready. i.e. in the JoinNotification there is a new api added getMemberState(). This call would return the current true state of the member.
Of course, both "A" and "B" have JoinNotificationActionFactory and JoinedAndReadyNotificationActionFactory.
Thanks.
--
Bongjae Chang