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/16 23:29:02 UTC

[1/2] git commit: ACCUMULO-3132 kludge the deserialization to work with 1.6.0 FATE objects

Repository: accumulo
Updated Branches:
  refs/heads/master 94feef897 -> 58558e741


ACCUMULO-3132 kludge the deserialization to work with 1.6.0 FATE objects


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0055bab8
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0055bab8
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0055bab8

Branch: refs/heads/master
Commit: 0055bab8b94bb87c1b65db6223a5ae8840d2d52c
Parents: 7f62ec1
Author: Eric C. Newton <er...@gmail.com>
Authored: Tue Sep 16 17:22:53 2014 -0400
Committer: Eric C. Newton <er...@gmail.com>
Committed: Tue Sep 16 17:22:53 2014 -0400

----------------------------------------------------------------------
 .../java/org/apache/accumulo/fate/ZooStore.java | 25 ++++++++-
 .../org/apache/accumulo/master/state/TInfo.java | 35 ++++++++++++
 .../state/TraceRepoDeserializationTest.java     | 58 ++++++++++++++++++++
 3 files changed, 116 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/0055bab8/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 5fc1858..ec51ca7 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
@@ -19,8 +19,10 @@ 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;
@@ -69,12 +71,31 @@ public class ZooStore<T> implements TStore<T> {
       throw new RuntimeException(e);
     }
   }
+
+  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 ObjectInputStream(bais);
-      return ois.readObject();
+      ObjectInputStream ois = new KludgeInputStream(bais);
+      try {
+        return ois.readObject();
+      } finally {
+        ois.close();
+      }
     } catch (Exception e) {
       throw new RuntimeException(e);
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0055bab8/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
new file mode 100644
index 0000000..21b1533
--- /dev/null
+++ b/server/master/src/main/java/org/apache/accumulo/master/state/TInfo.java
@@ -0,0 +1,35 @@
+/*
+ * 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/0055bab8/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
new file mode 100644
index 0000000..fab57d1
--- /dev/null
+++ b/server/master/src/test/java/org/apache/accumulo/master/state/TraceRepoDeserializationTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.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 {
+  
+  // Zookeeper data for a merge request.
+  // To recreate:
+  // Fire up 1.6.0, create a table with a bunch of splits
+  // Merge the table back together.  Kill everything before it finishes
+  // and pull out the first serialized repo object with DumpZookeeper.
+  static private final String oldValue = 
+      "rO0ABXNyAC1vcmcuYXBhY2hlLmFjY3VtdWxvLm1hc3Rlci50YWJsZU9wcy5UcmFjZVJlc" +
+      "G8AAAAAAAAAAQIAAkwABHJlcG90AB9Mb3JnL2FwYWNoZS9hY2N1bXVsby9mYXRlL1Jl" +
+      "cG87TAAFdGluZm90AChMb3JnL2FwYWNoZS9hY2N1bXVsby90cmFjZS90aHJpZnQvVEl" +
+      "uZm87eHBzcgAwb3JnLmFwYWNoZS5hY2N1bXVsby5tYXN0ZXIudGFibGVPcHMuVGFibG" +
+      "VSYW5nZU9wAAAAAAAAAAECAAVbAAZlbmRSb3d0AAJbQkwAC25hbWVzcGFjZUlkdAAST" +
+      "GphdmEvbGFuZy9TdHJpbmc7TAACb3B0AD1Mb3JnL2FwYWNoZS9hY2N1bXVsby9zZXJ2" +
+      "ZXIvbWFzdGVyL3N0YXRlL01lcmdlSW5mbyRPcGVyYXRpb247WwAIc3RhcnRSb3dxAH4A" +
+      "BUwAB3RhYmxlSWRxAH4ABnhyAC5vcmcuYXBhY2hlLmFjY3VtdWxvLm1hc3Rlci50YWJs" +
+      "ZU9wcy5NYXN0ZXJSZXBvAAAAAAAAAAECAAB4cHVyAAJbQqzzF/gGCFTgAgAAeHAAAAAA" +
+      "dAAIK2RlZmF1bHR+cgA7b3JnLmFwYWNoZS5hY2N1bXVsby5zZXJ2ZXIubWFzdGVyLnN0" +
+      "YXRlLk1lcmdlSW5mbyRPcGVyYXRpb24AAAAAAAAAABIAAHhyAA5qYXZhLmxhbmcuRW51" +
+      "bQAAAAAAAAAAEgAAeHB0AAVNRVJHRXEAfgALdAABMnNyACZvcmcuYXBhY2hlLmFjY3Vt" +
+      "dWxvLnRyYWNlLnRocmlmdC5USW5mb79UcL31bhZ9AwADQgAQX19pc3NldF9iaXRmaWVs" +
+      "ZEoACHBhcmVudElkSgAHdHJhY2VJZHhwdwUWABYAAHg=";
+  
+  @Test
+  public void test() throws Exception {
+    byte bytes[] = Base64.decodeBase64(oldValue);
+    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+    ObjectInputStream ois = new ZooStore.KludgeInputStream(bais);
+    ois.readObject();
+    ois.close();
+  }
+  
+}


[2/2] git commit: Merge branch '1.6.1-SNAPSHOT'

Posted by ec...@apache.org.
Merge branch '1.6.1-SNAPSHOT'


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/58558e74
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/58558e74
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/58558e74

Branch: refs/heads/master
Commit: 58558e74139ef14399e7c022158a4ec986654d6e
Parents: 94feef8 0055bab
Author: Eric C. Newton <er...@gmail.com>
Authored: Tue Sep 16 17:28:47 2014 -0400
Committer: Eric C. Newton <er...@gmail.com>
Committed: Tue Sep 16 17:28:47 2014 -0400

----------------------------------------------------------------------

----------------------------------------------------------------------