Author: cwiklik
Date: Thu Jan 17 18:14:20 2019
New Revision: 1851564

URL: http://svn.apache.org/viewvc?rev=1851564&view=rev
Log:
UIMA-5960 modified to accept zero for a waitTime

Modified:
    
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/ServiceConfiguration.java
    
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/main/PullService.java
    
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/protocol/builtin/DefaultNoTaskAvailableStrategy.java

Modified: 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/ServiceConfiguration.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/ServiceConfiguration.java?rev=1851564&r1=1851563&r2=1851564&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/ServiceConfiguration.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/ServiceConfiguration.java
 Thu Jan 17 18:14:20 2019
@@ -47,7 +47,7 @@ public class ServiceConfiguration {
        private String aeOverrides;
        private String maxErrors;
        private String errorWindowSize;
-       private int waitTimeWhenNoTaskGiven = 0;
+       private int waitTimeWhenNoTaskGiven = 30000;  // unit=ms
        private ClassLoader sysCL=null;
     private String processType;
 

Modified: 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/main/PullService.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/main/PullService.java?rev=1851564&r1=1851563&r2=1851564&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/main/PullService.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/main/PullService.java
 Thu Jan 17 18:14:20 2019
@@ -40,9 +40,11 @@ import org.apache.uima.ducc.ps.service.e
 import org.apache.uima.ducc.ps.service.errors.ServiceInitializationException;
 import org.apache.uima.ducc.ps.service.monitor.IServiceMonitor;
 import org.apache.uima.ducc.ps.service.processor.IServiceProcessor;
+import org.apache.uima.ducc.ps.service.protocol.INoTaskAvailableStrategy;
 import org.apache.uima.ducc.ps.service.protocol.IServiceProtocolHandler;
 import 
org.apache.uima.ducc.ps.service.protocol.builtin.DefaultNoTaskAvailableStrategy;
 import 
org.apache.uima.ducc.ps.service.protocol.builtin.DefaultServiceProtocolHandler;
+import org.apache.uima.ducc.ps.service.protocol.builtin.NoWaitStrategy;
 import org.apache.uima.ducc.ps.service.registry.DefaultRegistryClient;
 import org.apache.uima.ducc.ps.service.registry.IRegistryClient;
 import org.apache.uima.ducc.ps.service.transport.IServiceTransport;
@@ -184,11 +186,13 @@ public class PullService implements ISer
                        // this down just before thread dies.
                        CountDownLatch stopLatch = new CountDownLatch(scaleout);
                        serviceProcessor.setScaleout(scaleout);
+                       INoTaskAvailableStrategy waitStrategy = 
+                                       new 
DefaultNoTaskAvailableStrategy(waitTimeInMillis);
                        // add default protocol handler
                protocolHandler =
                                           new 
DefaultServiceProtocolHandler.Builder()
                                           .withProcessor(serviceProcessor)
-                                          .withNoTaskStrategy(new 
DefaultNoTaskAvailableStrategy(waitTimeInMillis))
+                                          .withNoTaskStrategy(waitStrategy)
                                           .withService(this)
                                           .withTransport(transport)
                                           .withDoneLatch(stopLatch)

Modified: 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/protocol/builtin/DefaultNoTaskAvailableStrategy.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/protocol/builtin/DefaultNoTaskAvailableStrategy.java?rev=1851564&r1=1851563&r2=1851564&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/protocol/builtin/DefaultNoTaskAvailableStrategy.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/protocol/builtin/DefaultNoTaskAvailableStrategy.java
 Thu Jan 17 18:14:20 2019
@@ -23,14 +23,18 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
 
+import org.apache.uima.UIMAFramework;
 import org.apache.uima.ducc.ps.service.protocol.INoTaskAvailableStrategy;
+import org.apache.uima.util.Level;
+import org.apache.uima.util.Logger;
 
 public class DefaultNoTaskAvailableStrategy implements 
INoTaskAvailableStrategy {
        private int waitTime;   
        private final ReentrantLock lock = new ReentrantLock();
-       
-       public DefaultNoTaskAvailableStrategy(int waitTimeInSecs) {
-               this.waitTime = waitTimeInSecs;
+       Logger logger = 
UIMAFramework.getLogger(DefaultNoTaskAvailableStrategy.class);
+       public DefaultNoTaskAvailableStrategy(int waitTimeInMillis) {
+               this.waitTime = waitTimeInMillis;
+               logger.log(Level.INFO, ">>>>>>>> Service Wait Time For 
Task:"+waitTimeInMillis+" ms");
        }
        /**
         * This methods is called when a service is stopping. There is no
@@ -50,7 +54,7 @@ public class DefaultNoTaskAvailableStrat
                        // wait only if wait time > 0. Indefinite wait is not 
supported. If waitTime=0, it means no wait
                        if ( waitTime > 0 ) {
                                try {
-                                       waitAwhileCondition.await(waitTime, 
TimeUnit.SECONDS);
+                                       waitAwhileCondition.await(waitTime, 
TimeUnit.MILLISECONDS);
                                } catch( InterruptedException e) {
                                        
System.out.println("DefaultNoTaskAvailableStrategy.handleNoTaskSupplied() - 
Waiting interrupted "+" Thread:"+Thread.currentThread().getId());
                                }


Reply via email to