Has anyone used (or needed) an HAComponent pattern before? The object would be
instantiated on each member of the cluster but only “activated” on one node.
If that node fails or is shutdown another member will automatically activate
its instance. The distributed lock service could be used to arbitrate access
something like this:
/**
* Invoke to activate a component. Only one instance of the component is
* allowed to be active in the distributed system at any given time. This
* method blocks until the component is activated on this member or the
* component is released.
*
* @param ds
* the distributed system
* @param retryDelay
* the retry delay in millis
*/
protected void activate(DistributedSystem ds, int retryDelay) {
DistributedLockService dls = DistributedLockService.create(DLS_SERVICE, ds);
while (!abort && !Thread.interrupted()) {
if (dls.lock(getClass().getName(), retryDelay, -1)) {
locked = true;
return;
}
}
}
Anthony