You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bu...@apache.org on 2018/08/14 18:04:16 UTC

[02/15] hbase git commit: HBASE-21012 Revert the change of serializing TimeRangeTracker

HBASE-21012 Revert the change of serializing TimeRangeTracker

Signed-off-by: Michael Stack <st...@apache.org>
Signed-off-by: zhangduo <zh...@apache.org>
Signed-off-by: Chia-Ping Tsai <ch...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/699ea4c7
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/699ea4c7
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/699ea4c7

Branch: refs/heads/HBASE-20387
Commit: 699ea4c7d02c4871a57c1cb1a984c3451c54cc6b
Parents: a3ab930
Author: brandboat <br...@gmail.com>
Authored: Thu Aug 9 12:27:25 2018 +0800
Committer: Chia-Ping Tsai <ch...@gmail.com>
Committed: Sat Aug 11 22:17:04 2018 +0800

----------------------------------------------------------------------
 .../hbase/regionserver/TimeRangeTracker.java    | 27 +++++++++++++++-----
 src/main/asciidoc/_chapters/upgrading.adoc      | 12 +++++++++
 2 files changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/699ea4c7/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/TimeRangeTracker.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/TimeRangeTracker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/TimeRangeTracker.java
index 5c0eee5..d995fc6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/TimeRangeTracker.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/TimeRangeTracker.java
@@ -19,7 +19,9 @@
 package org.apache.hadoop.hbase.regionserver;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
+import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -206,13 +208,24 @@ public abstract class TimeRangeTracker {
     }
   }
 
-  public static byte[] toByteArray(TimeRangeTracker tracker) {
-    return ProtobufUtil.prependPBMagic(
-        HBaseProtos.TimeRangeTracker.newBuilder()
-          .setFrom(tracker.getMin())
-          .setTo(tracker.getMax())
-          .build()
-          .toByteArray());
+  /**
+   * This method used to serialize TimeRangeTracker (TRT) by protobuf while this breaks the
+   * forward compatibility on HFile.(See HBASE-21008) In previous hbase version ( < 2.0.0 ) we use
+   * DataOutput to serialize TRT, these old versions don't have capability to deserialize TRT
+   * which is serialized by protobuf. So we need to revert the change of serializing
+   * TimeRangeTracker back to DataOutput. For more information, please check HBASE-21012.
+   * @param tracker TimeRangeTracker needed to be serialized.
+   * @return byte array filled with serialized TimeRangeTracker.
+   * @throws IOException if something goes wrong in writeLong.
+   */
+  public static byte[] toByteArray(TimeRangeTracker tracker) throws IOException {
+    try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
+      try (DataOutputStream dos = new DataOutputStream(bos)) {
+        dos.writeLong(tracker.getMin());
+        dos.writeLong(tracker.getMax());
+        return bos.toByteArray();
+      }
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/699ea4c7/src/main/asciidoc/_chapters/upgrading.adoc
----------------------------------------------------------------------
diff --git a/src/main/asciidoc/_chapters/upgrading.adoc b/src/main/asciidoc/_chapters/upgrading.adoc
index bc2ec1c..6dc788a 100644
--- a/src/main/asciidoc/_chapters/upgrading.adoc
+++ b/src/main/asciidoc/_chapters/upgrading.adoc
@@ -588,6 +588,18 @@ The internal changes to HBase during this upgrade were sufficient for compilatio
 
 If you previously relied on client side tracing integrated with HBase operations, it is recommended that you upgrade your usage to HTrace 4 as well.
 
+[[upgrade2.0.hfile.compatability]]
+.HFile lose forward compatability
+
+HFiles generated by 2.0.0, 2.0.1, 2.1.0 are not forward compatible to 1.4.6-, 1.3.2.1-, 1.2.6.1-,
+and other inactive releases. Why HFile lose compatability is hbase in new versions
+(2.0.0, 2.0.1, 2.1.0) use protobuf to serialize/deserialize TimeRangeTracker (TRT) while old
+versions use DataInput/DataOutput. To solve this, We have to put
+link:https://jira.apache.org/jira/browse/HBASE-21012[HBASE-21012]
+to 2.x and put link:https://jira.apache.org/jira/browse/HBASE-21013[HBASE-21013] in 1.x.
+For more information, please check
+link:https://jira.apache.org/jira/browse/HBASE-21008[HBASE-21008].
+
 [[upgrade2.0.perf]]
 .Performance