public class LeaderInformationRegister extends Object
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 and Description |
---|
LeaderInformationRegister(Map<String,LeaderInformation> leaderInformationPerComponentId)
Creates a
LeaderInformationRegister based on the passed leader information. |
Modifier and Type | Method and Description |
---|---|
static LeaderInformationRegister |
clear(LeaderInformationRegister leaderInformationRegister,
String componentId)
Creates a new
LeaderInformationRegister that matches the passed LeaderInformationRegister except for the entry of componentId which is removed if it
existed. |
static LeaderInformationRegister |
empty() |
Optional<LeaderInformation> |
forComponentId(String componentId)
Returns the
LeaderInformation that is stored or an empty Optional if no entry
exists for the passed componentId . |
LeaderInformation |
forComponentIdOrEmpty(String componentId)
Returns a
LeaderInformation which is empty if no LeaderInformation is stored
for the passed componentId . |
Iterable<String> |
getRegisteredComponentIds()
Returns the
componentId s for which leader information is stored. |
boolean |
hasLeaderInformation(String componentId)
Checks whether the register holds non-empty
LeaderInformation for the passed componentId . |
boolean |
hasNoLeaderInformation()
Checks that no non-empty
LeaderInformation is stored. |
static LeaderInformationRegister |
merge(LeaderInformationRegister leaderInformationRegister,
String componentId,
LeaderInformation leaderInformation)
Merges another
LeaderInformationRegister with additional leader information into a
new LeaderInformationRegister instance. |
static LeaderInformationRegister |
of(String componentId,
LeaderInformation leaderInformation)
Creates a single-entry instance containing only the passed information.
|
public LeaderInformationRegister(Map<String,LeaderInformation> leaderInformationPerComponentId)
LeaderInformationRegister
based on the passed leader information.public static LeaderInformationRegister empty()
public static LeaderInformationRegister of(String componentId, LeaderInformation leaderInformation)
public static LeaderInformationRegister merge(@Nullable LeaderInformationRegister leaderInformationRegister, String componentId, LeaderInformation leaderInformation)
LeaderInformationRegister
with additional leader information into a
new LeaderInformationRegister
instance. Any existing LeaderInformation
for
the passed componentId
will be overwritten.
Empty LeaderInformation
results in the removal of the corresponding entry (if it
exists).
public static LeaderInformationRegister clear(@Nullable LeaderInformationRegister leaderInformationRegister, String componentId)
LeaderInformationRegister
that matches the passed LeaderInformationRegister
except for the entry of componentId
which is removed if it
existed.public Optional<LeaderInformation> forComponentId(String componentId)
LeaderInformation
that is stored or an empty Optional
if no entry
exists for the passed componentId
.public LeaderInformation forComponentIdOrEmpty(String componentId)
LeaderInformation
which is empty if no LeaderInformation
is stored
for the passed componentId
.public Iterable<String> getRegisteredComponentIds()
componentId
s for which leader information is stored.public boolean hasLeaderInformation(String componentId)
LeaderInformation
for the passed componentId
.public boolean hasNoLeaderInformation()
LeaderInformation
is stored.true
, if there is no entry that refers to a non-empty LeaderInformation
; otherwise false
(i.e. either no information is stored under
any componentId
or there are entries for certain componentId
s that refer
to an empty LeaderInformation
record).Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.