hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1711891 [19/50] - in /hbase/hbase.apache.org/trunk: ./ apidocs/ apidocs/org/apache/hadoop/hbase/ apidocs/org/apache/hadoop/hbase/class-use/ apidocs/org/apache/hadoop/hbase/client/ apidocs/org/apache/hadoop/hbase/client/class-use/ apidocs/o...
Date Mon, 02 Nov 2015 03:51:05 GMT
Modified: hbase/hbase.apache.org/trunk/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.QueryType.html
URL: http://svn.apache.org/viewvc/hbase/hbase.apache.org/trunk/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.QueryType.html?rev=1711891&r1=1711890&r2=1711891&view=diff
==============================================================================
--- hbase/hbase.apache.org/trunk/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.QueryType.html (original)
+++ hbase/hbase.apache.org/trunk/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.QueryType.html Mon Nov  2 03:51:02 2015
@@ -310,7 +310,7 @@
 <span class="sourceLineNo">302</span>      parsedInfo = parseRegionInfoFromRegionName(regionName);<a name="line.302"></a>
 <span class="sourceLineNo">303</span>      row = getMetaKeyForRegion(parsedInfo);<a name="line.303"></a>
 <span class="sourceLineNo">304</span>    } catch (Exception parseEx) {<a name="line.304"></a>
-<span class="sourceLineNo">305</span>      // Ignore. This is used with tableName passed as regionName.<a name="line.305"></a>
+<span class="sourceLineNo">305</span>      ; // Ignore. This is used with tableName passed as regionName.<a name="line.305"></a>
 <span class="sourceLineNo">306</span>    }<a name="line.306"></a>
 <span class="sourceLineNo">307</span>    Get get = new Get(row);<a name="line.307"></a>
 <span class="sourceLineNo">308</span>    get.addFamily(HConstants.CATALOG_FAMILY);<a name="line.308"></a>
@@ -927,1070 +927,1063 @@
 <span class="sourceLineNo">919</span>   * @return A ServerName instance or null if necessary fields not found or empty.<a name="line.919"></a>
 <span class="sourceLineNo">920</span>   */<a name="line.920"></a>
 <span class="sourceLineNo">921</span>  @Nullable<a name="line.921"></a>
