public class DefaultMultipleComponentLeaderElectionService extends Object implements MultipleComponentLeaderElectionService, MultipleComponentLeaderElectionDriver.Listener
MultipleComponentLeaderElectionService that allows to
register multiple LeaderElectionEventHandler.| Constructor and Description |
|---|
DefaultMultipleComponentLeaderElectionService(org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler,
MultipleComponentLeaderElectionDriverFactory multipleComponentLeaderElectionDriverFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this service.
|
LeaderElectionDriverFactory |
createDriverFactory(String componentId)
Creates a
LeaderElectionDriverFactory for the given leader name. |
boolean |
hasLeadership(String componentId)
Returns whether the given component has leadership.
|
void |
isLeader()
Callback that is called once the driver obtains the leadership.
|
void |
notifyAllKnownLeaderInformation(Collection<LeaderInformationWithComponentId> leaderInformationWithComponentIds)
Notifies the listener about all currently known leader information.
|
void |
notifyLeaderInformationChange(String componentId,
LeaderInformation leaderInformation)
Notifies the listener about a changed leader information for the given component.
|
void |
notLeader()
Callback that is called once the driver loses the leadership.
|
void |
publishLeaderInformation(String componentId,
LeaderInformation leaderInformation)
Publishes the given leader information for the component identified by the given leader name.
|
void |
registerLeaderElectionEventHandler(String componentId,
LeaderElectionEventHandler leaderElectionEventHandler)
Registers a new leader election event handler under the given component id.
|
void |
unregisterLeaderElectionEventHandler(String componentId)
Unregisters the leader election event handler with the given component id.
|
public DefaultMultipleComponentLeaderElectionService(org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler,
MultipleComponentLeaderElectionDriverFactory multipleComponentLeaderElectionDriverFactory)
throws Exception
Exceptionpublic void close()
throws Exception
MultipleComponentLeaderElectionServiceclose in interface MultipleComponentLeaderElectionServiceException - if the service failed to closepublic LeaderElectionDriverFactory createDriverFactory(String componentId)
MultipleComponentLeaderElectionServiceLeaderElectionDriverFactory for the given leader name.createDriverFactory in interface MultipleComponentLeaderElectionServicecomponentId - identifying the component for which to create a leader election driver
factorypublic void publishLeaderInformation(String componentId, LeaderInformation leaderInformation)
MultipleComponentLeaderElectionServicepublishLeaderInformation in interface MultipleComponentLeaderElectionServicecomponentId - identifying the componentleaderInformation - leader informationpublic void registerLeaderElectionEventHandler(String componentId, LeaderElectionEventHandler leaderElectionEventHandler)
MultipleComponentLeaderElectionServiceregisterLeaderElectionEventHandler in interface MultipleComponentLeaderElectionServicecomponentId - identifying the leader election event handlerleaderElectionEventHandler - leader election event handler to registerpublic void unregisterLeaderElectionEventHandler(String componentId) throws Exception
MultipleComponentLeaderElectionServiceunregisterLeaderElectionEventHandler in interface MultipleComponentLeaderElectionServicecomponentId - identifying the componentException - if the leader election event handler could not be unregisteredpublic boolean hasLeadership(String componentId)
MultipleComponentLeaderElectionServicehasLeadership in interface MultipleComponentLeaderElectionServicecomponentId - identifying the componenttrue if the component has leadership otherwise falsepublic void isLeader()
MultipleComponentLeaderElectionDriver.ListenerisLeader in interface MultipleComponentLeaderElectionDriver.Listenerpublic void notLeader()
MultipleComponentLeaderElectionDriver.ListenernotLeader in interface MultipleComponentLeaderElectionDriver.Listenerpublic void notifyLeaderInformationChange(String componentId, LeaderInformation leaderInformation)
MultipleComponentLeaderElectionDriver.ListenernotifyLeaderInformationChange in interface MultipleComponentLeaderElectionDriver.ListenercomponentId - identifying the component whose leader information has changedleaderInformation - new leader informationpublic void notifyAllKnownLeaderInformation(Collection<LeaderInformationWithComponentId> leaderInformationWithComponentIds)
MultipleComponentLeaderElectionDriver.ListenernotifyAllKnownLeaderInformation in interface MultipleComponentLeaderElectionDriver.ListenerleaderInformationWithComponentIds - leader information with component idsCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.