You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by bu...@apache.org on 2017/04/25 19:56:31 UTC

svn commit: r1792648 - in /uima/uima-ducc/trunk: uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/ uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/ uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/deploy/uima/ uima-ducc-...

Author: burn
Date: Tue Apr 25 19:56:31 2017
New Revision: 1792648

URL: http://svn.apache.org/viewvc?rev=1792648&view=rev
Log:
UIMA-5404 Put state update port in env as well as sys props

Modified:
    uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java
    uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java
    uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/deploy/uima/UimaAsServiceConfiguration.java
    uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/DuccCommandExecutor.java
    uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccUser.java
    uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/agent/ProcessStateUpdate.java
    uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jp/JobProcessConfiguration.java
    uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/service/ServiceConfiguration.java

Modified: uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java?rev=1792648&r1=1792647&r2=1792648&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java Tue Apr 25 19:56:31 2017
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -95,10 +95,12 @@ import org.apache.uima.ducc.transport.ev
 public class NodeAgent extends AbstractDuccComponent implements Agent, ProcessLifecycleObserver {
   public static DuccLogger logger = DuccLogger.getLogger(NodeAgent.class, COMPONENT_NAME);
 
-  public static final String ProcessStateUpdatePort = "ducc.agent.process.state.update.port";
+  //  Replaced by duplicate in org.apache.uima.ducc.transport.agent.ProcessStateUpdate
+  //public static final String ProcessStateUpdatePort = "ducc.agent.process.state.update.port";
+
   public static int SIGKILL=9;
   public static int SIGTERM=15;
-  
+
   //for LinuxNodeMetrics logging
   public static AtomicLong logCounter = new AtomicLong();
   public static String cgroupFailureReason;
@@ -127,7 +129,7 @@ public class NodeAgent extends AbstractD
   private DuccEventDispatcher commonProcessDispatcher;
 
   private DuccEventDispatcher inventoryDispatcher;
-  
+
   private Object monitor = new Object();
 
   boolean duccLingExists = false;
@@ -143,7 +145,7 @@ public class NodeAgent extends AbstractD
   private volatile boolean stopping = false;
 
   private Object stopLock = new Object();
-  
+
   private RogueProcessReaper rogueProcessReaper = new RogueProcessReaper(logger, 5, 10);
 
   public volatile boolean useCgroups = false;
@@ -157,25 +159,25 @@ public class NodeAgent extends AbstractD
   public int shareQuantum;
 
   private boolean agentVirtual = System.getProperty("ducc.agent.virtual") == null ? false : true;
-  
+
   // This flag, when true, forces the agent to be "real"
   // regardless of the value of ducc.agent.virtual.
   // In the future, this flag and support for ducc.agent.virtual
-  // should be removed altogether.  
+  // should be removed altogether.
   // This is to support CGroups for all agents,
   // which was previously disabled for virtual ones.
   private boolean agentRealOnly = true;
-  
+
   public boolean pageSizeFetched = false;
 
   public int pageSize = 4096; // default
 
   public int cpuClockRate = 100;
-  
+
   public int numProcessors=0;
-  
+
   private AgentEventListener eventListener;
-  
+
   //  indicates whether or not this agent received at least one publication
   //  from the PM. This flag is used to determine if the agent should use
   //  rogue process detector. The detector will be used if this flag is true.
@@ -206,7 +208,7 @@ public class NodeAgent extends AbstractD
   public void setAgentEventListener(AgentEventListener listener) {
 	  eventListener = listener;
   }
-  
+
   public boolean isVirtual() {
 	  boolean retVal = agentVirtual;
 	  if(agentRealOnly) {
@@ -214,10 +216,10 @@ public class NodeAgent extends AbstractD
 	  }
 	  return retVal;
   }
-  
+
   /**
    * C'tor for dependecy injection
-   * 
+   *
    * @param nodeIdentity
    *          - this Agent's identity
    * @param launcher
@@ -230,7 +232,7 @@ public class NodeAgent extends AbstractD
     super(COMPONENT_NAME, context);
 
     Utils.findDuccHome();  // add DUCC_HOME to System.properties
-    
+
     // Running a real agent
     agentVirtual = System.getProperty("ducc.agent.virtual") == null ? false : true;
 
@@ -239,13 +241,13 @@ public class NodeAgent extends AbstractD
     this.configurationFactory = factory;
     this.commonProcessDispatcher = factory.getCommonProcessDispatcher(context);
     this.inventoryDispatcher = factory.getORDispatcher(context);
-    
+
     // fetch Page Size from the OS and cache it
     pageSize = getOSPageSize();
-    
-    
+
+
     numProcessors = getNodeProcessors();
-    
+
     logger.info("NodeAgent", null, "OS Page Size:" + pageSize);
 
     cpuClockRate = getOSClockRate();
@@ -308,14 +310,14 @@ public class NodeAgent extends AbstractD
             }
             // scan /proc/mounts for base cgroup dir
             String cgroupsBaseDir = fetchCgroupsBaseDir("/proc/mounts");
-            
+
             if ( cgUtilsPath == null ) {
             	useCgroups = false;
                 logger.info("nodeAgent", null, "------- CGroups Disabled - Unable to Find Cgroups Utils Directory. Add/Modify ducc.agent.launcher.cgroups.utils.dir property in ducc.properties");
             } else if ( cgroupsBaseDir == null || cgroupsBaseDir.trim().length() == 0) {
             	useCgroups = false;
                 logger.info("nodeAgent", null, "------- CGroups Disabled - Unable to Find Cgroups Root Directory in /proc/mounts");
-            	
+
             } else {
             	logger.info("nodeAgent",null,"Agent found cgroups runtime in "+cgUtilsPath+" cgroups base dir="+cgroupsBaseDir);
             	// if cpuacct is configured in cgroups, the subsystems list will be updated
@@ -338,8 +340,8 @@ public class NodeAgent extends AbstractD
                   try {
                 	  String containerId = "test";
                 	  // validate cgroups by creating a dummy cgroup. The code checks if cgroup actually got created by
-                	  // verifying existence of test cgroup file. The second step in verification is to check if 
-                	  // CPU control is working. Configured in cgconfig.conf, the CPU control allows for setting 
+                	  // verifying existence of test cgroup file. The second step in verification is to check if
+                	  // CPU control is working. Configured in cgconfig.conf, the CPU control allows for setting
                 	  // cpu.shares. The code will attempt to set the shares and subsequently tries to read the
                 	  // value from cpu.shares file to make sure the values match. Any exception in the above steps
                 	  // will cause cgroups to be disabled.
@@ -347,7 +349,7 @@ public class NodeAgent extends AbstractD
                 	  cgroupsManager.validator(cgroupsBaseDir, containerId, System.getProperty("user.name"),false)
                 	              .cgcreate()
                 	              .cgset(100);   // write cpu.shares=100 and validate
-                	  
+
                 	  // cleanup dummy cgroup
                 	  cgroupsManager.destroyContainer(containerId, System.getProperty("user.name"), SIGKILL);
                 	  useCgroups = true;
@@ -383,7 +385,7 @@ public class NodeAgent extends AbstractD
       logger.info("nodeAgent", null, "------- CGroups Not Enabled on this Machine");
       cgroupFailureReason = "------- CGroups Not Enabled on this Machine - check ducc.properties: ducc.agent.launcher.cgroups.enable ";
     }
-    
+
     // begin publishing node metrics
     factory.startNodeMetrics(this);
 
@@ -407,7 +409,7 @@ public class NodeAgent extends AbstractD
 
     }
   }
-  
+
   private String fetchCgroupsBaseDir(String mounts) {
 	  String cbaseDir=null;
 	  BufferedReader br = null;
@@ -415,11 +417,11 @@ public class NodeAgent extends AbstractD
 		  FileInputStream fis = new FileInputStream(mounts);
 			//Construct BufferedReader from InputStreamReader
 		  br = new BufferedReader(new InputStreamReader(fis));
-		 
+
 		String line = null;
 		while ((line = br.readLine()) != null) {
 			System.out.println(line);
-			if ( line.trim().startsWith("cgroup") ) { 
+			if ( line.trim().startsWith("cgroup") ) {
 				String[] cgroupsInfo = line.split(" ");
 				if ( cgroupsInfo[1].trim().equals("/cgroup") ) {
 					cbaseDir = cgroupsInfo[1].trim();
@@ -428,10 +430,10 @@ public class NodeAgent extends AbstractD
 					// return the mount point minus the memory part
 					cbaseDir = cgroupsInfo[1].substring(0, cgroupsInfo[1].indexOf("/memory") );
 					break;
-				} 
+				}
 			}
 		}  // while
-		 
+
 	  } catch( Exception e) {
 	        logger.info("nodeAgent", null,
 	                "------- Agent failed while checking for existence of ducc_ling", e);
@@ -570,7 +572,7 @@ public class NodeAgent extends AbstractD
       if (commandLine != null) {
           if (commandLine.getExecutable() != null && commandLine.getExecutable().length() > 0) return false;
           if (commandLine.getCommandLine() != null && commandLine.getCommandLine().length > 0) return false;
-      } 
+      }
       return true;
   }
 
@@ -580,7 +582,7 @@ public class NodeAgent extends AbstractD
 
   /**
    * Stops any process that is in agent's inventory but not in provided job list sent by the PM.
-   * 
+   *
    * @param lifecycleController
    *          - instance implementing stopProcess() method
    * @param jobDeploymentList
@@ -659,7 +661,7 @@ public class NodeAgent extends AbstractD
 
   /**
    * Reconciles agent inventory with job processes sent by PM
-   * 
+   *
    * @param lifecycleController
    *          - instance implementing stopProcess and startProcess
    * @param process
@@ -779,7 +781,7 @@ public class NodeAgent extends AbstractD
 	  long overLimit = 0;
 	 for (ManagedProcess deployedProcess : deployedProcesses) {
 	   if ( deployedProcess.getDuccProcess().getDuccId().equals(process.getDuccId()) ) {
-	   	  overLimit = deployedProcess.getMaxSwapThreshold() - process.getSwapUsage(); 
+	   	  overLimit = deployedProcess.getMaxSwapThreshold() - process.getSwapUsage();
 	   }
 	 }
 	 if ( overLimit < 0 ) {
@@ -799,9 +801,9 @@ public class NodeAgent extends AbstractD
       inventorySemaphore.acquire();
       // find the fattest process in terms of absolute use of swap over the process limit
       for (Entry<DuccId, IDuccProcess> processEntry : getInventoryRef().entrySet()) {
-        if (isProcessRunning(processEntry.getValue()) 
+        if (isProcessRunning(processEntry.getValue())
         		&& isOverSwapLimit(processEntry.getValue())
-                && (biggestProcess == null  
+                && (biggestProcess == null
                 || getSwapOverLimit(biggestProcess) < getSwapOverLimit(processEntry.getValue()))) {
           biggestProcess = processEntry.getValue();
         }
@@ -838,12 +840,12 @@ public class NodeAgent extends AbstractD
 	}
   /**
    * Called when Agent receives request to start a process.
-   * 
+   *
    * @param process
    *          - IDuccProcess instance with identity (DuccId)
    * @param commandLine
    *          - fully defined command line that will be used to exec the process.
-   * 
+   *
    */
   public void startProcess(IDuccProcess process, ICommandLine commandLine, IDuccStandardInfo info,
           DuccId workDuccId, ProcessMemoryAssignment processMemoryAssignment) {
@@ -895,10 +897,10 @@ public class NodeAgent extends AbstractD
 
   /**
    * Called when Agent receives request to stop a process.
-   * 
+   *
    * @param process
    *          - IDuccProcess instance with identity (DuccId)
-   * 
+   *
    */
   public void stopProcess(IDuccProcess process) {
     String methodName = "stopProcess";
@@ -944,7 +946,7 @@ public class NodeAgent extends AbstractD
    * Checks if process with a given PID has already registered memory collector Camel route. This
    * route periodically fetches resident memory of a process with a given PID. Each process
    * collector route is identified by process PID.
-   * 
+   *
    * @param pid
    *          - process PID also id of its route
    * @return - true if memory collector route has already been created. False, otherwise
@@ -961,7 +963,7 @@ public class NodeAgent extends AbstractD
 
   /**
    * Remove given process from Agent's inventory
-   * 
+   *
    * @param process
    *          - process to purge from inventory
    * @throws Exception
@@ -1017,7 +1019,7 @@ public class NodeAgent extends AbstractD
 
   /**
    * Called when UIMA AS service wrapper sends an update when a process status changes.
-   * 
+   *
    * @param duccEvent
    *          - Ducc event object
    *
@@ -1045,10 +1047,10 @@ public class NodeAgent extends AbstractD
           ITimeWindow tw = processEntry.getValue().getTimeWindowInit();
           if (tw.getEnd() == null ) {
         	if ( !duccEvent.getState().equals(ProcessState.Initializing)) {
-        		// Mark the time the process ended initialization. It also 
+        		// Mark the time the process ended initialization. It also
         		// covers a case when the process terminates while initializing
           	    tw.setEnd(TimeStamp.getCurrentMillis());
-            
+
             	if ( duccEvent.getState().equals(ProcessState.Running)) {
         		    ITimeWindow twr = new TimeWindow();
         		    String millis;
@@ -1109,7 +1111,7 @@ public class NodeAgent extends AbstractD
                     + processEntry.getValue().getDuccId()
                     + " Was Previously Tagged for Kill While It Was Starting");
             undeployProcess(processEntry.getValue());
-          } else if ( deployedProcess != null && deployedProcess.doKill() && 
+          } else if ( deployedProcess != null && deployedProcess.doKill() &&
         		  deployedProcess.getDuccProcess().getProcessState().equals(ProcessState.Stopped) ) {
         	  deployedProcess.getDuccProcess().setReasonForStoppingProcess(ReasonForStoppingProcess.KilledByDucc.toString());
           } else if ( deployedProcess != null && ( deployedProcess.doKill()
@@ -1132,7 +1134,7 @@ public class NodeAgent extends AbstractD
                   && (duccEvent.getState().equals(ProcessState.Initializing) || duccEvent
                           .getState().equals(ProcessState.Running))) {
             if ( duccEvent.getState().equals(ProcessState.Running) ) {
-               if ( processEntry.getValue().getUimaPipelineComponents() != null && 
+               if ( processEntry.getValue().getUimaPipelineComponents() != null &&
             		processEntry.getValue().getUimaPipelineComponents().size() > 0 ) {
             	   processEntry.getValue().getUimaPipelineComponents().clear();
             	   if ( duccEvent.getUimaPipeline() != null ) {
@@ -1154,7 +1156,7 @@ public class NodeAgent extends AbstractD
 
             StringBuffer sb = new StringBuffer();
             if ( duccEvent.getState().equals(ProcessState.Running) ) {
-               if ( processEntry.getValue().getUimaPipelineComponents() != null && 
+               if ( processEntry.getValue().getUimaPipelineComponents() != null &&
             		processEntry.getValue().getUimaPipelineComponents().size() > 0 ) {
             	   processEntry.getValue().getUimaPipelineComponents().clear();
             	   if ( duccEvent.getUimaPipeline() != null ) {
@@ -1169,7 +1171,7 @@ public class NodeAgent extends AbstractD
                     methodName,
                     null,
                     sb.toString());
-            
+
             logger.info(
                     methodName,
                     null,
@@ -1187,7 +1189,7 @@ public class NodeAgent extends AbstractD
             	}
 
 //            super.getContext().stopRoute(duccEvent.getPid());
-            
+
             // remove route from context, otherwise the routes accumulate over time causing memory leak
             super.getContext().removeRoute(duccEvent.getPid());
             StringBuffer sb = new StringBuffer();
@@ -1195,7 +1197,7 @@ public class NodeAgent extends AbstractD
                     methodName,
                     null,
                     "Removed Camel Route from Context for PID:"+duccEvent.getPid());
-            
+
             for ( Route route : super.getContext().getRoutes() ) {
             	sb.append("Camel Context - RouteId:"+route.getId()+"\n");
             }
@@ -1203,8 +1205,8 @@ public class NodeAgent extends AbstractD
                     methodName,
                     null,
                     sb.toString());
-            
-            
+
+
             if ( deployedProcess.getMetricsProcessor() != null ) {
             	deployedProcess.getMetricsProcessor().close();  // close open fds (stat and statm files)
             }
@@ -1239,20 +1241,20 @@ public class NodeAgent extends AbstractD
             //deployedProcess.setStopping();
 
             // Mark process for death. Doesnt actually kill the process
-            
+
             deployedProcess.kill();
             logger.info(methodName, null, ">>>> Agent Handling Process InitializationTimeout. PID:"
                     + duccEvent.getPid() + " Killing Process");
-          
+
             undeployProcess(processEntry.getValue());
-            
-          } 
-          else if (duccEvent.getState().equals(ProcessState.Stopping)) { 
+
+          }
+          else if (duccEvent.getState().equals(ProcessState.Stopping)) {
         	  if ( duccEvent.getMessage() != null && duccEvent.getMessage().equals(ReasonForStoppingProcess.ExceededErrorThreshold.toString())) {
                   processEntry.getValue().
             	    setReasonForStoppingProcess(ReasonForStoppingProcess.ExceededErrorThreshold.toString());
         	  }
-              if ( !deployedProcess.getDuccProcess().getProcessState().equals(ProcessState.Stopped) && 
+              if ( !deployedProcess.getDuccProcess().getProcessState().equals(ProcessState.Stopped) &&
             	   !deployedProcess.getDuccProcess().getProcessState().equals(ProcessState.Stopping) )  {
             	  deployedProcess.getDuccProcess().setProcessState(ProcessState.Stopping);
                   deployedProcess.setStopping();
@@ -1281,7 +1283,7 @@ public class NodeAgent extends AbstractD
 
   /**
    * Deploys process using supplied command line
-   * 
+   *
    * @param process
    *          - Process with identity (DuccId)
    * @param commandLine
@@ -1335,9 +1337,9 @@ public class NodeAgent extends AbstractD
 
   class AgentStreamConsumer implements Runnable {
 	  private InputStream theStream;
-	  
+
 	  AgentStreamConsumer(InputStream is) {
-		theStream = is;  
+		theStream = is;
 	  }
   	public void run() {
   	  String methodName = "AgentStreamConsumer.run";
@@ -1354,7 +1356,7 @@ public class NodeAgent extends AbstractD
         }
         catch (Throwable t)
         {
-    		logger.warn(methodName, null, t);  
+    		logger.warn(methodName, null, t);
           t.printStackTrace();
         }
         finally
@@ -1365,11 +1367,11 @@ public class NodeAgent extends AbstractD
           } catch( Exception e) {}
         }
 	}
-}	  
+}
   enum SIGNAL {
 	SIGTERM("-15"),
     SIGKILL("-9");
-    
+
 	String signal="";
 	SIGNAL(String kind) {
 		  signal = kind;
@@ -1380,7 +1382,7 @@ public class NodeAgent extends AbstractD
   };
   class ProcessRunner implements Runnable {
 	  ManagedProcess deployedProcess;
-	  
+
 	  public ProcessRunner(final ManagedProcess deployedProcess) {//final String pid, SIGNAL signal ) {
 		  this.deployedProcess = deployedProcess;
 	  }
@@ -1388,16 +1390,16 @@ public class NodeAgent extends AbstractD
 		  stopProcess(deployedProcess.getDuccProcess());
  	  }
   }
-  
+
   private boolean runnable(ManagedProcess process) {
 	  return ( process.getDuccProcess().getProcessState().equals(ProcessState.Initializing) ||
 			   process.getDuccProcess().getProcessState().equals(ProcessState.Starting) ||
 			   process.getDuccProcess().getProcessState().equals(ProcessState.Running) );
   }
-  
+
   /**
    * This method is called when an agent receives a STOP request. It
-   * sends SIGTERM to all child processes and starts a timer. If the 
+   * sends SIGTERM to all child processes and starts a timer. If the
    * timer pops and child processes are still running, the agent takes
    * itself out via halt()
    */
@@ -1418,22 +1420,22 @@ public class NodeAgent extends AbstractD
             ExecutorService executor = Executors.newSingleThreadExecutor();
             executor.execute( new ProcessRunner(deployedProcess) ); //pid,SIGNAL.SIGTERM));
 	      }
-	      
+
 	  } catch( Exception e) {
-		logger.warn(methodName, null, e);  
+		logger.warn(methodName, null, e);
 	  }
 	  return wait;
   }
-      
+
       private void killChildProcesses() {
     	  String methodName = "killChildProcesses";
-    	  
+
 
     	  try {
       	    if ( useCgroups ) {
     	        logger.info("stop", null, "CgroupsManager.cleanup() before ");
     	        // Since SIGTERM may not be enough to take down a process, use cgroups to find
-    	        // any process still standing and do hard kill 
+    	        // any process still standing and do hard kill
     	        cgroupsManager.cleanup();
     	        logger.info("stop", null, "CgroupsManager.cleanup() after ");
     	    } else {
@@ -1456,19 +1458,19 @@ public class NodeAgent extends AbstractD
 
       	        deployedProcess.setStopping();
       			deployedProcess.setStopPriority(StopPriority.DONT_WAIT);
-      			
+
                   launcher.launchProcess(this, getIdentity(),deployedProcess.getDuccProcess(), cmdLine, this, deployedProcess);
       	      }
 
     	    }
     	  } catch( Exception e) {
-    		logger.warn(methodName, null, e);  
+    		logger.warn(methodName, null, e);
     	  }
-    	          	  
+
       }
   /**
    * Kills a given process
-   * 
+   *
    * @param process
    *          - process to kill
    */
@@ -1585,7 +1587,7 @@ public class NodeAgent extends AbstractD
                   methodName,
                   null,
                   "Removed Camel Route from Context for PID:"+process.getPID());