-<span class="sourceLineNo">922</span>  private static ServerName getServerName(final Result r, final int replicaId) {<a name="line.922"></a>
-<span class="sourceLineNo">923</span>    byte[] serverColumn = getServerColumn(replicaId);<a name="line.923"></a>
-<span class="sourceLineNo">924</span>    Cell cell = r.getColumnLatestCell(getCatalogFamily(), serverColumn);<a name="line.924"></a>
-<span class="sourceLineNo">925</span>    if (cell == null || cell.getValueLength() == 0) return null;<a name="line.925"></a>
-<span class="sourceLineNo">926</span>    String hostAndPort = Bytes.toString(<a name="line.926"></a>
-<span class="sourceLineNo">927</span>      cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());<a name="line.927"></a>
-<span class="sourceLineNo">928</span>    byte[] startcodeColumn = getStartCodeColumn(replicaId);<a name="line.928"></a>
-<span class="sourceLineNo">929</span>    cell = r.getColumnLatestCell(getCatalogFamily(), startcodeColumn);<a name="line.929"></a>
-<span class="sourceLineNo">930</span>    if (cell == null || cell.getValueLength() == 0) return null;<a name="line.930"></a>
-<span class="sourceLineNo">931</span>    return ServerName.valueOf(hostAndPort,<a name="line.931"></a>
-<span class="sourceLineNo">932</span>      Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));<a name="line.932"></a>
-<span class="sourceLineNo">933</span>  }<a name="line.933"></a>
-<span class="sourceLineNo">934</span><a name="line.934"></a>
-<span class="sourceLineNo">935</span>  /**<a name="line.935"></a>
-<span class="sourceLineNo">936</span>   * The latest seqnum that the server writing to meta observed when opening the region.<a name="line.936"></a>
-<span class="sourceLineNo">937</span>   * E.g. the seqNum when the result of {@link #getServerName(Result, int)} was written.<a name="line.937"></a>
-<span class="sourceLineNo">938</span>   * @param r Result to pull the seqNum from<a name="line.938"></a>
-<span class="sourceLineNo">939</span>   * @return SeqNum, or HConstants.NO_SEQNUM if there's no value written.<a name="line.939"></a>
-<span class="sourceLineNo">940</span>   */<a name="line.940"></a>
-<span class="sourceLineNo">941</span>  private static long getSeqNumDuringOpen(final Result r, final int replicaId) {<a name="line.941"></a>
-<span class="sourceLineNo">942</span>    Cell cell = r.getColumnLatestCell(getCatalogFamily(), getSeqNumColumn(replicaId));<a name="line.942"></a>
-<span class="sourceLineNo">943</span>    if (cell == null || cell.getValueLength() == 0) return HConstants.NO_SEQNUM;<a name="line.943"></a>
-<span class="sourceLineNo">944</span>    return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());<a name="line.944"></a>
-<span class="sourceLineNo">945</span>  }<a name="line.945"></a>
-<span class="sourceLineNo">946</span><a name="line.946"></a>
-<span class="sourceLineNo">947</span>  /**<a name="line.947"></a>
-<span class="sourceLineNo">948</span>   * Returns an HRegionLocationList extracted from the result.<a name="line.948"></a>
-<span class="sourceLineNo">949</span>   * @return an HRegionLocationList containing all locations for the region range or null if<a name="line.949"></a>
-<span class="sourceLineNo">950</span>   *  we can't deserialize the result.<a name="line.950"></a>
-<span class="sourceLineNo">951</span>   */<a name="line.951"></a>
-<span class="sourceLineNo">952</span>  @Nullable<a name="line.952"></a>
-<span class="sourceLineNo">953</span>  public static RegionLocations getRegionLocations(final Result r) {<a name="line.953"></a>
-<span class="sourceLineNo">954</span>    if (r == null) return null;<a name="line.954"></a>
-<span class="sourceLineNo">955</span>    HRegionInfo regionInfo = getHRegionInfo(r, getRegionInfoColumn());<a name="line.955"></a>
-<span class="sourceLineNo">956</span>    if (regionInfo == null) return null;<a name="line.956"></a>
-<span class="sourceLineNo">957</span><a name="line.957"></a>
-<span class="sourceLineNo">958</span>    List&lt;HRegionLocation&gt; locations = new ArrayList&lt;HRegionLocation&gt;(1);<a name="line.958"></a>
-<span class="sourceLineNo">959</span>    NavigableMap&lt;byte[],NavigableMap&lt;byte[],byte[]&gt;&gt; familyMap = r.getNoVersionMap();<a name="line.959"></a>
-<span class="sourceLineNo">960</span><a name="line.960"></a>
-<span class="sourceLineNo">961</span>    locations.add(getRegionLocation(r, regionInfo, 0));<a name="line.961"></a>
-<span class="sourceLineNo">962</span><a name="line.962"></a>
-<span class="sourceLineNo">963</span>    NavigableMap&lt;byte[], byte[]&gt; infoMap = familyMap.get(getCatalogFamily());<a name="line.963"></a>
-<span class="sourceLineNo">964</span>    if (infoMap == null) return new RegionLocations(locations);<a name="line.964"></a>
-<span class="sourceLineNo">965</span><a name="line.965"></a>
-<span class="sourceLineNo">966</span>    // iterate until all serverName columns are seen<a name="line.966"></a>
-<span class="sourceLineNo">967</span>    int replicaId = 0;<a name="line.967"></a>
-<span class="sourceLineNo">968</span>    byte[] serverColumn = getServerColumn(replicaId);<a name="line.968"></a>
-<span class="sourceLineNo">969</span>    SortedMap&lt;byte[], byte[]&gt; serverMap = infoMap.tailMap(serverColumn, false);<a name="line.969"></a>
-<span class="sourceLineNo">970</span>    if (serverMap.isEmpty()) return new RegionLocations(locations);<a name="line.970"></a>
+<span class="sourceLineNo">922</span>  @InterfaceAudience.Private // for use by HMaster#getTableRegionRow which is used for testing only<a name="line.922"></a>
+<span class="sourceLineNo">923</span>  public static ServerName getServerName(final Result r, final int replicaId) {<a name="line.923"></a>
+<span class="sourceLineNo">924</span>    byte[] serverColumn = getServerColumn(replicaId);<a name="line.924"></a>
+<span class="sourceLineNo">925</span>    Cell cell = r.getColumnLatestCell(getCatalogFamily(), serverColumn);<a name="line.925"></a>
+<span class="sourceLineNo">926</span>    if (cell == null || cell.getValueLength() == 0) return null;<a name="line.926"></a>
+<span class="sourceLineNo">927</span>    String hostAndPort = Bytes.toString(<a name="line.927"></a>
+<span class="sourceLineNo">928</span>      cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());<a name="line.928"></a>
+<span class="sourceLineNo">929</span>    byte[] startcodeColumn = getStartCodeColumn(replicaId);<a name="line.929"></a>
+<span class="sourceLineNo">930</span>    cell = r.getColumnLatestCell(getCatalogFamily(), startcodeColumn);<a name="line.930"></a>
+<span class="sourceLineNo">931</span>    if (cell == null || cell.getValueLength() == 0) return null;<a name="line.931"></a>
+<span class="sourceLineNo">932</span>    try {<a name="line.932"></a>
+<span class="sourceLineNo">933</span>      return ServerName.valueOf(hostAndPort,<a name="line.933"></a>
+<span class="sourceLineNo">934</span>          Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));<a name="line.934"></a>
+<span class="sourceLineNo">935</span>    } catch (IllegalArgumentException e) {<a name="line.935"></a>
+<span class="sourceLineNo">936</span>      LOG.error("Ignoring invalid region for server " + hostAndPort + "; cell=" + cell, e);<a name="line.936"></a>
+<span class="sourceLineNo">937</span>      return null;<a name="line.937"></a>
+<span class="sourceLineNo">938</span>    }<a name="line.938"></a>
+<span class="sourceLineNo">939</span>  }<a name="line.939"></a>
+<span class="sourceLineNo">940</span><a name="line.940"></a>
+<span class="sourceLineNo">941</span>  /**<a name="line.941"></a>
+<span class="sourceLineNo">942</span>   * The latest seqnum that the server writing to meta observed when opening the region.<a name="line.942"></a>
+<span class="sourceLineNo">943</span>   * E.g. the seqNum when the result of {@link #getServerName(Result, int)} was written.<a name="line.943"></a>
+<span class="sourceLineNo">944</span>   * @param r Result to pull the seqNum from<a name="line.944"></a>
+<span class="sourceLineNo">945</span>   * @return SeqNum, or HConstants.NO_SEQNUM if there's no value written.<a name="line.945"></a>
+<span class="sourceLineNo">946</span>   */<a name="line.946"></a>
+<span class="sourceLineNo">947</span>  private static long getSeqNumDuringOpen(final Result r, final int replicaId) {<a name="line.947"></a>
+<span class="sourceLineNo">948</span>    Cell cell = r.getColumnLatestCell(getCatalogFamily(), getSeqNumColumn(replicaId));<a name="line.948"></a>
+<span class="sourceLineNo">949</span>    if (cell == null || cell.getValueLength() == 0) return HConstants.NO_SEQNUM;<a name="line.949"></a>
+<span class="sourceLineNo">950</span>    return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());<a name="line.950"></a>
+<span class="sourceLineNo">951</span>  }<a name="line.951"></a>
+<span class="sourceLineNo">952</span><a name="line.952"></a>
+<span class="sourceLineNo">953</span>  /**<a name="line.953"></a>
+<span class="sourceLineNo">954</span>   * Returns an HRegionLocationList extracted from the result.<a name="line.954"></a>
+<span class="sourceLineNo">955</span>   * @return an HRegionLocationList containing all locations for the region range or null if<a name="line.955"></a>
+<span class="sourceLineNo">956</span>   *  we can't deserialize the result.<a name="line.956"></a>
+<span class="sourceLineNo">957</span>   */<a name="line.957"></a>
+<span class="sourceLineNo">958</span>  @Nullable<a name="line.958"></a>
+<span class="sourceLineNo">959</span>  public static RegionLocations getRegionLocations(final Result r) {<a name="line.959"></a>
+<span class="sourceLineNo">960</span>    if (r == null) return null;<a name="line.960"></a>
+<span class="sourceLineNo">961</span>    HRegionInfo regionInfo = getHRegionInfo(r, getRegionInfoColumn());<a name="line.961"></a>
+<span class="sourceLineNo">962</span>    if (regionInfo == null) return null;<a name="line.962"></a>
+<span class="sourceLineNo">963</span><a name="line.963"></a>
+<span class="sourceLineNo">964</span>    List&lt;HRegionLocation&gt; locations = new ArrayList&lt;HRegionLocation&gt;(1);<a name="line.964"></a>
+<span class="sourceLineNo">965</span>    NavigableMap&lt;byte[],NavigableMap&lt;byte[],byte[]&gt;&gt; familyMap = r.getNoVersionMap();<a name="line.965"></a>
+<span class="sourceLineNo">966</span><a name="line.966"></a>
+<span class="sourceLineNo">967</span>    locations.add(getRegionLocation(r, regionInfo, 0));<a name="line.967"></a>
+<span class="sourceLineNo">968</span><a name="line.968"></a>
+<span class="sourceLineNo">969</span>    NavigableMap&lt;byte[], byte[]&gt; infoMap = familyMap.get(getCatalogFamily());<a name="line.969"></a>
+<span class="sourceLineNo">970</span>    if (infoMap == null) return new RegionLocations(locations);<a name="line.970"></a>
 <span class="sourceLineNo">971</span><a name="line.971"></a>
-<span class="sourceLineNo">972</span>    for (Map.Entry&lt;byte[], byte[]&gt; entry : serverMap.entrySet()) {<a name="line.972"></a>
-<span class="sourceLineNo">973</span>      replicaId = parseReplicaIdFromServerColumn(entry.getKey());<a name="line.973"></a>
-<span class="sourceLineNo">974</span>      if (replicaId &lt; 0) {<a name="line.974"></a>
-<span class="sourceLineNo">975</span>        break;<a name="line.975"></a>
-<span class="sourceLineNo">976</span>      }<a name="line.976"></a>
-<span class="sourceLineNo">977</span>      HRegionLocation location = getRegionLocation(r, regionInfo, replicaId);<a name="line.977"></a>
-<span class="sourceLineNo">978</span>      // In case the region replica is newly created, it's location might be null. We usually do not<a name="line.978"></a>
-<span class="sourceLineNo">979</span>      // have HRL's in RegionLocations object with null ServerName. They are handled as null HRLs.<a name="line.979"></a>
-<span class="sourceLineNo">980</span>      if (location == null || location.getServerName() == null) {<a name="line.980"></a>
-<span class="sourceLineNo">981</span>        locations.add(null);<a name="line.981"></a>
-<span class="sourceLineNo">982</span>      } else {<a name="line.982"></a>
-<span class="sourceLineNo">983</span>        locations.add(location);<a name="line.983"></a>
-<span class="sourceLineNo">984</span>      }<a name="line.984"></a>
-<span class="sourceLineNo">985</span>    }<a name="line.985"></a>
-<span class="sourceLineNo">986</span><a name="line.986"></a>
-<span class="sourceLineNo">987</span>    return new RegionLocations(locations);<a name="line.987"></a>
-<span class="sourceLineNo">988</span>  }<a name="line.988"></a>
-<span class="sourceLineNo">989</span><a name="line.989"></a>
-<span class="sourceLineNo">990</span>  /**<a name="line.990"></a>
-<span class="sourceLineNo">991</span>   * Returns the HRegionLocation parsed from the given meta row Result<a name="line.991"></a>
-<span class="sourceLineNo">992</span>   * for the given regionInfo and replicaId. The regionInfo can be the default region info<a name="line.992"></a>
-<span class="sourceLineNo">993</span>   * for the replica.<a name="line.993"></a>
-<span class="sourceLineNo">994</span>   * @param r the meta row result<a name="line.994"></a>
-<span class="sourceLineNo">995</span>   * @param regionInfo RegionInfo for default replica<a name="line.995"></a>
-<span class="sourceLineNo">996</span>   * @param replicaId the replicaId for the HRegionLocation<a name="line.996"></a>
-<span class="sourceLineNo">997</span>   * @return HRegionLocation parsed from the given meta row Result for the given replicaId<a name="line.997"></a>
-<span class="sourceLineNo">998</span>   */<a name="line.998"></a>
-<span class="sourceLineNo">999</span>  private static HRegionLocation getRegionLocation(final Result r, final HRegionInfo regionInfo,<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>                                                   final int replicaId) {<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>    ServerName serverName = getServerName(r, replicaId);<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>    long seqNum = getSeqNumDuringOpen(r, replicaId);<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>    HRegionInfo replicaInfo = RegionReplicaUtil.getRegionInfoForReplica(regionInfo, replicaId);<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>    return new HRegionLocation(replicaInfo, serverName, seqNum);<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>  }<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span><a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>  /**<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>   * Returns HRegionInfo object from the column<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>   * HConstants.CATALOG_FAMILY:HConstants.REGIONINFO_QUALIFIER of the catalog<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>   * table Result.<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>   * @param data a Result object from the catalog table scan<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>   * @return HRegionInfo or null<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>   */<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>  public static HRegionInfo getHRegionInfo(Result data) {<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>    return getHRegionInfo(data, HConstants.REGIONINFO_QUALIFIER);<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>  }<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span><a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>  /**<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>   * Returns the HRegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>   * &lt;code&gt;qualifier&lt;/code&gt; of the catalog table result.<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>   * @param r a Result object from the catalog table scan<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>   * @param qualifier Column family qualifier<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>   * @return An HRegionInfo instance or null.<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>   */<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>  @Nullable<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>  private static HRegionInfo getHRegionInfo(final Result r, byte [] qualifier) {<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>    Cell cell = r.getColumnLatestCell(getCatalogFamily(), qualifier);<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>    if (cell == null) return null;<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>    return HRegionInfo.parseFromOrNull(cell.getValueArray(),<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>      cell.getValueOffset(), cell.getValueLength());<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>  }<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span><a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>  /**<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>   * Returns the daughter regions by reading the corresponding columns of the catalog table<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>   * Result.<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>   * @param data a Result object from the catalog table scan<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>   * @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>   * parent<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>   */<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>  public static PairOfSameType&lt;HRegionInfo&gt; getDaughterRegions(Result data) {<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>    HRegionInfo splitA = getHRegionInfo(data, HConstants.SPLITA_QUALIFIER);<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>    HRegionInfo splitB = getHRegionInfo(data, HConstants.SPLITB_QUALIFIER);<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span><a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>    return new PairOfSameType&lt;HRegionInfo&gt;(splitA, splitB);<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>  }<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span><a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>  /**<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>   * Returns the merge regions by reading the corresponding columns of the catalog table<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>   * Result.<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>   * @param data a Result object from the catalog table scan<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>   * @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>   * parent<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>   */<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>  public static PairOfSameType&lt;HRegionInfo&gt; getMergeRegions(Result data) {<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>    HRegionInfo mergeA = getHRegionInfo(data, HConstants.MERGEA_QUALIFIER);<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    HRegionInfo mergeB = getHRegionInfo(data, HConstants.MERGEB_QUALIFIER);<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span><a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>    return new PairOfSameType&lt;HRegionInfo&gt;(mergeA, mergeB);<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>  }<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span><a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>  /**<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>   * Fetch table state for given table from META table<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>   * @param conn connection to use<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>   * @param tableName table to fetch state for<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>   * @return state<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>   * @throws IOException<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>   */<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>  @Nullable<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>  public static TableState getTableState(Connection conn, TableName tableName)<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>      throws IOException {<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>    Table metaHTable = getMetaHTable(conn);<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span>    Get get = new Get(tableName.getName()).addColumn(getTableFamily(), getStateColumn());<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>    long time = EnvironmentEdgeManager.currentTime();<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>    get.setTimeRange(0, time);<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>    Result result =<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>        metaHTable.get(get);<a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>    return getTableState(result);<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>  }<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span><a name="line.1079"></a>
-<span class="sourceLineNo">1080</span>  /**<a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>   * Fetch table states from META table<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>   * @param conn connection to use<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>   * @return map {tableName -&amp;gt; state}<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span>   * @throws IOException<a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>   */<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>  public static Map&lt;TableName, TableState&gt; getTableStates(Connection conn)<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>      throws IOException {<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span>    final Map&lt;TableName, TableState&gt; states = new LinkedHashMap&lt;&gt;();<a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>    Visitor collector = new Visitor() {<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>      @Override<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>      public boolean visit(Result r) throws IOException {<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span>        TableState state = getTableState(r);<a name="line.1092"></a>
-<span class="sourceLineNo">1093</span>        if (state != null)<a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>          states.put(state.getTableName(), state);<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>        return true;<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span>      }<a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>    };<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>    fullScanTables(conn, collector);<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>    return states;<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span>  }<a name="line.1100"></a>
-<span class="sourceLineNo">1101</span><a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>  /**<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>   * Updates state in META<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>   * @param conn connection to use<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>   * @param tableName table to look for<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>   * @throws IOException<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span>   */<a name="line.1107"></a>
-<span class="sourceLineNo">1108</span>  public static void updateTableState(Connection conn, TableName tableName,<a name="line.1108"></a>
-<span class="sourceLineNo">1109</span>      TableState.State actual) throws IOException {<a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>    updateTableState(conn, new TableState(tableName, actual));<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>  }<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span><a name="line.1112"></a>
-<span class="sourceLineNo">1113</span>  /**<a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>   * Decode table state from META Result.<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span>   * Should contain cell from HConstants.TABLE_FAMILY<a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>   * @param r result<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>   * @return null if not found<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>   * @throws IOException<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>   */<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>  @Nullable<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>  public static TableState getTableState(Result r)<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span>      throws IOException {<a name="line.1122"></a>
-<span class="sourceLineNo">1123</span>    Cell cell = r.getColumnLatestCell(getTableFamily(), getStateColumn());<a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>    if (cell == null) return null;<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>    try {<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>      return TableState.parseFrom(TableName.valueOf(r.getRow()),<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>          Arrays.copyOfRange(cell.getValueArray(),<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>          cell.getValueOffset(), cell.getValueOffset() + cell.getValueLength()));<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>    } catch (DeserializationException e) {<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span>      throw new IOException(e);<a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>    }<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span><a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>  }<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span><a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>  /**<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>   * Implementations 'visit' a catalog table row.<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>   */<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span>  public interface Visitor {<a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>    /**<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>     * Visit the catalog table row.<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>     * @param r A row from catalog table<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span>     * @return True if we are to proceed scanning the table, else false if<a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>     * we are to stop now.<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span>     */<a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>    boolean visit(final Result r) throws IOException;<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>  }<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span><a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>  /**<a name="line.1148"></a>
-<span class="sourceLineNo">1149</span>   * Implementations 'visit' a catalog table row but with close() at the end.<a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>   */<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span>  public interface CloseableVisitor extends Visitor, Closeable {<a name="line.1151"></a>
+<span class="sourceLineNo">972</span>    // iterate until all serverName columns are seen<a name="line.972"></a>
+<span class="sourceLineNo">973</span>    int replicaId = 0;<a name="line.973"></a>
+<span class="sourceLineNo">974</span>    byte[] serverColumn = getServerColumn(replicaId);<a name="line.974"></a>
+<span class="sourceLineNo">975</span>    SortedMap&lt;byte[], byte[]&gt; serverMap = infoMap.tailMap(serverColumn, false);<a name="line.975"></a>
+<span class="sourceLineNo">976</span>    if (serverMap.isEmpty()) return new RegionLocations(locations);<a name="line.976"></a>
+<span class="sourceLineNo">977</span><a name="line.977"></a>
+<span class="sourceLineNo">978</span>    for (Map.Entry&lt;byte[], byte[]&gt; entry : serverMap.entrySet()) {<a name="line.978"></a>
+<span class="sourceLineNo">979</span>      replicaId = parseReplicaIdFromServerColumn(entry.getKey());<a name="line.979"></a>
+<span class="sourceLineNo">980</span>      if (replicaId &lt; 0) {<a name="line.980"></a>
+<span class="sourceLineNo">981</span>        break;<a name="line.981"></a>
+<span class="sourceLineNo">982</span>      }<a name="line.982"></a>
+<span class="sourceLineNo">983</span>      HRegionLocation location = getRegionLocation(r, regionInfo, replicaId);<a name="line.983"></a>
+<span class="sourceLineNo">984</span>      // In case the region replica is newly created, it's location might be null. We usually do not<a name="line.984"></a>
+<span class="sourceLineNo">985</span>      // have HRL's in RegionLocations object with null ServerName. They are handled as null HRLs.<a name="line.985"></a>
+<span class="sourceLineNo">986</span>      if (location == null || location.getServerName() == null) {<a name="line.986"></a>
+<span class="sourceLineNo">987</span>        locations.add(null);<a name="line.987"></a>
+<span class="sourceLineNo">988</span>      } else {<a name="line.988"></a>
+<span class="sourceLineNo">989</span>        locations.add(location);<a name="line.989"></a>
+<span class="sourceLineNo">990</span>      }<a name="line.990"></a>
+<span class="sourceLineNo">991</span>    }<a name="line.991"></a>
+<span class="sourceLineNo">992</span><a name="line.992"></a>
+<span class="sourceLineNo">993</span>    return new RegionLocations(locations);<a name="line.993"></a>
+<span class="sourceLineNo">994</span>  }<a name="line.994"></a>
+<span class="sourceLineNo">995</span><a name="line.995"></a>
+<span class="sourceLineNo">996</span>  /**<a name="line.996"></a>
+<span class="sourceLineNo">997</span>   * Returns the HRegionLocation parsed from the given meta row Result<a name="line.997"></a>
+<span class="sourceLineNo">998</span>   * for the given regionInfo and replicaId. The regionInfo can be the default region info<a name="line.998"></a>
+<span class="sourceLineNo">999</span>   * for the replica.<a name="line.999"></a>
+<span class="sourceLineNo">1000</span>   * @param r the meta row result<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>   * @param regionInfo RegionInfo for default replica<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>   * @param replicaId the replicaId for the HRegionLocation<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>   * @return HRegionLocation parsed from the given meta row Result for the given replicaId<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span>   */<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>  private static HRegionLocation getRegionLocation(final Result r, final HRegionInfo regionInfo,<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>                                                   final int replicaId) {<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>    ServerName serverName = getServerName(r, replicaId);<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span>    long seqNum = getSeqNumDuringOpen(r, replicaId);<a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>    HRegionInfo replicaInfo = RegionReplicaUtil.getRegionInfoForReplica(regionInfo, replicaId);<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>    return new HRegionLocation(replicaInfo, serverName, seqNum);<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>  }<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span><a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>  /**<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>   * Returns HRegionInfo object from the column<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>   * HConstants.CATALOG_FAMILY:HConstants.REGIONINFO_QUALIFIER of the catalog<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>   * table Result.<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>   * @param data a Result object from the catalog table scan<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span>   * @return HRegionInfo or null<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>   */<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>  public static HRegionInfo getHRegionInfo(Result data) {<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>    return getHRegionInfo(data, HConstants.REGIONINFO_QUALIFIER);<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span>  }<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span><a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>  /**<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>   * Returns the HRegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>   * &lt;code&gt;qualifier&lt;/code&gt; of the catalog table result.<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>   * @param r a Result object from the catalog table scan<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>   * @param qualifier Column family qualifier<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>   * @return An HRegionInfo instance or null.<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>   */<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>  @Nullable<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>  private static HRegionInfo getHRegionInfo(final Result r, byte [] qualifier) {<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>    Cell cell = r.getColumnLatestCell(getCatalogFamily(), qualifier);<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>    if (cell == null) return null;<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>    return HRegionInfo.parseFromOrNull(cell.getValueArray(),<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>      cell.getValueOffset(), cell.getValueLength());<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>  }<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span><a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>  /**<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span>   * Returns the daughter regions by reading the corresponding columns of the catalog table<a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>   * Result.<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>   * @param data a Result object from the catalog table scan<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>   * @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>   * parent<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>   */<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>  public static PairOfSameType&lt;HRegionInfo&gt; getDaughterRegions(Result data) {<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span>    HRegionInfo splitA = getHRegionInfo(data, HConstants.SPLITA_QUALIFIER);<a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>    HRegionInfo splitB = getHRegionInfo(data, HConstants.SPLITB_QUALIFIER);<a name="line.1048"></a>
+<span class="sourceLineNo">1049</span><a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>    return new PairOfSameType&lt;HRegionInfo&gt;(splitA, splitB);<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>  }<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span><a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>  /**<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>   * Returns the merge regions by reading the corresponding columns of the catalog table<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>   * Result.<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span>   * @param data a Result object from the catalog table scan<a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>   * @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>   * parent<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>   */<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>  public static PairOfSameType&lt;HRegionInfo&gt; getMergeRegions(Result data) {<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span>    HRegionInfo mergeA = getHRegionInfo(data, HConstants.MERGEA_QUALIFIER);<a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>    HRegionInfo mergeB = getHRegionInfo(data, HConstants.MERGEB_QUALIFIER);<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span><a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>    return new PairOfSameType&lt;HRegionInfo&gt;(mergeA, mergeB);<a name="line.1064"></a>
+<span class="sourceLineNo">1065</span>  }<a name="line.1065"></a>
+<span class="sourceLineNo">1066</span><a name="line.1066"></a>
+<span class="sourceLineNo">1067</span>  /**<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>   * Fetch table state for given table from META table<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span>   * @param conn connection to use<a name="line.1069"></a>
+<span class="sourceLineNo">1070</span>   * @param tableName table to fetch state for<a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>   * @return state<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span>   * @throws IOException<a name="line.1072"></a>
+<span class="sourceLineNo">1073</span>   */<a name="line.1073"></a>
+<span class="sourceLineNo">1074</span>  @Nullable<a name="line.1074"></a>
+<span class="sourceLineNo">1075</span>  public static TableState getTableState(Connection conn, TableName tableName)<a name="line.1075"></a>
+<span class="sourceLineNo">1076</span>      throws IOException {<a name="line.1076"></a>
+<span class="sourceLineNo">1077</span>    Table metaHTable = getMetaHTable(conn);<a name="line.1077"></a>
+<span class="sourceLineNo">1078</span>    Get get = new Get(tableName.getName()).addColumn(getTableFamily(), getStateColumn());<a name="line.1078"></a>
+<span class="sourceLineNo">1079</span>    long time = EnvironmentEdgeManager.currentTime();<a name="line.1079"></a>
+<span class="sourceLineNo">1080</span>    get.setTimeRange(0, time);<a name="line.1080"></a>
+<span class="sourceLineNo">1081</span>    Result result =<a name="line.1081"></a>
+<span class="sourceLineNo">1082</span>        metaHTable.get(get);<a name="line.1082"></a>
+<span class="sourceLineNo">1083</span>    return getTableState(result);<a name="line.1083"></a>
+<span class="sourceLineNo">1084</span>  }<a name="line.1084"></a>
+<span class="sourceLineNo">1085</span><a name="line.1085"></a>
+<span class="sourceLineNo">1086</span>  /**<a name="line.1086"></a>
+<span class="sourceLineNo">1087</span>   * Fetch table states from META table<a name="line.1087"></a>
+<span class="sourceLineNo">1088</span>   * @param conn connection to use<a name="line.1088"></a>
+<span class="sourceLineNo">1089</span>   * @return map {tableName -&amp;gt; state}<a name="line.1089"></a>
+<span class="sourceLineNo">1090</span>   * @throws IOException<a name="line.1090"></a>
+<span class="sourceLineNo">1091</span>   */<a name="line.1091"></a>
+<span class="sourceLineNo">1092</span>  public static Map&lt;TableName, TableState&gt; getTableStates(Connection conn)<a name="line.1092"></a>
+<span class="sourceLineNo">1093</span>      throws IOException {<a name="line.1093"></a>
+<span class="sourceLineNo">1094</span>    final Map&lt;TableName, TableState&gt; states = new LinkedHashMap&lt;&gt;();<a name="line.1094"></a>
+<span class="sourceLineNo">1095</span>    Visitor collector = new Visitor() {<a name="line.1095"></a>
+<span class="sourceLineNo">1096</span>      @Override<a name="line.1096"></a>
+<span class="sourceLineNo">1097</span>      public boolean visit(Result r) throws IOException {<a name="line.1097"></a>
+<span class="sourceLineNo">1098</span>        TableState state = getTableState(r);<a name="line.1098"></a>
+<span class="sourceLineNo">1099</span>        if (state != null)<a name="line.1099"></a>
+<span class="sourceLineNo">1100</span>          states.put(state.getTableName(), state);<a name="line.1100"></a>
+<span class="sourceLineNo">1101</span>        return true;<a name="line.1101"></a>
+<span class="sourceLineNo">1102</span>      }<a name="line.1102"></a>
+<span class="sourceLineNo">1103</span>    };<a name="line.1103"></a>
+<span class="sourceLineNo">1104</span>    fullScanTables(conn, collector);<a name="line.1104"></a>
+<span class="sourceLineNo">1105</span>    return states;<a name="line.1105"></a>
+<span class="sourceLineNo">1106</span>  }<a name="line.1106"></a>
+<span class="sourceLineNo">1107</span><a name="line.1107"></a>
+<span class="sourceLineNo">1108</span>  /**<a name="line.1108"></a>
+<span class="sourceLineNo">1109</span>   * Updates state in META<a name="line.1109"></a>
+<span class="sourceLineNo">1110</span>   * @param conn connection to use<a name="line.1110"></a>
+<span class="sourceLineNo">1111</span>   * @param tableName table to look for<a name="line.1111"></a>
+<span class="sourceLineNo">1112</span>   * @throws IOException<a name="line.1112"></a>
+<span class="sourceLineNo">1113</span>   */<a name="line.1113"></a>
+<span class="sourceLineNo">1114</span>  public static void updateTableState(Connection conn, TableName tableName,<a name="line.1114"></a>
+<span class="sourceLineNo">1115</span>      TableState.State actual) throws IOException {<a name="line.1115"></a>
+<span class="sourceLineNo">1116</span>    updateTableState(conn, new TableState(tableName, actual));<a name="line.1116"></a>
+<span class="sourceLineNo">1117</span>  }<a name="line.1117"></a>
+<span class="sourceLineNo">1118</span><a name="line.1118"></a>
+<span class="sourceLineNo">1119</span>  /**<a name="line.1119"></a>
+<span class="sourceLineNo">1120</span>   * Decode table state from META Result.<a name="line.1120"></a>
+<span class="sourceLineNo">1121</span>   * Should contain cell from HConstants.TABLE_FAMILY<a name="line.1121"></a>
+<span class="sourceLineNo">1122</span>   * @param r result<a name="line.1122"></a>
+<span class="sourceLineNo">1123</span>   * @return null if not found<a name="line.1123"></a>
+<span class="sourceLineNo">1124</span>   * @throws IOException<a name="line.1124"></a>
+<span class="sourceLineNo">1125</span>   */<a name="line.1125"></a>
+<span class="sourceLineNo">1126</span>  @Nullable<a name="line.1126"></a>
+<span class="sourceLineNo">1127</span>  public static TableState getTableState(Result r)<a name="line.1127"></a>
+<span class="sourceLineNo">1128</span>      throws IOException {<a name="line.1128"></a>
+<span class="sourceLineNo">1129</span>    Cell cell = r.getColumnLatestCell(getTableFamily(), getStateColumn());<a name="line.1129"></a>
+<span class="sourceLineNo">1130</span>    if (cell == null) return null;<a name="line.1130"></a>
+<span class="sourceLineNo">1131</span>    try {<a name="line.1131"></a>
+<span class="sourceLineNo">1132</span>      return TableState.parseFrom(TableName.valueOf(r.getRow()),<a name="line.1132"></a>
+<span class="sourceLineNo">1133</span>          Arrays.copyOfRange(cell.getValueArray(),<a name="line.1133"></a>
+<span class="sourceLineNo">1134</span>          cell.getValueOffset(), cell.getValueOffset() + cell.getValueLength()));<a name="line.1134"></a>
+<span class="sourceLineNo">1135</span>    } catch (DeserializationException e) {<a name="line.1135"></a>
+<span class="sourceLineNo">1136</span>      throw new IOException(e);<a name="line.1136"></a>
+<span class="sourceLineNo">1137</span>    }<a name="line.1137"></a>
+<span class="sourceLineNo">1138</span><a name="line.1138"></a>
+<span class="sourceLineNo">1139</span>  }<a name="line.1139"></a>
+<span class="sourceLineNo">1140</span><a name="line.1140"></a>
+<span class="sourceLineNo">1141</span>  /**<a name="line.1141"></a>
+<span class="sourceLineNo">1142</span>   * Implementations 'visit' a catalog table row.<a name="line.1142"></a>
+<span class="sourceLineNo">1143</span>   */<a name="line.1143"></a>
+<span class="sourceLineNo">1144</span>  public interface Visitor {<a name="line.1144"></a>
+<span class="sourceLineNo">1145</span>    /**<a name="line.1145"></a>
+<span class="sourceLineNo">1146</span>     * Visit the catalog table row.<a name="line.1146"></a>
+<span class="sourceLineNo">1147</span>     * @param r A row from catalog table<a name="line.1147"></a>
+<span class="sourceLineNo">1148</span>     * @return True if we are to proceed scanning the table, else false if<a name="line.1148"></a>
+<span class="sourceLineNo">1149</span>     * we are to stop now.<a name="line.1149"></a>
+<span class="sourceLineNo">1150</span>     */<a name="line.1150"></a>
+<span class="sourceLineNo">1151</span>    boolean visit(final Result r) throws IOException;<a name="line.1151"></a>
 <span class="sourceLineNo">1152</span>  }<a name="line.1152"></a>
 <span class="sourceLineNo">1153</span><a name="line.1153"></a>
 <span class="sourceLineNo">1154</span>  /**<a name="line.1154"></a>
-<span class="sourceLineNo">1155</span>   * A {@link Visitor} that collects content out of passed {@link Result}.<a name="line.1155"></a>
+<span class="sourceLineNo">1155</span>   * Implementations 'visit' a catalog table row but with close() at the end.<a name="line.1155"></a>
 <span class="sourceLineNo">1156</span>   */<a name="line.1156"></a>
