Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
Z
Zookeeper-DS05
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mohammad.salama
Zookeeper-DS05
Commits
f2378dec
Commit
f2378dec
authored
Dec 07, 2023
by
mohammad.salama
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZooKeeper - Herd Effect - DS06
parent
e7046cc9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
workspace.xml
.idea/workspace.xml
+9
-1
ZookeeperProject.jar
ZookeeperProject.jar
+0
-0
LeaderElection.java
src/LeaderElection.java
+10
-2
No files found.
.idea/workspace.xml
View file @
f2378dec
...
...
@@ -42,7 +42,7 @@
<recent
name=
"D:\HIAST\FIY\FS\Distributed Systems\Lab\5\Session\ZookeeperProject"
/>
</key>
</component>
<component
name=
"RunManager"
selected=
"Application.C
3
"
>
<component
name=
"RunManager"
selected=
"Application.C
4
"
>
<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>
...
...
ZookeeperProject.jar
View file @
f2378dec
No preview for this file type
src/LeaderElection.java
View file @
f2378dec
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment