Author: degenaro Date: Wed Sep 23 13:59:59 2015 New Revision: 1704855 URL: http://svn.apache.org/viewvc?rev=1704855&view=rev Log: UIMA-4532 DUCC OR+WS expunge "shares"
fix: unable to restore Jobs/Services due to serial UID mismatch Added: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/DeserializerObjectInputStream.java (with props) Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/JavaCommandLine.java uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/NonJavaCommandLine.java uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccSchedulingInfo.java uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/HistoryPersistenceManager.java Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/JavaCommandLine.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/JavaCommandLine.java?rev=1704855&r1=1704854&r2=1704855&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/JavaCommandLine.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/JavaCommandLine.java Wed Sep 23 13:59:59 2015 @@ -21,8 +21,10 @@ package org.apache.uima.ducc.transport.c import java.util.ArrayList; import java.util.List; -@SuppressWarnings("serial") public class JavaCommandLine extends ACommandLine { + + private static final long serialVersionUID = 1L; + private String className; private String classpath; protected List<String> options = new ArrayList<String>(); Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/NonJavaCommandLine.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/NonJavaCommandLine.java?rev=1704855&r1=1704854&r2=1704855&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/NonJavaCommandLine.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/cmdline/NonJavaCommandLine.java Wed Sep 23 13:59:59 2015 @@ -18,8 +18,10 @@ */ package org.apache.uima.ducc.transport.cmdline; -@SuppressWarnings("serial") public class NonJavaCommandLine extends ACommandLine { + + private static final long serialVersionUID = 1L; + public NonJavaCommandLine(String executable) { super(executable); } Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccSchedulingInfo.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/DuccSchedulingInfo.java?rev=1704855&r1=1704854&r2=1704855&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccSchedulingInfo.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/DuccSchedulingInfo.java Wed Sep 23 13:59:59 2015 @@ -210,7 +210,14 @@ public class DuccSchedulingInfo implemen public long getLongProcessesMax() { - return Long.parseLong(processesMax); + long retVal = 0; + try { + retVal = Long.parseLong(processesMax); + } + catch(Exception e) { + + } + return retVal; } Added: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/DeserializerObjectInputStream.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/DeserializerObjectInputStream.java?rev=1704855&view=auto ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/DeserializerObjectInputStream.java (added) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/DeserializerObjectInputStream.java Wed Sep 23 13:59:59 2015 @@ -0,0 +1,66 @@ +/* + * 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.transport.event.common.history; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; + +import org.apache.uima.ducc.common.main.DuccService; +import org.apache.uima.ducc.common.utils.DuccLogger; + +public class DeserializerObjectInputStream extends ObjectInputStream { + + private DuccLogger logger = DuccService + .getDuccLogger(DeserializerObjectInputStream.class.getName()); + + protected DeserializerObjectInputStream(InputStream is) throws IOException, + SecurityException { + super(is); + } + + protected ObjectStreamClass readClassDescriptor() throws IOException, + ClassNotFoundException { + String location = "readClassDescriptor"; + ObjectStreamClass resultClassDescriptor = super.readClassDescriptor(); // initially streams descriptor + @SuppressWarnings("rawtypes") + Class localClass; // the class in the local JVM that this descriptor represents. + try { + localClass = Class.forName(resultClassDescriptor.getName()); + } catch (ClassNotFoundException e) { + String text = "No local class for " + resultClassDescriptor.getName(); + logger.error(location, null, text, e); + return resultClassDescriptor; + } + ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass); + if (localClassDescriptor != null) { // only if class implements serializable + final long localSUID = localClassDescriptor.getSerialVersionUID(); + final long streamSUID = resultClassDescriptor.getSerialVersionUID(); + if (streamSUID != localSUID) { // check for serialVersionUID mismatch. + final StringBuffer sb = new StringBuffer("Overriding serialized class version mismatch: "); + sb.append("local serialVersionUID = ").append(localSUID); + sb.append(" stream serialVersionUID = ").append(streamSUID); + logger.trace(location, null, sb); + resultClassDescriptor = localClassDescriptor; // Use local class descriptor for deserialization + } + } + return resultClassDescriptor; + } +} Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/DeserializerObjectInputStream.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/common/history/DeserializerObjectInputStream.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=1704855&r1=1704854&r2=1704855&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 13:59:59 2015 @@ -22,7 +22,6 @@ 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; @@ -134,15 +133,21 @@ public class HistoryPersistenceManager i public IDuccWorkJob restoreJob(long duccid) throws Exception { - //String methodName = "jobRestore"; + String location = "jobRestore"; IDuccWorkJob job = null; - String fileName = ""+duccid + "." + dwj; - FileInputStream fis = null; - ObjectInputStream in = null; - fis = new FileInputStream(historyDirectory_jobs+File.separator+fileName); - in = new ObjectInputStream(fis); - job = (IDuccWorkJob) in.readObject(); - in.close(); + try { + String fileName = ""+duccid + "." + dwj; + logger.trace(location, new DuccId(duccid), fileName); + FileInputStream fis = null; + DeserializerObjectInputStream in = null; + fis = new FileInputStream(historyDirectory_jobs+File.separator+fileName); + in = new DeserializerObjectInputStream(fis); + job = (IDuccWorkJob) in.readObject(); + in.close(); + } + catch(Exception e) { + logger.error(location, new DuccId(duccid), e); + } return job; } @@ -247,16 +252,21 @@ public class HistoryPersistenceManager i public IDuccWorkReservation restoreReservation(long duccid) throws Exception { - //String methodName = "reservationRestore"; + String location = "reservationRestore"; IDuccWorkReservation reservation = null; - FileInputStream fis = null; - ObjectInputStream in = null; - String fileName = ""+duccid + "." + dwr; - - fis = new FileInputStream(historyDirectory_reservations+File.separator+fileName); - in = new ObjectInputStream(fis); - reservation = (IDuccWorkReservation) in.readObject(); - in.close(); + try { + FileInputStream fis = null; + DeserializerObjectInputStream 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); + reservation = (IDuccWorkReservation) in.readObject(); + in.close(); + } + catch(Exception e) { + logger.error(location, new DuccId(duccid), e); + } return reservation; } @@ -381,16 +391,21 @@ public class HistoryPersistenceManager i public IDuccWorkService restoreService(long duccid) throws Exception { - //String methodName = "restoreService"; + String location = "restoreService"; IDuccWorkService service = null; - FileInputStream fis = null; - ObjectInputStream in = null; - String fileName = ""+duccid + "." + dws; - - fis = new FileInputStream(historyDirectory_services+File.separator+fileName); - in = new ObjectInputStream(fis); - service = (IDuccWorkService) in.readObject(); - in.close(); + try { + FileInputStream fis = null; + DeserializerObjectInputStream 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); + service = (IDuccWorkService) in.readObject(); + in.close(); + } + catch(Exception e) { + logger.error(location, new DuccId(duccid), e); + } return service; } @@ -468,9 +483,9 @@ public class HistoryPersistenceManager i try { logger.trace(methodName, null, "restore:"+fileName); FileInputStream fis = null; - ObjectInputStream in = null; + DeserializerObjectInputStream in = null; fis = new FileInputStream(historyDirectory_services+File.separator+fileName); - in = new ObjectInputStream(fis); + in = new DeserializerObjectInputStream(fis); service = (IDuccWorkService) in.readObject(); in.close(); }