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 2016/10/19 13:49:59 UTC

svn commit: r1765594 - in /uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm: ServiceManagerComponent.java ServiceManagerHelper.java

Author: degenaro
Date: Wed Oct 19 13:49:59 2016
New Revision: 1765594

URL: http://svn.apache.org/viewvc?rev=1765594&view=rev
Log:
UIMA-5060 DUCC Orchestrator (OR) "warm" restart issues

- for restoration of next service sequence number, use the greater of seqno in state/sm.properties and registry from database comprising services
- log a WARNing in or.log if services data is used

Added:
    uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerHelper.java   (with props)
Modified:
    uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerComponent.java

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=1765594&r1=1765593&r2=1765594&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 Oct 19 13:49:59 2016
@@ -91,17 +91,18 @@ public class ServiceManagerComponent
 	 * 
 	 */
 	private static DuccLogger logger = DuccLogger.getLogger(ServiceManagerComponent.class.getName(), COMPONENT_NAME);	
-    DuccWorkMap localMap = null;
+	private static DuccId jobid = null;
+	
+	private DuccWorkMap localMap = null;
 
     private DuccEventDispatcher eventDispatcher;
     private String stateEndpoint;
 
     private ServiceHandler handler = null;
-    IStateServices stateHandler = null;
+    private IStateServices stateHandler = null;
 
     //HashMap<String, BaseUimaAsService> services = new HashMap<String, BaseUimaAsService>();	
 
-
     static int meta_ping_rate = 60000;       // interval in ms to ping the service
     static int meta_ping_stability = 5;           // number of missed pings before we mark the service down
     static int meta_ping_timeout = 500;      // timeout on ping 
@@ -123,7 +124,7 @@ public class ServiceManagerComponent
     private boolean testmode = false;
     private boolean orchestrator_alive = false;
 
-    Map<String, String> administrators = new HashMap<String, String>();
+    private Map<String, String> administrators = new HashMap<String, String>();
 
     // Local SM version
     //    1.1.0 - reworked SM
@@ -131,7 +132,7 @@ public class ServiceManagerComponent
     //    1.1.4 - dynamic mod of all registration parms.  Add debug and max-init-time parms.
     //    1.1.0 - resync with release, sigh.
     //    2.0.0 - Update for new release.
-    String version = "2.1.0";
+    private String version = "2.1.0";
 
 	public ServiceManagerComponent(CamelContext context) 
     {
@@ -242,6 +243,12 @@ public class ServiceManagerComponent
             }
         } 
 
+        long dbSeqNo = ServiceManagerHelper.getLargestServiceSeqNo();
+        if(dbSeqNo > seq) {
+        	logger.warn(methodName, jobid, "file:"+seq+" "+"db:"+dbSeqNo);
+        	seq = (int) dbSeqNo;
+        }
+        
         idFactory = new DuccIdFactory(seq);
 
         synchronized(this) {

Added: uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerHelper.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerHelper.java?rev=1765594&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerHelper.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerHelper.java Wed Oct 19 13:49:59 2016
@@ -0,0 +1,53 @@
+/*
+ * 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.util.NavigableSet;
+
+import org.apache.uima.ducc.common.persistence.services.IStateServices;
+import org.apache.uima.ducc.common.persistence.services.StateServicesDirectory;
+import org.apache.uima.ducc.common.persistence.services.StateServicesFactory;
+import org.apache.uima.ducc.common.utils.DuccLogger;
+import org.apache.uima.ducc.common.utils.id.DuccId;
+
+public class ServiceManagerHelper {
+
+	private static DuccLogger logger = DuccLogger.getLogger(ServiceManagerHelper.class.getName(), SmConstants.COMPONENT_NAME);	
+    private static DuccId jobid = null;
+	
+    /**
+     * fetch largest service sequence number from database
+     */
+    public static long getLargestServiceSeqNo() {
+    	String location = "getLargestServiceSeqNo";
+    	long seqno = -1;
+    	try {
+    		IStateServices iss = StateServicesFactory.getInstance(ServiceManagerHelper.class.getName(), SmConstants.COMPONENT_NAME);
+    		StateServicesDirectory ssd = iss.getStateServicesDirectory();
+    		NavigableSet<Long> keys = ssd.getDescendingKeySet();
+    		if(!keys.isEmpty()) {
+    			seqno = keys.first();
+    		}
+    	}
+    	catch(Exception e) {
+    		logger.error(location, jobid, e);
+    	}
+    	return seqno;
+    }
+}

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

Propchange: uima/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceManagerHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain