HBASE-14711 Remove or annotate deprecated methods in HRegionInfo
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4c25549e Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4c25549e Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4c25549e Branch: refs/heads/hbase-12439 Commit: 4c25549e9f270ecef6c13bff8f46cef68bf5ba56 Parents: 6cc6d83 Author: Jonathan M Hsieh <jmhs...@apache.org> Authored: Wed Oct 28 11:16:48 2015 -0700 Committer: Jonathan M Hsieh <jmhs...@apache.org> Committed: Sun Nov 1 04:29:51 2015 -0800 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/HRegionInfo.java | 118 +------------------ .../apache/hadoop/hbase/MetaTableAccessor.java | 27 ++--- .../apache/hadoop/hbase/client/HBaseAdmin.java | 4 +- .../hadoop/hbase/master/CatalogJanitor.java | 25 ++-- .../org/apache/hadoop/hbase/master/HMaster.java | 4 +- .../hadoop/hbase/master/RegionStateStore.java | 4 +- .../org/apache/hadoop/hbase/util/HBaseFsck.java | 4 +- .../org/apache/hadoop/hbase/util/HMerge.java | 4 +- .../org/apache/hadoop/hbase/util/Merge.java | 5 +- .../hadoop/hbase/HBaseTestingUtility.java | 2 +- .../hbase/TestMetaTableAccessorNoCluster.java | 10 +- .../TestMasterOperationsForRegionReplicas.java | 2 +- .../hbase/master/TestMasterTransitions.java | 3 +- .../TestRegionMergeTransactionOnCluster.java | 7 +- .../util/hbck/OfflineMetaRebuildTestCore.java | 2 +- .../hadoop/hbase/thrift/ThriftServerRunner.java | 5 +- 16 files changed, 55 insertions(+), 171 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java index 9b13c16..59c698f 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java @@ -31,7 +31,6 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.client.RegionReplicaUtil; import org.apache.hadoop.hbase.KeyValue.KVComparator; -import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.exceptions.DeserializationException; import org.apache.hadoop.hbase.master.RegionState; import org.apache.hadoop.hbase.protobuf.ProtobufUtil; @@ -41,8 +40,6 @@ import org.apache.hadoop.hbase.util.ByteStringer; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.JenkinsHash; import org.apache.hadoop.hbase.util.MD5Hash; -import org.apache.hadoop.hbase.util.Pair; -import org.apache.hadoop.hbase.util.PairOfSameType; import org.apache.hadoop.io.DataInputBuffer; /** @@ -839,7 +836,7 @@ public class HRegionInfo implements Comparable<HRegionInfo> { /** * @return Comparator to use comparing {@link KeyValue}s. - * @deprecated This method should not have been here. Use Region#getCellComparator() + * @deprecated Use Region#getCellComparator(). deprecated for hbase 2.0, remove for hbase 3.0 */ @Deprecated public KVComparator getComparator() { @@ -1096,119 +1093,6 @@ public class HRegionInfo implements Comparable<HRegionInfo> { } /** - * Extract a HRegionInfo and ServerName from catalog table {@link Result}. - * @param r Result to pull from - * @return A pair of the {@link HRegionInfo} and the {@link ServerName} - * (or null for server address if no address set in hbase:meta). - * @deprecated use MetaTableAccessor methods for interacting with meta layouts - */ - @Deprecated - public static Pair<HRegionInfo, ServerName> getHRegionInfoAndServerName(final Result r) { - HRegionInfo info = - getHRegionInfo(r, HConstants.REGIONINFO_QUALIFIER); - ServerName sn = getServerName(r); - return new Pair<HRegionInfo, ServerName>(info, sn); - } - - /** - * Returns HRegionInfo object from the column - * HConstants.CATALOG_FAMILY:HConstants.REGIONINFO_QUALIFIER of the catalog - * table Result. - * @param data a Result object from the catalog table scan - * @return HRegionInfo or null - * @deprecated use MetaTableAccessor methods for interacting with meta layouts - */ - @Deprecated - public static HRegionInfo getHRegionInfo(Result data) { - return getHRegionInfo(data, HConstants.REGIONINFO_QUALIFIER); - } - - /** - * Returns the daughter regions by reading the corresponding columns of the catalog table - * Result. - * @param data a Result object from the catalog table scan - * @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split - * parent - * @deprecated use MetaTableAccessor methods for interacting with meta layouts - */ - @Deprecated - public static PairOfSameType<HRegionInfo> getDaughterRegions(Result data) throws IOException { - HRegionInfo splitA = getHRegionInfo(data, HConstants.SPLITA_QUALIFIER); - HRegionInfo splitB = getHRegionInfo(data, HConstants.SPLITB_QUALIFIER); - - return new PairOfSameType<HRegionInfo>(splitA, splitB); - } - - /** - * Returns the merge regions by reading the corresponding columns of the catalog table - * Result. - * @param data a Result object from the catalog table scan - * @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split - * parent - * @deprecated use MetaTableAccessor methods for interacting with meta layouts - */ - @Deprecated - public static PairOfSameType<HRegionInfo> getMergeRegions(Result data) throws IOException { - HRegionInfo mergeA = getHRegionInfo(data, HConstants.MERGEA_QUALIFIER); - HRegionInfo mergeB = getHRegionInfo(data, HConstants.MERGEB_QUALIFIER); - - return new PairOfSameType<HRegionInfo>(mergeA, mergeB); - } - - /** - * Returns the HRegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and - * <code>qualifier</code> of the catalog table result. - * @param r a Result object from the catalog table scan - * @param qualifier Column family qualifier -- either - * {@link HConstants#SPLITA_QUALIFIER}, {@link HConstants#SPLITB_QUALIFIER} or - * {@link HConstants#REGIONINFO_QUALIFIER}. - * @return An HRegionInfo instance or null. - * @deprecated use MetaTableAccessor methods for interacting with meta layouts - */ - @Deprecated - public static HRegionInfo getHRegionInfo(final Result r, byte [] qualifier) { - Cell cell = r.getColumnLatestCell( - HConstants.CATALOG_FAMILY, qualifier); - if (cell == null) return null; - return parseFromOrNull(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); - } - - /** - * @deprecated use MetaTableAccessor methods for interacting with meta layouts - */ - @Deprecated - public static ServerName getServerName(final Result r) { - Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER); - if (cell == null || cell.getValueLength() == 0) return null; - String hostAndPort = Bytes.toString( - cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); - cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, - HConstants.STARTCODE_QUALIFIER); - if (cell == null || cell.getValueLength() == 0) return null; - try { - return ServerName.valueOf(hostAndPort, - Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); - } catch (IllegalArgumentException e) { - LOG.error("Ignoring invalid region for server " + hostAndPort + "; cell=" + cell, e); - return null; - } - } - - /** - * The latest seqnum that the server writing to meta observed when opening the region. - * E.g. the seqNum when the result of {@link #getServerName(Result)} was written. - * @param r Result to pull the seqNum from - * @return SeqNum, or HConstants.NO_SEQNUM if there's no value written. - * @deprecated use MetaTableAccessor methods for interacting with meta layouts - */ - @Deprecated - public static long getSeqNumDuringOpen(final Result r) { - Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, HConstants.SEQNUM_QUALIFIER); - if (cell == null || cell.getValueLength() == 0) return HConstants.NO_SEQNUM; - return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); - } - - /** * Parses an HRegionInfo instance from the passed in stream. Presumes the HRegionInfo was * serialized to the stream with {@link #toDelimitedByteArray()} * @param in http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java index d3d7608..a1303e6 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java @@ -302,7 +302,7 @@ public class MetaTableAccessor { parsedInfo = parseRegionInfoFromRegionName(regionName); row = getMetaKeyForRegion(parsedInfo); } catch (Exception parseEx) { - // Ignore. This is used with tableName passed as regionName. + ; // Ignore. This is used with tableName passed as regionName. } Get get = new Get(row); get.addFamily(HConstants.CATALOG_FAMILY); @@ -919,7 +919,8 @@ public class MetaTableAccessor { * @return A ServerName instance or null if necessary fields not found or empty. */ @Nullable - private static ServerName getServerName(final Result r, final int replicaId) { + @InterfaceAudience.Private // for use by HMaster#getTableRegionRow which is used for testing only + public static ServerName getServerName(final Result r, final int replicaId) { byte[] serverColumn = getServerColumn(replicaId); Cell cell = r.getColumnLatestCell(getCatalogFamily(), serverColumn); if (cell == null || cell.getValueLength() == 0) return null; @@ -928,8 +929,13 @@ public class MetaTableAccessor { byte[] startcodeColumn = getStartCodeColumn(replicaId); cell = r.getColumnLatestCell(getCatalogFamily(), startcodeColumn); if (cell == null || cell.getValueLength() == 0) return null; - return ServerName.valueOf(hostAndPort, - Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); + try { + return ServerName.valueOf(hostAndPort, + Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); + } catch (IllegalArgumentException e) { + LOG.error("Ignoring invalid region for server " + hostAndPort + "; cell=" + cell, e); + return null; + } } /** @@ -1244,19 +1250,6 @@ public class MetaTableAccessor { * @return Count or regions in table <code>tableName</code> * @throws IOException */ - @Deprecated - public static int getRegionCount(final Configuration c, final String tableName) - throws IOException { - return getRegionCount(c, TableName.valueOf(tableName)); - } - - /** - * Count regions in <code>hbase:meta</code> for passed table. - * @param c Configuration object - * @param tableName table name to count regions for - * @return Count or regions in table <code>tableName</code> - * @throws IOException - */ public static int getRegionCount(final Configuration c, final TableName tableName) throws IOException { try (Connection connection = ConnectionFactory.createConnection(c)) { http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 9995499..82bfee7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -2091,6 +2091,7 @@ public class HBaseAdmin implements Admin { compact(master, getMobRegionInfo(tableName), major, columnFamily); break; case NORMAL: + default: ZooKeeperWatcher zookeeper = null; try { checkTableExists(tableName); @@ -2685,7 +2686,7 @@ public class HBaseAdmin implements Admin { MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() { @Override public boolean visit(Result data) throws IOException { - HRegionInfo info = HRegionInfo.getHRegionInfo(data); + HRegionInfo info = MetaTableAccessor.getHRegionInfo(data); if (info == null) { LOG.warn("No serialized HRegionInfo in " + data); return true; @@ -4371,6 +4372,7 @@ public class HBaseAdmin implements Admin { } break; case NORMAL: + default: ZooKeeperWatcher zookeeper = new ZooKeeperWatcher(conf, ZK_IDENTIFIER_PREFIX + connection.toString(), new ThrowableAbortable()); http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java index e9fca27..ef2a005 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java @@ -113,8 +113,8 @@ public class CatalogJanitor extends ScheduledChore { * parent regioninfos * @throws IOException */ - Triple<Integer, Map<HRegionInfo, Result>, Map<HRegionInfo, Result>> getMergedRegionsAndSplitParents() - throws IOException { + Triple<Integer, Map<HRegionInfo, Result>, Map<HRegionInfo, Result>> + getMergedRegionsAndSplitParents() throws IOException { return getMergedRegionsAndSplitParents(null); } @@ -128,8 +128,8 @@ public class CatalogJanitor extends ScheduledChore { * parent regioninfos * @throws IOException */ - Triple<Integer, Map<HRegionInfo, Result>, Map<HRegionInfo, Result>> getMergedRegionsAndSplitParents( - final TableName tableName) throws IOException { + Triple<Integer, Map<HRegionInfo, Result>, Map<HRegionInfo, Result>> + getMergedRegionsAndSplitParents(final TableName tableName) throws IOException { final boolean isTableSpecified = (tableName != null); // TODO: Only works with single hbase:meta region currently. Fix. final AtomicInteger count = new AtomicInteger(0); @@ -145,7 +145,7 @@ public class CatalogJanitor extends ScheduledChore { public boolean visit(Result r) throws IOException { if (r == null || r.isEmpty()) return true; count.incrementAndGet(); - HRegionInfo info = HRegionInfo.getHRegionInfo(r); + HRegionInfo info = MetaTableAccessor.getHRegionInfo(r); if (info == null) return true; // Keep scanning if (isTableSpecified && info.getTable().compareTo(tableName) > 0) { @@ -225,10 +225,9 @@ public class CatalogJanitor extends ScheduledChore { int mergeCleaned = 0; Map<HRegionInfo, Result> mergedRegions = scanTriple.getSecond(); for (Map.Entry<HRegionInfo, Result> e : mergedRegions.entrySet()) { - HRegionInfo regionA = HRegionInfo.getHRegionInfo(e.getValue(), - HConstants.MERGEA_QUALIFIER); - HRegionInfo regionB = HRegionInfo.getHRegionInfo(e.getValue(), - HConstants.MERGEB_QUALIFIER); + PairOfSameType<HRegionInfo> p = MetaTableAccessor.getMergeRegions(e.getValue()); + HRegionInfo regionA = p.getFirst(); + HRegionInfo regionB = p.getSecond(); if (regionA == null || regionB == null) { LOG.warn("Unexpected references regionA=" + (regionA == null ? "null" : regionA.getRegionNameAsString()) @@ -255,8 +254,10 @@ public class CatalogJanitor extends ScheduledChore { cleanParent(e.getKey(), e.getValue())) { splitCleaned++; } else { - // We could not clean the parent, so it's daughters should not be cleaned either (HBASE-6160) - PairOfSameType<HRegionInfo> daughters = HRegionInfo.getDaughterRegions(e.getValue()); + // We could not clean the parent, so it's daughters should not be + // cleaned either (HBASE-6160) + PairOfSameType<HRegionInfo> daughters = + MetaTableAccessor.getDaughterRegions(e.getValue()); parentNotCleaned.add(daughters.getFirst().getEncodedName()); parentNotCleaned.add(daughters.getSecond().getEncodedName()); } @@ -322,7 +323,7 @@ public class CatalogJanitor extends ScheduledChore { return result; } // Run checks on each daughter split. - PairOfSameType<HRegionInfo> daughters = HRegionInfo.getDaughterRegions(rowContent); + PairOfSameType<HRegionInfo> daughters = MetaTableAccessor.getDaughterRegions(rowContent); Pair<Boolean, Boolean> a = checkDaughterInFs(parent, daughters.getFirst()); Pair<Boolean, Boolean> b = checkDaughterInFs(parent, daughters.getSecond()); if (hasNoReferences(a) && hasNoReferences(b)) { http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index f160835..afa6c7a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -1949,7 +1949,9 @@ public class HMaster extends HRegionServer implements MasterServices, Server { if (data == null || data.size() <= 0) { return true; } - Pair<HRegionInfo, ServerName> pair = HRegionInfo.getHRegionInfoAndServerName(data); + Pair<HRegionInfo, ServerName> pair = + new Pair(MetaTableAccessor.getHRegionInfo(data), + MetaTableAccessor.getServerName(data,0)); if (pair == null) { return false; } http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java index 36986be..bc5173a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java @@ -65,9 +65,9 @@ public class RegionStateStore { /** * Returns the {@link ServerName} from catalog table {@link Result} * where the region is transitioning. It should be the same as - * {@link HRegionInfo#getServerName(Result)} if the server is at OPEN state. + * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state. * @param r Result to pull the transitioning server name from - * @return A ServerName instance or {@link HRegionInfo#getServerName(Result)} + * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)} * if necessary fields not found or empty. */ static ServerName getRegionServer(final Result r, int replicaId) { http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index bc3da96..fa138be 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -3417,7 +3417,7 @@ public class HBaseFsck extends Configured implements Closeable { || hri.isMetaRegion())) { return true; } - PairOfSameType<HRegionInfo> daughters = HRegionInfo.getDaughterRegions(result); + PairOfSameType<HRegionInfo> daughters = MetaTableAccessor.getDaughterRegions(result); for (HRegionLocation h : rl.getRegionLocations()) { if (h == null || h.getRegionInfo() == null) { continue; @@ -3440,7 +3440,7 @@ public class HBaseFsck extends Configured implements Closeable { throw new IOException("Two entries in hbase:meta are same " + previous); } } - PairOfSameType<HRegionInfo> mergeRegions = HRegionInfo.getMergeRegions(result); + PairOfSameType<HRegionInfo> mergeRegions = MetaTableAccessor.getMergeRegions(result); for (HRegionInfo mergeRegion : new HRegionInfo[] { mergeRegions.getFirst(), mergeRegions.getSecond() }) { if (mergeRegion != null) { http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java index c37f952..53c5cef 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java @@ -259,7 +259,7 @@ class HMerge { if (results == null) { return null; } - HRegionInfo region = HRegionInfo.getHRegionInfo(results); + HRegionInfo region = MetaTableAccessor.getHRegionInfo(results); if (region == null) { throw new NoSuchElementException("meta region entry missing " + Bytes.toString(HConstants.CATALOG_FAMILY) + ":" + @@ -293,7 +293,7 @@ class HMerge { currentRow = metaScanner.next(); continue; } - HRegionInfo region = HRegionInfo.getHRegionInfo(currentRow); + HRegionInfo region = MetaTableAccessor.getHRegionInfo(currentRow); if (!region.getTable().equals(this.tableName)) { currentRow = metaScanner.next(); continue; http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java index c63bcad..44b3138 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java @@ -23,6 +23,7 @@ import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.FileSystem; @@ -124,7 +125,7 @@ public class Merge extends Configured implements Tool { Result result1 = meta.get(get); Preconditions.checkState(!result1.isEmpty(), "First region cells can not be null"); - HRegionInfo info1 = HRegionInfo.getHRegionInfo(result1); + HRegionInfo info1 = MetaTableAccessor.getHRegionInfo(result1); if (info1 == null) { throw new NullPointerException("info1 is null using key " + Bytes.toStringBinary(region1) + " in " + meta); @@ -134,7 +135,7 @@ public class Merge extends Configured implements Tool { Result result2 = meta.get(get); Preconditions.checkState(!result2.isEmpty(), "Second region cells can not be null"); - HRegionInfo info2 = HRegionInfo.getHRegionInfo(result2); + HRegionInfo info2 = MetaTableAccessor.getHRegionInfo(result2); if (info2 == null) { throw new NullPointerException("info2 is null using key " + meta); } http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index ff17065..473419e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -2333,7 +2333,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { List<byte[]> rows = new ArrayList<byte[]>(); ResultScanner s = t.getScanner(new Scan()); for (Result result : s) { - HRegionInfo info = HRegionInfo.getHRegionInfo(result); + HRegionInfo info = MetaTableAccessor.getHRegionInfo(result); if (info == null) { LOG.error("No region info for row " + Bytes.toString(result.getRow())); // TODO figure out what to do for this new hosed case. http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessorNoCluster.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessorNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessorNoCluster.java index eefadd8..227db6f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessorNoCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableAccessorNoCluster.java @@ -85,29 +85,29 @@ public class TestMetaTableAccessorNoCluster { @Test public void testGetHRegionInfo() throws IOException { - assertNull(HRegionInfo.getHRegionInfo(new Result())); + assertNull(MetaTableAccessor.getHRegionInfo(new Result())); List<Cell> kvs = new ArrayList<Cell>(); Result r = Result.create(kvs); - assertNull(HRegionInfo.getHRegionInfo(r)); + assertNull(MetaTableAccessor.getHRegionInfo(r)); byte [] f = HConstants.CATALOG_FAMILY; // Make a key value that doesn't have the expected qualifier. kvs.add(new KeyValue(HConstants.EMPTY_BYTE_ARRAY, f, HConstants.SERVER_QUALIFIER, f)); r = Result.create(kvs); - assertNull(HRegionInfo.getHRegionInfo(r)); + assertNull(MetaTableAccessor.getHRegionInfo(r)); // Make a key that does not have a regioninfo value. kvs.add(new KeyValue(HConstants.EMPTY_BYTE_ARRAY, f, HConstants.REGIONINFO_QUALIFIER, f)); - HRegionInfo hri = HRegionInfo.getHRegionInfo(Result.create(kvs)); + HRegionInfo hri = MetaTableAccessor.getHRegionInfo(Result.create(kvs)); assertTrue(hri == null); // OK, give it what it expects kvs.clear(); kvs.add(new KeyValue(HConstants.EMPTY_BYTE_ARRAY, f, HConstants.REGIONINFO_QUALIFIER, HRegionInfo.FIRST_META_REGIONINFO.toByteArray())); - hri = HRegionInfo.getHRegionInfo(Result.create(kvs)); + hri = MetaTableAccessor.getHRegionInfo(Result.create(kvs)); assertNotNull(hri); assertTrue(hri.equals(HRegionInfo.FIRST_META_REGIONINFO)); } http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java index c825be4..7a4baf3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java @@ -291,7 +291,7 @@ public class TestMasterOperationsForRegionReplicas { Visitor visitor = new Visitor() { @Override public boolean visit(Result r) throws IOException { - if (HRegionInfo.getHRegionInfo(r).getTable().equals(table)) count.incrementAndGet(); + if (MetaTableAccessor.getHRegionInfo(r).getTable().equals(table)) count.incrementAndGet(); return true; } }; http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java index 4e6460b..b973a36 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java @@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; @@ -490,7 +491,7 @@ public class TestMasterTransitions { scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); ResultScanner s = meta.getScanner(scan); for (Result r = null; (r = s.next()) != null;) { - HRegionInfo hri = HRegionInfo.getHRegionInfo(r); + HRegionInfo hri = MetaTableAccessor.getHRegionInfo(r); if (hri == null) break; if (!hri.getTable().equals(TABLENAME)) { continue; http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java index ae3ad1a..1c99fe3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java @@ -224,10 +224,9 @@ public class TestRegionMergeTransactionOnCluster { HConstants.MERGEB_QUALIFIER) != null); // merging regions' directory are in the file system all the same - HRegionInfo regionA = HRegionInfo.getHRegionInfo(mergedRegionResult, - HConstants.MERGEA_QUALIFIER); - HRegionInfo regionB = HRegionInfo.getHRegionInfo(mergedRegionResult, - HConstants.MERGEB_QUALIFIER); + PairOfSameType<HRegionInfo> p = MetaTableAccessor.getMergeRegions(mergedRegionResult); + HRegionInfo regionA = p.getFirst(); + HRegionInfo regionB = p.getSecond(); FileSystem fs = master.getMasterFileSystem().getFileSystem(); Path rootDir = master.getMasterFileSystem().getRootDir(); http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java index ecda77f..a14f845 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java @@ -248,7 +248,7 @@ public class OfflineMetaRebuildTestCore { List<Delete> dels = new ArrayList<Delete>(); for (Result r : scanner) { HRegionInfo info = - HRegionInfo.getHRegionInfo(r); + MetaTableAccessor.getHRegionInfo(r); if(info != null && !info.getTable().getNamespaceAsString() .equals(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR)) { Delete d = new Delete(r.getRow()); http://git-wip-us.apache.org/repos/asf/hbase/blob/4c25549e/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java ---------------------------------------------------------------------- diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java index cc8cd29..462c86b 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java @@ -58,6 +58,7 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableNotFoundException; @@ -1682,7 +1683,7 @@ public class ThriftServerRunner implements Runnable { } // find region start and end keys - HRegionInfo regionInfo = HRegionInfo.getHRegionInfo(startRowResult); + HRegionInfo regionInfo = MetaTableAccessor.getHRegionInfo(startRowResult); if (regionInfo == null) { throw new IOException("HRegionInfo REGIONINFO was null or " + " empty in Meta for row=" @@ -1696,7 +1697,7 @@ public class ThriftServerRunner implements Runnable { region.version = HREGION_VERSION; // version not used anymore, PB encoding used. // find region assignment to server - ServerName serverName = HRegionInfo.getServerName(startRowResult); + ServerName serverName = MetaTableAccessor.getServerName(startRowResult, 0); if (serverName != null) { region.setServerName(Bytes.toBytes(serverName.getHostname())); region.port = serverName.getPort();