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/12 21:02:01 UTC

svn commit: r1791186 - in /uima/uima-ducc/trunk: uima-ducc-cli/ uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/ uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/ uima-ducc-cli/s...

Author: burn
Date: Wed Apr 12 21:02:00 2017
New Revision: 1791186

URL: http://svn.apache.org/viewvc?rev=1791186&view=rev
Log:
UIMA-5392 Moved Uima-AS pinger and some ws code out of cli project and changed its pom to reduce its dependencies

Added:
    uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsServiceMonitor.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQuery.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryMachines.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryReservations.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFacts.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFactsList.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/NodePidList.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFacts.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFactsList.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/MachineFactsTest.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/ReservationFactsTest.java   (with props)
Removed:
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/UimaAsPing.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/UimaAsServiceMonitor.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/DuccWebQuery.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/DuccWebQueryMachines.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/DuccWebQueryReservations.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/MachineFacts.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/MachineFactsList.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/NodePidList.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/ReservationFacts.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/ReservationFactsList.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/test/java/org/apache/uima/ducc/cli/test/MachineFactsTest.java
    uima/uima-ducc/trunk/uima-ducc-cli/src/test/java/org/apache/uima/ducc/cli/test/ReservationFactsTest.java
    uima/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/scheduler/WorkItem.java
Modified:
    uima/uima-ducc/trunk/uima-ducc-cli/pom.xml
    uima/uima-ducc/trunk/uima-ducc-examples/pom.xml
    uima/uima-ducc/trunk/uima-ducc-examples/src/main/java/org/apache/uima/ducc/ping/SamplePing.java
    uima/uima-ducc/trunk/uima-ducc-parent/pom.xml
    uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerComponent.java
    uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesDataHelper.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
    uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java

Modified: uima/uima-ducc/trunk/uima-ducc-cli/pom.xml
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-cli/pom.xml?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-cli/pom.xml (original)
+++ uima/uima-ducc/trunk/uima-ducc-cli/pom.xml Wed Apr 12 21:02:00 2017
@@ -63,50 +63,47 @@ uima-ducc/uima-ducc-cli-${ducc.version}.
     <dependency>
       <groupId>org.apache.uima</groupId>
       <artifactId>uima-ducc-common</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.uima</groupId>
-      <artifactId>uima-ducc-transport</artifactId>
-    </dependency>
+	  <exclusions>
+		<exclusion>
+		  <groupId>*</groupId>
+		  <artifactId>*</artifactId>
+		</exclusion>
+	  </exclusions>
 
-    <dependency>
-      <groupId>org.apache.uima</groupId>
-      <artifactId>uimaj-core</artifactId>
     </dependency>
 
     <dependency>
       <groupId>org.apache.uima</groupId>
-      <artifactId>uimaj-as-core</artifactId>
+      <artifactId>uima-ducc-transport</artifactId>
+	  <exclusions>
+		<exclusion>
+		  <groupId>*</groupId>
+		  <artifactId>*</artifactId>
+		</exclusion>
+	  </exclusions>
     </dependency>
 
     <dependency>
       <groupId>org.apache.uima</groupId>
-      <artifactId>uimaj-as-activemq</artifactId>
+      <artifactId>uima-ducc-user</artifactId>
 	  <exclusions>
 		<exclusion>
-		  <groupId>org.eclipse.jetty</groupId>
-		  <artifactId>jetty-webapp</artifactId>
-		</exclusion>
-		<exclusion>
-		  <groupId>net.sf.josql</groupId>
-		  <artifactId>josql</artifactId>
-		</exclusion>
-		<exclusion>
-		  <groupId>net.sf.josql</groupId>
-		  <artifactId>gentlyweb-utils</artifactId>
+		  <groupId>*</groupId>
+		  <artifactId>*</artifactId>
 		</exclusion>
 	  </exclusions>
     </dependency>
 
     <dependency>
-      <groupId>commons-cli</groupId>
-      <artifactId>commons-cli</artifactId>
+      <groupId>org.apache.uima</groupId>
+      <artifactId>uimaj-core</artifactId>
     </dependency>
 
+	<!-- Gson is needed just for one of the junit tests -->
     <dependency>
       <groupId>com.google.code.gson</groupId>
       <artifactId>gson</artifactId>
+	  <scope>test</scope>
     </dependency>
 
   </dependencies>

Modified: uima/uima-ducc/trunk/uima-ducc-examples/pom.xml
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-examples/pom.xml?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-examples/pom.xml (original)
+++ uima/uima-ducc/trunk/uima-ducc-examples/pom.xml Wed Apr 12 21:02:00 2017
@@ -61,6 +61,11 @@
 			<artifactId>uima-ducc-cli</artifactId>
 		</dependency>
 
+        <dependency>
+			<groupId>org.apache.uima</groupId>
+			<artifactId>uima-ducc-sm</artifactId>
+		</dependency>
+
   </dependencies>
      
 

Modified: uima/uima-ducc/trunk/uima-ducc-examples/src/main/java/org/apache/uima/ducc/ping/SamplePing.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-examples/src/main/java/org/apache/uima/ducc/ping/SamplePing.java?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-examples/src/main/java/org/apache/uima/ducc/ping/SamplePing.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-examples/src/main/java/org/apache/uima/ducc/ping/SamplePing.java Wed Apr 12 21:02:00 2017
@@ -42,10 +42,10 @@ import org.apache.uima.cas.CAS;
 import org.apache.uima.collection.EntityProcessStatus;
 import org.apache.uima.ducc.cli.AServicePing;
 import org.apache.uima.ducc.cli.ServiceStatistics;
-import org.apache.uima.ducc.cli.UimaAsServiceMonitor;
 import org.apache.uima.ducc.common.IServiceStatistics;
 import org.apache.uima.ducc.common.TcpStreamHandler;
 import org.apache.uima.ducc.common.utils.DuccProperties;
+import org.apache.uima.ducc.sm.UimaAsServiceMonitor;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.apache.uima.util.Level;
 

Modified: uima/uima-ducc/trunk/uima-ducc-parent/pom.xml
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-parent/pom.xml?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-parent/pom.xml (original)
+++ uima/uima-ducc/trunk/uima-ducc-parent/pom.xml Wed Apr 12 21:02:00 2017
@@ -257,7 +257,6 @@ ${uimaDUCCNoticeText}
                <version>${http.commons.core.version}</version>
              </dependency>
 
-
              <dependency>
 			    <groupId>org.apache.uima</groupId>
 			    <artifactId>uima-ducc-cli</artifactId>
@@ -276,7 +275,6 @@ ${uimaDUCCNoticeText}
 			    <version>${project.version}</version>
   		     </dependency>
 
-
              <dependency>
 			    <groupId>org.apache.uima</groupId>
 			    <artifactId>uima-ducc-common</artifactId>
@@ -285,6 +283,12 @@ ${uimaDUCCNoticeText}
 
              <dependency>
 			    <groupId>org.apache.uima</groupId>
+			    <artifactId>uima-ducc-container</artifactId>
+                <version>${project.version}</version>			
+		     </dependency>
+
+             <dependency>
+			    <groupId>org.apache.uima</groupId>
 			    <artifactId>uima-ducc-database</artifactId>
                 <version>${project.version}</version>			
 		     </dependency>
@@ -295,6 +299,12 @@ ${uimaDUCCNoticeText}
 			    <version>${project.version}</version>
   		    </dependency>
 
+             <dependency>
+			    <groupId>org.apache.uima</groupId>
+			    <artifactId>uima-ducc-sm</artifactId>
+			    <version>${project.version}</version>
+  		    </dependency>
+
 			<dependency>
 				<groupId>net.java.dev.jna</groupId>
 				<artifactId>jna</artifactId>

Modified: uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerComponent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerComponent.java?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerComponent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerComponent.java Wed Apr 12 21:02:00 2017
@@ -30,7 +30,6 @@ import java.util.UUID;
 
 import org.apache.camel.CamelContext;
 import org.apache.uima.ducc.cli.IUiOptions.UiOption;
-import org.apache.uima.ducc.cli.UimaAsPing;
 import org.apache.uima.ducc.common.boot.DuccDaemonRuntimeProperties;
 import org.apache.uima.ducc.common.boot.DuccDaemonRuntimeProperties.DaemonName;
 import org.apache.uima.ducc.common.component.AbstractDuccComponent;

Modified: uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java Wed Apr 12 21:02:00 2017
@@ -38,8 +38,6 @@ import javax.naming.ServiceUnavailableEx
 
 import org.apache.uima.UIMAFramework;
 import org.apache.uima.ducc.cli.IUiOptions.UiOption;
-import org.apache.uima.ducc.cli.UimaAsPing;
-import org.apache.uima.ducc.cli.UimaAsServiceMonitor;
 import org.apache.uima.ducc.common.IServiceStatistics;
 import org.apache.uima.ducc.common.TcpStreamHandler;
 import org.apache.uima.ducc.common.persistence.services.IStateServices;

Added: uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,330 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.sm;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.StringReader;
+import java.net.URI;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.aae.message.UIMAMessage;
+import org.apache.uima.ducc.cli.AServicePing;
+import org.apache.uima.ducc.cli.ServiceStatistics;
+import org.apache.uima.ducc.common.IServiceStatistics;
+import org.apache.uima.ducc.common.utils.DuccProperties;
+
+public class UimaAsPing extends AServicePing {
+    
+    private String endpoint;
+    private String brokerURI;
+    private int meta_timeout;
+
+    private String broker_host;
+    private int broker_jmx_port;
+    private UimaAsServiceMonitor monitor;
+
+    private String nodeIp;
+    private String pid;
+
+    private Connection connection;
+
+    private Session producerSession;
+
+    private MessageProducer producer;
+
+    private Session consumerSession;
+
+    private TemporaryQueue consumerDestination;
+
+    private MessageConsumer consumer;
+
+    private boolean failover = false;
+
+    public UimaAsPing() {
+    }
+
+    // Construct a monitor unless collection of JMX statistics is disabled
+    // - jmx port is specified as 'none', or 
+    // - using the failover protocol
+    public void init(String args, String ep)
+        throws Exception
+    {
+        monitor = null;
+        if ( args == null ) {
+            meta_timeout = 5000;
+            broker_jmx_port = 1099;
+        } else {
+            // turn the argument string into properties and load 'broker_jmx_port' & 'meta_timeout'
+            String lines = args.replace(',', '\n');
+            DuccProperties props = new DuccProperties();
+            props.load(new StringReader(lines));
+            meta_timeout = props.getIntProperty("meta-timeout", 5000);
+            if ("none".equals(props.getProperty("broker-jmx-port"))) {
+                return;
+            } else {
+                broker_jmx_port = props.getIntProperty("broker-jmx-port", 1099);
+            }
+        }
+        
+        // Ep is of the form UIMA-AS:queuename:broker
+        String tokens[] = ep.split(":", 3);
+        endpoint = tokens[1];
+        brokerURI = tokens[2];
+        
+        // Parse broker URL to get the host for jmx.
+        // First check for the failover protocol, which is not supported for JMX statistics
+        if (brokerURI.startsWith("failover:")) {
+            failover  = true;
+            return;
+        }
+        try {                
+            URI uri = new URI(brokerURI);
+            broker_host = uri.getHost();
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Invalid broker URL '" + brokerURI + "'");
+        }
+
+        doLog("init", "Initializing UimaAsServiceMonitor: endpoint:" + endpoint + " broker_host:" + broker_host + " broker_jmx_port:"
+                    + broker_jmx_port);
+        monitor = new UimaAsServiceMonitor(endpoint, broker_host, broker_jmx_port);
+    }
+
+    private void initJMS() throws JMSException {
+        String methodName = "initJMS";
+    	ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerURI);
+		connection = factory.createConnection();
+        connection.start();
+        doLog(methodName, "Connection started");
+
+        producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Queue producerQueue = producerSession.createQueue(endpoint);
+        producer = producerSession.createProducer(producerQueue);
+        consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        consumerDestination = consumerSession.createTemporaryQueue();
+        consumer = consumerSession.createConsumer(consumerDestination);
+        doLog(methodName, "Created queues and sessions");
+    }
+    public void stop()
+    { try {
+        if (producerSession != null) {
+            producerSession.close();
+        }
+        if (consumerSession != null) {
+            consumerSession.close();
+        }
+        if ( connection != null ) {
+        	connection.close();
+        }
+    } catch (JMSException e) {                                                                                                                                                                       
+        e.printStackTrace();
+    }
+
+    	
+        if ( monitor != null ) monitor.stop();
+    }
+
+    void evaluateService(IServiceStatistics stats)
+    {
+    	//String methodName = "evaluatePing";
+        // Note that this particular pinger considers 'health' to be a function of whether
+        // the get-mata worked AND the queue statistics.
+        try {
+            if ( monitor != null ) {
+                monitor.collect();
+                long cc = monitor.getProducerCount();
+                if ( cc > 0 ) {
+                    last_use = System.currentTimeMillis();
+                }                
+            }
+            stats.setHealthy(true);       // this pinger defines 'healthy' as
+                                          // 'service responds to get-meta and broker returns jmx stats'
+        } catch ( Throwable t ) {
+            doLog("evaluateService", "EXCEPTION::::"+serializeThrowable(t));
+        	stats.setHealthy(false);
+            monitor.setJmxFailure(t.getMessage());
+        }
+    }
+
+    private String serializeThrowable(Throwable t) {
+    	String msg="";
+    	if ( t != null ) {
+    	   ByteArrayOutputStream bstream = new ByteArrayOutputStream();
+    	   PrintStream pstream = new PrintStream(bstream);
+    	   t.printStackTrace(pstream);
+    	   pstream.close();
+    	   msg = bstream.toString();
+    	}
+    	return msg;
+    }
+    /**
+     * Override from AServicePing
+     */
+    public long getLastUse()
+    {
+        return last_use;
+    }
+
+    public IServiceStatistics getStatistics()
+    {
+        String methodName = "getStatistics";
+        doLog(methodName, "***********************************************");
+
+        IServiceStatistics statistics = new ServiceStatistics(false, false, "<NA>");
+        String failure_reason = null;
+
+        nodeIp = "N/A";
+        pid = "N/A";
+
+        evaluateService(statistics);       // if we get here, the get-meta worked well enough
+        ExecutorService executor = null;
+        Exception excp = null;
+        boolean gmfail = false;
+        Future<Boolean> future = null;
+        try {
+        	initJMS();
+        	
+            TextMessage msg = producerSession.createTextMessage();
+            msg.setStringProperty(AsynchAEMessage.MessageFrom, consumerDestination.getQueueName());
+            msg.setStringProperty(UIMAMessage.ServerURI, brokerURI);
+            msg.setIntProperty(AsynchAEMessage.MessageType, AsynchAEMessage.Request);
+            msg.setIntProperty(AsynchAEMessage.Command, AsynchAEMessage.GetMeta);
+            msg.setJMSReplyTo(consumerDestination);
+            msg.setText("");
+
+            doLog(methodName, "Sending getMeta request to " + endpoint + " at " + brokerURI);
+            producer.send(msg);
+            long startTime = System.currentTimeMillis();
+            executor = Executors.newSingleThreadExecutor();
+            future = executor.submit(new Callable<Boolean>() {
+                public Boolean call() throws Exception {
+                	// First receive() is to get IP and PID of the process that will process getMeta
+                    ActiveMQTextMessage serviceInfoReply = (ActiveMQTextMessage) consumer.receive();
+                    nodeIp = serviceInfoReply.getStringProperty(AsynchAEMessage.ServerIP); 
+        		    pid = serviceInfoReply.getStringProperty(AsynchAEMessage.UimaASProcessPID);
+                    // second receive() is for GetMeta reply
+        		    // dont need to process the actual reply. If receive() succeeds we have 
+        		    // a good GetMeta call
+        		    consumer.receive();
+                	return true;
+                }
+              }
+            );
+            // wait for getMeta reply and timeout if not received within allotted window
+            future.get(meta_timeout, TimeUnit.MILLISECONDS);
+            future.cancel(true);
+            long replyTime = System.currentTimeMillis() - startTime;
+            statistics.setAlive(true);
+            statistics.setHealthy(true && statistics.isHealthy());
+
+            statistics.setInfo("Get-meta took " + replyTime + " msecs.");
+            doLog(methodName, "Reply received in ", replyTime, " ms");
+            gmfail = false;
+        } catch ( ExecutionException e) {
+            excp = e;
+            gmfail = true;
+            statistics.setHealthy(false);
+            statistics.setAlive(false);
+            statistics.setInfo("Ping error: " + e);
+            doLog(methodName, null, "Error while awaiting getmeta reply from ", nodeIp, "PID", pid);
+        	if ( future != null ) {
+        		future.cancel(true);
+        	}
+        } catch ( InterruptedException e) {
+            excp = e;
+            gmfail = true;
+            statistics.setHealthy(false);
+            statistics.setAlive(false);
+            statistics.setInfo("Ping error: " + e);
+            doLog(methodName, null, "Thread interrupted while waiting for getmeta reply from ", nodeIp, "PID", pid);
+        	if ( future != null ) {
+        		future.cancel(true);
+        	}
+        } catch( TimeoutException e) {
+            excp = e;
+            gmfail = true;
+            statistics.setHealthy(false);
+            statistics.setAlive(false);
+            statistics.setInfo("Ping error: " + e);
+            doLog(methodName, null, "Get-Meta timeout ("+meta_timeout+" ms) from ", nodeIp, "PID", pid);
+        	if ( future != null ) {
+        		future.cancel(true);
+        	}
+        	
+        } catch (JMSException e) {
+            excp = e;
+            gmfail = true;
+            statistics.setHealthy(false);
+            statistics.setAlive(false);
+            statistics.setInfo("Ping error: " + e);
+            //e.printStackTrace();
+        } finally {
+        	stop();
+        	if ( executor != null ) {
+            	executor.shutdownNow();
+        	}
+        }
+        if ( gmfail || excp != null ) {
+            failure_reason = "Cannot issue getMeta to: " + endpoint + ":" + brokerURI; 
+            if ( excp != null ) {
+                if (excp.getCause() == null ) {
+                    failure_reason = failure_reason + ": " + excp.toString();
+                } else {
+                    failure_reason = failure_reason + ": " + excp.getCause();
+                }
+            }
+            doLog(methodName, failure_reason);
+        }
+
+        if ( monitor == null ) {                   // no jmx active
+            if ( failure_reason != null ) {
+                statistics.setInfo(failure_reason);
+            } else {
+                if (failover) {
+                    statistics.setInfo("(JMX statistics not available for failover protocol)");
+                } else {
+                    statistics.setInfo("Ping to " + nodeIp + ": " + pid + " ok. (JMX disabled.)");
+                }
+            }
+        } else {
+            monitor.setSource(nodeIp, pid, gmfail, failure_reason);
+            statistics.setInfo(monitor.format());
+        }
+
+        return statistics;
+    }
+ }

