public class DefaultLeaderRetrievalService extends Object implements LeaderRetrievalService, LeaderRetrievalEventHandler
DefaultLeaderElectionService
. Composed with different
LeaderRetrievalDriver
, we could retrieve the leader information from different storage.
The leader address as well as the current leader session ID will be retrieved from LeaderRetrievalDriver
.Constructor and Description |
---|
DefaultLeaderRetrievalService(LeaderRetrievalDriverFactory leaderRetrievalDriverFactory)
Creates a default leader retrieval service with specified
LeaderRetrievalDriverFactory . |
Modifier and Type | Method and Description |
---|---|
void |
notifyLeaderAddress(LeaderInformation leaderInformation)
Called by specific
LeaderRetrievalDriver to notify leader address. |
void |
start(LeaderRetrievalListener listener)
Starts the leader retrieval service with the given listener to listen for new leaders.
|
void |
stop()
Stops the leader retrieval service.
|
public DefaultLeaderRetrievalService(LeaderRetrievalDriverFactory leaderRetrievalDriverFactory)
LeaderRetrievalDriverFactory
.leaderRetrievalDriverFactory
- LeaderRetrievalDriverFactory
used for creating
LeaderRetrievalDriver
.public void start(LeaderRetrievalListener listener) throws Exception
LeaderRetrievalService
start
in interface LeaderRetrievalService
listener
- The leader retrieval listener which will be notified about new leaders.Exception
public void stop() throws Exception
LeaderRetrievalService
stop
in interface LeaderRetrievalService
Exception
public void notifyLeaderAddress(LeaderInformation leaderInformation)
LeaderRetrievalDriver
to notify leader address.notifyLeaderAddress
in interface LeaderRetrievalEventHandler
leaderInformation
- new notified leader information address. The exception will be
handled by leader listener.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.