You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2014/09/17 17:19:59 UTC
[2/5] git commit: ACCUMULO-3132 setting TInfo's serialization value
is much simpler After discussing it with [~kturner],
this change seems simpler and supports 1.6.1 -> 1.6.0 revert of an upgrade.
The unit test will catch any re-generation of the file.
ACCUMULO-3132 setting TInfo's serialization value is much simpler
After discussing it with [~kturner], this change seems simpler and
supports 1.6.1 -> 1.6.0 revert of an upgrade. The unit test will
catch any re-generation of the file.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/597b787c
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/597b787c
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/597b787c
Branch: refs/heads/master
Commit: 597b787cee82a0cb3a8c39e70de312878d0182fc
Parents: 0055bab
Author: Eric C. Newton <er...@gmail.com>
Authored: Wed Sep 17 11:14:04 2014 -0400
Committer: Eric C. Newton <er...@gmail.com>
Committed: Wed Sep 17 11:14:04 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/fate/ZooStore.java | 19 +----------
.../org/apache/accumulo/master/state/TInfo.java | 35 --------------------
.../state/TraceRepoDeserializationTest.java | 6 ++--
.../org/apache/accumulo/trace/thrift/TInfo.java | 5 +++
4 files changed, 10 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/597b787c/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java b/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
index ec51ca7..34e3b91 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
@@ -19,10 +19,8 @@ package org.apache.accumulo.fate;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.security.SecureRandom;
@@ -72,25 +70,10 @@ public class ZooStore<T> implements TStore<T> {
}
}
- public static class KludgeInputStream extends ObjectInputStream {
- @Override
- protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
- // hack to recover serialized TInfo objects stored in zookeeper between releases
- if (desc.getName().equals("org.apache.accumulo.trace.thrift.TInfo")) {
- return Class.forName("org.apache.accumulo.master.state.TInfo");
- }
- return super.resolveClass(desc);
- }
-
- public KludgeInputStream(InputStream in) throws IOException {
- super(in);
- }
- }
-
private Object deserialize(byte ser[]) {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(ser);
- ObjectInputStream ois = new KludgeInputStream(bais);
+ ObjectInputStream ois = new ObjectInputStream(bais);
try {
return ois.readObject();
} finally {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/597b787c/server/master/src/main/java/org/apache/accumulo/master/state/TInfo.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/state/TInfo.java b/server/master/src/main/java/org/apache/accumulo/master/state/TInfo.java
deleted file mode 100644
index 21b1533..0000000
--- a/server/master/src/main/java/org/apache/accumulo/master/state/TInfo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.accumulo.master.state;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-// ACCUMULO-3132
-// Total hack around the serialization of TInfo into zookeeper
-// This class has to keep the same name, and its name is hardcoded in the Fate module
-public class TInfo extends org.apache.accumulo.trace.thrift.TInfo {
- private static final long serialVersionUID = -4659975753252858243l;
-
- private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
- try {
- read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(ois)));
- } catch (org.apache.thrift.TException te) {
- throw new java.io.IOException(te);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/597b787c/server/master/src/test/java/org/apache/accumulo/master/state/TraceRepoDeserializationTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/state/TraceRepoDeserializationTest.java b/server/master/src/test/java/org/apache/accumulo/master/state/TraceRepoDeserializationTest.java
index fab57d1..96877f1 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/state/TraceRepoDeserializationTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/state/TraceRepoDeserializationTest.java
@@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import org.apache.accumulo.core.util.Base64;
-import org.apache.accumulo.fate.ZooStore;
import org.junit.Test;
public class TraceRepoDeserializationTest {
@@ -46,11 +45,14 @@ public class TraceRepoDeserializationTest {
"dWxvLnRyYWNlLnRocmlmdC5USW5mb79UcL31bhZ9AwADQgAQX19pc3NldF9iaXRmaWVs" +
"ZEoACHBhcmVudElkSgAHdHJhY2VJZHhwdwUWABYAAHg=";
+ // If this test fails add:
+ // private static final long serialVersionUID = -4659975753252858243l;
+ // back into org.apache.accumulo.trace.thrift.TInfo
@Test
public void test() throws Exception {
byte bytes[] = Base64.decodeBase64(oldValue);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ZooStore.KludgeInputStream(bais);
+ ObjectInputStream ois = new ObjectInputStream(bais);
ois.readObject();
ois.close();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/597b787c/trace/src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/thrift/TInfo.java b/trace/src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
index 9f899bf..1046149 100644
--- a/trace/src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
@@ -49,6 +49,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("all") public class TInfo implements org.apache.thrift.TBase<TInfo, TInfo._Fields>, java.io.Serializable, Cloneable, Comparable<TInfo> {
+
+ //ACCUMULO-3132
+ //Total hack around the serialization of TInfo into zookeeper
+ private static final long serialVersionUID = -4659975753252858243l;
+
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TInfo");
private static final org.apache.thrift.protocol.TField TRACE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("traceId", org.apache.thrift.protocol.TType.I64, (short)1);