You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2017/04/03 17:17:33 UTC

svn commit: r1790025 - in /uima/uima-ducc/trunk: src/main/resources/ uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/ uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/ uima-ducc-orchestrator/src/main/java/org/apache/uima...

Author: degenaro
Date: Mon Apr  3 17:17:33 2017
New Revision: 1790025

URL: http://svn.apache.org/viewvc?rev=1790025&view=rev
Log:
UIMA-4883 DUCC system events log

In particular, RM CLI/API requests via AMQ to OR, then AMQ to RM.

Modified:
    uima/uima-ducc/trunk/src/main/resources/default.ducc.properties
    uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java
    uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/IDuccLoggerComponents.java
    uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java
    uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java
    uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java

Modified: uima/uima-ducc/trunk/src/main/resources/default.ducc.properties
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/src/main/resources/default.ducc.properties?rev=1790025&r1=1790024&r2=1790025&view=diff
==============================================================================
--- uima/uima-ducc/trunk/src/main/resources/default.ducc.properties (original)
+++ uima/uima-ducc/trunk/src/main/resources/default.ducc.properties Mon Apr  3 17:17:33 2017
@@ -737,6 +737,12 @@ ducc.rm.admin.endpoint = ducc.rm.admin.c
 # This is the JMS endpoint type used for RM administrative requests.
 ducc.rm.admin.endpoint.type = queue
 
+# This JMS endpoint used for RM administrative requests.
+ducc.rm.via.or.admin.endpoint = ducc.rm.via.or.admin.channel
+
+# This is the JMS endpoint type used for RM administrative requests.
+ducc.rm.via.or.admin.endpoint.type = queue
+
 # Unmanaged Reservations are usually assigned to machines whose size exactly matches the 
 # requested size, after rounding up to a multiple of the node pool's quantum.
 # When this property is positive, machines up to this many GB larger than the rounded up

Modified: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java?rev=1790025&r1=1790024&r2=1790025&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java Mon Apr  3 17:17:33 2017
@@ -67,6 +67,9 @@ import com.thoughtworks.xstream.security
  * The use of this class's Java API is intended for DUCC System programming, and requires
  * the Camel, Spring, ActiveMQ, and Log4j classes in the classpath, as well as the DUCC
  * Transport and Common jars.
+ * 
+ * Requests that are destined for the RM are routed through the OR for recording in the
+ * system-events.log using ducc.rm.via.or.admin.endpoint specified in default.ducc.properties.
  */ 
 public class DuccRmAdmin 
     extends AbstractDuccComponent 
@@ -87,7 +90,7 @@ public class DuccRmAdmin
      * @param context This is the Camel context to use.  Usually it is sufficient to simply provide
      *                <code>new DefaultCamelContext()</code>.
      * @param epname  This is the RM JMS endpoint as configured in ducc.properties.  Usually it is
