Class ShardTerms
- java.lang.Object
-
- org.apache.solr.client.solrj.cloud.ShardTerms
-
- All Implemented Interfaces:
MapSerializable
,MapWriter
,NavigableObject
,org.noggit.JSONWriter.Writable
public class ShardTerms extends Object implements MapWriter
Hold values of terms, this class is immutable. Create a new instance for every mutation
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriter
MapWriter.EntryWriter
-
-
Constructor Summary
Constructors Constructor Description ShardTerms()
ShardTerms(Map<String,Long> values, int version)
ShardTerms(ShardTerms newTerms, int version)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canBecomeLeader(String coreNodeName)
CancoreNodeName
become leader?ShardTerms
doneRecovering(String coreNodeName)
MarkcoreNodeName
as finished recoveringShardTerms
ensureHighestTermsAreNotZero()
Return a newShardTerms
in which the highest terms are not zerolong
getMaxTerm()
Long
getTerm(String coreNodeName)
Map<String,Long>
getTerms()
int
getVersion()
boolean
haveHighestTermValue(String coreNodeName)
IscoreNodeName
's term highest?ShardTerms
increaseTerms(String leader, Set<String> replicasNeedingRecovery)
boolean
isRecovering(String name)
static String
recoveringTerm(String coreNodeName)
ShardTerms
registerTerm(String coreNodeName)
Return a newShardTerms
in which the associate term ofcoreNodeName
is not nullShardTerms
removeTerm(String coreNodeName)
Return a newShardTerms
in which terms for thecoreNodeName
are removedShardTerms
setTermEqualsToLeader(String coreNodeName)
Return a newShardTerms
in which the term ofcoreNodeName
is maxShardTerms
setTermToZero(String coreNodeName)
Return a newShardTerms
in which the associate term ofcoreNodeName
is equal to zero, creating it if it does not previously exist.ShardTerms
startRecovering(String coreNodeName)
MarkcoreNodeName
as recoveringString
toString()
void
writeMap(MapWriter.EntryWriter ew)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.solr.common.NavigableObject
_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size
-
-
-
-
Constructor Detail
-
ShardTerms
public ShardTerms()
-
ShardTerms
public ShardTerms(ShardTerms newTerms, int version)
-
-
Method Detail
-
writeMap
public void writeMap(MapWriter.EntryWriter ew) throws IOException
- Specified by:
writeMap
in interfaceMapWriter
- Throws:
IOException
-
canBecomeLeader
public boolean canBecomeLeader(String coreNodeName)
CancoreNodeName
become leader?- Parameters:
coreNodeName
- of the replica- Returns:
- true if
coreNodeName
can become leader, false if otherwise
-
haveHighestTermValue
public boolean haveHighestTermValue(String coreNodeName)
IscoreNodeName
's term highest?- Parameters:
coreNodeName
- of the replica- Returns:
- true if term of
coreNodeName
is highest
-
increaseTerms
public ShardTerms increaseTerms(String leader, Set<String> replicasNeedingRecovery)
- Parameters:
leader
- coreNodeName of leaderreplicasNeedingRecovery
- set of replicas in which their terms should be lower than leader's term- Returns:
- null if term of
leader
is already higher thanreplicasNeedingRecovery
-
ensureHighestTermsAreNotZero
public ShardTerms ensureHighestTermsAreNotZero()
Return a newShardTerms
in which the highest terms are not zero- Returns:
- null if highest terms are already larger than zero
-
removeTerm
public ShardTerms removeTerm(String coreNodeName)
Return a newShardTerms
in which terms for thecoreNodeName
are removed- Parameters:
coreNodeName
- of the replica- Returns:
- null if term of
coreNodeName
is already not exist
-
registerTerm
public ShardTerms registerTerm(String coreNodeName)
Return a newShardTerms
in which the associate term ofcoreNodeName
is not null- Parameters:
coreNodeName
- of the replica- Returns:
- null if term of
coreNodeName
is already exist
-
setTermToZero
public ShardTerms setTermToZero(String coreNodeName)
Return a newShardTerms
in which the associate term ofcoreNodeName
is equal to zero, creating it if it does not previously exist.- Parameters:
coreNodeName
- of the replica- Returns:
- null if the term of
coreNodeName
already exists and is zero
-
setTermEqualsToLeader
public ShardTerms setTermEqualsToLeader(String coreNodeName)
Return a newShardTerms
in which the term ofcoreNodeName
is max- Parameters:
coreNodeName
- of the replica- Returns:
- null if term of
coreNodeName
is already maximum
-
getMaxTerm
public long getMaxTerm()
-
startRecovering
public ShardTerms startRecovering(String coreNodeName)
MarkcoreNodeName
as recovering- Parameters:
coreNodeName
- of the replica- Returns:
- null if
coreNodeName
is already marked as doing recovering
-
doneRecovering
public ShardTerms doneRecovering(String coreNodeName)
MarkcoreNodeName
as finished recovering- Parameters:
coreNodeName
- of the replica- Returns:
- null if term of
coreNodeName
is already finished doing recovering
-
getVersion
public int getVersion()
-
isRecovering
public boolean isRecovering(String name)
-
-