Class SimDistribStateManager
- java.lang.Object
-
- org.apache.solr.cloud.autoscaling.sim.SimDistribStateManager
-
- All Implemented Interfaces:
Closeable,AutoCloseable,DistribStateManager,SolrCloseable
public class SimDistribStateManager extends Object implements DistribStateManager
SimulatedDistribStateManagerthat keeps all data locally in a static structure. Instances of this class are identified by their id in order to simulate the deletion of ephemeral nodes whenclose()is invoked.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimDistribStateManager.Node
-
Constructor Summary
Constructors Constructor Description SimDistribStateManager()SimDistribStateManager(ActionThrottle actionThrottle, ActionError actionError)SimDistribStateManager(SimDistribStateManager.Node root)Construct new state manager that uses provided root node for storing data.SimDistribStateManager(SimDistribStateManager.Node root, ActionThrottle actionThrottle, ActionError actionError)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear this instance.voidclose()voidcopyFrom(DistribStateManager other, boolean failOnExists)Copy all content from another DistribStateManager.StringcreateData(String path, byte[] data, org.apache.zookeeper.CreateMode mode)static SimDistribStateManager.NodecreateNewRootNode()AutoScalingConfiggetAutoScalingConfig(org.apache.zookeeper.Watcher watcher)VersionedDatagetData(String path, org.apache.zookeeper.Watcher watcher)SimDistribStateManager.NodegetRoot()Get the root node of the tree used by this instance.booleanhasData(String path)List<String>listData(String path)List<String>listData(String path, org.apache.zookeeper.Watcher watcher)voidmakePath(String path)voidmakePath(String path, byte[] data, org.apache.zookeeper.CreateMode createMode, boolean failOnExists)List<org.apache.zookeeper.OpResult>multi(Iterable<org.apache.zookeeper.Op> ops)voidremoveData(String path, int version)voidsetData(String path, byte[] data, int version)voidsimSetAutoScalingConfig(AutoScalingConfig cfg)SimDistribStateManagerwithEphemeralId(String id)Create a copy of this instance using a specified ephemeral owner id.-
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.client.solrj.cloud.DistribStateManager
getAutoScalingConfig, getData, listTree, removeRecursively
-
Methods inherited from interface org.apache.solr.common.SolrCloseable
isClosed
-
-
-
-
Constructor Detail
-
SimDistribStateManager
public SimDistribStateManager()
-
SimDistribStateManager
public SimDistribStateManager(SimDistribStateManager.Node root)
Construct new state manager that uses provided root node for storing data.- Parameters:
root- if null then a new root node will be created.
-
SimDistribStateManager
public SimDistribStateManager(ActionThrottle actionThrottle, ActionError actionError)
-
SimDistribStateManager
public SimDistribStateManager(SimDistribStateManager.Node root, ActionThrottle actionThrottle, ActionError actionError)
-
-
Method Detail
-
createNewRootNode
public static SimDistribStateManager.Node createNewRootNode()
-
copyFrom
public void copyFrom(DistribStateManager other, boolean failOnExists) throws InterruptedException, IOException, org.apache.zookeeper.KeeperException, AlreadyExistsException, BadVersionException
Copy all content from another DistribStateManager.- Parameters:
other- another state manager.failOnExists- abort copy when one or more paths already exist (the state of this manager remains unchanged).- Throws:
InterruptedExceptionIOExceptionorg.apache.zookeeper.KeeperExceptionAlreadyExistsExceptionBadVersionException
-
withEphemeralId
public SimDistribStateManager withEphemeralId(String id)
Create a copy of this instance using a specified ephemeral owner id. This is useful when performing node operations that require using a specific id. Note: this instance should never be closed, it can be just discarded after use.- Parameters:
id- ephemeral owner id
-
getRoot
public SimDistribStateManager.Node getRoot()
Get the root node of the tree used by this instance. It could be a static shared root node.
-
clear
public void clear()
Clear this instance. All nodes, watchers and data is deleted.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
hasData
public boolean hasData(String path) throws IOException
- Specified by:
hasDatain interfaceDistribStateManager- Throws:
IOException
-
listData
public List<String> listData(String path) throws NoSuchElementException, IOException
- Specified by:
listDatain interfaceDistribStateManager- Throws:
NoSuchElementExceptionIOException
-
listData
public List<String> listData(String path, org.apache.zookeeper.Watcher watcher) throws NoSuchElementException, IOException
- Specified by:
listDatain interfaceDistribStateManager- Throws:
NoSuchElementExceptionIOException
-
getData
public VersionedData getData(String path, org.apache.zookeeper.Watcher watcher) throws NoSuchElementException, IOException
- Specified by:
getDatain interfaceDistribStateManager- Throws:
NoSuchElementExceptionIOException
-
makePath
public void makePath(String path) throws IOException
- Specified by:
makePathin interfaceDistribStateManager- Throws:
IOException
-
makePath
public void makePath(String path, byte[] data, org.apache.zookeeper.CreateMode createMode, boolean failOnExists) throws AlreadyExistsException, IOException, org.apache.zookeeper.KeeperException, InterruptedException
- Specified by:
makePathin interfaceDistribStateManager- Throws:
AlreadyExistsExceptionIOExceptionorg.apache.zookeeper.KeeperExceptionInterruptedException
-
createData
public String createData(String path, byte[] data, org.apache.zookeeper.CreateMode mode) throws AlreadyExistsException, NoSuchElementException, IOException
- Specified by:
createDatain interfaceDistribStateManager- Throws:
AlreadyExistsExceptionNoSuchElementExceptionIOException
-
removeData
public void removeData(String path, int version) throws NoSuchElementException, NotEmptyException, BadVersionException, IOException
- Specified by:
removeDatain interfaceDistribStateManager- Throws:
NoSuchElementExceptionNotEmptyExceptionBadVersionExceptionIOException
-
setData
public void setData(String path, byte[] data, int version) throws NoSuchElementException, BadVersionException, IOException
- Specified by:
setDatain interfaceDistribStateManager- Throws:
NoSuchElementExceptionBadVersionExceptionIOException
-
multi
public List<org.apache.zookeeper.OpResult> multi(Iterable<org.apache.zookeeper.Op> ops) throws BadVersionException, NoSuchElementException, AlreadyExistsException, IOException, org.apache.zookeeper.KeeperException, InterruptedException
- Specified by:
multiin interfaceDistribStateManager- Throws:
BadVersionExceptionNoSuchElementExceptionAlreadyExistsExceptionIOExceptionorg.apache.zookeeper.KeeperExceptionInterruptedException
-
getAutoScalingConfig
public AutoScalingConfig getAutoScalingConfig(org.apache.zookeeper.Watcher watcher) throws InterruptedException, IOException
- Specified by:
getAutoScalingConfigin interfaceDistribStateManager- Throws:
InterruptedExceptionIOException
-
simSetAutoScalingConfig
public void simSetAutoScalingConfig(AutoScalingConfig cfg) throws Exception
- Throws:
Exception
-
-