From 4c413e0c50777e1d0cbe72f8f081da96063913c0 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Wed, 29 Nov 2017 11:43:07 -0800 Subject: [PATCH] HBASE-19376 Fix more binary compatibility problems with branch-1.4 / branch-1 --- .../apache/hadoop/hbase/ClusterStatus.java | 25 +++++++- .../apache/hadoop/hbase/client/Result.java | 15 +++++ .../hadoop/hbase/filter/FilterList.java | 9 +++ .../hbase/mapreduce/TableInputFormatBase.java | 62 ++++++++++++++++++- .../hbase/master/ClusterStatusPublisher.java | 7 +-- .../master/snapshot/SnapshotManager.java | 13 +++- 6 files changed, 120 insertions(+), 11 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java index 10637d68a89..2eb116245e9 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java @@ -20,12 +20,15 @@ package org.apache.hadoop.hbase; import com.google.common.base.Objects; +import com.google.common.collect.Sets; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -41,7 +44,6 @@ import org.apache.hadoop.hbase.protobuf.generated.FSProtos.HBaseVersionFileConte import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType; -import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.VersionedWritable; @@ -100,6 +102,26 @@ public class ClusterStatus extends VersionedWritable { super(); } + @Deprecated + public ClusterStatus(String hbaseVersion, String clusterid, List deadServers, + ServerName master) { + this(hbaseVersion, clusterid, new HashMap(), deadServers, master, + new ArrayList(), new HashSet(), new String[0], null); + } + + @Deprecated + public ClusterStatus(final String hbaseVersion, final String clusterid, + final Map servers, + final Collection deadServers, + final ServerName master, + final Collection backupMasters, + final Map rit, + final String[ ] masterCoprocessors, + final Boolean balancerOn) { + this(hbaseVersion, clusterid, servers, deadServers, master, backupMasters, Sets.newHashSet(rit.values()), + masterCoprocessors, balancerOn); + } + public ClusterStatus(final String hbaseVersion, final String clusterid, final Map servers, final Collection deadServers, @@ -109,7 +131,6 @@ public class ClusterStatus extends VersionedWritable { final String[] masterCoprocessors, final Boolean balancerOn) { this.hbaseVersion = hbaseVersion; - this.liveServers = servers; this.deadServers = deadServers; this.master = master; diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java index ffd7695d235..d14171f8ddb 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java @@ -869,6 +869,21 @@ public class Result implements CellScannable, CellScanner { * @return The complete result that is formed by combining all of the partial results together * @throws IOException A complete result cannot be formed because the results in the partial list * come from different rows + * @deprecated + */ + @Deprecated + public static Result createCompleteResult(List partialResults) + throws IOException { + return createCompleteResult((Iterable)partialResults); + } + + /** + * Forms a single result from the partial results in the partialResults list. This method is + * useful for reconstructing partial results on the client side. + * @param partialResults iterable of partial results + * @return The complete result that is formed by combining all of the partial results together + * @throws IOException A complete result cannot be formed because the results in the partial list + * come from different rows */ public static Result createCompleteResult(Iterable partialResults) throws IOException { diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java index 8345fcfdcdf..8b0e8b2eac9 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java @@ -301,6 +301,15 @@ final public class FilterList extends Filter { return this.reversed; } + /** + * @param maxFilters ignored + * @deprecated + */ + @Deprecated + public String toString(int maxFilters) { + return this.filterListBase.toString(); + } + @Override public String toString() { return this.filterListBase.toString(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java index f4c2f9b1a1b..c5c00cecc81 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java @@ -24,7 +24,6 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -32,7 +31,6 @@ import javax.naming.NamingException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.HConstants; @@ -437,6 +435,28 @@ extends InputFormat { } return res; } + + /** + * Calculates the number of MapReduce input splits for the map tasks. The number of + * MapReduce input splits depends on the average region size. + * Make it 'public' for testing + *

+ * Deprecated. Former functionality has been replaced by calculateAutoBalancedSplits and + * will function differently. Do not use. + *

+ * @param list The list of input splits before balance. + * @param context The current job context. + * @param average The average size of all regions . + * @return The list of input splits. + * @throws IOException + * @deprecated + */ + @Deprecated + public List calculateRebalancedSplits(List list, JobContext context, + long average) throws IOException { + return calculateAutoBalancedSplits(list, average); + } + /** * Calculates the number of MapReduce input splits for the map tasks. The number of * MapReduce input splits depends on the average region size. @@ -515,6 +535,44 @@ extends InputFormat { return resultList; } + /** + * Deprecated. Do not use. + * @param start Start key of the region + * @param end End key of the region + * @param isText It determines to use text key mode or binary key mode + * @return The split point in the region. + */ + @Deprecated + public static byte[] getSplitKey(byte[] start, byte[] end, boolean isText) { + byte upperLimitByte; + byte lowerLimitByte; + //Use text mode or binary mode. + if (isText) { + //The range of text char set in ASCII is [32,126], the lower limit is space and the upper + // limit is '~'. + upperLimitByte = '~'; + lowerLimitByte = ' '; + } else { + upperLimitByte = -1; + lowerLimitByte = 0; + } + // For special case + // Example 1 : startkey=null, endkey="hhhqqqwww", splitKey="h" + // Example 2 (text key mode): startKey="ffffaaa", endKey=null, splitkey="f~~~~~~" + if (start.length == 0 && end.length == 0){ + return new byte[]{(byte) ((lowerLimitByte + upperLimitByte) / 2)}; + } + if (start.length == 0 && end.length != 0){ + return new byte[]{ end[0] }; + } + if (start.length != 0 && end.length == 0){ + byte[] result =new byte[start.length]; + result[0]=start[0]; + return result; + } + return Bytes.split(start, end, false, 1)[1]; + } + /** * @deprecated mistakenly made public in 0.98.7. scope will change to package-private */ diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterStatusPublisher.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterStatusPublisher.java index 4d4358c5799..00c738b8d7d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterStatusPublisher.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ClusterStatusPublisher.java @@ -161,13 +161,8 @@ public class ClusterStatusPublisher extends ScheduledChore { // hbase:meta server name. ClusterStatus cs = new ClusterStatus(VersionInfo.getVersion(), master.getMasterFileSystem().getClusterId().toString(), - null, sns, - master.getServerName(), - null, - null, - null, - null); + master.getServerName()); publisher.publish(cs); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java index 3efe984bdd8..d5aaca9d7d7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java @@ -683,7 +683,18 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable /** * Restore the specified snapshot - * @param reqSnapshot + * @param reqSnapshot the snapshot to restore + * @throws IOException + */ + @Deprecated + public void restoreSnapshot(SnapshotDescription reqSnapshot) throws IOException { + restoreSnapshot(reqSnapshot, false); + } + + /** + * Restore the specified snapshot + * @param reqSnapshot the snapshot to restore + * @param restoreAcl whether or not to restore ACLs on the snapshot * @throws IOException */ public void restoreSnapshot(SnapshotDescription reqSnapshot, boolean restoreAcl)