|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.jini.start.ServiceConfigurationZNodeMonitorTask
public class ServiceConfigurationZNodeMonitorTask
This is a standing task whose Future is monitored by the
ServicesManagerServer. For each ServiceConfiguration znode,
there is one such task per ServicesManagerServer. The task holding
the ZLock is the one that handles state changes for
ServiceConfiguration znode, including its children, which are the
logical service instance znodes.
If the ServicesManagerServer dies, then its znodes will be deleted
from the lock queues and someone else (if anyone is left alive) will get the
lock and manage the logical service.
If the task itself dies, then the ServicesManagerServer needs to log
an error and create a new instance of the task.
| Field Summary | |
|---|---|
protected String |
className
|
protected static boolean |
DEBUG
|
protected JiniFederation |
fed
|
protected static boolean |
INFO
|
protected IServiceListener |
listener
|
protected static org.apache.log4j.Logger |
log
|
| Constructor Summary | |
|---|---|
ServiceConfigurationZNodeMonitorTask(JiniFederation fed,
IServiceListener listener,
String className)
|
|
| Method Summary | |
|---|---|
protected void |
acquireLockAndRun()
Waits until it acquires the lock and then runWithLock(ZLock) |
protected void |
balanceAll(ManagedServiceConfiguration config,
String[] watchedSet)
|
protected void |
balanceLogicalServices(ManagedServiceConfiguration config)
Consider the logical service instances for the ServiceConfiguration and if necessary makes an adjustment to the
#of logical services that are running. |
protected void |
balancePhysicalServices(ManagedServiceConfiguration config,
String[] watchedSet)
Consider all the physical service containers and initiates a competition to create or destroy a physical service instance for each logical service that is out of balance. |
Void |
call()
Contends for a ZLock on #zpath and then maintains a
balance between: (a) the ServiceConfiguration state for a service
type; (b) the #of logical service instances for that service type; and
(c) the #of physical service instances for any logical service instance
for that service type. |
protected void |
handleEvent(com.bigdata.jini.start.ServiceConfigurationZNodeMonitorTask.ServiceConfigurationHierarchyWatcher watcher,
org.apache.zookeeper.WatchedEvent e)
Handle a WatchedEvent that was read from a queue. |
protected void |
runWithLock(ZLock zlock)
Runs with the zlock held. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
protected static final boolean INFO
protected static final boolean DEBUG
protected final JiniFederation fed
protected final IServiceListener listener
protected final String className
| Constructor Detail |
|---|
public ServiceConfigurationZNodeMonitorTask(JiniFederation fed,
IServiceListener listener,
String className)
fed - className - The class name (aka service type).| Method Detail |
|---|
public Void call()
throws Exception
ZLock on #zpath and then maintains a
balance between: (a) the ServiceConfiguration state for a service
type; (b) the #of logical service instances for that service type; and
(c) the #of physical service instances for any logical service instance
for that service type.
The set of znodes to be watched is dynamic. Its only fixed fixed member
is the ServiceConfiguration znode. We need to change the watch
set as new logical services are created or destroyed and as new physical
services are created or destroyed.
This only watch znodes and takes action while the ZLock is held.
If it looses the ZLock, it will seek to re-acquire the lock. No
actions are taken in the zookeeper event thread. They are all pushed into
a queue and then processed in the thread that executes call().
The queue also prevents us from attempting to make more than one
adjustment to the managed services at a time.
Note: This task is designed to run until cancelled. It will trap anything
but an InterruptedException and restart from
acquireLockAndRun().
call in interface Callable<Void>Exception
protected void acquireLockAndRun()
throws Exception
runWithLock(ZLock)
Exception
protected void runWithLock(ZLock zlock)
throws Exception
zlock -
Exception
protected void balanceAll(ManagedServiceConfiguration config,
String[] watchedSet)
throws Exception
config - watchedSet -
Exception
protected void balanceLogicalServices(ManagedServiceConfiguration config)
throws Exception
ServiceConfiguration and if necessary makes an adjustment to the
#of logical services that are running.
config - A recent snapshot of the ServiceConfiguration state.
Exception
protected void balancePhysicalServices(ManagedServiceConfiguration config,
String[] watchedSet)
throws org.apache.zookeeper.KeeperException,
InterruptedException
MonitorCreatePhysicalServiceLocksTask, which watches a well
known znode for the appearence of new lock nodes and then enters into a
competition to create a new physical service instance. Therefore while
this initiates the competition for processing to handle the imbalance,
the imbalance is NOT correct while we are in this method.
config - A recent snapshot of the ServiceConfiguration state.watchedSet - The set of watched znodes (this includes the physical service
containers, which is what we need here).
InterruptedException
org.apache.zookeeper.KeeperException
protected void handleEvent(com.bigdata.jini.start.ServiceConfigurationZNodeMonitorTask.ServiceConfigurationHierarchyWatcher watcher,
org.apache.zookeeper.WatchedEvent e)
throws Exception
WatchedEvent that was read from a queue.
ServiceConfiguration znode itself, then
we need to test ALL watched logicalService znodes and ALL watched
physicalService znodes. This is identical to the setup procedure when we
gain the ZLock and setup the
ServiceConfigurationHierarchyWatcher.
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||