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 2015/09/23 21:51:51 UTC
svn commit: r1704926 - in /uima/sandbox/uima-ducc/trunk:
uima-ducc-common/src/main/java/org/apache/uima/ducc/common/
uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/
Author: degenaro
Date: Wed Sep 23 19:51:47 2015
New Revision: 1704926
URL: http://svn.apache.org/viewvc?rev=1704926&view=rev
Log:
UIMA-4532 DUCC OR+WS expunge "shares"
fix: employ environment variable DUCC_TOLERATE_SERIAL_VERSION_UID_MISMATCH that defaults to False unless a Boolean-izable corresponding string value is specified
Added:
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/DuccEnvironmentHelper.java (with props)
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/HistoryPersistenceManager.java
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/DuccEnvironmentHelper.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/DuccEnvironmentHelper.java?rev=1704926&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/DuccEnvironmentHelper.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/DuccEnvironmentHelper.java Wed Sep 23 19:51:47 2015
@@ -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.common;
+
+import java.util.Map;
+
+import org.apache.uima.ducc.common.main.DuccService;
+import org.apache.uima.ducc.common.utils.DuccLogger;
+import org.apache.uima.ducc.common.utils.id.DuccId;
+
+public class DuccEnvironmentHelper {
+
+ private static DuccLogger logger = DuccService.getDuccLogger(DuccEnvironmentHelper.class.getName());
+ private static DuccId jobId = null;
+
+ // Boolean
+
+ public static String DUCC_TOLERATE_SERIAL_VERSION_UID_MISMATCH = "DUCC_TOLERATE_SERIAL_VERSION_UID_MISMATCH";
+
+ private static Boolean tolerate_serial_version_uid_mismatch = null;
+
+ public static boolean isTolerateSerialVersionUidMismatch() {
+ String location = "isTolerateSerialVersionUidMismatch";
+ boolean retVal = false;
+ if(tolerate_serial_version_uid_mismatch == null) {
+ try {
+ Map<String, String> env = System.getenv();
+ if(env != null) {
+ String key = DUCC_TOLERATE_SERIAL_VERSION_UID_MISMATCH;
+ if(env.containsKey(key)) {
+ String value = env.get(key);
+ logger.info(location, jobId, key+"="+value);
+ if(value != null) {
+ tolerate_serial_version_uid_mismatch = Boolean.valueOf(value);
+ retVal = tolerate_serial_version_uid_mismatch.booleanValue();
+ }
+ }
+ else {
+ logger.debug(location, jobId, key+" "+"not found in environment");
+ }
+ }
+ }
+ catch(Exception e) {
+ logger.error(location, jobId, e);
+ }
+ }
+ else {
+ retVal = tolerate_serial_version_uid_mismatch.booleanValue();
+ }
+ return retVal;
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/DuccEnvironmentHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/DuccEnvironmentHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/HistoryPersistenceManager.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/HistoryPersistenceManager.java?rev=1704926&r1=1704925&r2=1704926&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/HistoryPersistenceManager.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/HistoryPersistenceManager.java Wed Sep 23 19:51:47 2015
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,6 +30,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import org.apache.uima.ducc.common.DuccEnvironmentHelper;
import org.apache.uima.ducc.common.IDuccEnv;
import org.apache.uima.ducc.common.main.DuccService;
import org.apache.uima.ducc.common.utils.DuccLogger;
@@ -79,7 +81,18 @@ public class HistoryPersistenceManager i
String retVal = id;
return retVal;
}
-
+
+ private ObjectInputStream getObjectInputStream(FileInputStream fis) throws SecurityException, IOException {
+ ObjectInputStream retVal = null;
+ if(DuccEnvironmentHelper.isTolerateSerialVersionUidMismatch()) {
+ retVal = new DeserializerObjectInputStream(fis);
+ }
+ else {
+ retVal = new ObjectInputStream(fis);
+ }
+ return retVal;
+ }
+
public void saveJob(IDuccWorkJob duccWorkJob) throws IOException {
String id = normalize(""+duccWorkJob.getDuccId().getFriendly());
String fileName = historyDirectory_jobs+File.separator+id+"."+dwj;
@@ -139,9 +152,9 @@ public class HistoryPersistenceManager i
String fileName = ""+duccid + "." + dwj;
logger.trace(location, new DuccId(duccid), fileName);
FileInputStream fis = null;
- DeserializerObjectInputStream in = null;
+ ObjectInputStream in = null;
fis = new FileInputStream(historyDirectory_jobs+File.separator+fileName);
- in = new DeserializerObjectInputStream(fis);
+ in = getObjectInputStream(fis);
job = (IDuccWorkJob) in.readObject();
in.close();
}
@@ -256,11 +269,11 @@ public class HistoryPersistenceManager i
IDuccWorkReservation reservation = null;
try {
FileInputStream fis = null;
- DeserializerObjectInputStream in = null;
+ ObjectInputStream in = null;
String fileName = ""+duccid + "." + dwr;
logger.trace(location, new DuccId(duccid), fileName);
fis = new FileInputStream(historyDirectory_reservations+File.separator+fileName);
- in = new DeserializerObjectInputStream(fis);
+ in = getObjectInputStream(fis);
reservation = (IDuccWorkReservation) in.readObject();
in.close();
}
@@ -395,11 +408,11 @@ public class HistoryPersistenceManager i
IDuccWorkService service = null;
try {
FileInputStream fis = null;
- DeserializerObjectInputStream in = null;
+ ObjectInputStream in = null;
String fileName = ""+duccid + "." + dws;
logger.trace(location, new DuccId(duccid), fileName);
fis = new FileInputStream(historyDirectory_services+File.separator+fileName);
- in = new DeserializerObjectInputStream(fis);
+ in = getObjectInputStream(fis);
service = (IDuccWorkService) in.readObject();
in.close();
}
@@ -483,9 +496,9 @@ public class HistoryPersistenceManager i
try {
logger.trace(methodName, null, "restore:"+fileName);
FileInputStream fis = null;
- DeserializerObjectInputStream in = null;
+ ObjectInputStream in = null;
fis = new FileInputStream(historyDirectory_services+File.separator+fileName);
- in = new DeserializerObjectInputStream(fis);
+ in = getObjectInputStream(fis);
service = (IDuccWorkService) in.readObject();
in.close();
}