-          
+
           for ( Route route : super.getContext().getRoutes() ) {
           	sb.append("Camel Context - RouteId:"+route.getId()+"\n");
           }
@@ -1711,7 +1713,7 @@ public class NodeAgent extends AbstractD
           NodeUsersCollector.ProcessInfo cpi) throws Exception {
 
     synchronized (monitor) {
-    	// if cgroups are enabled, check if a given PID (cpi) exists in any of 
+    	// if cgroups are enabled, check if a given PID (cpi) exists in any of
     	// the containers. If so, the process is not rogue.
     	if ( useCgroups ) {
     		if ( cgroupsManager.isPidInCGroup(String.valueOf(cpi.getPid())) ) {
@@ -1750,8 +1752,8 @@ public class NodeAgent extends AbstractD
       if (foundDeployedProcessWithNoPID) {
         return false;
       } else if ( cpi.getPPid() == 1 ) {   // Any process owned by init is rogue
-    	  // interrupt agent's thread blocking in waitFor() awaiting process termination. 
-    	  // This process is a zombie and there is no need to waste the thread. 
+    	  // interrupt agent's thread blocking in waitFor() awaiting process termination.
+    	  // This process is a zombie and there is no need to waste the thread.
     	  interruptThreadInWaitFor(String.valueOf(cpi.getPid()));
     	  return true;
       }  else {
@@ -1791,7 +1793,7 @@ public class NodeAgent extends AbstractD
   /**
    * Process resident memory collector routes. Collects resident memory at fixed interval from the
    * OS.
-   * 
+   *
    */
   public class ProcessMemoryUsageRoute extends RouteBuilder {
     private NodeAgent agent;
@@ -1823,27 +1825,27 @@ public class NodeAgent extends AbstractD
 	        return;
         }
 		stopping = true;
-		
-	    // Send an empty process map as the final inventory 
-	    HashMap<DuccId, IDuccProcess> emptyMap = 
+
+	    // Send an empty process map as the final inventory
+	    HashMap<DuccId, IDuccProcess> emptyMap =
 	    		new HashMap<DuccId, IDuccProcess>();
 	    DuccEvent duccEvent = new NodeInventoryUpdateDuccEvent(emptyMap,getLastORSequence(), getIdentity());
 	    inventoryDispatcher.dispatch(duccEvent);
 	    logger.info("stop", null, "Agent published final inventory");
-	    
+
 	    configurationFactory.stopRoutes();
-	    
+
 	    logger.info("stop", null, "Agent stopping managed processes");
 	    // Dispatch SIGTERM to all child processes
 	    boolean wait = stopChildProcesses();
-	    
+
 	    // Stop publishing inventory. Once the route is down the agent forces last publication
 	    // sending an empty process map.
 	    //configurationFactory.stopInventoryRoute();
 
 	    if ( wait && deployedProcesses.size() > 0 ) {
 	        logger.info("stop", null, "Agent Sent SIGTERM to ALL Child Processes - Number of Deployed Processes:"+deployedProcesses.size());
-	    	// wait for awhile 
+	    	// wait for awhile
 	      synchronized (this) {
 	    	  long waittime = 60000;
 	    	  if (configurationFactory.processStopTimeout != null ) {
@@ -1881,7 +1883,7 @@ public class NodeAgent extends AbstractD
 	    super.stop();
 	    logger.info("stop", null, "Reaper thread finished - calling super.stop()");
 	  }
-*/	
+*/
 	    stopLock.wait(2000);
 	    super.stop();
 	    logger.info("stop", null, "Reaper thread finished - calling super.stop()");
@@ -1900,7 +1902,7 @@ public class NodeAgent extends AbstractD
 
   /**
    * Copies reservations sent by the PM. It copies reservations associated with this node.
-   * 
+   *
    * @param reserves
    *          - list of ALL reservations
    * @throws Exception
@@ -2143,7 +2145,7 @@ public class NodeAgent extends AbstractD
   }
 
   public DuccLogger getLogger() {
-    return logger; 
+    return logger;
   }
 
   public void handleAdminEvent(DuccAdminEvent event) throws Exception {

Modified: uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java?rev=1792648&r1=1792647&r2=1792648&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java Tue Apr 25 19:56:31 2017
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -53,6 +53,7 @@ import org.apache.uima.ducc.common.utils
 import org.apache.uima.ducc.transport.DuccExchange;
 import org.apache.uima.ducc.transport.DuccTransportConfiguration;
 import org.apache.uima.ducc.transport.agent.NodeMetricsConfiguration;
+import org.apache.uima.ducc.transport.agent.ProcessStateUpdate;
 import org.apache.uima.ducc.transport.dispatcher.DuccEventDispatcher;
 import org.apache.uima.ducc.transport.event.common.IDuccProcess;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -83,14 +84,14 @@ public class AgentConfiguration {
   private CamelContext camelContext;
 
   private RouteBuilder metricsRouteBuilder;
-  
+
   private RouteBuilder inventoryRouteBuilder;
 
   /* Deprecated
   @Value("#{ systemProperties['ducc.agent.launcher.thread.pool.size'] }")
   String launcherThreadPoolSize;
    */
-  
+
   @Value("#{ systemProperties['ducc.agent.launcher.process.stop.timeout'] }")
   public String processStopTimeout;
 
@@ -117,7 +118,7 @@ public class AgentConfiguration {
   @Value("#{ systemProperties['ducc.agent.launcher.cgroups.retry.delay.factor'] }")
   public String retryDelayFactor;
 
-  
+
   @Autowired
   DuccTransportConfiguration agentTransport;
 
@@ -129,10 +130,10 @@ public class AgentConfiguration {
 
   /**
    * Creates {@code AgentEventListener} that will handle incoming messages.
-   * 
+   *
    * @param agent
    *          - {@code NodeAgent} instance to initialize the listener
-   * 
+   *
    * @return {@code AgentEventListener} instance
    */
   public AgentEventListener agentDelegateListener(NodeAgent agent) {
@@ -141,13 +142,13 @@ public class AgentConfiguration {
 
   /**
    * Creates Camel Router to generate Node Metrics at regular intervals.
-   * 
+   *
    * @param targetEndpointToReceiveNodeMetricsUpdate
    *          - where to post NodeMetrics
    * @param nodeMetricsPublishRate
    *          - how to publish NodeMetrics
    * @return - {@code RouteBuilder} instance
-   * 
+   *
    * @throws Exception
    */
   private RouteBuilder routeBuilderForNodeMetricsPost(final NodeAgent agent,
@@ -173,13 +174,13 @@ public class AgentConfiguration {
 
   /**
    * Creates Camel Router to generate Node Metrics at regular intervals.
-   * 
+   *
    * @param targetEndpointToReceiveNodeMetricsUpdate
    *          - where to post NodeMetrics
    * @param nodeMetricsPublishRate
    *          - how to publish NodeMetrics
    * @return - {@code RouteBuilder} instance
-   * 
+   *
    * @throws Exception
    */
   private RouteBuilder routeBuilderForNodeInventoryPost(final NodeAgent agent,
@@ -193,7 +194,7 @@ public class AgentConfiguration {
         final Predicate blastGuard = new DuccBlastGuardPredicate(agent.getLogger());
         onException(Exception.class).maximumRedeliveries(0).handled(true)
                 .process(new ErrorProcessor());
-        
+
         from("timer:nodeInventoryTimer?fixedRate=true&period=" + nodeInventoryPublishRate)
                 .routeId("NodeInventoryPostRoute")
                 // This route uses a filter to prevent sudden bursts of messages which
@@ -214,10 +215,10 @@ public class AgentConfiguration {
 
   /**
    * Creates Camel Router to handle incoming messages
-   * 
+   *
    * @param delegate
    *          - {@code AgentEventListener} to delegate messages to
-   * 
+   *
    * @return {@code RouteBuilder} instance
    */
   public synchronized RouteBuilder routeBuilderForIncomingRequests(final NodeAgent agent,
@@ -236,10 +237,10 @@ public class AgentConfiguration {
 
   /**
    * Creates Camel Router to handle incoming messages
-   * 
+   *
    * @param delegate
    *          - {@code AgentEventListener} to delegate messages to
-   * 
+   *
    * @return {@code RouteBuilder} instance
    */
   public synchronized RouteBuilder routeBuilderForManagedProcessStateUpdate(final NodeAgent agent,
@@ -423,7 +424,7 @@ public class AgentConfiguration {
       AgentEventListener delegateListener = agentDelegateListener(agent);
 
       agent.setAgentEventListener(delegateListener);
-      
+
       if (common.managedProcessStateUpdateEndpointType != null
               && common.managedProcessStateUpdateEndpointType.equalsIgnoreCase("socket")) {
         String agentSocketParams = "";
@@ -434,24 +435,24 @@ public class AgentConfiguration {
         common.managedProcessStateUpdateEndpoint = "mina:tcp://localhost:" + agentPort
                 + agentSocketParams;
         // Remember the agent port since we need to tell JPs where to send their state updates
-        System.setProperty(NodeAgent.ProcessStateUpdatePort, String.valueOf(agentPort));
+        System.setProperty(ProcessStateUpdate.ProcessStateUpdatePort, String.valueOf(agentPort));
       }
       camelContext
               .addRoutes(this.routeBuilderForManagedProcessStateUpdate(agent, delegateListener));
       camelContext.addRoutes(this.routeBuilderForIncomingRequests(agent, delegateListener));
-      
-      inventoryRouteBuilder = 
+
+      inventoryRouteBuilder =
     		  (this.routeBuilderForNodeInventoryPost(agent,
     	              common.nodeInventoryEndpoint, Integer.parseInt(common.nodeInventoryPublishRate)));
-      
+
       camelContext.addRoutes(inventoryRouteBuilder);
 /*
       metricsRouteBuilder = this.routeBuilderForNodeMetricsPost(agent, common.nodeMetricsEndpoint,
               Integer.parseInt(common.nodeMetricsPublishRate));
       camelContext.addRoutes(metricsRouteBuilder);
-*/      
-      
-      
+*/
+
+
       logger.info("nodeAgent", null, "------- Agent Initialized - Identity Name:"
               + agent.getIdentity().getName() + " IP:" + agent.getIdentity().getIp()
               + " JP State Update Endpoint:" + common.managedProcessStateUpdateEndpoint);
@@ -464,17 +465,17 @@ public class AgentConfiguration {
   }
 
   public void startNodeMetrics(NodeAgent agent) throws Exception {
-	  
+
   	  nodeMetricsProcessor.setAgent(agent);
 	  metricsRouteBuilder = this.routeBuilderForNodeMetricsPost(agent, common.nodeMetricsEndpoint,
               Integer.parseInt(common.nodeMetricsPublishRate));
       camelContext.addRoutes(metricsRouteBuilder);
-  
+
   }
   public void stopRoutes() throws Exception {
 	  camelContext.stop();
 	  logger.info("AgentConfigureation.stopRoutes", null,"Camel Context stopped");
-	  
+
   }
   @Bean
   @PostConstruct
@@ -506,7 +507,7 @@ public class AgentConfiguration {
   public void stopInventoryRoute() {
 	    stopRoute(inventoryRouteBuilder.getRouteCollection(),">>>> Agent Stopped Publishing Inventory");
   }
-  
+
   public void stopMetricsRoute() {
     stopRoute(metricsRouteBuilder.getRouteCollection(),">>>> Agent Stopped Publishing Metrics");
 //    try {
@@ -528,7 +529,7 @@ public class AgentConfiguration {
 	      for (RouteDefinition rd : rsd.getRoutes()) {
 	        camelContext.stopRoute(rd.getId());
 	        camelContext.removeRoute(rd.getId());
-	        logger.info(methodName, null, logMsg); 
+	        logger.info(methodName, null, logMsg);
 	      }
 
 	    } catch (Exception e) {

Modified: uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/deploy/uima/UimaAsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/deploy/uima/UimaAsServiceConfiguration.java?rev=1792648&r1=1792647&r2=1792648&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/deploy/uima/UimaAsServiceConfiguration.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/deploy/uima/UimaAsServiceConfiguration.java Tue Apr 25 19:56:31 2017
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -35,6 +35,7 @@ import org.apache.uima.ducc.common.confi
 import org.apache.uima.ducc.common.utils.Utils;
 import org.apache.uima.ducc.transport.DuccExchange;
 import org.apache.uima.ducc.transport.DuccTransportConfiguration;
+import org.apache.uima.ducc.transport.agent.ProcessStateUpdate;
 import org.apache.uima.ducc.transport.dispatcher.DuccEventDispatcher;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -51,25 +52,25 @@ public class UimaAsServiceConfiguration
 	DuccTransportConfiguration transport;
 	@Autowired
 	CommonConfiguration common;
-	
+
 	RouteBuilder routeBuilder;
 	CamelContext camelContext;
-	
+
 	@Value("#{ systemProperties['ducc.uima-as.swap.usage.script'] }")
 	String swapUsageCollectorScript;
-	
+
 	/**
-	 * Creates Camel Router to handle incoming messages 
-	 * 
+	 * Creates Camel Router to handle incoming messages
+	 *
 	 * @param delegate - {@code AgentEventListener} to delegate messages to
-	 * 
+	 *
 	 * @return {@code RouteBuilder} instance
 	 */
-	public synchronized RouteBuilder routeBuilderForIncomingRequests(final String thisNodeIP, 
+	public synchronized RouteBuilder routeBuilderForIncomingRequests(final String thisNodeIP,
 			final ProcessEventListener delegate) {
 		return new RouteBuilder() {
 		  //	Custom filter to select messages that are targeted for this process
-			//  Checks the PID in a message to determine if this process is 
+			//  Checks the PID in a message to determine if this process is
 			//  the target.
 			Predicate filter = new DuccProcessFilter(thisNodeIP);
 			public void configure() throws Exception {
@@ -77,12 +78,12 @@ public class UimaAsServiceConfiguration
          onException(Exception.class).handled(true).process(new ErrorProcessor()).end();
 
 			  from(common.managedServiceEndpoint)
-			 
+
 				.choice().when(filter)
 						.bean(delegate)
 				.end()
 				.setId(common.managedServiceEndpoint);
-	
+
 			}
 		};
 	}
@@ -115,9 +116,9 @@ public class UimaAsServiceConfiguration
 		try {
 			//	Assume IP address provided from environment. In production this
 			//  will be the actual node IP. In testing, the IP can be virtual
-			//  when running multiple agents on the same node. The agent is 
+			//  when running multiple agents on the same node. The agent is
 			//  responsible for providing the IP in this process environment.
-			String thisNodeIP = 
+			String thisNodeIP =
 			(System.getenv(IDuccUser.EnvironmentVariable.DUCC_IP.value()) == null) ? InetAddress.getLocalHost().getHostAddress() : System.getenv(IDuccUser.EnvironmentVariable.DUCC_IP.value());
 	    camelContext = common.camelContext();
 	    int serviceSocketPort = 0;
@@ -126,34 +127,37 @@ public class UimaAsServiceConfiguration
 	    if ( common.managedServiceEndpointParams != null ) {
 	      jpSocketParams = "?"+common.managedServiceEndpointParams;
 	    }
-	    
+
 	    if ( common.managedProcessStateUpdateEndpointParams != null ) {
 	      agentSocketParams = "?"+common.managedProcessStateUpdateEndpointParams;
       }
       // set up agent socket endpoint where this UIMA AS service will send state updates
 	    if ( common.managedProcessStateUpdateEndpointType != null && common.managedProcessStateUpdateEndpointType.equalsIgnoreCase("socket") ) {
-	      common.managedProcessStateUpdateEndpoint = 
-	              "mina:tcp://localhost:"+System.getProperty(NodeAgent.ProcessStateUpdatePort)+agentSocketParams;
+	      String updatePort = System.getProperty(ProcessStateUpdate.ProcessStateUpdatePort);
+	      if (updatePort == null) {
+	        updatePort = System.getenv(IDuccUser.EnvironmentVariable.DUCC_UPDATE_PORT.value());
+	      }
+	      common.managedProcessStateUpdateEndpoint = "mina:tcp://localhost:" + updatePort + agentSocketParams;
 	    }
 	    // set up a socket endpoint where the UIMA AS service will receive events sent from its agent
 	    if ( common.managedServiceEndpointType != null && common.managedServiceEndpointType.equalsIgnoreCase("socket")) {
         serviceSocketPort = Utils.findFreePort();
         // service is on the same node as the agent
-        common.managedServiceEndpoint = 
+        common.managedServiceEndpoint =
                 "mina:tcp://localhost:"+serviceSocketPort+jpSocketParams;
 	    }
-	    
-	    //	optionally configures Camel Context for JMS. Checks the 'agentRequestEndpoint' to 
-			//  to determine type of transport. If the the endpoint starts with "activemq:", a 
+
+	    //	optionally configures Camel Context for JMS. Checks the 'agentRequestEndpoint' to
+			//  to determine type of transport. If the the endpoint starts with "activemq:", a
 			//  special ActiveMQ component will be activated to enable JMS transport
-			
+
 	    DuccEventDispatcher eventDispatcher =
 				transport.duccEventDispatcher(common.managedProcessStateUpdateEndpoint, camelContext);
-			
-	    
-			ManagedUimaService service = 
+
+
+			ManagedUimaService service =
 	        	new ManagedUimaService(common.saxonJarPath,
-	        			common.dd2SpringXslPath, 
+	        			common.dd2SpringXslPath,
 	        			serviceAdapter(eventDispatcher,common.managedServiceEndpoint), camelContext);
 	    service.setConfigFactory(this);
 	    service.setAgentStateUpdateEndpoint(common.managedProcessStateUpdateEndpoint);
@@ -162,14 +166,14 @@ public class UimaAsServiceConfiguration
 	     System.out.println("## Agent Service State Update Endpoint:"+common.managedProcessStateUpdateEndpoint+" ##");
 	     System.out.println("#######################################################");
 
-	    
+
 			ProcessEventListener delegateListener = processDelegateListener(service);
 			delegateListener.setDuccEventDispatcher(eventDispatcher);
 			routeBuilder = this.routeBuilderForIncomingRequests(thisNodeIP, delegateListener);
 			camelContext.addRoutes(routeBuilder);
-		
+
 			return service;
-			
+
 		} catch( Exception e) {
 			e.printStackTrace();
 			throw e;
@@ -187,7 +191,7 @@ public class UimaAsServiceConfiguration
 	}
 	private class DuccProcessFilter implements Predicate {
 		String thisNodeIP;
-		public DuccProcessFilter(final String thisNodeIP) { 
+		public DuccProcessFilter(final String thisNodeIP) {
 			this.thisNodeIP = thisNodeIP;
 		}
 		public synchronized boolean matches(Exchange exchange) {

Modified: uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/DuccCommandExecutor.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/DuccCommandExecutor.java?rev=1792648&r1=1792647&r2=1792648&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/DuccCommandExecutor.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/DuccCommandExecutor.java Tue Apr 25 19:56:31 2017
@@ -38,6 +38,7 @@ import org.apache.uima.ducc.common.utils
 import org.apache.uima.ducc.common.utils.TimeStamp;
 import org.apache.uima.ducc.common.utils.Utils;
 import org.apache.uima.ducc.common.utils.id.DuccId;
+import org.apache.uima.ducc.transport.agent.ProcessStateUpdate;
 import org.apache.uima.ducc.transport.cmdline.ACommandLine;
 import org.apache.uima.ducc.transport.cmdline.ICommandLine;
 import org.apache.uima.ducc.transport.cmdline.JavaCommandLine;
@@ -780,8 +781,8 @@ public class DuccCommandExecutor extends
           if (System.getProperties().containsKey("ducc.agent.managed.process.state.update.endpoint.type")) {
             String type = System.getProperty("ducc.agent.managed.process.state.update.endpoint.type");
             if (type != null && type.equalsIgnoreCase("socket")) {
-              cmdLine.addOption("-D" + NodeAgent.ProcessStateUpdatePort + "="
-                      + System.getProperty(NodeAgent.ProcessStateUpdatePort));
+              cmdLine.addOption("-D" + ProcessStateUpdate.ProcessStateUpdatePort + "="
+                      + System.getProperty(ProcessStateUpdate.ProcessStateUpdatePort));
             }
           }
 					// NOTE - These are redundant since the information is also
@@ -801,11 +802,13 @@ public class DuccCommandExecutor extends
 				}
 				// add JobId and the log prefix to the env so additional
 				// similarly-named log files can be created
+				// Also put the state update port in the environment for custom services
 				processEnv.put(IDuccUser.EnvironmentVariable.DUCC_ID_JOB.value(), String
 						.valueOf(((ManagedProcess) super.managedProcess)
 								.getWorkDuccId().getFriendly()));
 				processEnv.put(IDuccUser.EnvironmentVariable.DUCC_LOG_PREFIX.value(), processLogDir
 						+ processLogFile);
+				processEnv.put(IDuccUser.EnvironmentVariable.DUCC_UPDATE_PORT.value(), System.getProperty(ProcessStateUpdate.ProcessStateUpdatePort));
 			}
 
 			// Replace the reserved DUCC variable with the architecture of this node (ppc64 or amd64 or ...)

Modified: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccUser.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccUser.java?rev=1792648&r1=1792647&r2=1792648&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccUser.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/IDuccUser.java Tue Apr 25 19:56:31 2017
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -21,13 +21,14 @@ package org.apache.uima.ducc.common;
 // Note: Coordinate with org.apache.uima.ducc.IUser
 
 public interface IDuccUser {
-	
+
 	public enum EnvironmentVariable {
 		DUCC_HOME("DUCC_HOME"),
 		DUCC_ID_JOB("DUCC_JOBID"),
 		DUCC_ID_PROCESS("DUCC_PROCESSID"),
 		DUCC_ID_SERVICE("DUCC_SERVICE_INSTANCE"),
 		DUCC_LOG_PREFIX("DUCC_PROCESS_LOG_PREFIX"),
+		DUCC_UPDATE_PORT("DUCC_STATE_UPDATE_PORT"),
 		//
 		DUCC_IP("DUCC_IP"),
 		DUCC_NODENAME("DUCC_NODENAME"),
@@ -36,29 +37,29 @@ public interface IDuccUser {
 		//
 		USER("USER"),
 		;
-		
+
 		private String value = null;
-		
+
 		private EnvironmentVariable(String valueForKey) {
 			setValue(valueForKey);
 		}
-		
+
 		private void setValue(String valueForKey) {
 			value = valueForKey;
 		}
-		
+
 		private String getValue() {
 			return value;
 		}
-		
+
 		public String standard() {
 			return name();
 		}
-		
+
 		public String mapped() {
 			return getValue();
 		}
-		
+
 		public String value() {
 			String retVal = mapped();
 			switch(this) {
@@ -68,33 +69,33 @@ public interface IDuccUser {
 			return retVal;
 		}
 	}
-	
+
 	public enum DashD {
 		DUCC_ID_PROCESS_UNIQUE("ducc.deploy.JpUniqueId"),
 		;
-		
+
 		private String value = null;
-		
+
 		private DashD(String valueForKey) {
 			setValue(valueForKey);
 		}
-		
+
 		private void setValue(String valueForKey) {
 			value = valueForKey;
 		}
-		
+
 		private String getValue() {
 			return value;
 		}
-		
+
 		public String standard() {
 			return name();
 		}
-		
+
 		public String mapped() {
 			return getValue();
 		}
-		
+
 		public String value() {
 			String retVal = mapped();
 			switch(this) {
@@ -103,10 +104,10 @@ public interface IDuccUser {
 			}
 			return retVal;
 		}
-		
+
 		public String dvalue() {
 			return "-D"+value();
 		}
 	}
-	
+
 }

Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/agent/ProcessStateUpdate.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/agent/ProcessStateUpdate.java?rev=1792648&r1=1792647&r2=1792648&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/agent/ProcessStateUpdate.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/agent/ProcessStateUpdate.java Tue Apr 25 19:56:31 2017
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -28,7 +28,7 @@ public class ProcessStateUpdate implemen
 	  public static final String ProcessStateUpdatePort = "ducc.agent.process.state.update.port";
 
 	/**
-   * 
+   *
    */
   private static final long serialVersionUID = 1L;
   ProcessState state;
@@ -38,7 +38,7 @@ public class ProcessStateUpdate implemen
 	String processJmxUrl;
 	String message;
 	List<IUimaPipelineAEComponent> uimaPipeline;
-	
+
 	public ProcessStateUpdate(ProcessState state, String pid, String duccProcessId) {
 		this(state,pid,duccProcessId,null,null);
 	}
@@ -97,5 +97,5 @@ public class ProcessStateUpdate implemen
   public void setSocketEndpoint(String socketEndpoint ) {
     this.socketEndpoint = socketEndpoint;
   }
-	
+
 }

Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jp/JobProcessConfiguration.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jp/JobProcessConfiguration.java?rev=1792648&r1=1792647&r2=1792648&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jp/JobProcessConfiguration.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/jp/JobProcessConfiguration.java Tue Apr 25 19:56:31 2017
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -51,10 +51,10 @@ public class JobProcessConfiguration {
 
 	/**
 	 * Creates Camel Router to handle incoming messages
-	 * 
+	 *
 	 * @param delegate
 	 *            - {@code AgentEventListener} to delegate messages to
-	 * 
+	 *
 	 * @return {@code RouteBuilder} instance
 	 */
     /*
@@ -198,12 +198,15 @@ public class JobProcessConfiguration {
 			}
 			// set up agent socket endpoint where this UIMA AS service will send
 			// state updates
+			// If not is system properties try envirobment
 			if (common.managedProcessStateUpdateEndpointType != null
 					&& common.managedProcessStateUpdateEndpointType
 							.equalsIgnoreCase("socket")) {
-				common.managedProcessStateUpdateEndpoint = AGENT_ENDPOINT
-						+ System.getProperty(ProcessStateUpdate.ProcessStateUpdatePort)
-						+ agentSocketParams;
+			  String updatePort = System.getProperty(ProcessStateUpdate.ProcessStateUpdatePort);
+			  if (updatePort == null) {
+			    updatePort = System.getenv(IDuccUser.EnvironmentVariable.DUCC_UPDATE_PORT.value());
+			  }
+				common.managedProcessStateUpdateEndpoint = AGENT_ENDPOINT	+ updatePort + agentSocketParams;
 			}
 			// set up a socket endpoint where the UIMA AS service will receive
 			// events sent from its agent

Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/service/ServiceConfiguration.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/service/ServiceConfiguration.java?rev=1792648&r1=1792647&r2=1792648&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/service/ServiceConfiguration.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/configuration/service/ServiceConfiguration.java Tue Apr 25 19:56:31 2017
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -56,10 +56,10 @@ public class ServiceConfiguration {
 	RouteBuilder routeBuilder;
 	/**
 	 * Creates Camel Router to handle incoming messages
-	 * 
+	 *
 	 * @param delegate
 	 *            - {@code AgentEventListener} to delegate messages to
-	 * 
+	 *
 	 * @return {@code RouteBuilder} instance
 	 */
 	public synchronized RouteBuilder routeBuilderForIncomingRequests(
@@ -96,7 +96,7 @@ public class ServiceConfiguration {
 		}
 	}
 
-	
+
 	private void checkPrereqs() {
 /*
 		boolean uimaAsJob = false;
@@ -177,7 +177,7 @@ public class ServiceConfiguration {
 			// custom processor class can be provided in the command line.
 			// Its not required. If not present, this code will assign one
 			// based on jobType
-			if ( System.getProperty(FlagsHelper.Name.JpProcessorClass.pname() ) == null  ) { 
+			if ( System.getProperty(FlagsHelper.Name.JpProcessorClass.pname() ) == null  ) {
 				String containerClass = "org.apache.uima.ducc.user.service.UimaASServiceContainer";
 				// Save the container class. This will be referenced from the
 				// DuccJobService.initialize()
@@ -200,9 +200,11 @@ public class ServiceConfiguration {
 			if (common.managedProcessStateUpdateEndpointType != null
 					&& common.managedProcessStateUpdateEndpointType
 							.equalsIgnoreCase("socket")) {
-				common.managedProcessStateUpdateEndpoint = AGENT_ENDPOINT
-						+ System.getProperty(ProcessStateUpdate.ProcessStateUpdatePort)
-						+ agentSocketParams;
+			  String updatePort = System.getProperty(ProcessStateUpdate.ProcessStateUpdatePort);
+			  if (updatePort == null) {
+			    updatePort = System.getenv(IDuccUser.EnvironmentVariable.DUCC_UPDATE_PORT.value());
+			  }
+				common.managedProcessStateUpdateEndpoint = AGENT_ENDPOINT + updatePort + agentSocketParams;
 			}
 			// set up a socket endpoint where the UIMA AS service will receive
 			// events sent from its agent
@@ -232,8 +234,8 @@ public class ServiceConfiguration {
 					+ common.managedProcessStateUpdateEndpoint + " ##");
 			System.out
 					.println("#######################################################");
-			
-			
+
+
 			duccComponent = new ServiceComponent("UimaProcess",
 					camelContext, this);