Commit f2378dec authored by mohammad.salama's avatar mohammad.salama

ZooKeeper - Herd Effect - DS06

parent e7046cc9
......@@ -42,7 +42,7 @@
<recent name="D:\HIAST\FIY\FS\Distributed Systems\Lab\5\Session\ZookeeperProject" />
</key>
</component>
<component name="RunManager" selected="Application.C3">
<component name="RunManager" selected="Application.C4">
<configuration name="C1" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="LeaderElection" />
<module name="ZookeeperProject" />
......@@ -64,8 +64,16 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="C4" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="LeaderElection" />
<module name="ZookeeperProject" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="Application.C1" />
<item itemvalue="Application.C4" />
<item itemvalue="Application.C2" />
<item itemvalue="Application.C3" />
</list>
......
No preview for this file type
......@@ -129,14 +129,22 @@ public class LeaderElection implements Watcher
{
System.out.println("Detecting Node Deleted ");
System.out.println("prev full name is : " + prevZnodeFullName);
///Stat prevExist = zooKeeper.exists(prevZnodeFullName, this);
List<String> children = zooKeeper.getChildren(ELECTION_NAMESPACE, false);
Collections.sort(children);
if (leader.equals(prevZnode))
{
this.leader = currentZnodeName;
prevZnode = currentZnodeName;
prevZnodeFullName = currentZondeFullName;
setLeaderInData();
}
else
{
prevZnode = children.get(children.indexOf(currentZnodeName) - 1);
prevZnodeFullName = ELECTION_NAMESPACE + "/" + prevZnode;
Stat prevExist = zooKeeper.exists(prevZnodeFullName , this);
}
System.out.println("I am Listening to Node " + prevZnode);
setLeaderInData();
}
catch (InterruptedException e)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment