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
SimulatedDistribStateManager
that 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 class
SimDistribStateManager.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 void
clear()
Clear this instance.void
close()
void
copyFrom(DistribStateManager other, boolean failOnExists)
Copy all content from another DistribStateManager.String
createData(String path, byte[] data, org.apache.zookeeper.CreateMode mode)
static SimDistribStateManager.Node
createNewRootNode()
AutoScalingConfig
getAutoScalingConfig(org.apache.zookeeper.Watcher watcher)
VersionedData
getData(String path, org.apache.zookeeper.Watcher watcher)
SimDistribStateManager.Node
getRoot()
Get the root node of the tree used by this instance.boolean
hasData(String path)
List<String>
listData(String path)
List<String>
listData(String path, org.apache.zookeeper.Watcher watcher)
void
makePath(String path)
void
makePath(String path, byte[] data, org.apache.zookeeper.CreateMode createMode, boolean failOnExists)
List<org.apache.zookeeper.OpResult>
multi(Iterable<org.apache.zookeeper.Op> ops)
void
removeData(String path, int version)
void
setData(String path, byte[] data, int version)
void
simSetAutoScalingConfig(AutoScalingConfig cfg)
SimDistribStateManager
withEphemeralId(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:
InterruptedException
IOException
org.apache.zookeeper.KeeperException
AlreadyExistsException
BadVersionException
-
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
hasData
public boolean hasData(String path) throws IOException
- Specified by:
hasData
in interfaceDistribStateManager
- Throws:
IOException
-
listData
public List<String> listData(String path) throws NoSuchElementException, IOException
- Specified by:
listData
in interfaceDistribStateManager
- Throws:
NoSuchElementException
IOException
-
listData
public List<String> listData(String path, org.apache.zookeeper.Watcher watcher) throws NoSuchElementException, IOException
- Specified by:
listData
in interfaceDistribStateManager
- Throws:
NoSuchElementException
IOException
-
getData
public VersionedData getData(String path, org.apache.zookeeper.Watcher watcher) throws NoSuchElementException, IOException
- Specified by:
getData
in interfaceDistribStateManager
- Throws:
NoSuchElementException
IOException
-
makePath
public void makePath(String path) throws IOException
- Specified by:
makePath
in 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:
makePath
in interfaceDistribStateManager
- Throws:
AlreadyExistsException
IOException
org.apache.zookeeper.KeeperException
InterruptedException
-
createData
public String createData(String path, byte[] data, org.apache.zookeeper.CreateMode mode) throws AlreadyExistsException, NoSuchElementException, IOException
- Specified by:
createData
in interfaceDistribStateManager
- Throws:
AlreadyExistsException
NoSuchElementException
IOException
-
removeData
public void removeData(String path, int version) throws NoSuchElementException, NotEmptyException, BadVersionException, IOException
- Specified by:
removeData
in interfaceDistribStateManager
- Throws:
NoSuchElementException
NotEmptyException
BadVersionException
IOException
-
setData
public void setData(String path, byte[] data, int version) throws NoSuchElementException, BadVersionException, IOException
- Specified by:
setData
in interfaceDistribStateManager
- Throws:
NoSuchElementException
BadVersionException
IOException
-
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:
multi
in interfaceDistribStateManager
- Throws:
BadVersionException
NoSuchElementException
AlreadyExistsException
IOException
org.apache.zookeeper.KeeperException
InterruptedException
-
getAutoScalingConfig
public AutoScalingConfig getAutoScalingConfig(org.apache.zookeeper.Watcher watcher) throws InterruptedException, IOException
- Specified by:
getAutoScalingConfig
in interfaceDistribStateManager
- Throws:
InterruptedException
IOException
-
simSetAutoScalingConfig
public void simSetAutoScalingConfig(AutoScalingConfig cfg) throws Exception
- Throws:
Exception
-
-