Package org.apache.solr.cloud
Class CloudUtil
- java.lang.Object
-
- org.apache.solr.cloud.CloudUtil
-
public class CloudUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_TIMEOUT
-
Constructor Summary
Constructors Constructor Description CloudUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkSharedFSFailoverReplaced(CoreContainer cc, CoreDescriptor desc)
See if coreNodeName has been taken over by another baseUrl and unload core + throw exception if it has been.static CollectionStatePredicate
clusterShape(int expectedShards, int expectedReplicas)
Return aCollectionStatePredicate
that returns true if a collection has the expected number of active shards and replicasstatic CollectionStatePredicate
clusterShape(int expectedShards, int expectedReplicas, boolean withInactive, boolean requireLeaders)
Return aCollectionStatePredicate
that returns true if a collection has the expected number of shards and replicas.static Map<String,byte[]>
getTrustedKeys(SolrZkClient zk, String dir)
Read the list of public keys from ZKstatic boolean
replicaExists(ClusterState clusterState, String collection, String shard, String coreNodeName)
static String
unifiedResourcePath(SolrResourceLoader loader)
Returns a displayable unified path to the given resource.static long
waitForState(SolrCloudManager cloudManager, String collection, long wait, TimeUnit unit, CollectionStatePredicate predicate)
Wait for a particular collection state to appear.static long
waitForState(SolrCloudManager cloudManager, String message, String collection, CollectionStatePredicate predicate)
Wait for a particular collection state to appear.
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final int DEFAULT_TIMEOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
checkSharedFSFailoverReplaced
public static void checkSharedFSFailoverReplaced(CoreContainer cc, CoreDescriptor desc)
See if coreNodeName has been taken over by another baseUrl and unload core + throw exception if it has been.
-
replicaExists
public static boolean replicaExists(ClusterState clusterState, String collection, String shard, String coreNodeName)
-
unifiedResourcePath
public static String unifiedResourcePath(SolrResourceLoader loader)
Returns a displayable unified path to the given resource. For non-solrCloud that will be the same as getConfigDir, but for Cloud it will be getConfigSetZkPath ending in a /Note: Do not use this to generate a valid file path, but for debug printing etc
- Parameters:
loader
- Resource loader instance- Returns:
- a String of path to resource
-
getTrustedKeys
public static Map<String,byte[]> getTrustedKeys(SolrZkClient zk, String dir)
Read the list of public keys from ZK
-
waitForState
public static long waitForState(SolrCloudManager cloudManager, String message, String collection, CollectionStatePredicate predicate)
Wait for a particular collection state to appear. This is a convenience method using theDEFAULT_TIMEOUT
- Parameters:
cloudManager
- current instance ofSolrCloudManager
message
- a message to report on failurecollection
- the collection to watchpredicate
- a predicate to match against the collection state
-
waitForState
public static long waitForState(SolrCloudManager cloudManager, String collection, long wait, TimeUnit unit, CollectionStatePredicate predicate) throws InterruptedException, TimeoutException, IOException
Wait for a particular collection state to appear. This is a convenience method using theDEFAULT_TIMEOUT
- Parameters:
cloudManager
- current instance ofSolrCloudManager
collection
- the collection to watchwait
- timeout valueunit
- timeout unitpredicate
- a predicate to match against the collection state- Throws:
InterruptedException
TimeoutException
IOException
-
clusterShape
public static CollectionStatePredicate clusterShape(int expectedShards, int expectedReplicas)
Return aCollectionStatePredicate
that returns true if a collection has the expected number of active shards and replicas- Parameters:
expectedShards
- expected number of active shardsexpectedReplicas
- expected number of active replicas
-
clusterShape
public static CollectionStatePredicate clusterShape(int expectedShards, int expectedReplicas, boolean withInactive, boolean requireLeaders)
Return aCollectionStatePredicate
that returns true if a collection has the expected number of shards and replicas.Note: for shards marked as inactive the current Solr behavior is that replicas remain active.
SimCloudManager
follows this behavior.- Parameters:
expectedShards
- expected number of shardsexpectedReplicas
- expected number of active replicaswithInactive
- if true then count also inactive shardsrequireLeaders
- if true then require that each shard has a leader
-
-