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/05/20 21:01:48 UTC

svn commit: r1744796 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi: ActionGet.java IMetaMetaCas.java MetaMetaCas.java

Author: degenaro
Date: Fri May 20 21:01:48 2016
New Revision: 1744796

URL: http://svn.apache.org/viewvc?rev=1744796&view=rev
Log:
UIMA-4938 DUCC Job Driver (JD) erroneously determines: fewer work items than expected

- fetch MetaCas and corresponding CasManager status together under synchronization, to avoid partial truths leading to erroneous prematurity determination

Added:
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/IMetaMetaCas.java   (with props)
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/MetaMetaCas.java   (with props)
Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/ActionGet.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/ActionGet.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/ActionGet.java?rev=1744796&r1=1744795&r2=1744796&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/ActionGet.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/ActionGet.java Fri May 20 21:01:48 2016
@@ -58,6 +58,7 @@ public class ActionGet implements IActio
 	private ConcurrentHashMap<IRemoteWorkerProcess, Long> warnedJobDiscontinued = new ConcurrentHashMap<IRemoteWorkerProcess, Long>();
 	private ConcurrentHashMap<IRemoteWorkerProcess, Long> warnedProcessDiscontinued = new ConcurrentHashMap<IRemoteWorkerProcess, Long>();
 	private ConcurrentHashMap<IRemoteWorkerProcess, Long> warnedExhausted = new ConcurrentHashMap<IRemoteWorkerProcess, Long>();
+	private ConcurrentHashMap<IRemoteWorkerProcess, Long> warnedPremature = new ConcurrentHashMap<IRemoteWorkerProcess, Long>();
 	
 	private String allCasesProcessed = "all CASes processed";
 	private String fewerWorkItemsAvailableThanExpected = "fewer work items available than expected";
@@ -126,21 +127,38 @@ public class ActionGet implements IActio
 		}
 		return metaCas;
 	}
+
+	/**
+	 * Get MetaCas and CasManager status together
+	 * (under synchronization for consistency!)
+	 */
 	