Propchange: uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsServiceMonitor.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsServiceMonitor.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsServiceMonitor.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsServiceMonitor.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,450 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.sm;
+
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+import javax.management.QueryExp;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.activemq.broker.jmx.BrokerViewMBean;
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.uima.ducc.cli.ServiceStatistics;
+import org.apache.uima.ducc.common.IServiceStatistics;
+
+public class UimaAsServiceMonitor
+{
+
+    private String qname;
+    private String broker_url;
+
+    private JMXConnector jmxc;
+    private BrokerViewMBean brokerMBean;
+    private QueueViewMBean monitoredQueue;
+    private IServiceStatistics qstats;
+
+
+	double enqueueTime ; 
+    long consumerCount ;
+    long producerCount ;
+    long queueSize     ;
+    long minEnqueueTime;
+    long maxEnqueueTime;
+    long inFlightCount ;
+    long dequeueCount  ;
+    long enqueueCount  ;
+    long dispatchCount ;
+    long expiredCount  ;
+    
+    boolean alive = false;
+    boolean healthy = false;
+    
+    String nodeId;
+    String pid;
+    boolean gmfail = false;
+    String  failure_reason = null;
+
+    String jmxFailure = null;
+
+    String broker_host;
+    volatile boolean useNewJmxQueryString = false;
+    public UimaAsServiceMonitor(String qname, String broker_host, int broker_jmx_port)
+    {
+        this.broker_host = broker_host;
+    	this.qname = qname;
+        this.broker_url = "service:jmx:rmi:///jndi/rmi://"+ broker_host + ":" + broker_jmx_port + "/jmxrmi";        
+        this.qstats = new ServiceStatistics(false, false, "N/A");
+    }
+
+//     public ServiceStatistics getStatistics()
+//     {
+//         try {
+//             collect();
+//             qstats.setAlive(true);        // if we don't croak gathering stuff, we're not dead
+//             qstats.setHealthy(true);
+//             qstats.setInfo(format());
+//         } catch ( Throwable t ) {
+//             qstats.setAlive(false);        // if we don't croak gathering stuff, we're not dead
+//             qstats.setHealthy(false);
+//             qstats.setInfo(t.getMessage());
+//         }
+//     	return qstats;
+//     }
+    
+    private ObjectName getBrokerObjectName(MBeanServerConnection conn, String brokerQuery, String brokerNameProperty ) throws Exception {
+        ObjectName brokerObjectName = null;
+    	for (Object nameObject : conn.queryNames(new ObjectName(brokerQuery), (QueryExp) null)) {
+            //find the brokername object
+            brokerObjectName = (ObjectName) nameObject;
+
+            // the following code checks if the current object represents AMQ Broker MBean which looks like:
+            // org.apache.activemq:type=Broker,brokerName=localhost
+            // The above has just 2 properties: type and brokerName. We are after the brokerName here. Only
+            // one MBean has just these two properties.
+            Map<String,String> parts = brokerObjectName.getKeyPropertyList();
+            boolean done = false;
+            if ( parts.size() == 2) {  // looking for two properties Object only 
+            	for( Entry<String,String> entry : parts.entrySet()) {
+//                    if ( entry.getKey().equals("brokerName")) {   // need this property
+                    if ( entry.getKey().equals(brokerNameProperty)) {   // need this property
+                    	done = true;    // found a match. Got a broker ObjectName
+                    	break;
+                    }
+            	}
+            }
+            if ( done ) {
+            	break;
+            }
+//            if (brokerObjectName.getCanonicalName().endsWith("Type=Broker")) {
+                // Extract just the name from the canonical name
+                //String brokerName = brokerObjectName.getCanonicalName().substring(0, brokerObjectName.getCanonicalName().indexOf(","));
+                //System.out.println("Canonical name of broker is " + brokerObjectName.getCanonicalName());
+                //System.out.println("broker name is " + brokerName);
+        }
+    	return brokerObjectName;
+    }
+    
+    /**
+     * Connect to ActiveMq and find the mbean for the queue we're trying to monitor
+     */
+    public void init(String parm /* parm not used in this impl */)
+        throws Exception
+    {
+        JMXServiceURL url = new JMXServiceURL(broker_url);
+        jmxc = JMXConnectorFactory.connect(url);
+        MBeanServerConnection conn = jmxc.getMBeanServerConnection();        
+        String jmxDomain = "org.apache.activemq";  
+        String brokerJmxDomain = null;
+        
+        //
+        // First get the broker name. Assume we are connecting to AMQ broker version >= 5.8.0
+        //
+        String brokerNameProperty = "brokerName";  
+        String destinationId = ",destinationType=Queue,destinationName=";
+        ObjectName brokerObjectName = null;
+        String brokerQuery = jmxDomain + ":type=Broker,*"; 
+        // Get ObjectName for the Broker. The getBrokerObjectName() returns null if 
+        // version of broker < 5.8.0
+        brokerObjectName = getBrokerObjectName(conn, brokerQuery, brokerNameProperty);
+        if ( brokerObjectName == null ) {  // broker version 5.7
+            // this is a fall back mechanism in case we are connected to an older broker ( < 5.8.0).
+        	// In older versions of AMQ query syntax is different. 
+        	brokerQuery = jmxDomain + ":Type=Broker,*";
+        	brokerNameProperty = "BrokerName";
+        	destinationId = ",Type=Queue,Destination=";
+            brokerObjectName = getBrokerObjectName(conn, brokerQuery, brokerNameProperty);
+            String bcn = brokerObjectName.getCanonicalName();
+            brokerJmxDomain = bcn.substring(0,bcn.indexOf(","));
+        } else {
+        	brokerJmxDomain = brokerObjectName.getCanonicalName();
+        }
+        ObjectName targetQueueON = new ObjectName(brokerJmxDomain+destinationId+qname);
+        QueueViewMBean brokerQMBean = (QueueViewMBean) MBeanServerInvocationHandler.newProxyInstance(conn, targetQueueON ,QueueViewMBean.class, true);
+        monitoredQueue = brokerQMBean;
+        
+        if ( monitoredQueue == null ) {
+            throw new IllegalStateException("Cannot find queue: " + qname);
+        }        
+    }
+
+    public void clearQueues()
+        throws Throwable
+    {
+        // String methodName = "clearQueues";
+        init(null);
+
+        if ( ( qname != null ) && ( brokerMBean != null ) ) {
+            brokerMBean.removeQueue(qname);
+        }
+        stop();
+    }
+
+    public void resetStatistics()
+    {
+        try {
+            init(null);
+            
+            if ( monitoredQueue != null ) {
+                monitoredQueue.resetStatistics();
+            }
+            stop();
+        } catch (Throwable t) {
+            // Nothing .. we don't care if this fails; this is just
+            // prophylaxis.  If there is really a problem it will show
+            // up later.
+        }
+    }
+
+    public void stop()
+    {
+        try {
+			if ( jmxc != null ) {
+			    jmxc.close();
+			    jmxc = null;
+			}
+		} catch (IOException e) {
+			// don't really care
+		}
+    }
+
+    public void setJmxFailure(String msg)
+    {
+        this.jmxFailure = msg;
+    }
+
+    public void setSource(String nodeId, String pid, boolean gmfail, String failure_reason)
+    {
+        this.nodeId = nodeId;
+        this.pid = pid;
+        this.gmfail = gmfail;
+        this.failure_reason = failure_reason;
+    }
+
+    public void setSource(String nodeId, String pid, boolean gmfail)
+    {
+        this.nodeId = nodeId;
+        this.pid = pid;
+        this.gmfail = gmfail;
+        this.failure_reason = null;
+    }
+
+    public IServiceStatistics getStatistics()
+    {
+        try {
+            collect();
+            qstats.setAlive(true);        // if we don't croak gathering stuff, we're not dead
+            qstats.setHealthy(true);
+            qstats.setInfo(format());
+        } catch ( Throwable t ) {
+            qstats.setAlive(false);        // if we don't croak gathering stuff, we're not dead
+            qstats.setHealthy(false);
+            qstats.setInfo(t.getMessage());
+        }
+    	return qstats;
+    }
+
+    public String format()
+    {
+        String answer = null;
+        if ( jmxFailure != null ) {
+            answer = "JMX Failure[" 
+                + jmxFailure + "]" 
+                +  "] MetaNode[" + nodeId
+                +  "] MetaPid[" + pid
+                ;
+
+        } else {
+            answer = "QDEPTH[" + queueSize
+                +  "] AveNQ[" + new DecimalFormat("####.##").format(enqueueTime)
+                +  "] Consum[" + consumerCount
+                +  "] Prod[" + producerCount
+                +  "] minNQ[" + minEnqueueTime
+                +  "] maxNQ[" + maxEnqueueTime
+                +  "] expCnt[" + expiredCount
+                +  "] inFlt[" + inFlightCount
+                +  "] DQ[" + dequeueCount
+                +  "] NQ[" + enqueueCount
+                +  "] NDisp[" + dispatchCount
+                +  "] MetaNode[" + nodeId
+                +  "] MetaPid[" + pid 
+                +  "]"
+                ;
+        }
+
+        if ( gmfail ) {
+            if ( failure_reason == null ) {
+                answer = answer + "; getMeta failure to service.";
+            } else {
+                answer = answer + ": " + failure_reason;
+            }
+        }
+        return answer;
+    }
+
+    public void collect()
+        throws Throwable
+    {
+    	// String methodName = "collect";
+        init(null);
+        if ( monitoredQueue != null ) {
+            enqueueTime    = monitoredQueue.getAverageEnqueueTime();
+            consumerCount  = monitoredQueue.getConsumerCount();
+            producerCount  = monitoredQueue.getProducerCount();
+            queueSize      = monitoredQueue.getQueueSize();
+            minEnqueueTime = monitoredQueue.getMinEnqueueTime();
+            maxEnqueueTime = monitoredQueue.getMaxEnqueueTime();
+            inFlightCount  = monitoredQueue.getInFlightCount();
+            dequeueCount   = monitoredQueue.getDequeueCount();
+            enqueueCount   = monitoredQueue.getEnqueueCount();
+            dispatchCount  = monitoredQueue.getDispatchCount();
+            expiredCount   = monitoredQueue.getExpiredCount();
+            monitoredQueue.resetStatistics();
+        } else {
+            enqueueTime    = 0;
+            consumerCount  = 0;
+            producerCount  = 0;
+            queueSize      = 0;
+            minEnqueueTime = 0;
+            maxEnqueueTime = 0;
+            inFlightCount  = 0;
+            dequeueCount   = 0;
+            enqueueCount   = 0;
+            dispatchCount  = 0;
+            expiredCount   = 0;
+        }
+
+        stop();
+    }
+
+    public long getQueueSize()
+    {
+        return queueSize;
+    }
+
+    /**
+	 * @return the enqueueTime
+	 */
+	public double getEnqueueTime() {
+		return enqueueTime;
+	}
+
+	/**
+	 * @return the consumerCount
+	 */
+	public long getConsumerCount() {
+		return consumerCount;
+	}
+
+	/**
+	 * @return the producerCount
+	 */
+	public long getProducerCount() {
+		return producerCount;
+	}
+
+	/**
+	 * @return the minEnqueueTime
+	 */
+	public long getMinEnqueueTime() {
+		return minEnqueueTime;
+	}
+
+	/**
+	 * @return the maxEnqueueTime
+	 */
+	public long getMaxEnqueueTime() {
+		return maxEnqueueTime;
+	}
+
+	/**
+	 * @return the inFlightCount
+	 */
+	public long getInFlightCount() {
+		return inFlightCount;
+	}
+
+	/**
+	 * @return the dequeueCount
+	 */
+	public long getDequeueCount() {
+		return dequeueCount;
+	}
+
+	/**
+	 * @return the enqueueCount
+	 */
+	public long getEnqueueCount() {
+		return enqueueCount;
+	}
+
+	/**
+	 * @return the dispatchCount
+	 */
+	public long getDispatchCount() {
+		return dispatchCount;
+	}
+
+	/**
+	 * @return the expiredCount
+	 */
+	public long getExpiredCount() {
+		return expiredCount;
+	}
+
+	/**
+	 * @return the healthy
+	 */
+	public boolean isHealthy() {
+		return healthy;
+	}
+
+	/**
+	 * @return the gmfail
+	 */
+	public boolean isGmfail() {
+		return gmfail;
+	}
+
+	/**
+	 * @return the jmxFailure
+	 */
+	public String getJmxFailure() {
+		return jmxFailure;
+	}
+
+    public static void main(String[] args)
+    {
+        // System.out.println(args[0] + " " + args[1] + " " + args[2]);
+        UimaAsServiceMonitor m = new UimaAsServiceMonitor(args[0], args[1], Integer.parseInt(args[2])); // qname, broker host, broker port
+
+        try {
+			m.init(null);                      // connect to amq
+		} catch (Exception e1) {
+			// TODO Auto-generated catch block
+			System.out.println("Cannot connect:");
+			e1.printStackTrace();
+            return;
+		}
+
+
+        while ( true ) {
+            IServiceStatistics qs = null;
+            try {
+                qs = m.getStatistics();
+            } catch (Throwable t) {
+                System.out.println("Cannot collect stats.  The queue may have been deleted. Details:");
+                t.printStackTrace();
+                return;
+            }
+            System.out.println(qs.toString());
+            try {
+				Thread.sleep(3000);
+			} catch (InterruptedException e) {
+			}
+        }
+    }
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsServiceMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesData.java Wed Apr 12 21:02:00 2017
@@ -29,9 +29,6 @@ import java.util.TreeMap;
 import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.uima.ducc.cli.ws.json.MachineFacts;
-import org.apache.uima.ducc.cli.ws.json.MachineFactsList;
-import org.apache.uima.ducc.cli.ws.json.NodePidList;
 import org.apache.uima.ducc.common.ConvertSafely;
 import org.apache.uima.ducc.common.IDuccEnv;
 import org.apache.uima.ducc.common.Node;
@@ -45,6 +42,9 @@ import org.apache.uima.ducc.common.utils
 import org.apache.uima.ducc.transport.event.NodeMetricsUpdateDuccEvent;
 import org.apache.uima.ducc.transport.event.ProcessInfo;
 import org.apache.uima.ducc.ws.MachineInfo.MachineStatus;
+import org.apache.uima.ducc.ws.cli.json.MachineFacts;
+import org.apache.uima.ducc.ws.cli.json.MachineFactsList;
+import org.apache.uima.ducc.ws.cli.json.NodePidList;
 import org.apache.uima.ducc.ws.db.DbQuery;
 import org.apache.uima.ducc.ws.db.IDbMachine;
 import org.apache.uima.ducc.ws.server.DuccWebProperties;

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesDataHelper.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesDataHelper.java?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesDataHelper.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccMachinesDataHelper.java Wed Apr 12 21:02:00 2017
@@ -18,8 +18,8 @@
 */
 package org.apache.uima.ducc.ws;
 
-import org.apache.uima.ducc.cli.ws.json.MachineFacts;
-import org.apache.uima.ducc.cli.ws.json.MachineFactsList;
+import org.apache.uima.ducc.ws.cli.json.MachineFacts;
+import org.apache.uima.ducc.ws.cli.json.MachineFactsList;
 
 public class DuccMachinesDataHelper {
 	

Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQuery.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQuery.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQuery.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQuery.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.cli;
+
+import java.net.InetAddress;
+
+import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
+import org.apache.uima.ducc.common.utils.Utils;
+
+public class DuccWebQuery {
+	
+	protected DuccPropertiesResolver dpr = DuccPropertiesResolver.getInstance();
+	
+	protected String DUCC_HOME = Utils.findDuccHome();
+	protected String ws_scheme = "http";
+	protected String ws_host = "localhost";
+	protected String ws_port = "42133";
+	protected String ws_servlet = null;;
+	
+	protected boolean showURL = true;
+	
+	protected DuccWebQuery(String servlet) {
+		assert_ducc_home();
+		determine_host();
+		determine_port();
+		ws_servlet = servlet;
+	}
+	
+	protected void assert_ducc_home() {
+		if(DUCC_HOME == null) {
+			throw new RuntimeException("DUCC_HOME not specified");
+		}
+	}
+	
+	protected void determine_host() {
+		try {
+			ws_host = java.net.InetAddress.getLocalHost().getHostName();
+		}
+		catch(Exception e) {
+		}
+		String host = dpr.getProperty(DuccPropertiesResolver.ducc_ws_host);
+		if(host != null) {
+			ws_host = host;
+		}
+		if(ws_host != null) {
+			if(ws_host.length() > 0) {
+				if(!ws_host.contains(".")) {
+					try {
+						InetAddress addr = InetAddress.getLocalHost();
+						String canonicalHostName = addr.getCanonicalHostName();
+						if(canonicalHostName.startsWith(ws_host)) {
+							ws_host = canonicalHostName;
+						}
+					}
+					catch(Exception e) {
+						
+					}
+				}
+			}
+		}
+	}
+	
+	protected void determine_port() {
+		String port = dpr.getProperty(DuccPropertiesResolver.ducc_ws_port);
+		if(port != null) {
+			ws_port = port;
+		}
+	}
+	
+	protected String getUrlString() {
+		String urlString = ws_scheme+"://"+ws_host+":"+ws_port+ws_servlet;
+		if(showURL) {
+			System.out.println(urlString);
+		}
+		return urlString;
+	}
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryMachines.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryMachines.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryMachines.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryMachines.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.cli;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.ducc.ws.cli.json.MachineFacts;
+import org.apache.uima.ducc.ws.cli.json.MachineFactsList;
+
+import com.google.gson.Gson;
+
+public class DuccWebQueryMachines extends DuccWebQuery {
+
+	private DuccWebQueryMachines() {
+		super("/ducc-servlet/json-format-machines");
+	}
+
+	private MachineFactsList get() throws Exception {
+		URL url = new URL(getUrlString());
+		URLConnection ucon = url.openConnection();
+		BufferedReader br = new BufferedReader(new InputStreamReader(ucon.getInputStream()));
+		String jSon = br.readLine();
+		Gson gson = new Gson();
+		MachineFactsList fl = gson.fromJson(jSon, MachineFactsList.class);
+        br.close();
+        return fl;
+	}
+	
+	private String stringify(List<String> list) {
+		StringBuffer sb = new StringBuffer();
+		for(String item : list) {
+			if(sb.length() > 0) {
+				sb.append(",");
+			}
+			sb.append(item);
+		}
+		return "["+sb.toString()+"]";
+	}
+	
+	private void display(MachineFactsList fl) {
+		if(fl != null) {
+			Iterator<MachineFacts> fIterator = fl.iterator();
+			while(fIterator.hasNext()) {
+				MachineFacts f = fIterator.next();
+				System.out.println(f.name);
+				System.out.println("  "+"status: "+f.status);
+				System.out.println("  "+"aliens: "+ stringify(f.aliens));
+				System.out.println("  "+"swapInuse: "+ f.swapInuse);
+				System.out.println("  "+"swapFree: "+ f.swapFree);
+				System.out.println("  "+"memoryTotal: "+ f.memTotal);
+				System.out.println("  "+"memoryFree: "+ f.memFree);
+				System.out.println("  "+"ip: "+ f.ip);
+				System.out.println("  "+"heartbeat: "+ f.heartbeat);
+			}
+		}
+		else {
+			System.out.println("?");
+		}
+	}
+	
+	private void main_instance(String[] args) throws Exception {
+		MachineFactsList fl = get();
+		display(fl);
+	}
+	
+	public static void main(String[] args) {
+		try {
+			DuccWebQueryMachines dwq = new DuccWebQueryMachines();
+			dwq.main_instance(args);
+		}
+		catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+}
\ No newline at end of file

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryMachines.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryReservations.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryReservations.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryReservations.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryReservations.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ducc.ws.cli;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.ducc.ws.cli.json.NodePidList;
+import org.apache.uima.ducc.ws.cli.json.ReservationFacts;
+import org.apache.uima.ducc.ws.cli.json.ReservationFactsList;
+
+import com.google.gson.Gson;
+
+public class DuccWebQueryReservations extends DuccWebQuery {
+
+	private DuccWebQueryReservations() {
+		super("/ducc-servlet/json-format-reservations");
+	}
+
+	private ReservationFactsList get() throws Exception {
+		URL url = new URL(getUrlString());
+		URLConnection ucon = url.openConnection();
+		BufferedReader br = new BufferedReader(new InputStreamReader(ucon.getInputStream()));
+		String jSon = br.readLine();
+		Gson gson = new Gson();
+		ReservationFactsList fl = gson.fromJson(jSon, ReservationFactsList.class);
+        br.close();
+        return fl;
+	}
+	
+	private String stringify(List<NodePidList> list) {
+		StringBuffer sb = new StringBuffer();
+		for(NodePidList nodePids : list) {
+			String node = nodePids.node;
+			StringBuffer pb = new StringBuffer();
+			for(String pid : nodePids.pids) {
+				if(pb.length() > 0) {
+					pb.append(",");
+				}
+				pb.append(pid);
+			}
+			String pids = pb.toString();
+			if(sb.length() > 0) {
+				sb.append(",");
+			}
+			sb.append(node+"{"+pids+"}");
+		}
+		return "["+sb.toString()+"]";
+	}
+	
+	private void display(ReservationFactsList fl) {
+		if(fl != null) {
+			Iterator<ReservationFacts> fIterator = fl.iterator();
+			while(fIterator.hasNext()) {
+				ReservationFacts f = fIterator.next();
+				System.out.println(f.id);
+				System.out.println("  "+"start: "+f.start);
+				System.out.println("  "+"end: "+ f.end);
+				System.out.println("  "+"user: "+ f.user);
+				System.out.println("  "+"clas: "+ f.rclass);
+				System.out.println("  "+"state: "+ f.state);
+				System.out.println("  "+"reason: "+ f.reason);
+				System.out.println("  "+"allocation: "+ f.allocation);
+				System.out.println("  "+"processes: "+ stringify(f.userProcesses));
+				System.out.println("  "+"size: "+ f.size);
+				System.out.println("  "+"list: "+ f.list);
+				System.out.println("  "+"description: "+ f.description);
+			}
+		}
+		else {
+			System.out.println("?");
+		}
+	}
+	
+	private void main_instance(String[] args) throws Exception {
+		ReservationFactsList fl = get();
+		display(fl);
+	}
+	
+	// TODO: Add support for maxRecords=<n> query parameter
+	
+	public static void main(String[] args) {
+		try {
+			DuccWebQueryReservations dwq = new DuccWebQueryReservations();
+			dwq.main_instance(args);
+		}
+		catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+}
\ No newline at end of file

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/DuccWebQueryReservations.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFacts.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFacts.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFacts.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFacts.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.cli.json;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class MachineFacts implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+	
+	public String status;
+	public String statusReason;
+	public String ip;
+	public String name;
+	public String memTotal;
+	public String memFree;
+	public String memReserve;
+	public String quantum;
+	public String swapInuse;
+	public String swapDelta;
+	public String swapFree;
+	public double cpu;
+	public boolean cgroupsEnabled = false;
+	public boolean cgroupsCpuReportingEnabled = false;
+	public List<String> aliens;
+	public String heartbeat;
+	
+	public MachineFacts(String status,
+			       String statusReason,
+				   String ip,
+				   String name,
+				   String memTotal,
+				   String memFree,
+				   String swapInuse,
+				   String swapDelta,
+				   String swapFree,
+				   double cpu,
+				   boolean cgroupsEnabled,
+				   boolean cgroupsCpuReportingEnabled,
+				   List<String> aliens,
+				   String heartbeat
+				   ) 
+	{
+		this.status = status;
+		this.statusReason = statusReason;
+		this.ip = ip;
+		this.name = name;
+		this.memTotal = memTotal;
+		this.memFree = memFree;
+		this.memReserve = "0";
+		this.quantum = "";
+		this.swapInuse = swapInuse;
+		this.swapDelta = swapDelta;
+		this.swapFree = swapFree;
+		this.cpu = cpu;
+		this.cgroupsEnabled = cgroupsEnabled;
+		this.cgroupsCpuReportingEnabled = cgroupsCpuReportingEnabled;
+		this.aliens = aliens;
+		this.heartbeat = heartbeat;
+	}
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFacts.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFactsList.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFactsList.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFactsList.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFactsList.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.cli.json;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class MachineFactsList extends ArrayList<MachineFacts> implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/MachineFactsList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/NodePidList.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/NodePidList.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/NodePidList.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/NodePidList.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.cli.json;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class NodePidList implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+	
+	public String node;
+	public List<String> pids;
+	
+	public NodePidList(String node, List<String> pids) {
+		this.node = node;
+		this.pids = pids;
+	}
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/NodePidList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFacts.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFacts.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFacts.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFacts.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.cli.json;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class ReservationFacts implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+	
+	public String id;
+	public String start;
+	public String end;
+	public String user;
+	public String rclass;
+	public String state;
+	public String reason;
+	public String allocation;
+	public List<NodePidList> userProcesses;
+	public String size;
+	public List<String> list;
+	public String description;
+	
+	public ReservationFacts(
+				String id, 
+				String start,
+				String end,
+				String user,
+				String rclass,
+				String state,
+				String reason,
+				String allocation,
+				List<NodePidList> userProcesses,
+				String size,
+				List<String> list,
+				String description
+				) 
+	{
+		this.id = id;
+		this.start = start;
+		this.end = end;
+		this.user = user;
+		this.rclass = rclass;
+		this.state = state;
+		this.reason = reason;
+		this.allocation = allocation;
+		this.userProcesses = userProcesses;
+		this.size = size;
+		this.list = list;
+		this.description = description;
+	}
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFacts.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFactsList.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFactsList.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFactsList.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFactsList.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.cli.json;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class ReservationFactsList extends ArrayList<ReservationFacts> implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/cli/json/ReservationFactsList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java Wed Apr 12 21:02:00 2017
@@ -47,8 +47,6 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.uima.ducc.cli.DuccUiConstants;
-import org.apache.uima.ducc.cli.ws.json.MachineFacts;
-import org.apache.uima.ducc.cli.ws.json.MachineFactsList;
 import org.apache.uima.ducc.common.CancelReasons.CancelReason;
 import org.apache.uima.ducc.common.ConvertSafely;
 import org.apache.uima.ducc.common.NodeConfiguration;
@@ -101,6 +99,8 @@ import org.apache.uima.ducc.ws.DuccMachi
 import org.apache.uima.ducc.ws.MachineInfo;
 import org.apache.uima.ducc.ws.authentication.DuccAsUser;
 import org.apache.uima.ducc.ws.authentication.DuccAuthenticator;
+import org.apache.uima.ducc.ws.cli.json.MachineFacts;
+import org.apache.uima.ducc.ws.cli.json.MachineFactsList;
 import org.apache.uima.ducc.ws.helper.BrokerHelper;
 import org.apache.uima.ducc.ws.helper.DatabaseHelper;
 import org.apache.uima.ducc.ws.helper.DiagnosticsHelper;

Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java?rev=1791186&r1=1791185&r2=1791186&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java Wed Apr 12 21:02:00 2017
@@ -36,10 +36,6 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.uima.ducc.cli.ws.json.MachineFactsList;
-import org.apache.uima.ducc.cli.ws.json.NodePidList;
-import org.apache.uima.ducc.cli.ws.json.ReservationFacts;
-import org.apache.uima.ducc.cli.ws.json.ReservationFactsList;
 import org.apache.uima.ducc.common.ConvertSafely;
 import org.apache.uima.ducc.common.IDuccEnv;
 import org.apache.uima.ducc.common.NodeConfiguration;
@@ -78,6 +74,10 @@ import org.apache.uima.ducc.ws.Info;
 import org.apache.uima.ducc.ws.JobInfo;
 import org.apache.uima.ducc.ws.MachineInfo;
 import org.apache.uima.ducc.ws.ReservationInfo;
+import org.apache.uima.ducc.ws.cli.json.MachineFactsList;
+import org.apache.uima.ducc.ws.cli.json.NodePidList;
+import org.apache.uima.ducc.ws.cli.json.ReservationFacts;
+import org.apache.uima.ducc.ws.cli.json.ReservationFactsList;
 import org.apache.uima.ducc.ws.helper.BrokerHelper;
 import org.apache.uima.ducc.ws.helper.BrokerHelper.FrameworkAttribute;
 import org.apache.uima.ducc.ws.helper.BrokerHelper.JmxKeyWord;

Added: uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/MachineFactsTest.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/MachineFactsTest.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/MachineFactsTest.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/MachineFactsTest.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.test;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.uima.ducc.ws.cli.json.MachineFacts;
+import org.apache.uima.ducc.ws.cli.json.MachineFactsList;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+
+public class MachineFactsTest {
+	
+	private Random random = new Random();
+	
+	private String[] statusSet = { "defined", "down", "up" };
+	private String[] memorySet = { "", "24", "31", "39", "43", "47", "79" };
+	
+	private String createStatus() {
+		int index = random.nextInt(statusSet.length);
+		String status = statusSet[index];
+		return status;
+	}
+	
+	private String createIP() {
+		String ip = "";
+		int type = random.nextInt(10);
+		if(type > 2) {
+			int index = random.nextInt(256);
+			ip = "192.168.5."+index;
+		}
+		return ip;
+	}
+	
+	private String createName() {
+		String name = "node1"+random.nextInt(801);
+		return name;
+	}
+	
+	private String createMemory() {
+		int index = random.nextInt(memorySet.length);
+		String memory = memorySet[index];
+		return memory;
+	}
+	
+	private String createSwap() {
+		String swap = "";
+		int type = random.nextInt(10);
+		if(type > 2) {
+			int index = random.nextInt(10);
+			swap = ""+index;
+		}
+		return swap;
+	}
+	
+	private String createFree() {
+		String free = "";
+		int type = random.nextInt(10);
+		if(type > 2) {
+			int index = random.nextInt(10);
+			free = ""+index;
+		}
+		return free;
+	}
+	
+	private double createCPU() {
+		return random.nextDouble();
+	}
+	
+	private boolean createCgroupsEnabled() {
+		return random.nextBoolean();
+	}
+	
+	private boolean createCgroupsCpuReportingEnabled() {
+		return random.nextBoolean();
+	}
+	
+	private List<String> createAliens() {
+		List<String> aliens = new ArrayList<String>();
+		int count = random.nextInt(10);
+		for(int i=0;i<count;i++) {
+			aliens.add(""+random.nextInt(99999));
+		}
+		return aliens;
+	}
+	
+	private String createHeartbeat() {
+		String heartbeat = "";
+		int type = random.nextInt(100);
+		int beat = random.nextInt(60);
+		if(type > 5) {
+			if(type > 15) {
+				heartbeat = ""+beat;
+			}
+			else {
+				heartbeat = ""+random.nextInt(600)+60;
+			}
+		}
+		return heartbeat;
+	}
+	
+	private MachineFacts createMachineFacts() {
+		String status = createStatus();
+		String ip = createIP();
+		String name = createName();
+		String memTotal = createMemory();
+		String memFree = createMemory();
+		String swap = createSwap();
+		String delta = createSwap();
+		String free = createFree();
+		double cpu = createCPU();
+		boolean cgroupsEnabled = createCgroupsEnabled();
+		boolean cgroupsCpuReportingEnabled = createCgroupsCpuReportingEnabled();
+		List<String> aliens = createAliens();
+		String heartbeat = createHeartbeat();
+		MachineFacts machineFacts = new MachineFacts(status,"",ip,name, memTotal, memFree, swap, delta, free, cpu, cgroupsEnabled, cgroupsCpuReportingEnabled, aliens, heartbeat);
+		return machineFacts;
+	}
+	
+	private MachineFactsList createMachineFactsList() {
+		MachineFactsList machineFactsList = new MachineFactsList();
+		for(int i=0; i<10; i++) {
+			machineFactsList.add(createMachineFacts());
+		} 
+		return machineFactsList;
+	}
+	
+	private boolean compare(MachineFacts m1, MachineFacts m2) {
+		boolean retVal = false;
+		try {
+			if(true
+			&& m1.heartbeat.equals(m2.heartbeat) 
+			&& m1.ip.equals(m2.ip) 
+			&& m1.memTotal.equals(m2.memTotal) 
+			&& m1.memFree.equals(m2.memFree) 
+			&& m1.name.equals(m2.name) 
+			&& m1.status.equals(m2.status) 
+			&& m1.swapInuse.equals(m2.swapInuse) 
+			&& m1.swapDelta.equals(m2.swapDelta) 
+			&& m1.swapFree.equals(m2.swapFree) 
+			) {
+				retVal = true;
+			}
+		}
+		catch(Exception e) {
+		}
+		return retVal;
+	}
+	
+	@BeforeClass
+	public static void setUpBeforeClass() throws Exception {
+	}
+
+	@AfterClass
+	public static void tearDownAfterClass() throws Exception {
+	}
+
+	@Before
+	public void setUp() throws Exception {
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	@Test
+	public void testMachineFacts() {
+		MachineFactsTest machineFactsTest = new MachineFactsTest();
+		MachineFactsList machineFactsList = machineFactsTest.createMachineFactsList();
+		Gson gson = new Gson();
+		String jSon = gson.toJson(machineFactsList);
+		MachineFactsList reconstituted = gson.fromJson(jSon, MachineFactsList.class);
+		for(int i=0; i<machineFactsList.size(); i++) {
+			MachineFacts m1 = machineFactsList.get(i);
+			MachineFacts m2 = reconstituted.get(i);
+			if(!compare(m1,m2)) {
+				fail("missing "+"name="+m1.name);
+			}
+		}
+	}
+
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/MachineFactsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/ReservationFactsTest.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/ReservationFactsTest.java?rev=1791186&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/ReservationFactsTest.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/ReservationFactsTest.java Wed Apr 12 21:02:00 2017
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.ws.test;
+
+import static org.junit.Assert.*;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.uima.ducc.ws.cli.json.NodePidList;
+import org.apache.uima.ducc.ws.cli.json.ReservationFacts;
+import org.apache.uima.ducc.ws.cli.json.ReservationFactsList;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+
+public class ReservationFactsTest {
+	
+	private Random random = new Random();
+	
+	private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss EEE");
+	
+	private String[] rClassSet = { "fixed", "reserve", "reserve-p7", "JobDriver" };
+	private String[] stateSet = { "Assigned", "Completed", "WaitingForResources" };
+	private String[] reasonSet = { "", "CanceledByUser", "CanceledBySystem", "ResourcesUnavailable" };
+	private String[] descriptionSet = { "", "java-remote2", "Trainer:TrainerJob", "ducc!", "Job Driver", "DistributionalSimilaritySemanticAccessServer1", "wics" };
+	
+	private String createId() {
+		return ""+random.nextInt(10000);
+	}
+	
+	private String createStart() {
+		return simpleDateFormat.format(new Date());
+	}
+	
+	private String createEnd() {
+		return simpleDateFormat.format(new Date());
+	}
+	
+	private String createUser() {
+		return "user"+random.nextInt(10);
+	}
+	
+	private String createRclass() {
+		int index = random.nextInt(rClassSet.length);
+		return rClassSet[index];
+	}
+	
+	private String createState() {
+		int index = random.nextInt(stateSet.length);
+		return stateSet[index];
+	}
+	
+	private String createReason() {
+		int index = random.nextInt(reasonSet.length);
+		return reasonSet[index];
+	}
+	
+	private String createAllocation() {
+		return ""+random.nextInt(4);
+	}
+
+	private String createSize() {
+		return ""+(1+random.nextInt(50))+".0";
+	}
+	
+	private List<NodePidList> createUserProcesses() {
+		ArrayList<NodePidList> list = new ArrayList<NodePidList>();
+		int nodeCount = random.nextInt(5);
+		for(int i=0; i<nodeCount; i++) {
+			String node = "node1"+random.nextInt(801);
+			int pidCount = random.nextInt(10);
+			ArrayList<String> pidList = new ArrayList<String>();
+			for(int j=0; j<pidCount; j++) {
+				String pid = ""+random.nextInt(99999);
+				pidList.add(pid);
+			}
+			NodePidList npl = new NodePidList(node,pidList);
+			list.add(npl);
+		}
+		return list;
+	}
+	
+	private List<String> createList() {
+		List<String> list = new ArrayList<String>();
+		return list;
+	}
+	
+	private String createDescription() {
+		int index = random.nextInt(descriptionSet.length);
+		return descriptionSet[index];
+	}
+	
+	private ReservationFacts createReservationFacts() {
+		String id = createId();
+		String start = createStart();
+		String end = createEnd();
+		String user = createUser();
+		String rclass = createRclass();
+		String state = createState();
+		String reason = createReason();
+		String allocation = createAllocation();
+		List<NodePidList> userProcesses = createUserProcesses();
+		String size = createSize();
+		List<String> list = createList();
+		String description = createDescription();
+		
+		ReservationFacts reservationFacts = new ReservationFacts(id,start,end,user,rclass,state,reason,allocation,userProcesses,size,list,description);
+		return reservationFacts;
+	}
+	
+	private ReservationFactsList createReservationFactsList() {
+		ReservationFactsList reservationFactsList = new ReservationFactsList();
+		for(int i=0; i<10; i++) {
+			reservationFactsList.add(createReservationFacts());
+		}
+		return reservationFactsList;
+	}
+	
+	public static void main(String[] args) {
+		ReservationFactsTest reservationFactsTest = new ReservationFactsTest();
+		ReservationFactsList reservationFactsList = reservationFactsTest.createReservationFactsList();
+		Gson gson = new Gson();
+		String jSon = gson.toJson(reservationFactsList);
+		System.out.println(jSon);
+		ReservationFactsList reconstituted = gson.fromJson(jSon, ReservationFactsList.class);
+		for(ReservationFacts reservation : reconstituted) {
+			System.out.println(reservation.id);
+		}
+	}
+	private boolean compare(ReservationFacts r1, ReservationFacts r2) {
+		boolean retVal = false;
+		try {
+			if(true
+			&& r1.allocation.equals(r2.allocation) 
+			&& r1.description.equals(r2.description) 
+			&& r1.end.equals(r2.end) 
+			&& r1.id.equals(r2.id) 
+			&& r1.rclass.equals(r2.rclass) 
+			&& r1.reason.equals(r2.reason) 
+			&& r1.size.equals(r2.size)
+			&& r1.start.equals(r2.start) 
+			&& r1.state.equals(r2.state) 
+			&& r1.user.equals(r2.user) 
+			) {
+				retVal = true;
+			}
+		}
+		catch(Exception e) {
+		}
+		return retVal;
+	}
+	
+	@BeforeClass
+	public static void setUpBeforeClass() throws Exception {
+	}
+
+	@AfterClass
+	public static void tearDownAfterClass() throws Exception {
+	}
+
+	@Before
+	public void setUp() throws Exception {
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	@Test
+	public void test() {
+		ReservationFactsTest reservationFactsTest = new ReservationFactsTest();
+		ReservationFactsList reservationFactsList = reservationFactsTest.createReservationFactsList();
+		Gson gson = new Gson();
+		String jSon = gson.toJson(reservationFactsList);
+		ReservationFactsList reconstituted = gson.fromJson(jSon, ReservationFactsList.class);
+		for(int i=0; i<reservationFactsList.size(); i++) {
+			ReservationFacts r1 = reservationFactsList.get(i);
+			ReservationFacts r2 = reconstituted.get(i);
+			if(!compare(r1,r2)) {
+				fail("missing "+"id="+r1.id);
+			}
+		}
+	}
+
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/test/java/org/apache/uima/ducc/ws/test/ReservationFactsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native