Class DefaultLeaderRetrievalService
- java.lang.Object
-
- org.apache.flink.runtime.leaderretrieval.DefaultLeaderRetrievalService
-
- All Implemented Interfaces:
LeaderRetrievalEventHandler
,LeaderRetrievalService
public class DefaultLeaderRetrievalService extends Object implements LeaderRetrievalService, LeaderRetrievalEventHandler
The counterpart to theDefaultLeaderElectionService
. Composed with differentLeaderRetrievalDriver
, we could retrieve the leader information from different storage. The leader address as well as the current leader session ID will be retrieved fromLeaderRetrievalDriver
.
-
-
Constructor Summary
Constructors Constructor Description DefaultLeaderRetrievalService(LeaderRetrievalDriverFactory leaderRetrievalDriverFactory)
Creates a default leader retrieval service with specifiedLeaderRetrievalDriverFactory
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
notifyLeaderAddress(LeaderInformation leaderInformation)
Called by specificLeaderRetrievalDriver
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.
-
-
-
Constructor Detail
-
DefaultLeaderRetrievalService
public DefaultLeaderRetrievalService(LeaderRetrievalDriverFactory leaderRetrievalDriverFactory)
Creates a default leader retrieval service with specifiedLeaderRetrievalDriverFactory
.- Parameters:
leaderRetrievalDriverFactory
-LeaderRetrievalDriverFactory
used for creatingLeaderRetrievalDriver
.
-
-
Method Detail
-
start
public void start(LeaderRetrievalListener listener) throws Exception
Description copied from interface:LeaderRetrievalService
Starts the leader retrieval service with the given listener to listen for new leaders. This method can only be called once.- Specified by:
start
in interfaceLeaderRetrievalService
- Parameters:
listener
- The leader retrieval listener which will be notified about new leaders.- Throws:
Exception
-
stop
public void stop() throws Exception
Description copied from interface:LeaderRetrievalService
Stops the leader retrieval service.- Specified by:
stop
in interfaceLeaderRetrievalService
- Throws:
Exception
-
notifyLeaderAddress
public void notifyLeaderAddress(LeaderInformation leaderInformation)
Called by specificLeaderRetrievalDriver
to notify leader address.- Specified by:
notifyLeaderAddress
in interfaceLeaderRetrievalEventHandler
- Parameters:
leaderInformation
- new notified leader information address. The exception will be handled by leader listener.
-
-