-	private IMetaCas getMetaCas(IActionData actionData) throws JobDriverException {
-		IMetaCas metaCas = null;
+	private synchronized IMetaMetaCas getMetaMetaCas(IActionData actionData) throws JobDriverException {
+		IMetaMetaCas mmc = new MetaMetaCas();
 		JobDriver jd = JobDriver.getInstance();
 		CasManager cm = jd.getCasManager();
-		while(true) {
-			try {
-				metaCas = cm.getMetaCas();
-				break;
-			}
-			catch(ProxyException e) {
-				handleException(actionData, e);
+		// get status
+		mmc.setExhausted(cm.getCasManagerStats().isExhausted());
+		mmc.setPremature(cm.getCasManagerStats().isPremature());
+		mmc.setKillJob(cm.getCasManagerStats().isKillJob());
+		// if CASes are still possible, attempt fetch
+		if(!mmc.isExhausted() && !mmc.isPremature() && !mmc.isKillJob()) {
+			while(true) {
+				try {
+					// fetch CAS
+					mmc.setMetaCas(cm.getMetaCas());
+					// update status
+					mmc.setExhausted(cm.getCasManagerStats().isExhausted());
+					mmc.setPremature(cm.getCasManagerStats().isPremature());
+					mmc.setKillJob(cm.getCasManagerStats().isKillJob());
+					break;
+				}
+				catch(ProxyException e) {
+					handleException(actionData, e);
+				}
 			}
 		}
-		return metaCas;
+		return mmc;
 	}
 	
 	@Override
@@ -160,10 +178,10 @@ public class ActionGet implements IActio
 				JobDriver jd = JobDriver.getInstance();
 				JobDriverHelper jdh = JobDriverHelper.getInstance();
 				jd.advanceJdState(JdState.Active);
-				CasManager cm = jd.getCasManager();
 				IMetaCas metaCas = null;
 				JobProcessBlacklist jobProcessBlacklist = JobProcessBlacklist.getInstance();
-				if(cm.getCasManagerStats().isExhausted()) {
+				IMetaMetaCas mmc = getMetaMetaCas(actionData);
+				if(mmc.isExhausted()) {
 					if(!warnedExhausted.containsKey(rwp)) {
 						MessageBuffer mbx = LoggerHelper.getMessageBuffer(actionData);
 						mbx.append(Standardize.Label.node.get()+rwp.getNodeName());
@@ -174,7 +192,7 @@ public class ActionGet implements IActio
 					}
 					TransactionHelper.addResponseHint(trans, Hint.Exhausted);
 				}
-				if(cm.getCasManagerStats().isPremature()) {
+				if(mmc.isPremature()) {
 					if(!warnedExhausted.containsKey(rwp)) {
 						String text = fewerWorkItemsAvailableThanExpected;
 						jd.killJob(CompletionType.Exception, text);
@@ -187,7 +205,7 @@ public class ActionGet implements IActio
 					}
 					TransactionHelper.addResponseHint(trans, Hint.Premature);
 				}
-				else if(cm.getCasManagerStats().isKillJob()) {
+				else if(mmc.isKillJob()) {
 					if(!warnedJobDiscontinued.containsKey(rwp)) {
 						MessageBuffer mb = LoggerHelper.getMessageBuffer(actionData);
 						mb.append(Standardize.Label.node.get()+rwp.getNodeName());
@@ -210,7 +228,7 @@ public class ActionGet implements IActio
 					TransactionHelper.addResponseHint(trans, Hint.Blacklisted);
 				}
 				else {
-					metaCas = getMetaCas(actionData);
+					metaCas = mmc.getMetaCas();
 				}
 				wi.setMetaCas(metaCas);
 				trans.setMetaCas(metaCas);
@@ -241,19 +259,19 @@ public class ActionGet implements IActio
 					MessageBuffer mb = LoggerHelper.getMessageBuffer(actionData);
 					mb.append("No CAS found for processing");
 					logger.debug(location, ILogger.null_id, mb.toString());
-					if(cm.getCasManagerStats().isExhausted()) {
+					if(mmc.isExhausted()) {
 						if(!warnedExhausted.containsKey(rwp)) {
 							MessageBuffer mbx = LoggerHelper.getMessageBuffer(actionData);
 							mbx.append(Standardize.Label.node.get()+rwp.getNodeName());
 							mbx.append(Standardize.Label.pid.get()+rwp.getPid());
 							mbx.append(Standardize.Label.text.get()+allCasesProcessed);
-							logger.debug(location, ILogger.null_id, mbx.toString());
+							logger.warn(location, ILogger.null_id, mbx.toString());
 							warnedExhausted.put(rwp, new Long(System.currentTimeMillis()));
 						}
 						TransactionHelper.addResponseHint(trans, Hint.Exhausted);
 					}
-					if(cm.getCasManagerStats().isPremature()) {
-						if(!warnedExhausted.containsKey(rwp)) {
+					if(mmc.isPremature()) {
+						if(!warnedPremature.containsKey(rwp)) {
 							String text = fewerWorkItemsAvailableThanExpected;
 							jd.killJob(CompletionType.Exception, text);
 							MessageBuffer mbx = LoggerHelper.getMessageBuffer(actionData);
@@ -261,7 +279,7 @@ public class ActionGet implements IActio
 							mbx.append(Standardize.Label.pid.get()+rwp.getPid());
 							mbx.append(Standardize.Label.text.get()+text);
 							logger.debug(location, ILogger.null_id, mbx.toString());
-							warnedExhausted.put(rwp, new Long(System.currentTimeMillis()));
+							warnedPremature.put(rwp, new Long(System.currentTimeMillis()));
 						}
 						TransactionHelper.addResponseHint(trans, Hint.Premature);
 					}

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/IMetaMetaCas.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/IMetaMetaCas.java?rev=1744796&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/IMetaMetaCas.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/IMetaMetaCas.java Fri May 20 21:01:48 2016
@@ -0,0 +1,40 @@
+/*
+ * 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.container.jd.fsm.wi;
+
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+
+/**
+ * An interface for storing MetaCAS 
+ * and CasManager status together
+ */
+public interface IMetaMetaCas {
+
+	public boolean isExhausted();
+	public void setExhausted(boolean value);
+	
+	public boolean isPremature();
+	public void setPremature(boolean value);
+	
+	public boolean isKillJob();
+	public void setKillJob(boolean value);
+	
+	public IMetaCas getMetaCas();
+	public void setMetaCas(IMetaCas value);
+}

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/IMetaMetaCas.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/IMetaMetaCas.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/MetaMetaCas.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/MetaMetaCas.java?rev=1744796&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/MetaMetaCas.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/MetaMetaCas.java Fri May 20 21:01:48 2016
@@ -0,0 +1,79 @@
+/*
+ * 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.container.jd.fsm.wi;
+
+import org.apache.uima.ducc.container.net.iface.IMetaCas;
+
+/**
+ * An implementation for storing MetaCAS 
+ * and CasManager status together
+ */
+
+public class MetaMetaCas implements IMetaMetaCas {
+
+	private boolean exhausted;
+	private boolean premature;
+	private boolean killJob;
+	
+	private IMetaCas metaCas;
+	
+	public MetaMetaCas() {
+	}
+	
+	@Override
+	public boolean isExhausted() {
+		return exhausted;
+	}
+
+	@Override
+	public void setExhausted(boolean value) {
+		exhausted = value;
+	}
+
+	@Override
+	public boolean isPremature() {
+		return premature;
+	}
+
+	@Override
+	public void setPremature(boolean value) {
+	premature = value;
+	}
+
+	@Override
+	public boolean isKillJob() {
+		return killJob;
+	}
+
+	@Override
+	public void setKillJob(boolean value) {
+		killJob = value;
+	}
+
+	@Override
+	public IMetaCas getMetaCas() {
+		return metaCas;
+	}
+
+	@Override
+	public void setMetaCas(IMetaCas value) {
+		metaCas = value;
+	}
+
+}

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/MetaMetaCas.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/fsm/wi/MetaMetaCas.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain