Class LeaderInformationRegister
java.lang.Object
org.apache.flink.runtime.leaderelection.LeaderInformationRegister
A register containing the
LeaderInformation for multiple contenders based on their
componentId. No empty LeaderInformation is stored physically. No entry and an entry with
an empty LeaderInformation are, therefore, semantically the same.-
Constructor Summary
ConstructorsConstructorDescriptionLeaderInformationRegister(Map<String, LeaderInformation> leaderInformationPerComponentId) Creates aLeaderInformationRegisterbased on the passed leader information. -
Method Summary
Modifier and TypeMethodDescriptionstatic LeaderInformationRegisterclear(LeaderInformationRegister leaderInformationRegister, String componentId) Creates a newLeaderInformationRegisterthat matches the passedLeaderInformationRegisterexcept for the entry ofcomponentIdwhich is removed if it existed.static LeaderInformationRegisterempty()forComponentId(String componentId) Returns theLeaderInformationthat is stored or an emptyOptionalif no entry exists for the passedcomponentId.forComponentIdOrEmpty(String componentId) Returns aLeaderInformationwhich is empty if noLeaderInformationis stored for the passedcomponentId.Returns thecomponentIds for which leader information is stored.booleanhasLeaderInformation(String componentId) Checks whether the register holds non-emptyLeaderInformationfor the passedcomponentId.booleanChecks that no non-emptyLeaderInformationis stored.static LeaderInformationRegistermerge(LeaderInformationRegister leaderInformationRegister, String componentId, LeaderInformation leaderInformation) Merges anotherLeaderInformationRegisterwith additional leader information into a newLeaderInformationRegisterinstance.static LeaderInformationRegisterof(String componentId, LeaderInformation leaderInformation) Creates a single-entry instance containing only the passed information.
-
Constructor Details
-
LeaderInformationRegister
Creates aLeaderInformationRegisterbased on the passed leader information.
-
-
Method Details
-
empty
-
of
Creates a single-entry instance containing only the passed information. -
merge
public static LeaderInformationRegister merge(@Nullable LeaderInformationRegister leaderInformationRegister, String componentId, LeaderInformation leaderInformation) Merges anotherLeaderInformationRegisterwith additional leader information into a newLeaderInformationRegisterinstance. Any existingLeaderInformationfor the passedcomponentIdwill be overwritten.Empty
LeaderInformationresults in the removal of the corresponding entry (if it exists). -
clear
public static LeaderInformationRegister clear(@Nullable LeaderInformationRegister leaderInformationRegister, String componentId) Creates a newLeaderInformationRegisterthat matches the passedLeaderInformationRegisterexcept for the entry ofcomponentIdwhich is removed if it existed. -
forComponentId
Returns theLeaderInformationthat is stored or an emptyOptionalif no entry exists for the passedcomponentId. -
forComponentIdOrEmpty
Returns aLeaderInformationwhich is empty if noLeaderInformationis stored for the passedcomponentId. -
getRegisteredComponentIds
Returns thecomponentIds for which leader information is stored. -
hasLeaderInformation
Checks whether the register holds non-emptyLeaderInformationfor the passedcomponentId. -
hasNoLeaderInformation
public boolean hasNoLeaderInformation()Checks that no non-emptyLeaderInformationis stored.- Returns:
true, if there is no entry that refers to a non-emptyLeaderInformation; otherwisefalse(i.e. either no information is stored under anycomponentIdor there are entries for certaincomponentIds that refer to an emptyLeaderInformationrecord).
-