Package org.apache.zookeeper.test.system
Class InstanceManager
- java.lang.Object
-
- org.apache.zookeeper.test.system.InstanceManager
-
- All Implemented Interfaces:
AsyncCallback
,AsyncCallback.ChildrenCallback
,Watcher
public class InstanceManager extends java.lang.Object implements AsyncCallback.ChildrenCallback, Watcher
This class doles out assignments to InstanceContainers that are registered to a ZooKeeper znode. The znode will have four child nodes: * ready: this znode indicates that the InstanceManager is running * available: the children of this znode are ephemeral nodes representing running InstanceContainers * assignments: there will be a child under this znode for each available InstanceContainer. those znodes will have a child for each assigned instance * reports: there will be a child under this znode for each instance that is running. it will have the report string from the instance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.zookeeper.AsyncCallback
AsyncCallback.ACLCallback, AsyncCallback.AllChildrenNumberCallback, AsyncCallback.Children2Callback, AsyncCallback.ChildrenCallback, AsyncCallback.Create2Callback, AsyncCallback.DataCallback, AsyncCallback.EphemeralsCallback, AsyncCallback.MultiCallback, AsyncCallback.StatCallback, AsyncCallback.StringCallback, AsyncCallback.VoidCallback
-
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
Watcher.Event, Watcher.WatcherType
-
-
Constructor Summary
Constructors Constructor Description InstanceManager(ZooKeeper zk, java.lang.String prefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
assignInstance(java.lang.String name, java.lang.Class<? extends Instance> clazz, java.lang.String params, int weight)
void
close()
java.lang.String
getStatus(java.lang.String name, long timeout)
void
process(WatchedEvent event)
void
processResult(int rc, java.lang.String path, java.lang.Object ctx, java.util.List<java.lang.String> children)
Process the result of the asynchronous call.void
reconfigureInstance(java.lang.String name, java.lang.String params)
void
removeInstance(java.lang.String name)
void
resetStatus(java.lang.String name)
-
-
-
Constructor Detail
-
InstanceManager
public InstanceManager(ZooKeeper zk, java.lang.String prefix) throws KeeperException, java.lang.InterruptedException
- Throws:
KeeperException
java.lang.InterruptedException
-
-
Method Detail
-
processResult
public void processResult(int rc, java.lang.String path, java.lang.Object ctx, java.util.List<java.lang.String> children)
Description copied from interface:AsyncCallback.ChildrenCallback
Process the result of the asynchronous call.On success, rc is
KeeperException.Code.OK
.On failure, rc is set to the corresponding failure code in
KeeperException
.KeeperException.Code.NONODE
- The node on given path doesn't exist for some API calls.
- Specified by:
processResult
in interfaceAsyncCallback.ChildrenCallback
- Parameters:
rc
- The return code or the result of the call.path
- The path that we passed to asynchronous calls.ctx
- Whatever context object that we passed to asynchronous calls.children
- An unordered array of children of the node on given path.- See Also:
ZooKeeper.getChildren(String, boolean, AsyncCallback.ChildrenCallback, Object)
,ZooKeeper.getChildren(String, Watcher, AsyncCallback.ChildrenCallback, Object)
-
process
public void process(WatchedEvent event)
-
assignInstance
public java.lang.String assignInstance(java.lang.String name, java.lang.Class<? extends Instance> clazz, java.lang.String params, int weight) throws NoAvailableContainers, DuplicateNameException, java.lang.InterruptedException, KeeperException
- Throws:
NoAvailableContainers
DuplicateNameException
java.lang.InterruptedException
KeeperException
-
reconfigureInstance
public void reconfigureInstance(java.lang.String name, java.lang.String params) throws NoAssignmentException, java.lang.InterruptedException, KeeperException
- Throws:
NoAssignmentException
java.lang.InterruptedException
KeeperException
-
removeInstance
public void removeInstance(java.lang.String name) throws java.lang.InterruptedException, KeeperException
- Throws:
java.lang.InterruptedException
KeeperException
-
resetStatus
public void resetStatus(java.lang.String name) throws java.lang.InterruptedException, KeeperException
- Throws:
java.lang.InterruptedException
KeeperException
-
getStatus
public java.lang.String getStatus(java.lang.String name, long timeout) throws KeeperException, java.lang.InterruptedException
- Throws:
KeeperException
java.lang.InterruptedException
-
close
public void close() throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
-