You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2018/05/02 17:47:09 UTC

svn commit: r1830780 - /uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/sd/task/DuccServiceTaskProtocolHandler.java

Author: cwiklik
Date: Wed May  2 17:47:09 2018
New Revision: 1830780

URL: http://svn.apache.org/viewvc?rev=1830780&view=rev
Log:
UIMA-5756 modify code which block if no task is available. Wait for 2 secs between retries for the max of 60 secs

Modified:
    uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/sd/task/DuccServiceTaskProtocolHandler.java

Modified: uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/sd/task/DuccServiceTaskProtocolHandler.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/sd/task/DuccServiceTaskProtocolHandler.java?rev=1830780&r1=1830779&r2=1830780&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/sd/task/DuccServiceTaskProtocolHandler.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/sd/task/DuccServiceTaskProtocolHandler.java Wed May  2 17:47:09 2018
@@ -137,11 +137,16 @@ public class DuccServiceTaskProtocolHand
 		TaskAllocatorCallbackListener taskAllocator = 
 				sd.getTaskAllocator();
 		ITask task;
-		while( running ) {
+		// The max time we are willing to wait for a task is 60 secs
+		// with 2 secs wait time between retries. With the above
+		// the max number of retries is 30. When we reach the max
+		// retry, we return no work to the service.
+		long retryCount = 60/secondsToWait;
+		while( retryCount > 0 ) {
 			task = taskAllocator.getTask(taskConsumer);
-			// allocation system does not return a task (or empty)
+			// if allocation system does not return a task (or empty)
 			// block this thread and retry until a task becomes
-			// available
+			// available or until max retry count is exhausted
 			if ( task == null || task.isEmpty() ) {
 				try {
 					this.wait(secondsToWait*1000);
@@ -153,6 +158,7 @@ public class DuccServiceTaskProtocolHand
 				mmc.setMetaCas(metaTask);
 				break;
 			}
+			retryCount--;
 		}
 
 		return mmc;