Class SimNodeStateProvider
- java.lang.Object
-
- org.apache.solr.cloud.autoscaling.sim.SimNodeStateProvider
-
- All Implemented Interfaces:
Closeable,AutoCloseable,NodeStateProvider,SolrCloseable
public class SimNodeStateProvider extends Object implements NodeStateProvider
SimulatedNodeStateProvider. Note: in order to setup node-level metrics usesimSetNodeValues(String, Map). However, in order to setup core-level metrics useSimClusterStateProvider.simSetCollectionValue(String, String, Object, boolean, boolean).
-
-
Constructor Summary
Constructors Constructor Description SimNodeStateProvider(LiveNodesSet liveNodesSet, SimDistribStateManager stateManager, SimClusterStateProvider clusterStateProvider, Map<String,Map<String,Object>> nodeValues)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Map<String,Object>getNodeValues(String node, Collection<String> tags)Map<String,Map<String,List<ReplicaInfo>>>getReplicaInfo(String node, Collection<String> keys)Map<String,Object>getReplicaMetricsValues(String node, Collection<String> tags)Simulate getting replica metrics values.voidsimAddNodeValue(String node, String key, Object value)Add a node value, creating a list of values if necessary.Map<String,Map<String,Object>>simGetAllNodeValues()Get all node values.Set<String>simGetDeadNodes()Return a set of nodes that are not live but their values are still present.ObjectsimGetNodeValue(String node, String key)Get a node valueMap<String,Object>simGetNodeValues(String node)Get all values for a selected node.voidsimRemoveDeadNodes()Remove values that correspond to dead nodes.voidsimRemoveNodeValues(String node)Remove node values.voidsimSetNodeValue(String node, String key, Object value)Set a node value, replacing any previous value.voidsimSetNodeValues(String node, Map<String,Object> values)Set node values.ObjectsimUpdateNodeValue(String node, String key, Function<Object,Object> updater)Atomically update a node value.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.solr.common.SolrCloseable
isClosed
-
-
-
-
Constructor Detail
-
SimNodeStateProvider
public SimNodeStateProvider(LiveNodesSet liveNodesSet, SimDistribStateManager stateManager, SimClusterStateProvider clusterStateProvider, Map<String,Map<String,Object>> nodeValues)
-
-
Method Detail
-
simGetNodeValue
public Object simGetNodeValue(String node, String key)
Get a node value- Parameters:
node- node idkey- property name- Returns:
- property value or null if property or node doesn't exist.
-
simUpdateNodeValue
public Object simUpdateNodeValue(String node, String key, Function<Object,Object> updater) throws InterruptedException
Atomically update a node value.- Parameters:
node- node idkey- property nameupdater- updater function- Returns:
- previous property value or null if property or node didn't exist.
- Throws:
InterruptedException
-
simSetNodeValues
public void simSetNodeValues(String node, Map<String,Object> values) throws InterruptedException
Set node values. NOTE: if values contain 'nodeRole' key then /roles.json is updated.- Parameters:
node- node idvalues- values.- Throws:
InterruptedException
-
simSetNodeValue
public void simSetNodeValue(String node, String key, Object value) throws InterruptedException
Set a node value, replacing any previous value. NOTE: if key is 'nodeRole' then /roles.json is updated.- Parameters:
node- node idkey- property namevalue- property value- Throws:
InterruptedException
-
simAddNodeValue
public void simAddNodeValue(String node, String key, Object value) throws InterruptedException
Add a node value, creating a list of values if necessary. NOTE: if key is 'nodeRole' then /roles.json is updated.- Parameters:
node- node idkey- property namevalue- property value.- Throws:
InterruptedException
-
simRemoveNodeValues
public void simRemoveNodeValues(String node) throws InterruptedException
Remove node values. If values contained a 'nodeRole' key then /roles.json is updated.- Parameters:
node- node id- Throws:
InterruptedException
-
simRemoveDeadNodes
public void simRemoveDeadNodes() throws InterruptedExceptionRemove values that correspond to dead nodes. If values contained a 'nodeRole' key then /roles.json is updated.- Throws:
InterruptedException
-
simGetDeadNodes
public Set<String> simGetDeadNodes()
Return a set of nodes that are not live but their values are still present.
-
simGetAllNodeValues
public Map<String,Map<String,Object>> simGetAllNodeValues()
Get all node values.
-
simGetNodeValues
public Map<String,Object> simGetNodeValues(String node)
Get all values for a selected node.
-
getReplicaMetricsValues
public Map<String,Object> getReplicaMetricsValues(String node, Collection<String> tags)
Simulate getting replica metrics values. This uses per-replica properties set inSimClusterStateProvider.simSetCollectionValue(String, String, Object, boolean, boolean)and similar methods.- Parameters:
node- node idtags- metrics names- Returns:
- map of metrics names / values
-
getNodeValues
public Map<String,Object> getNodeValues(String node, Collection<String> tags)
- Specified by:
getNodeValuesin interfaceNodeStateProvider
-
getReplicaInfo
public Map<String,Map<String,List<ReplicaInfo>>> getReplicaInfo(String node, Collection<String> keys)
- Specified by:
getReplicaInfoin interfaceNodeStateProvider
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-