You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ch...@apache.org on 2013/04/17 21:30:12 UTC
svn commit: r1469038 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm:
ServiceEndpointReader.java ServiceHandler.java ServiceSet.java
ServiceSpecifier.java
Author: challngr
Date: Wed Apr 17 19:30:12 2013
New Revision: 1469038
URL: http://svn.apache.org/r1469038
Log:
UIMA-2739
Restart any registered process, up to the configured max. The error count is
reset to 0 on any manual (or system) start.
Removed:
uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceEndpointReader.java
uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSpecifier.java
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java
uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java?rev=1469038&r1=1469037&r2=1469038&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java Wed Apr 17 19:30:12 2013
@@ -283,7 +283,11 @@ public class ServiceHandler
logger.debug(methodName, sset.getId(), "Reference-starting registered service, instances =", ninstances);
sset.setReferencedStart(true);
for ( int i = 0; i < ninstances; i++ ) {
- sset.start();
+ if ( ! sset.start() ) {
+ s.addMessage(dep, "Can't start independent service.");
+ s.setState(ServiceState.NotAvailable);
+ break;
+ }
}
}
@@ -648,7 +652,7 @@ public class ServiceHandler
// Hard to know for sure, if there are a bunch of instances, some working and some not, how to manage this.
// But this is a state *change* of something, and the something is active, so probably the service is OK now
// if it hadn't been before.
- sset.resetRunFailures();
+ // sset.resetRunFailures();
} else {
sset.removeImplementor(id);
@@ -666,6 +670,8 @@ public class ServiceHandler
// all other cases are errors that contribute to the error count
if ( sset.excessiveRunFailures() ) { // if true, the count is exceeeded, but reset
logger.warn(methodName, null, "Process Failure: " + jct + " Maximum consecutive failures[" + sset.failure_run + "] max [" + sset.failure_max + "]");
+ } else {
+ sset.start();
}
break;
}
@@ -838,9 +844,11 @@ public class ServiceHandler
if ( update ) {
sset.setNInstances(running + instances);
}
-
+
+ sset.resetRunFailures(); // manual start overrides, if there's still a problem
+ // the service will be stopped soon anyway.
for ( int i = 0; i < wanted; i++ ) {
- sset.start();
+ if ( !sset.start() ) break;
}
}
@@ -1011,7 +1019,7 @@ public class ServiceHandler
if ( diff > 0 ) {
while ( diff-- > 0 ) {
- sset.start();
+ if ( !sset.start() ) break;
}
} else if ( diff < 0 ) {
sset.stop(-diff);
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java?rev=1469038&r1=1469037&r2=1469038&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java Wed Apr 17 19:30:12 2013
@@ -104,9 +104,6 @@ public class ServiceSet
// Registered services, the number of instances to maintain
int instances = 1;
- // max allowable failures before disabling autostart
- int max_failures = 5;
-
// UIMA-AS pinger
IServiceMeta serviceMeta = null;
@@ -126,10 +123,8 @@ public class ServiceSet
LingerTask linger = null;
long linger_time = 5000;
- // max allowed consecutive failures, current failure count
int failure_max = ServiceManagerComponent.failure_max;
- int failure_start = 0;
- int failure_run = 0;
+ int failure_run = 0; // max allowed consecutive failures, current failure count
//JobState job_state = JobState.Undefined;
//
@@ -446,17 +441,16 @@ public class ServiceSet
*/
void enforceAutostart()
{
- String methodName = "enforceAutostart";
+ //String methodName = "enforceAutostart";
if ( ! autostart ) return; // not doing auto, nothing to do
if ( stopped ) return; // doing auto, but we've been manually stopped
+ if ( failure_run >= failure_max ) return; // too many failures, no more enforcement
// could have more implementors than instances if some were started dynamically but the count not persisted
int needed = Math.max(0, instances - countImplementors());
- logger.debug(methodName, null, "ENFORCE: ", needed);
while ( (needed--) > 0 ) {
- start();
- logger.debug(methodName, null, "ENFORCE: ", needed);
+ if ( ! start() ) break;
}
}
@@ -649,7 +643,6 @@ public class ServiceSet
saveMetaProperties();
if ( auto ) {
// turning this on gives benefit of the doubt on failure management
- failure_start = 0;
failure_run = 0;
}
}
@@ -865,10 +858,6 @@ public class ServiceSet
{
String methodName = "establish.1";
- if ( job_state == JobState.Running ) {
- failure_run = 0;
- }
-
if ( service_class == ServiceClass.Implicit ) {
startPingThread();
return;
@@ -1032,8 +1021,6 @@ public class ServiceSet
String methodName = "runFailures";
if ( (++failure_run) > failure_max ) {
logger.debug(methodName, id, "RUN FAILURES EXCEEDED");
- setAutostart(false);
- failure_run = 0;
return true;
}
logger.debug(methodName, id, "RUN FAILURES NOT EXCEEDED YET", failure_run);
@@ -1155,7 +1142,7 @@ public class ServiceSet
/**
* This assumes the caller has already verified that I'm a registered service.
*/
- void start()
+ boolean start()
{
String methodName = "start";
@@ -1164,7 +1151,7 @@ public class ServiceSet
if ( ! isStartable() ) {
establish(); // this will just start the ping thread
- return;
+ return true;
}
// Simple use of ducc_ling, just submit as the user. The specification will have the working directory
@@ -1261,21 +1248,17 @@ public class ServiceSet
}
}
-
+
+ boolean rc = true;
if ( ! started ) {
logger.warn(methodName, null, "Request to start service " + id.toString() + " failed.");
- if ( (++failure_start) >= (failure_max) ) {
- logger.warn(methodName, null, "Start failure. Maximum consecutive failures[" + failure_max + "] exceeded{" + failure_start + "]. Autostart disabled.");
- setAutostart(false);
- failure_start = 0;
- }
-
+ setAutostart(false);
} else {
setServiceState(ServiceState.Initializing);
- failure_start = 0;
}
saveMetaProperties();
logger.debug(methodName, null, "ENDSTART ENDSTART ENDSTART ENDSTART ENDSTART ENDSTART");
+ return rc;
}
/**
@@ -1402,7 +1385,6 @@ public class ServiceSet
return;
}
- this.stopped = true;
logger.debug(methodName, id, "Stopping", count, "implementors");
for ( DuccId id: implementors.keySet() ) {
if ( (count--) > 0 ) {