Package org.apache.solr.common.cloud
Class ReplicaCount
java.lang.Object
org.apache.solr.common.cloud.ReplicaCount
Tracks the number of replicas per replica type. This class is mutable.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(Replica.Type type) Returns whether the number of replicas for a given type was explicitly defined.voiddecrement(Replica.Type type) Decrement the number of replicas for a given type.static ReplicaCountempty()booleanstatic ReplicaCountfromMessage(ZkNodeProps message) static ReplicaCountfromMessage(ZkNodeProps message, DocCollection collection) static ReplicaCountfromMessage(ZkNodeProps message, DocCollection collection, Integer defaultReplicationFactor) Creates aReplicaCountfrom a message.static ReplicaCountCreates aReplicaCountfrom a properties map.intget(Replica.Type type) Returns the number of replicas for a given type.Returns the first non-zero replica type that can be a leader.inthashCode()booleanReturns whether there is at least one replica which can be a leader.voidincrement(Replica.Type type) Increment the number of replicas for a given type.keySet()Returns the replica types for which a number of replicas was explicitly defined.static ReplicaCountstatic ReplicaCountof(Replica.Type type, Integer count) voidput(Replica.Type type, Integer count) Defines the number of replicas for a given type.toString()Returns a representation of this class which can be used for debugging.inttotal()Returns the total number of replicas.voidwriteProps(Map<String, Object> propMap) Add properties for replica counts as integers to a properties map.voidwriteProps(ModifiableSolrParams params) Add properties for replica counts as integers to Solr parameters.
-
Method Details
-
empty
-
of
-
of
-
fromMessage
-
fromMessage
-
fromMessage
public static ReplicaCount fromMessage(ZkNodeProps message, DocCollection collection, Integer defaultReplicationFactor) Creates aReplicaCountfrom a message.This method has a rich logic for defaulting parameters. A collection can optionally be provided as a fallback for all properties. Among all properties, replica factor is applied as the number of replicas for the default replica type. The default replica type can be provided as a property, or else comes from
Replica.Type.defaultType().Not all capabilities apply on every call of this method. For example, the message may not contain any replication factor.
- Parameters:
message- a message.collection- an optional collection providing defaults.defaultReplicationFactor- an additional optional default replica factor, if none is found in the collection.
-
fromProps
Creates aReplicaCountfrom a properties map.This method is much simpler than
fromMessage(org.apache.solr.common.cloud.ZkNodeProps), as it only considers properties containing a number of replicas (and ignores other properties such as the replication factor).- Parameters:
propMap- a properties map
-
get
Returns the number of replicas for a given type.- Parameters:
type- a replica type
-
contains
Returns whether the number of replicas for a given type was explicitly defined.- Parameters:
type- a replica type
-
keySet
Returns the replica types for which a number of replicas was explicitly defined. -
writeProps
Add properties for replica counts as integers to a properties map.- Parameters:
propMap- a properties map.
-
writeProps
Add properties for replica counts as integers to Solr parameters.- Parameters:
params- a set of modifiable Solr parameters.
-
put
Defines the number of replicas for a given type.- Parameters:
type- a replica typecount- a number of replicas (if null, mark the value as missing)
-
increment
Increment the number of replicas for a given type.- Parameters:
type- a replica type
-
decrement
Decrement the number of replicas for a given type.- Parameters:
type- a replica type
-
total
public int total()Returns the total number of replicas. -
hasLeaderReplica
public boolean hasLeaderReplica()Returns whether there is at least one replica which can be a leader. -
getLeaderType
Returns the first non-zero replica type that can be a leader.- Throws:
SolrException- if no such replica exists
-
equals
-
hashCode
public int hashCode() -
toString
Returns a representation of this class which can be used for debugging.
-