in uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java [1715:1953]
public synchronized void signal(ServiceInstance si)
{
String methodName = "signal";
if ( true ) {
ServiceState cumulative = cumulativeJobState();
//
// Note on the CUMULATIVE state: this is the cumulative state as determined by service processes. If they
// should all die at once through some temporary glitch the state could go to Unavailable even though the
// SM would now be in active retry - the states below avoid regression state if CUMULATIVE goes to
// Unavailable but the retry count indicates retry is still in progress.
//
//
// The ping state is pretty much always the right state. But if we're
// not yet pinging we need to see if any of the implementors states
// indicates we should be pinging, in which case, start the pinger.
//
logger.trace(methodName, id, "serviceState", getState(), "cumulativeState", cumulative);
switch ( getState() ) {
// If I'm brand new and something is initting then I can be too. If something is
// actually running then I can start a pinger which will set my state.
case Dispossessed:
return;
case Available:
switch ( cumulative ) {
case Starting:
logger.warn(methodName, id, "STATE REGRESSION:", getState(), "->", cumulative); // can't do anything about it but complain
setState(ServiceState.Starting, cumulative, si);
break;
case Initializing:
// Not immediately clear what would cause this other than an error but let's not crash.
logger.warn(methodName, id, "STATE REGRESSION:", getState(), "->", cumulative); // can't do anything about it but complain
setState(ServiceState.Initializing, cumulative, si);
break;
case Available:
setState(ServiceState.Available, cumulative, si);
break;
case Stopping:
setState(ServiceState.Stopping, cumulative, si);
break;
case Stopped:
setState(ServiceState.Stopped, cumulative, si);
break;
case Waiting:
setState(ServiceState.Waiting, cumulative, si);
break;
default:
stopPingThread();
logger.warn(methodName, id, "ILLEGAL STATE TRANSITION:", getState(), "->", cumulative);
break;
}
break;
// If I'm initting and now something is running we can start a pinger
case Initializing:
switch ( cumulative ) {
case Starting:
logger.warn(methodName, id, "STATE REGRESSION:", getState(), "->", cumulative); // can't do anything about it but complain
setState(ServiceState.Starting, cumulative, si);
break;
case Initializing:
setState(ServiceState.Initializing, cumulative, si);
break;
case Available:
logger.warn(methodName, id, "UNEXPECTED STATE TRANSITION:", getState(), "->", cumulative);
setState(ServiceState.Waiting, cumulative, si);
break;
case Stopping:
setState(ServiceState.Stopping, cumulative, si);
break;
case Stopped:
setState(ServiceState.Stopped, cumulative, si);
break;
case Waiting:
setState(ServiceState.Waiting, cumulative, si);
break;
default:
logger.warn(methodName, id, "ILLEGAL STATE TRANSITION:", getState(), "->", cumulative);
break;
}
break;
// If I'm initting and now something is running we can start a pinger
case Starting:
switch ( cumulative ) {
case Starting:
setState(ServiceState.Starting, cumulative, si);
break;
case Initializing:
setState(ServiceState.Initializing, cumulative, si);
break;
case Available:
setState(ServiceState.Waiting, cumulative, si);
break;
case Stopping:
logger.info(methodName, id, "RETRY RETRY RETRY prevents state regression from Initializing");
break;
case Stopped:
setState(ServiceState.Stopped, cumulative, si);
break;
case Waiting:
logger.warn(methodName, id, "ILLEGAL STATE TRANSITION:", getState(), "->", cumulative);
break;
}
break;
case Waiting:
switch ( cumulative ) {
case Starting:
logger.warn(methodName, id, "STATE REGRESSION:", getState(), "->", cumulative); // can't do anything about it but complain
setState(ServiceState.Starting, cumulative, si);
break;
case Initializing:
logger.warn(methodName, id, "STATE REGRESSION:", getState(), "->", cumulative); // can't do anything about it but complain
setState(ServiceState.Initializing, cumulative, si);
break;
case Available:
setState(ServiceState.Available, cumulative, si);
break;
case Stopping:
setState(ServiceState.Stopping, cumulative, si);
break;
case Stopped:
setState(ServiceState.Stopped, cumulative, si);
break;
case Waiting:
setState(ServiceState.Waiting, cumulative, si);
break;
default:
logger.warn(methodName, id, "ILLEGAL STATE TRANSITION:", getState(), "->", cumulative);
break;
}
break;
case Stopping:
switch ( cumulative ) {
case Starting:
setState(ServiceState.Starting, cumulative, si);
break;
case Initializing:
setState(ServiceState.Initializing, cumulative, si);
break;
case Available:
setState(ServiceState.Available, cumulative, si);
break;
case Stopped:
setState(ServiceState.Stopped, cumulative, si);
break;
case Stopping:
setState(ServiceState.Stopping, cumulative, si);
break;
default:
logger.warn(methodName, id, "ILLEGAL STATE TRANSITION:", getState(), "->", cumulative);
break;
}
break;
case Stopped:
// OK
// Every transition can happen here because of hot-start of SM
switch ( cumulative ) {
case Starting:
setState(ServiceState.Starting, cumulative, si);
break;
case Initializing:
setState(ServiceState.Initializing, cumulative, si);
break;
case Available:
setState(ServiceState.Waiting, cumulative, si);
break;
case Waiting:
setState(ServiceState.Waiting, cumulative, si);
break;
case Stopped:
// Trailing OR publications cause this. Just record it for the log.
setState(ServiceState.Stopped, cumulative, si);
break;
case Stopping:
setState(ServiceState.Stopping, cumulative, si);
logger.warn(methodName, id, "UNEXPECTED STATE:", getState(), "->", cumulative);
break;
case NotAvailable:
// junk. just ignore it
logger.warn(methodName, id, "UNEXPECTED STATE:", getState(), "->", cumulative);
break;
}
break;
case NotAvailable:
case Undefined:
// OK
logger.warn(methodName, id, "Illiegal state", getState(), "Ignored.");
break;
}
}
}