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/15 21:03:42 UTC
svn commit: r1468188 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm:
ServiceHandler.java ServiceSet.java
Author: challngr
Date: Mon Apr 15 19:03:42 2013
New Revision: 1468188
URL: http://svn.apache.org/r1468188
Log:
UIMA-2814
Unify stop/start paths and insure ping-only services work right.
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=1468188&r1=1468187&r2=1468188&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 Mon Apr 15 19:03:42 2013
@@ -840,14 +840,9 @@ public class ServiceHandler
}
for ( int i = 0; i < wanted; i++ ) {
- if ( sset.isStartable() ) {
- sset.start();
- } else {
- sset.establish(); // this will just start the ping thread
- }
+ sset.start();
}
-
}
ServiceReplyEvent stop(ServiceStopEvent ev)
@@ -868,28 +863,12 @@ public class ServiceHandler
}
if ( sset.isRegistered() ) {
- if ( (sset.countImplementors() == 0) && ( sset.isUimaAs()) ) {
+ if ( sset.isStopped() ) {
return new ServiceReplyEvent(false, "Service " + serviceIdString + " is already stopped.", sset.getKey(), sset.getId());
}
- int running = sset.countImplementors();
- int instances = ev.getInstances();
- int tolose;
- if ( instances == -1 ) {
- tolose = running;
- } else {
- tolose = Math.min(instances, running);
- }
-
-
- if ( tolose > 0 ) {
- pendingRequests.add(new ApiHandler(ev, this));
-// ApiHandler apih = new ApiHandler(ev, this);
-// Thread t = new Thread(apih);
-// t.start();
- }
-
- return new ServiceReplyEvent(true, "Service " + serviceIdString + " stop request accepted for [" + tolose + "] instances.", sset.getKey(), sset.getId());
+ pendingRequests.add(new ApiHandler(ev, this));
+ return new ServiceReplyEvent(true, "Service " + serviceIdString + " stop request accepted.", sset.getKey(), sset.getId());
} else {
return new ServiceReplyEvent(false, "Service " + friendly + " is not a registered service.", sset.getKey(), null);
}
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=1468188&r1=1468187&r2=1468188&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 Mon Apr 15 19:03:42 2013
@@ -341,6 +341,11 @@ public class ServiceSet
successors.clear();
}
+ boolean isStopped()
+ {
+ return stopped;
+ }
+
boolean hasPredecessor()
{
return predecessors.size() != 0;
@@ -1063,6 +1068,8 @@ public class ServiceSet
// checked and updated next run through the
// main state machine, and maybe ping restarted.
serviceMeta = null;
+ } else {
+ setServiceState(ServiceState.NotAvailable);
}
if ( isImplicit() ) {
@@ -1153,12 +1160,12 @@ public class ServiceSet
String methodName = "start";
logger.debug(methodName, null, "START START START START START START START START");
-// if ( service_type == ServiceType.Custom ) {
-// establish();
-// return;
-// }
+ this.stopped = false;
- this.stopped = false; // for registered
+ if ( ! isStartable() ) {
+ establish(); // this will just start the ping thread
+ return;
+ }
// Simple use of ducc_ling, just submit as the user. The specification will have the working directory
// and classpath needed for the service, handled by the Orchestrator and Job Driver.
@@ -1368,9 +1375,14 @@ public class ServiceSet
{
String methodName = "stop";
logger.debug(methodName, id, "Stopping all implementors");
+ this.stopped = true;
stopPingThread();
setServiceState(ServiceState.Stopping);
- this.stopped = true;
+
+ if ( ! isStartable() ) { // CUSTOM ping-only service
+ return;
+ }
+
for ( DuccId id : implementors.keySet() ) {
stopOneProcess(id);
}
@@ -1384,8 +1396,14 @@ public class ServiceSet
void stop(int count)
{
String methodName = "stop(count)";
- logger.debug(methodName, id, "Stopping", count, "implementors");
+
+ if ( ! isStartable() ) { // CUSTOM ping-only, only one running, let common code do the honors
+ stop();
+ return;
+ }
+
this.stopped = true;
+ logger.debug(methodName, id, "Stopping", count, "implementors");
for ( DuccId id: implementors.keySet() ) {
if ( (count--) > 0 ) {
stopOneProcess(id);