-<span class="sourceLineNo">1157</span>  static abstract class CollectingVisitor&lt;T&gt; implements Visitor {<a name="line.1157"></a>
-<span class="sourceLineNo">1158</span>    final List&lt;T&gt; results = new ArrayList&lt;T&gt;();<a name="line.1158"></a>
-<span class="sourceLineNo">1159</span>    @Override<a name="line.1159"></a>
-<span class="sourceLineNo">1160</span>    public boolean visit(Result r) throws IOException {<a name="line.1160"></a>
-<span class="sourceLineNo">1161</span>      if (r ==  null || r.isEmpty()) return true;<a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>      add(r);<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span>      return true;<a name="line.1163"></a>
-<span class="sourceLineNo">1164</span>    }<a name="line.1164"></a>
-<span class="sourceLineNo">1165</span><a name="line.1165"></a>
-<span class="sourceLineNo">1166</span>    abstract void add(Result r);<a name="line.1166"></a>
-<span class="sourceLineNo">1167</span><a name="line.1167"></a>
-<span class="sourceLineNo">1168</span>    /**<a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>     * @return Collected results; wait till visits complete to collect all<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span>     * possible results<a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>     */<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span>    List&lt;T&gt; getResults() {<a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>      return this.results;<a name="line.1173"></a>
-<span class="sourceLineNo">1174</span>    }<a name="line.1174"></a>
-<span class="sourceLineNo">1175</span>  }<a name="line.1175"></a>
-<span class="sourceLineNo">1176</span><a name="line.1176"></a>
-<span class="sourceLineNo">1177</span>  /**<a name="line.1177"></a>
-<span class="sourceLineNo">1178</span>   * Collects all returned.<a name="line.1178"></a>
-<span class="sourceLineNo">1179</span>   */<a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>  static class CollectAllVisitor extends CollectingVisitor&lt;Result&gt; {<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>    @Override<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>    void add(Result r) {<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>      this.results.add(r);<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>    }<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>  }<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span><a name="line.1186"></a>
-<span class="sourceLineNo">1187</span>  /**<a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>   * A Visitor that skips offline regions and split parents<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>   */<a name="line.1189"></a>
-<span class="sourceLineNo">1190</span>  public static abstract class DefaultVisitorBase implements Visitor {<a name="line.1190"></a>
-<span class="sourceLineNo">1191</span><a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>    public DefaultVisitorBase() {<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>      super();<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span>    }<a name="line.1194"></a>
-<span class="sourceLineNo">1195</span><a name="line.1195"></a>
-<span class="sourceLineNo">1196</span>    public abstract boolean visitInternal(Result rowResult) throws IOException;<a name="line.1196"></a>
+<span class="sourceLineNo">1157</span>  public interface CloseableVisitor extends Visitor, Closeable {<a name="line.1157"></a>
+<span class="sourceLineNo">1158</span>  }<a name="line.1158"></a>
+<span class="sourceLineNo">1159</span><a name="line.1159"></a>
+<span class="sourceLineNo">1160</span>  /**<a name="line.1160"></a>
+<span class="sourceLineNo">1161</span>   * A {@link Visitor} that collects content out of passed {@link Result}.<a name="line.1161"></a>
+<span class="sourceLineNo">1162</span>   */<a name="line.1162"></a>
+<span class="sourceLineNo">1163</span>  static abstract class CollectingVisitor&lt;T&gt; implements Visitor {<a name="line.1163"></a>
+<span class="sourceLineNo">1164</span>    final List&lt;T&gt; results = new ArrayList&lt;T&gt;();<a name="line.1164"></a>
+<span class="sourceLineNo">1165</span>    @Override<a name="line.1165"></a>
+<span class="sourceLineNo">1166</span>    public boolean visit(Result r) throws IOException {<a name="line.1166"></a>
+<span class="sourceLineNo">1167</span>      if (r ==  null || r.isEmpty()) return true;<a name="line.1167"></a>
+<span class="sourceLineNo">1168</span>      add(r);<a name="line.1168"></a>
+<span class="sourceLineNo">1169</span>      return true;<a name="line.1169"></a>
+<span class="sourceLineNo">1170</span>    }<a name="line.1170"></a>
+<span class="sourceLineNo">1171</span><a name="line.1171"></a>
+<span class="sourceLineNo">1172</span>    abstract void add(Result r);<a name="line.1172"></a>
+<span class="sourceLineNo">1173</span><a name="line.1173"></a>
+<span class="sourceLineNo">1174</span>    /**<a name="line.1174"></a>
+<span class="sourceLineNo">1175</span>     * @return Collected results; wait till visits complete to collect all<a name="line.1175"></a>
+<span class="sourceLineNo">1176</span>     * possible results<a name="line.1176"></a>
+<span class="sourceLineNo">1177</span>     */<a name="line.1177"></a>
+<span class="sourceLineNo">1178</span>    List&lt;T&gt; getResults() {<a name="line.1178"></a>
+<span class="sourceLineNo">1179</span>      return this.results;<a name="line.1179"></a>
+<span class="sourceLineNo">1180</span>    }<a name="line.1180"></a>
+<span class="sourceLineNo">1181</span>  }<a name="line.1181"></a>
+<span class="sourceLineNo">1182</span><a name="line.1182"></a>
+<span class="sourceLineNo">1183</span>  /**<a name="line.1183"></a>
+<span class="sourceLineNo">1184</span>   * Collects all returned.<a name="line.1184"></a>
+<span class="sourceLineNo">1185</span>   */<a name="line.1185"></a>
+<span class="sourceLineNo">1186</span>  static class CollectAllVisitor extends CollectingVisitor&lt;Result&gt; {<a name="line.1186"></a>
+<span class="sourceLineNo">1187</span>    @Override<a name="line.1187"></a>
+<span class="sourceLineNo">1188</span>    void add(Result r) {<a name="line.1188"></a>
+<span class="sourceLineNo">1189</span>      this.results.add(r);<a name="line.1189"></a>
+<span class="sourceLineNo">1190</span>    }<a name="line.1190"></a>
+<span class="sourceLineNo">1191</span>  }<a name="line.1191"></a>
+<span class="sourceLineNo">1192</span><a name="line.1192"></a>
+<span class="sourceLineNo">1193</span>  /**<a name="line.1193"></a>
+<span class="sourceLineNo">1194</span>   * A Visitor that skips offline regions and split parents<a name="line.1194"></a>
+<span class="sourceLineNo">1195</span>   */<a name="line.1195"></a>
+<span class="sourceLineNo">1196</span>  public static abstract class DefaultVisitorBase implements Visitor {<a name="line.1196"></a>
 <span class="sourceLineNo">1197</span><a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>    @Override<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span>    public boolean visit(Result rowResult) throws IOException {<a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>      HRegionInfo info = getHRegionInfo(rowResult);<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>      if (info == null) {<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>        return true;<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>      }<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span><a name="line.1204"></a>
-<span class="sourceLineNo">1205</span>      //skip over offline and split regions<a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>      if (!(info.isOffline() || info.isSplit())) {<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span>        return visitInternal(rowResult);<a name="line.1207"></a>
-<span class="sourceLineNo">1208</span>      }<a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>      return true;<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>    }<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>  }<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span><a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>  /**<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>   * A Visitor for a table. Provides a consistent view of the table's<a name="line.1214"></a>
-<span class="sourceLineNo">1215</span>   * hbase:meta entries during concurrent splits (see HBASE-5986 for details). This class<a name="line.1215"></a>
-<span class="sourceLineNo">1216</span>   * does not guarantee ordered traversal of meta entries, and can block until the<a name="line.1216"></a>
-<span class="sourceLineNo">1217</span>   * hbase:meta entries for daughters are available during splits.<a name="line.1217"></a>
-<span class="sourceLineNo">1218</span>   */<a name="line.1218"></a>
-<span class="sourceLineNo">1219</span>  public static abstract class TableVisitorBase extends DefaultVisitorBase {<a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>    private TableName tableName;<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span><a name="line.1221"></a>
-<span class="sourceLineNo">1222</span>    public TableVisitorBase(TableName tableName) {<a name="line.1222"></a>
-<span class="sourceLineNo">1223</span>      super();<a name="line.1223"></a>
-<span class="sourceLineNo">1224</span>      this.tableName = tableName;<a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>    }<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span><a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>    @Override<a name="line.1227"></a>
-<span class="sourceLineNo">1228</span>    public final boolean visit(Result rowResult) throws IOException {<a name="line.1228"></a>
-<span class="sourceLineNo">1229</span>      HRegionInfo info = getHRegionInfo(rowResult);<a name="line.1229"></a>
-<span class="sourceLineNo">1230</span>      if (info == null) {<a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>        return true;<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span>      }<a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>      if (!(info.getTable().equals(tableName))) {<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span>        return false;<a name="line.1234"></a>
-<span class="sourceLineNo">1235</span>      }<a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>      return super.visit(rowResult);<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span>    }<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span>  }<a name="line.1238"></a>
-<span class="sourceLineNo">1239</span><a name="line.1239"></a>
-<span class="sourceLineNo">1240</span>  /**<a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>   * Count regions in &lt;code&gt;hbase:meta&lt;/code&gt; for passed table.<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>   * @param c Configuration object<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>   * @param tableName table name to count regions for<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>   * @return Count or regions in table &lt;code&gt;tableName&lt;/code&gt;<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span>   * @throws IOException<a name="line.1245"></a>
-<span class="sourceLineNo">1246</span>   */<a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>  @Deprecated<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span>  public static int getRegionCount(final Configuration c, final String tableName)<a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>      throws IOException {<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>    return getRegionCount(c, TableName.valueOf(tableName));<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span>  }<a name="line.1251"></a>
-<span class="sourceLineNo">1252</span><a name="line.1252"></a>
-<span class="sourceLineNo">1253</span>  /**<a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>   * Count regions in &lt;code&gt;hbase:meta&lt;/code&gt; for passed table.<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>   * @param c Configuration object<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span>   * @param tableName table name to count regions for<a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>   * @return Count or regions in table &lt;code&gt;tableName&lt;/code&gt;<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span>   * @throws IOException<a name="line.1258"></a>
-<span class="sourceLineNo">1259</span>   */<a name="line.1259"></a>
-<span class="sourceLineNo">1260</span>  public static int getRegionCount(final Configuration c, final TableName tableName)<a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>  throws IOException {<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span>    try (Connection connection = ConnectionFactory.createConnection(c)) {<a name="line.1262"></a>
-<span class="sourceLineNo">1263</span>      return getRegionCount(connection, tableName);<a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>    }<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>  }<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span><a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>  /**<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span>   * Count regions in &lt;code&gt;hbase:meta&lt;/code&gt; for passed table.<a name="line.1268"></a>
-<span class="sourceLineNo">1269</span>   * @param connection Connection object<a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>   * @param tableName table name to count regions for<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>   * @return Count or regions in table &lt;code&gt;tableName&lt;/code&gt;<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span>   * @throws IOException<a name="line.1272"></a>
-<span class="sourceLineNo">1273</span>   */<a name="line.1273"></a>
-<span class="sourceLineNo">1274</span>  public static int getRegionCount(final Connection connection, final TableName tableName)<a name="line.1274"></a>
-<span class="sourceLineNo">1275</span>  throws IOException {<a name="line.1275"></a>
-<span class="sourceLineNo">1276</span>    try (RegionLocator locator = connection.getRegionLocator(tableName)) {<a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>      List&lt;HRegionLocation&gt; locations = locator.getAllRegionLocations();<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span>      return locations == null? 0: locations.size();<a name="line.1278"></a>
-<span class="sourceLineNo">1279</span>    }<a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>  }<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span><a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>  ////////////////////////<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>  // Editing operations //<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>  ////////////////////////<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span><a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>  /**<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>   * Generates and returns a Put containing the region into for the catalog table<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span>   */<a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>  public static Put makePutFromRegionInfo(HRegionInfo regionInfo)<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>    throws IOException {<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span>    return makePutFromRegionInfo(regionInfo, EnvironmentEdgeManager.currentTime());<a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>  }<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span><a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>  /**<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>   * Generates and returns a Put containing the region into for the catalog table<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>   */<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span>  public static Put makePutFromRegionInfo(HRegionInfo regionInfo, long ts)<a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>    throws IOException {<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>    Put put = new Put(regionInfo.getRegionName(), ts);<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>    addRegionInfo(put, regionInfo);<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>    return put;<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>  }<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span><a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>  /**<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>   * Generates and returns a Delete containing the region info for the catalog<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span>   * table<a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>   */<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>  public static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo) {<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>    long now = EnvironmentEdgeManager.currentTime();<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>    return makeDeleteFromRegionInfo(regionInfo, now);<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>  }<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span><a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>  /**<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span>   * Generates and returns a Delete containing the region info for the catalog<a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>   * table<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>   */<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>  public static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo, long ts) {<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>    if (regionInfo == null) {<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>      throw new IllegalArgumentException("Can't make a delete for null region");<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>    }<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>    Delete delete = new Delete(regionInfo.getRegionName());<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>    delete.addFamily(getCatalogFamily(), ts);<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>    return delete;<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>  }<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span><a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>  /**<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>   * Adds split daughters to the Put<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>   */<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>  public static Put addDaughtersToPut(Put put, HRegionInfo splitA, HRegionInfo splitB) {<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>    if (splitA != null) {<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>      put.addImmutable(<a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>        HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER, splitA.toByteArray());<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span>    }<a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>    if (splitB != null) {<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>      put.addImmutable(<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span>        HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER, splitB.toByteArray());<a name="line.1336"></a>
-<span class="sourceLineNo">1337</span>    }<a name="line.1337"></a>
-<span class="sourceLineNo">1338</span>    return put;<a name="line.1338"></a>
-<span class="sourceLineNo">1339</span>  }<a name="line.1339"></a>
-<span class="sourceLineNo">1340</span><a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>  /**<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>   * Put the passed &lt;code&gt;p&lt;/code&gt; to the &lt;code&gt;hbase:meta&lt;/code&gt; table.<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span>   * @param connection connection we're using<a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>   * @param p Put to add to hbase:meta<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span>   * @throws IOException<a name="line.1345"></a>
-<span class="sourceLineNo">1346</span>   */<a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>  static void putToMetaTable(final Connection connection, final Put p)<a name="line.1347"></a>
-<span class="sourceLineNo">1348</span>    throws IOException {<a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>    put(getMetaHTable(connection), p);<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>  }<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span><a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>  /**<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>   * @param t Table to use (will be closed when done).<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>   * @param p put to make<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>   * @throws IOException<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span>   */<a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>  private static void put(final Table t, final Put p) throws IOException {<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>    try {<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span>      if (METALOG.isDebugEnabled()) {<a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>        METALOG.debug(mutationToString(p));<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span>      }<a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>      t.put(p);<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>    } finally {<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>      t.close();<a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>    }<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span>  }<a name="line.1366"></a>
-<span class="sourceLineNo">1367</span><a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>  /**<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>   * Put the passed &lt;code&gt;ps&lt;/code&gt; to the &lt;code&gt;hbase:meta&lt;/code&gt; table.<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>   * @param connection connection we're using<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>   * @param ps Put to add to hbase:meta<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>   * @throws IOException<a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>   */<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>  public static void putsToMetaTable(final Connection connection, final List&lt;Put&gt; ps)<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>    throws IOException {<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>    Table t = getMetaHTable(connection);<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>    try {<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>      if (METALOG.isDebugEnabled()) {<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>        METALOG.debug(mutationsToString(ps));<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>      }<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>      t.put(ps);<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>    } finally {<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>      t.close();<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>    }<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>  }<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span><a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>  /**<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span>   * Delete the passed &lt;code&gt;d&lt;/code&gt; from the &lt;code&gt;hbase:meta&lt;/code&gt; table.<a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>   * @param connection connection we're using<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span>   * @param d Delete to add to hbase:meta<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>   * @throws IOException<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>   */<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>  static void deleteFromMetaTable(final Connection connection, final Delete d)<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>    throws IOException {<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>    List&lt;Delete&gt; dels = new ArrayList&lt;Delete&gt;(1);<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>    dels.add(d);<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>    deleteFromMetaTable(connection, dels);<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>  }<a name="line.1398"></a>
-<span class="sourceLineNo">1399</span><a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>  /**<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>   * Delete the passed &lt;code&gt;deletes&lt;/code&gt; from the &lt;code&gt;hbase:meta&lt;/code&gt; table.<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>   * @param connection connection we're using<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span>   * @param deletes Deletes to add to hbase:meta  This list should support #remove.<a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>   * @throws IOException<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span>   */<a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>  public static void deleteFromMetaTable(final Connection connection, final List&lt;Delete&gt; deletes)<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>    throws IOException {<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span>    Table t = getMetaHTable(connection);<a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>    try {<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>      if (METALOG.isDebugEnabled()) {<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>        METALOG.debug(mutationsToString(deletes));<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>      }<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span>      t.delete(deletes);<a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>    } finally {<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span>      t.close();<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>    }<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>  }<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span><a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>  /**<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span>   * Deletes some replica columns corresponding to replicas for the passed rows<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>   * @param metaRows rows in hbase:meta<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>   * @param replicaIndexToDeleteFrom the replica ID we would start deleting from<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>   * @param numReplicasToRemove how many replicas to remove<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>   * @param connection connection we're using to access meta table<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>   * @throws IOException<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>   */<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>  public static void removeRegionReplicasFromMeta(Set&lt;byte[]&gt; metaRows,<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>    int replicaIndexToDeleteFrom, int numReplicasToRemove, Connection connection)<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>      throws IOException {<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>    int absoluteIndex = replicaIndexToDeleteFrom + numReplicasToRemove;<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>    for (byte[] row : metaRows) {<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>      long now = EnvironmentEdgeManager.currentTime();<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span>      Delete deleteReplicaLocations = new Delete(row);<a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>      for (int i = replicaIndexToDeleteFrom; i &lt; absoluteIndex; i++) {<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>        deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>          getServerColumn(i), now);<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>        deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>          getSeqNumColumn(i), now);<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span>        deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>          getStartCodeColumn(i), now);<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>      }<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>      deleteFromMetaTable(connection, deleteReplicaLocations);<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>    }<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>  }<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span><a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>  /**<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>   * Execute the passed &lt;code&gt;mutations&lt;/code&gt; against &lt;code&gt;hbase:meta&lt;/code&gt; table.<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>   * @param connection connection we're using<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>   * @param mutations Puts and Deletes to execute on hbase:meta<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>   * @throws IOException<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>   */<a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>  public static void mutateMetaTable(final Connection connection,<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>                                     final List&lt;Mutation&gt; mutations)<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>    throws IOException {<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>    Table t = getMetaHTable(connection);<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>    try {<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>      if (METALOG.isDebugEnabled()) {<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span>        METALOG.debug(mutationsToString(mutations));<a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>      }<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>      t.batch(mutations, null);<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span>    } catch (InterruptedException e) {<a name="line.1461"></a>
-<span class="sourceLineNo">1462</span>      InterruptedIOException ie = new InterruptedIOException(e.getMessage());<a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>      ie.initCause(e);<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>      throw ie;<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>    } finally {<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>      t.close();<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>    }<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>  }<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span><a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>  /**<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>   * Adds a hbase:meta row for the specified new region.<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>   * @param connection connection we're using<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>   * @param regionInfo region information<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>   * @throws IOException if problem connecting or updating meta<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>   */<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>  public static void addRegionToMeta(Connection connection,<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span>                                     HRegionInfo regionInfo)<a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>    throws IOException {<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>    putToMetaTable(connection, makePutFromRegionInfo(regionInfo));<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>    LOG.info("Added " + regionInfo.getRegionNameAsString());<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>  }<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span><a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>  /**<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>   * Adds a hbase:meta row for the specified new region to the given catalog table. The<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>   * Table is not flushed or closed.<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>   * @param meta the Table for META<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>   * @param regionInfo region information<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>   * @throws IOException if problem connecting or updating meta<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>   */<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>  public static void addRegionToMeta(Table meta, HRegionInfo regionInfo) throws IOException {<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>    addRegionToMeta(meta, regionInfo, null, null);<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>  }<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span><a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>  /**<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>   * Adds a (single) hbase:meta row for the specified new region and its daughters. Note that this<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>   * does not add its daughter's as different rows, but adds information about the daughters<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>   * in the same row as the parent. Use<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>   * {@link #splitRegion(Connection, HRegionInfo, HRegionInfo, HRegionInfo, ServerName, int)}<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>   * if you want to do that.<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>   * @param meta the Table for META<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>   * @param regionInfo region information<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>   * @param splitA first split daughter of the parent regionInfo<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>   * @param splitB second split daughter of the parent regionInfo<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>   * @throws IOException if problem connecting or updating meta<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>   */<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>  public static void addRegionToMeta(Table meta, HRegionInfo regionInfo,<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>                                     HRegionInfo splitA, HRegionInfo splitB) throws IOException {<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>    Put put = makePutFromRegionInfo(regionInfo);<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>    addDaughtersToPut(put, splitA, splitB);<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>    meta.put(put);<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>    if (METALOG.isDebugEnabled()) {<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>      METALOG.debug(mutationToString(put));<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>    }<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>    if (LOG.isDebugEnabled()) {<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>      LOG.debug("Added " + regionInfo.getRegionNameAsString());<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>    }<a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>  }<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span><a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>  /**<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>   * Adds a (single) hbase:meta row for the specified new region and its daughters. Note that this<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>   * does not add its daughter's as different rows, but adds information about the daughters<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>   * in the same row as the parent. Use<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>   * {@link #splitRegion(Connection, HRegionInfo, HRegionInfo, HRegionInfo, ServerName, int)}<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>   * if you want to do that.<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>   * @param connection connection we're using<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>   * @param regionInfo region information<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>   * @param splitA first split daughter of the parent regionInfo<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>   * @param splitB second split daughter of the parent regionInfo<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>   * @throws IOException if problem connecting or updating meta<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>   */<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>  public static void addRegionToMeta(Connection connection, HRegionInfo regionInfo,<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>                                     HRegionInfo splitA, HRegionInfo splitB) throws IOException {<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>    Table meta = getMetaHTable(connection);<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>    try {<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>      addRegionToMeta(meta, regionInfo, splitA, splitB);<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>    } finally {<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>      meta.close();<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>    }<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>  }<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span><a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>  /**<a name="line.1541"></a>

[... 1221 lines stripped ...]



Mime
View raw message