Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
D
DS_Project_Part1
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
ali.saeed
DS_Project_Part1
Commits
2577b74a
Commit
2577b74a
authored
Jan 29, 2024
by
Ali Saeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update OnElectionAction class to launch grpc server in leader case
parent
f0d41f49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
14 deletions
+6
-14
OnElectionAction.java
...rc/main/java/Registration_Discovery/OnElectionAction.java
+6
-14
No files found.
registration-discovery-leader-reelection-cordinator-workers/src/main/java/Registration_Discovery/OnElectionAction.java
View file @
2577b74a
package
Registration_Discovery
;
import
org.apache.zookeeper.KeeperException
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.Bean
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
public
class
OnElectionAction
implements
OnElectionCallback
{
public
class
OnElectionAction
implements
OnElectionCallback
{
private
final
ServiceRegistry
serviceRegistry
;
private
final
int
port
;
public
OnElectionAction
(
ServiceRegistry
serviceRegistry
,
int
port
)
{
this
.
serviceRegistry
=
serviceRegistry
;
this
.
port
=
port
;
}
@Override
public
void
onElectedToBeLeader
()
{
serviceRegistry
.
unregisterFromCluster
();
serviceRegistry
.
registerForUpdates
();
Leader
leader
=
new
Leader
(
port
,
serviceRegistry
);
try
{
leader
.
start
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
GrpcServerLauncher
.
start
();
}
@Override
public
void
onWorker
()
{
try
{
...
...
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