Class ShardTerms

java.lang.Object
org.apache.solr.cloud.ShardTerms
All Implemented Interfaces:
org.apache.solr.common.MapSerializable, org.apache.solr.common.MapWriter, org.apache.solr.common.NavigableObject, org.noggit.JSONWriter.Writable

public class ShardTerms extends Object implements org.apache.solr.common.MapWriter
Hold values of terms, this class is immutable. Create a new instance for every mutation
  • Constructor Details

    • ShardTerms

      public ShardTerms()
    • ShardTerms

      public ShardTerms(ShardTerms newTerms, int version)
    • ShardTerms

      public ShardTerms(Map<String,Long> values, int version)
  • Method Details

    • writeMap

      public void writeMap(org.apache.solr.common.MapWriter.EntryWriter ew) throws IOException
      Specified by:
      writeMap in interface org.apache.solr.common.MapWriter
      Throws:
      IOException
    • canBecomeLeader

      public boolean canBecomeLeader(String coreNodeName)
      Can coreNodeName become leader?
      Parameters:
      coreNodeName - of the replica
      Returns:
      true if coreNodeName can become leader, false if otherwise
    • haveHighestTermValue

      public boolean haveHighestTermValue(String coreNodeName)
      Is coreNodeName's term highest?
      Parameters:
      coreNodeName - of the replica
      Returns:
      true if term of coreNodeName is highest
    • getTerm

      public Long getTerm(String coreNodeName)
    • increaseTerms

      public ShardTerms increaseTerms(String leader, Set<String> replicasNeedingRecovery)
      Return a new ShardTerms in which term of leader is higher than replicasNeedingRecovery
      Parameters:
      leader - coreNodeName of leader
      replicasNeedingRecovery - set of replicas in which their terms should be lower than leader's term
      Returns:
      null if term of leader is already higher than replicasNeedingRecovery
    • ensureHighestTermsAreNotZero

      public ShardTerms ensureHighestTermsAreNotZero()
      Return a new ShardTerms 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 new ShardTerms in which terms for the coreNodeName 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 new ShardTerms in which the associate term of coreNodeName 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 new ShardTerms in which the associate term of coreNodeName 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 new ShardTerms in which the term of coreNodeName 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)
      Mark coreNodeName as recovering
      Parameters:
      coreNodeName - of the replica
      Returns:
      null if coreNodeName is already marked as doing recovering
    • doneRecovering

      public ShardTerms doneRecovering(String coreNodeName)
      Mark coreNodeName as finished recovering
      Parameters:
      coreNodeName - of the replica
      Returns:
      null if term of coreNodeName is already finished doing recovering
    • recoveringTerm

      public static String recoveringTerm(String coreNodeName)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getVersion

      public int getVersion()
    • getTerms

      public Map<String,Long> getTerms()
    • isRecovering

      public boolean isRecovering(String name)