Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
L
leader-election-zookeeper
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
mohamadbashar.disoki
leader-election-zookeeper
Commits
4b023b0d
You need to sign in or sign up before continuing.
Commit
4b023b0d
authored
Dec 01, 2023
by
Mohamad Bashar Desoki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Leader Election process update
parent
2764a3fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
Readme.md
Readme.md
+9
-1
LeaderElection.java
src/main/java/LeaderElection.java
+6
-6
No files found.
Readme.md
View file @
4b023b0d
# Leader Election (Zookeeper)
# Leader Election (Zookeeper)
*topics*
*
Introduction to Cluster Coordination
*
Theory of Leader Election
*
Zookeeper Server and Client
*
Zookeeper Client Threading Model & Zookeeper Java API
*
Leader Election Implementation
*Useful links*
*Useful links*
*
[
Class ZooKeeper
](
https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html
)
*
[
Class ZooKeeper
](
https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html
)
*
[
wait notify and notifyall in java
](
https://javarevisited.blogspot.com/2011/05/wait-notify-and-notifyall-in-java.html
)
\ No newline at end of file
src/main/java/LeaderElection.java
View file @
4b023b0d
import
org.apache.zookeeper.*
;
import
org.apache.zookeeper.*
;
import
org.apache.zookeeper.data.Stat
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -65,16 +66,15 @@ public class LeaderElection implements Watcher {
...
@@ -65,16 +66,15 @@ public class LeaderElection implements Watcher {
case
None:
case
None:
if
(
watchedEvent
.
getState
()
==
Event
.
KeeperState
.
SyncConnected
)
{
if
(
watchedEvent
.
getState
()
==
Event
.
KeeperState
.
SyncConnected
)
{
System
.
out
.
println
(
"Successfully connected to Zookeeper"
);
System
.
out
.
println
(
"Successfully connected to Zookeeper"
);
}
else
{
}
else
if
(
watchedEvent
.
getState
()
==
Event
.
KeeperState
.
Disconnected
)
{
synchronized
(
zooKeeper
)
{
synchronized
(
zooKeeper
)
{
System
.
out
.
println
(
"Disconnected"
);
System
.
out
.
println
(
"Disconnected
from Zookeeper
"
);
zooKeeper
.
notifyAll
();
zooKeeper
.
notifyAll
();
}
}
}
else
if
(
watchedEvent
.
getState
()
==
Event
.
KeeperState
.
Closed
)
{
System
.
out
.
println
(
"Closed Successfully"
);
}
}
break
;
// case NodeCreated:
// if (watchedEvent.getState() == )
}
}
}
}
}
}
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