Hi Todd,
 Sorry for my late response. I had marked this email to respond but couldn't 
find the time :). Did you figure this out? It mostly looks like that as soon as 
you set a watch on /follower, some other node instantly creates another child 
of  /follower? Could that be the case?

Thanks
mahadev


On 8/26/10 8:09 PM, "Todd Nine" <t...@spidertracks.co.nz> wrote:

Sure thing.  The FollowerWatcher class is instantiated by the IClusterManager 
implementation.    It then performs the following

FollowerWatcher.init() which is intended to do the following.

1. Create our follower node so that other nodes know we exist at path 
"/com/spidertracks/aviator/cluster/follower/10.0.1.1"  where the last node is 
an ephemeral node with the internal IP address of the node.  These are lines 67 
through 72.
2. Signal to the clusterManager that the cluster has changed (line 79).  
Ultimately the clusterManager will perform a barrier for partitioning data ( a 
separate watcher)
3. Register a watcher to receive all future events on the follower path 
"/com/spidertracks/aviator/cluster/follower/" line 81.


Then we have the following characteristics in the watcher

1. If a node has been added or deleted from the children of 
"/com/spidertracks/aviator/cluster/follower" then continue.  Otherwise, ignore 
the event.  Lines 33 through 44
2. If this was an event we should process our cluster has changed, signal to 
the CusterManager that a node has either been added or removed. line 51.


I'm trying to encapsulate the detection of additions and deletions of child 
nodes within this Watcher.  All other events that occur due to a node being 
added or deleted should be handled externally by the clustermanager.

Thanks,
Todd


On Thu, 2010-08-26 at 19:26 -0700, Mahadev Konar wrote:
Hi Todd,
   The code that you point to, I am not able to make out the sequence of steps.
    Can you be more clear on what you are trying to do in terms of zookeeper 
api?

 Thanks
 mahadev
 On 8/26/10 5:58 PM, "Todd Nine" <t...@spidertracks.co.nz> wrote:


Hi all,
   I'm running into a strange issue I could use a hand with.   I've
 implemented leader election, and this is working well.  I'm now
 implementing a follower queue with ephemeral nodes. I have an interface
 IClusterManager which simply has the api "clusterChanged".  I don't care
 if nodes are added or deleted, I always want to fire this event.  I have
 the following basic algorithm.


 init

 Create a path with "/follower/"+mynode name

 fire the clusterChangedEvent

 Watch set the event watcher on the path "/follower".


 watch:

 reset the watch on "/follower"

 if event is not a NodeDeleted or NodeCreated, ignore

 fire the clustermanager event


 this seems pretty straightforward.  Here is what I'm expecting


 1. Create my node path
 2. fire the clusterChanged event
 3. Set watch on "/follower"
 4. Receive watch events for changes from any other nodes.

 What's actually happening

 1. Create my node path
 2. fire the clusterChanged event
 3. Set Watch on "/follower"
 4. Receive watch event for node created in step 1
 5. Receive future watch events for changes from any other nodes.


 Here is my code.  Since I set the watch after I create the node, I'm not
 expecting to receive the event for it.  Am I doing something incorrectly
 in creating my watch?  Here is my code.

 http://pastebin.com/zDXgLagd

 Thanks,
 Todd







Reply via email to