-     *                sufficient to provide <code>ducc.rm.admin.endpoint</code>.
+     *                sufficient to provide <code>ducc.rm.via.or.admin.endpoint</code>.
      */
 	public DuccRmAdmin(CamelContext context, String epname)
     {
@@ -107,7 +110,7 @@ public class DuccRmAdmin
 				// the admin events will be sent by the DuccServiceReaper
 				targetEndpoint = System.getProperty(epname);
                 if ( targetEndpoint == null ) {
-                    throw new IllegalArgumentException("Cannot find endpoint for RM admin.  Is 'ducc.rm.admin.endpoint' configured n ducc.properties?");
+                    throw new IllegalArgumentException("Cannot find endpoint for RM admin.  Is 'ducc.rm.via.or.admin.endpoint' configured n ducc.properties?");
                 }
 
 				// System.out.println("+++ Activating JMS Component for Endpoint:" + targetEndpoint + " Broker:" + brokerUrl);
@@ -190,7 +193,7 @@ public class DuccRmAdmin
 
 	 * @throws Exception if anything goes wrong in transmission or receipt of the request.
      */
-    private RmAdminReply dispatchAndWaitForReply(DuccAdminEvent duccEvent) 
+    public RmAdminReply dispatchAndWaitForReply(DuccAdminEvent duccEvent) 
         throws Exception 
     {
         int maxRetryCount = 20;
@@ -400,7 +403,7 @@ public class DuccRmAdmin
     {
 		int rc = 0;
 		try {
-			DuccRmAdmin admin = new DuccRmAdmin(new DefaultCamelContext(), "ducc.rm.admin.endpoint");
+			DuccRmAdmin admin = new DuccRmAdmin(new DefaultCamelContext(), "ducc.rm.via.or.admin.endpoint");
             rc = admin.run(args);
 		} catch (Throwable e) {
 			e.printStackTrace();

Modified: uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/IDuccLoggerComponents.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/IDuccLoggerComponents.java?rev=1790025&r1=1790024&r2=1790025&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/IDuccLoggerComponents.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/IDuccLoggerComponents.java Mon Apr  3 17:17:33 2017
@@ -25,6 +25,7 @@ public interface IDuccLoggerComponents {
 	public final String abbrv_orchestrator = "OR";
 	//public final String abbrv_transport = "TR";
 	public final String abbrv_servicesManager = "SM";
+	public final String abbrv_resourceManager = "RM";
 	public final String abbrv_webServer = "WS";
 	
 	public final String abbrv_user = "Us";

Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java?rev=1790025&r1=1790024&r2=1790025&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java Mon Apr  3 17:17:33 2017
@@ -25,14 +25,20 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.uima.ducc.common.NodeIdentity;
 import org.apache.uima.ducc.common.admin.event.DuccAdminEvent;
+import org.apache.uima.ducc.common.admin.event.RmAdminReply;
 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;
 import org.apache.uima.ducc.common.crypto.Crypto;
 import org.apache.uima.ducc.common.crypto.CryptoException;
 import org.apache.uima.ducc.common.internationalization.Messages;
+import org.apache.uima.ducc.common.main.DuccRmAdmin;
 import org.apache.uima.ducc.common.main.DuccService;
 import org.apache.uima.ducc.common.system.SystemState;
 import org.apache.uima.ducc.common.utils.DuccLogger;
@@ -54,8 +60,8 @@ import org.apache.uima.ducc.orchestrator
 import org.apache.uima.ducc.transport.event.CancelJobDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelReservationDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelServiceDuccEvent;
-import org.apache.uima.ducc.transport.event.DuccWorkRequestEvent;
 import org.apache.uima.ducc.transport.event.DuccEvent.EventType;
+import org.apache.uima.ducc.transport.event.DuccWorkRequestEvent;
 import org.apache.uima.ducc.transport.event.IDuccContext.DuccContext;
 import org.apache.uima.ducc.transport.event.JdRequestEvent;
 import org.apache.uima.ducc.transport.event.NodeInventoryUpdateDuccEvent;
@@ -331,6 +337,17 @@ implements Orchestrator {
 			logger.error(methodName, null, t);
 		}
 		super.start(service, args);
+		
+		/*
+		 * Route requests destined for RM though OR for recording in system-events.log.
+		 */
+		String adminEndpoint = System.getProperty("ducc.rm.via.or.admin.endpoint");
+        if ( adminEndpoint == null ) {
+            logger.warn(methodName, null, "No admin endpoint configured.  Not starting admin channel.");
+        } else {
+            startRmAdminChannel(adminEndpoint, this);
+        }
+		
 		DuccDaemonRuntimeProperties.getInstance().boot(DaemonName.Orchestrator,getProcessJmxUrl());
 		SystemEventsLogger.warn(IDuccLoggerComponents.abbrv_orchestrator, EventType.BOOT.name(), "");
 		logger.trace(methodName, null, messages.fetch("exit"));
@@ -1051,4 +1068,86 @@ implements Orchestrator {
 		logger.trace(methodName, dwid, messages.fetch("exit"));
 		return;
 	}
+	
+	//==================================================
+	
+	/**
+	 * See ResourceManagerComponent.  This code is a replication of that code for 
+	 * the purpose of routing requests CLI/API -> OR -> RM to support a single point
+	 * of entry and to record request/responses in the system-events.log.
+	 */
+	
+	private String RMAdminRoute = "RMAdminRoute";
+	
+    /**
+     * Creates Camel Router for Ducc RM admin events.
+     * 
+     * @param endpoint
+     *          - ducc admin endpoint
+     * @param delegate
+     *          - who to call when admin event arrives
+     * @throws Exception
+     */
+    private void startRmAdminChannel(final String endpoint, final AbstractDuccComponent delegate)
+        throws Exception 
+    {
+    	String methodName = "startRmAdminChannel";
+        getContext().addRoutes(new RouteBuilder() {
+                public void configure() {
+                	String methodName = "startRmAdminChannel.configure";
+                	if (logger != null) {
+                        logger.info(methodName, null, "Admin Channel Configure on endpoint:" + endpoint);
+                    }
+                    onException(Exception.class).handled(true).process(new ErrorProcessor());
+                    
+                    from(endpoint).routeId(RMAdminRoute).unmarshal().xstream()
+                         .process(new RmAdminEventProcessor(delegate));
+                }
+            });
+
+        getContext().startRoute(RMAdminRoute);
+        if (logger != null) {
+            logger.info(methodName, null, "Admin Channel Activated on endpoint:" + endpoint);
+        }
+    }
+
+    class RmAdminEventProcessor implements Processor 
+    {
+        final AbstractDuccComponent delegate;
+
+        private DuccRmAdmin admin = new DuccRmAdmin(new DefaultCamelContext(), "ducc.rm.admin.endpoint");
+        
+        public RmAdminEventProcessor(final AbstractDuccComponent delegate) 
+        {
+            this.delegate = delegate;
+        }
+
+        public void process(final Exchange exchange) 
+            throws Exception 
+        {            
+            String location = "RmAdminEventProcessor.process";
+            Object body = exchange.getIn().getBody();
+            logger.info(location, jobid, "Received Admin Message of Type:",  body.getClass().getName());
+            RmAdminReply reply = null;
+            if ( body instanceof DuccAdminEvent ) {
+                DuccAdminEvent dae = (DuccAdminEvent) body;
+                try {
+                	logger.debug(location, jobid, "dispatch");
+                	SystemEventsLogger.info(IDuccLoggerComponents.abbrv_resourceManager, dae);
+                	reply = admin.dispatchAndWaitForReply(dae);
+                	logger.debug(location, jobid, "dispatch completed");
+                	SystemEventsLogger.info(IDuccLoggerComponents.abbrv_resourceManager, dae, reply);
+                }
+                catch(Exception e) {
+                	logger.error(location, jobid, e);
+                }
+            } 
+            else {
+                logger.info(location, jobid, "Invalid RM event:", body.getClass().getName());
+                reply = new RmAdminReply();
+                reply.setMessage("Unrecognized RM event.");
+            }
+            exchange.getIn().setBody(reply);
+        }
+    }
 }

Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java?rev=1790025&r1=1790024&r2=1790025&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/config/OrchestratorConfiguration.java Mon Apr  3 17:17:33 2017
@@ -230,6 +230,7 @@ public class OrchestratorConfiguration {
 			// - send HTTP response back to CLI/API
 			if(obj instanceof AServiceRequest) {
 				AServiceRequest serviceRequest = exchange.getIn().getBody(AServiceRequest.class);
+				SystemEventsLogger.info(IDuccLoggerComponents.abbrv_servicesManager, serviceRequest);
 				ServiceReplyEvent serviceReply = serviceRequest.getReply();
 				exchange.getIn().setBody(serviceReply);
 				SystemEventsLogger.info(IDuccLoggerComponents.abbrv_servicesManager, serviceRequest, serviceReply);

Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java?rev=1790025&r1=1790024&r2=1790025&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java Mon Apr  3 17:17:33 2017
@@ -6,6 +6,8 @@ package org.apache.uima.ducc.orchestrato
  */
 import java.util.Properties;
 
+import org.apache.uima.ducc.common.admin.event.DuccAdminEvent;
+import org.apache.uima.ducc.common.admin.event.RmAdminReply;
 import org.apache.uima.ducc.transport.event.AServiceRequest;
 import org.apache.uima.ducc.transport.event.CancelJobDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelJobReplyDuccEvent;
@@ -221,7 +223,18 @@ public class SystemEventsLogger {
 	}
 	
 	/*
-	 * log a services request
+	 * log a service manager request
+	 */
+	public static void info(String daemon, AServiceRequest request) {
+		String user = request.getUser();
+		String type = request.getEventType().name();
+		String message = "request";
+		Object[] event = { message };
+		duccLogger.event_info(daemon, user, type, event);
+	}
+	
+	/*
+	 * log a service manager response
 	 */
 	public static void info(String daemon, AServiceRequest request, ServiceReplyEvent response) {
 		String user = request.getUser();
@@ -229,8 +242,40 @@ public class SystemEventsLogger {
 		long id = response.getId();
 		boolean rc = response.getReturnCode();
 		String message = response.getMessage();
-		Object[] event = { "id:"+id, "rc:"+rc, message};
+		Object[] event = { "id:"+id, "rc:"+rc, message };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
+	/*
+	 * log a resource manager request
+	 */
+	public static void info(String daemon, DuccAdminEvent request) {
+		String user = request.getUser();
+		String type = request.getClass().getSimpleName();
+		String message = "request";
+		Object[] event = { message };
+		duccLogger.event_info(daemon, user, type, event);
+	}
+	
+	/*
+	 * log a resource manager response
+	 */
+	public static void info(String daemon, DuccAdminEvent request, RmAdminReply response) {
+		String user = request.getUser();
+		String type = request.getClass().getSimpleName();
+		String message = normalize(response.getMessage());
+		Object[] event = { "response: "+message };
+		duccLogger.event_info(daemon, user, type, event);
+	}
+	
+	/*
+	 * normalize message
+	 */
+	private static String normalize(String message) {
+		String text = "";
+		if(message != null) {
+			text = message.trim();
+		}
+		return text;
+	}
 }