public class SimClusterStateProvider extends Object implements ClusterStateProvider
ClusterStateProvider.
The following behaviors are supported:
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_DOC_SIZE_BYTES |
| Constructor and Description |
|---|
SimClusterStateProvider(LiveNodesSet liveNodes,
SimCloudManager cloudManager)
The instance needs to be initialized using the
sim* methods in order
to ensure proper behavior, otherwise it will behave as a cluster with zero replicas. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
connect() |
void |
copyFrom(ClusterStateProvider other) |
void |
createSystemCollection() |
Map<String,String> |
getAliasProperties(String alias) |
Map<String,Object> |
getClusterProperties() |
ClusterState |
getClusterState() |
Set<String> |
getLiveNodes() |
String |
getPolicyNameByCollection(String coll) |
ClusterState.CollectionRef |
getState(String collection) |
boolean |
isClosed() |
List<String> |
resolveAlias(String alias) |
void |
simAddNode(String nodeId)
Add a new node to the cluster.
|
void |
simAddReplica(String nodeId,
ReplicaInfo replicaInfo,
boolean runLeaderElection)
Add a replica.
|
void |
simAddReplica(ZkNodeProps message,
NamedList results)
Add a new replica.
|
void |
simCreateCollection(ZkNodeProps props,
NamedList results)
Create a new collection.
|
void |
simCreateShard(ZkNodeProps message,
NamedList results)
Create a new shard.
|
void |
simDeleteAllCollections()
Remove all collections.
|
void |
simDeleteCollection(String collection,
String async,
NamedList results)
Delete a collection
|
void |
simDeleteShard(ZkNodeProps message,
NamedList results)
Delete a shard.
|
Map<String,Map<String,Object>> |
simGetCollectionStats() |
String |
simGetOverseerLeader() |
String |
simGetRandomNode()
Get random node id.
|
String |
simGetRandomNode(Random random)
Get random node id.
|
ReplicaInfo |
simGetReplicaInfo(String collection,
String coreNode) |
List<ReplicaInfo> |
simGetReplicaInfos(String node)
Return all replica infos for a node.
|
List<ReplicaInfo> |
simGetReplicaInfos(String collection,
String shard) |
List<String> |
simListCollections()
List collections.
|
void |
simMoveReplica(ZkNodeProps message,
NamedList results)
Move replica.
|
QueryResponse |
simQuery(QueryRequest req) |
void |
simRemoveDeadNodes()
Remove all replica information related to dead nodes.
|
boolean |
simRemoveNode(String nodeId)
Remove node from a cluster.
|
void |
simRemoveReplica(String nodeId,
String collection,
String coreNodeName)
Remove replica.
|
void |
simResetLeaderThrottles()
Reset the leader election throttles.
|
boolean |
simRestoreNode(String nodeId)
Restore a previously removed node.
|
void |
simSetClusterProperties(Map<String,Object> properties)
Set all cluster properties.
|
void |
simSetClusterProperty(String key,
Object value)
Set a cluster property.
|
void |
simSetClusterState(ClusterState initialState)
Initialize from an existing cluster state
|
void |
simSetCollectionProperties(String coll,
Map<String,Object> properties)
Set collection properties.
|
void |
simSetCollectionProperty(String coll,
String key,
String value)
Set collection property.
|
void |
simSetCollectionValue(String collection,
String key,
Object value)
Set per-collection value (eg.
|
void |
simSetCollectionValue(String collection,
String key,
Object value,
boolean delta,
boolean divide)
Set per-collection value (eg.
|
void |
simSetReplicaValues(String node,
Map<String,Map<String,List<ReplicaInfo>>> source,
boolean overwrite) |
void |
simSetShardValue(String collection,
String shard,
String key,
Object value)
Set per-collection value (eg.
|
void |
simSetShardValue(String collection,
String shard,
String key,
Object value,
boolean delta,
boolean divide)
Set per-collection value (eg.
|
void |
simSetSliceProperties(String coll,
String slice,
Map<String,Object> properties)
Set slice properties.
|
void |
simSplitShard(ZkNodeProps message,
NamedList results)
Split a shard.
|
UpdateResponse |
simUpdate(UpdateRequest req)
Simulate an update by modifying replica metrics.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetClusterProperty, getClusterProperty, getCollection, isRoutedAlias, resolveSimpleAliaspublic static final long DEFAULT_DOC_SIZE_BYTES
public SimClusterStateProvider(LiveNodesSet liveNodes, SimCloudManager cloudManager) throws Exception
sim* methods in order
to ensure proper behavior, otherwise it will behave as a cluster with zero replicas.Exceptionpublic void copyFrom(ClusterStateProvider other) throws Exception
Exceptionpublic void simSetClusterState(ClusterState initialState) throws Exception
initialState - initial cluster stateExceptionpublic void simResetLeaderThrottles()
public String simGetRandomNode()
public String simGetRandomNode(Random random)
random - instance of random.public void simAddNode(String nodeId) throws Exception
nodeId - unique node idExceptionpublic boolean simRemoveNode(String nodeId) throws Exception
nodeId - node idExceptionpublic void simRemoveDeadNodes()
throws Exception
Exceptionpublic String simGetOverseerLeader()
public boolean simRestoreNode(String nodeId) throws Exception
nodeId - node id to restoreExceptionpublic void simAddReplica(ZkNodeProps message, NamedList results) throws Exception
message - replica detailsresults - result of the operationExceptionpublic void simAddReplica(String nodeId, ReplicaInfo replicaInfo, boolean runLeaderElection) throws Exception
nodeId - node id where the replica will be addedreplicaInfo - replica inforunLeaderElection - if true then run a leader election after adding the replica.Exceptionpublic void simRemoveReplica(String nodeId, String collection, String coreNodeName) throws Exception
nodeId - node idcoreNodeName - coreNodeNameExceptionpublic void simCreateCollection(ZkNodeProps props, NamedList results) throws Exception
props - collection detailsresults - results of the operation.Exceptionpublic void simDeleteCollection(String collection, String async, NamedList results) throws Exception
collection - collection nameasync - async idresults - results of the operationExceptionpublic void simDeleteAllCollections()
throws Exception
Exceptionpublic void simMoveReplica(ZkNodeProps message, NamedList results) throws Exception
MoveReplicaCmd moveNormalReplica(...) method.message - operation detailsresults - operation results.Exceptionpublic void simCreateShard(ZkNodeProps message, NamedList results) throws Exception
CreateShardCmd.message - operation detailsresults - operation resultsExceptionpublic void simSplitShard(ZkNodeProps message, NamedList results) throws Exception
SplitShardCmd, including simulating its
quirks, and leaving the original parent slice in place.message - operation detailsresults - operation results.Exceptionpublic void simDeleteShard(ZkNodeProps message, NamedList results) throws Exception
DeleteShardCmdmessage - operation detailsresults - operation resultsExceptionpublic void createSystemCollection()
throws IOException
IOExceptionpublic UpdateResponse simUpdate(UpdateRequest req) throws SolrException, InterruptedException, IOException
SEARCHER.searcher.numDocs - increased by added docs, decreased by deleteById and deleteByQuerySEARCHER.searcher.deletedDocs - decreased by deleteById and deleteByQuery by up to numDocsSEARCHER.searcher.maxDoc - always increased by the number of added docs.IMPORTANT limitations:
*:*req - update request. This request MUST have the collection param set.UpdateResponseSolrException - on errors, such as nonexistent collection or unsupported deleteByQueryInterruptedExceptionIOExceptionpublic QueryResponse simQuery(QueryRequest req) throws SolrException, InterruptedException, IOException
public void simSetClusterProperties(Map<String,Object> properties) throws Exception
DistribStateManagerproperties - properties to setExceptionpublic void simSetClusterProperty(String key, Object value) throws Exception
DistribStateManagerkey - property namevalue - property valueExceptionpublic void simSetCollectionProperties(String coll, Map<String,Object> properties) throws Exception
coll - collection nameproperties - propertiesExceptionpublic void simSetCollectionProperty(String coll, String key, String value) throws Exception
coll - collection namekey - property namevalue - property valueExceptionpublic void simSetSliceProperties(String coll, String slice, Map<String,Object> properties) throws Exception
coll - collection nameslice - slice nameproperties - slice propertiesExceptionpublic void simSetCollectionValue(String collection, String key, Object value) throws Exception
collection - collection namekey - property namevalue - property valueExceptionpublic void simSetCollectionValue(String collection, String key, Object value, boolean delta, boolean divide) throws Exception
public void simSetShardValue(String collection, String shard, String key, Object value) throws Exception
collection - collection nameshard - shard name. If null then all shards will be affected.key - property namevalue - property valueExceptionpublic void simSetShardValue(String collection, String shard, String key, Object value, boolean delta, boolean divide) throws Exception
collection - collection nameshard - shard name. If null then all shards will be affected.key - property namevalue - property valuedelta - if true then treat the numeric value as delta to add to the existing value
(or set the value to delta if missing)divide - if the value is a Number and this is true, then the value will be evenly
divided by the number of replicas.Exceptionpublic void simSetReplicaValues(String node, Map<String,Map<String,List<ReplicaInfo>>> source, boolean overwrite)
public List<ReplicaInfo> simGetReplicaInfos(String node)
node - node idpublic List<ReplicaInfo> simGetReplicaInfos(String collection, String shard)
public ReplicaInfo simGetReplicaInfo(String collection, String coreNode)
public List<String> simListCollections() throws InterruptedException
InterruptedExceptionpublic Map<String,Map<String,Object>> simGetCollectionStats() throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic ClusterState.CollectionRef getState(String collection)
getState in interface ClusterStateProviderpublic Set<String> getLiveNodes()
getLiveNodes in interface ClusterStateProviderpublic List<String> resolveAlias(String alias)
resolveAlias in interface ClusterStateProviderpublic Map<String,String> getAliasProperties(String alias)
getAliasProperties in interface ClusterStateProviderpublic ClusterState getClusterState() throws IOException
getClusterState in interface ClusterStateProviderIOExceptionpublic Map<String,Object> getClusterProperties()
getClusterProperties in interface ClusterStateProviderpublic String getPolicyNameByCollection(String coll)
getPolicyNameByCollection in interface ClusterStateProviderpublic void connect()
connect in interface ClusterStateProviderpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic boolean isClosed()
isClosed in interface SolrCloseableCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.