ALF-10934: Prevent potential start/stop ping-pong of subsystems across a cluster

- When a cluster boots up or receives a reinit message it shouldn't be sending out any start messages

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31732 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2011-11-04 12:30:53 +00:00
parent a400747605
commit 0772435bda

View File

@@ -231,7 +231,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
{ {
if (start) if (start)
{ {
start(true); start(true, false);
} }
return this.state; return this.state;
} }
@@ -470,7 +470,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
this.lock.writeLock().lock(); this.lock.writeLock().lock();
try try
{ {
start(false); start(false, false);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -496,7 +496,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
destroy(false); destroy(false);
// fall through // fall through
case UNINITIALIZED: case UNINITIALIZED:
start(false); start(false, false);
} }
} }
finally finally
@@ -595,7 +595,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
} }
// Attempt to start locally // Attempt to start locally
start(false); start(false, true);
// We still haven't broadcast the start - a persist is required first so this will be done by the caller // We still haven't broadcast the start - a persist is required first so this will be done by the caller
} }
@@ -608,7 +608,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
} }
// Bring the bean back up across the cluster // Bring the bean back up across the cluster
start(true); start(true, false);
if (e instanceof RuntimeException) if (e instanceof RuntimeException)
{ {
throw (RuntimeException) e; throw (RuntimeException) e;
@@ -630,7 +630,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
this.lock.writeLock().lock(); this.lock.writeLock().lock();
try try
{ {
start(true); start(true, false);
} }
finally finally
{ {
@@ -641,10 +641,12 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
/** /**
* Starts the bean, optionally broadcasting the event to remote nodes. * Starts the bean, optionally broadcasting the event to remote nodes.
* *
* @param broadcast * @param broadcastNow
* Should the event be broadcast? * Should the event be broadcast immediately?
* @param broadcastLater
* Should the event be broadcast ever?
*/ */
protected void start(boolean broadcast) protected void start(boolean broadcastNow, boolean broadcastLater)
{ {
boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread(); boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread();
if (this.runtimeState != RuntimeState.STARTED) if (this.runtimeState != RuntimeState.STARTED)
@@ -663,10 +665,10 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
// fall through // fall through
case STOPPED: case STOPPED:
this.state.start(); this.state.start();
this.runtimeState = RuntimeState.PENDING_BROADCAST_START; this.runtimeState = broadcastLater ? RuntimeState.PENDING_BROADCAST_START : RuntimeState.STARTED;
// fall through // fall through
case PENDING_BROADCAST_START: case PENDING_BROADCAST_START:
if (broadcast) if (broadcastNow)
{ {
this.registry.broadcastStart(this); this.registry.broadcastStart(this);
this.runtimeState = RuntimeState.STARTED; this.runtimeState = RuntimeState.STARTED;