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
e9fc63f0
You need to sign in or sign up before continuing.
Commit
e9fc63f0
authored
Nov 30, 2023
by
mohammad.salama
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connection init - disconnected - closed
parent
180305ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
12 deletions
+33
-12
workspace.xml
.idea/workspace.xml
+9
-9
LeaderElection.java
src/LeaderElection.java
+24
-3
No files found.
.idea/workspace.xml
View file @
e9fc63f0
...
...
@@ -22,16 +22,16 @@
<option
name=
"hideEmptyMiddlePackages"
value=
"true"
/>
<option
name=
"showLibraryContents"
value=
"true"
/>
</component>
<component
name=
"PropertiesComponent"
>
<![CDATA[
{
"keyToString"
: {
"RunOnceActivity.OpenProjectViewOnStart": "true"
,
"RunOnceActivity.ShowReadmeOnStart": "true"
,
"last_opened_file_path": "D:/HIAST/FIY/FS/Distributed Systems/Lab/5/Session/ZookeeperProject/zookeeper-3.9.1-dependency"
,
"project.structure.last.edited": "Modules"
,
"project.structure.proportion": "0.15"
,
"project.structure.side.proportion": "0.2"
<component
name=
"PropertiesComponent"
>
{
"
keyToString
"
: {
"
RunOnceActivity.OpenProjectViewOnStart
"
:
"
true
"
,
"
RunOnceActivity.ShowReadmeOnStart
"
:
"
true
"
,
"
last_opened_file_path
"
:
"
D:/HIAST/FIY/FS/Distributed Systems/Lab/5/Session/ZookeeperProject/zookeeper-3.9.1-dependency
"
,
"
project.structure.last.edited
"
:
"
Modules
"
,
"
project.structure.proportion
"
:
"
0.15
"
,
"
project.structure.side.proportion
"
:
"
0.2
"
}
}
]]>
</component>
}
</component>
<component
name=
"RecentsManager"
>
<key
name=
"CopyFile.RECENT_KEYS"
>
<recent
name=
"D:\HIAST\FIY\FS\Distributed Systems\Lab\5\Session\ZookeeperProject"
/>
...
...
src/LeaderElection.java
View file @
e9fc63f0
...
...
@@ -10,7 +10,8 @@ public class LeaderElection implements Watcher {
private
static
final
int
SESSION_TIMEOUT
=
3000
;
private
ZooKeeper
zooKeeper
;
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
LeaderElection
leaderElection
=
new
LeaderElection
();
leaderElection
.
connectToZookeeper
();
leaderElection
.
run
();
...
...
@@ -38,12 +39,32 @@ public class LeaderElection implements Watcher {
else
if
(
watchedEvent
.
getState
()
==
Event
.
KeeperState
.
Closed
)
{
System
.
out
.
println
(
"Connection Closed"
);
System
.
exit
(
0
);
synchronized
(
zooKeeper
)
{
zooKeeper
.
notifyAll
();
try
{
zooKeeper
.
close
();
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
else
if
(
watchedEvent
.
getState
()
==
Event
.
KeeperState
.
Disconnected
)
{
System
.
out
.
println
(
"Disconnected"
);
System
.
exit
(
0
);
synchronized
(
zooKeeper
)
{
zooKeeper
.
notifyAll
();
try
{
zooKeeper
.
close
();
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
///System.exit(0);
}
break
;
}
...
...
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