hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [31/51] [partial] hbase git commit: Published site at 86be690b0723e814a655ad0ae8a6577d7111c1f2.
Date Sun, 22 Nov 2015 22:40:41 GMT
http://git-wip-us.apache.org/repos/asf/hbase/blob/155d5cd0/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.CreateTableFuture.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.CreateTableFuture.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.CreateTableFuture.html
index b8eace5..ac7cc07 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.CreateTableFuture.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.CreateTableFuture.html
@@ -2275,1198 +2275,1198 @@
 <span class="sourceLineNo">2267</span>    });<a name="line.2267"></a>
 <span class="sourceLineNo">2268</span>  }<a name="line.2268"></a>
 <span class="sourceLineNo">2269</span><a name="line.2269"></a>
-<span class="sourceLineNo">2270</span>  /**<a name="line.2270"></a>
-<span class="sourceLineNo">2271</span>   * Merge two regions. Asynchronous operation.<a name="line.2271"></a>
-<span class="sourceLineNo">2272</span>   * @param encodedNameOfRegionA encoded name of region a<a name="line.2272"></a>
-<span class="sourceLineNo">2273</span>   * @param encodedNameOfRegionB encoded name of region b<a name="line.2273"></a>
-<span class="sourceLineNo">2274</span>   * @param forcible true if do a compulsory merge, otherwise we will only merge<a name="line.2274"></a>
-<span class="sourceLineNo">2275</span>   *          two adjacent regions<a name="line.2275"></a>
-<span class="sourceLineNo">2276</span>   * @throws IOException<a name="line.2276"></a>
-<span class="sourceLineNo">2277</span>   */<a name="line.2277"></a>
-<span class="sourceLineNo">2278</span>  @Override<a name="line.2278"></a>
-<span class="sourceLineNo">2279</span>  public void mergeRegions(final byte[] encodedNameOfRegionA,<a name="line.2279"></a>
-<span class="sourceLineNo">2280</span>      final byte[] encodedNameOfRegionB, final boolean forcible)<a name="line.2280"></a>
-<span class="sourceLineNo">2281</span>      throws IOException {<a name="line.2281"></a>
-<span class="sourceLineNo">2282</span>    Pair&lt;HRegionInfo, ServerName&gt; pair = getRegion(encodedNameOfRegionA);<a name="line.2282"></a>
-<span class="sourceLineNo">2283</span>    if (pair != null &amp;&amp; pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID)<a name="line.2283"></a>
-<span class="sourceLineNo">2284</span>      throw new IllegalArgumentException("Can't invoke merge on non-default regions directly");<a name="line.2284"></a>
-<span class="sourceLineNo">2285</span>    pair = getRegion(encodedNameOfRegionB);<a name="line.2285"></a>
-<span class="sourceLineNo">2286</span>    if (pair != null &amp;&amp; pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID)<a name="line.2286"></a>
-<span class="sourceLineNo">2287</span>      throw new IllegalArgumentException("Can't invoke merge on non-default regions directly");<a name="line.2287"></a>
-<span class="sourceLineNo">2288</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2288"></a>
-<span class="sourceLineNo">2289</span>      @Override<a name="line.2289"></a>
-<span class="sourceLineNo">2290</span>      public Void call(int callTimeout) throws ServiceException {<a name="line.2290"></a>
-<span class="sourceLineNo">2291</span>        try {<a name="line.2291"></a>
-<span class="sourceLineNo">2292</span>          DispatchMergingRegionsRequest request = RequestConverter<a name="line.2292"></a>
-<span class="sourceLineNo">2293</span>              .buildDispatchMergingRegionsRequest(encodedNameOfRegionA,<a name="line.2293"></a>
-<span class="sourceLineNo">2294</span>                encodedNameOfRegionB, forcible);<a name="line.2294"></a>
-<span class="sourceLineNo">2295</span>          master.dispatchMergingRegions(null, request);<a name="line.2295"></a>
-<span class="sourceLineNo">2296</span>        } catch (DeserializationException de) {<a name="line.2296"></a>
-<span class="sourceLineNo">2297</span>          LOG.error("Could not parse destination server name: " + de);<a name="line.2297"></a>
-<span class="sourceLineNo">2298</span>        }<a name="line.2298"></a>
-<span class="sourceLineNo">2299</span>        return null;<a name="line.2299"></a>
-<span class="sourceLineNo">2300</span>      }<a name="line.2300"></a>
-<span class="sourceLineNo">2301</span>    });<a name="line.2301"></a>
-<span class="sourceLineNo">2302</span>  }<a name="line.2302"></a>
-<span class="sourceLineNo">2303</span><a name="line.2303"></a>
-<span class="sourceLineNo">2304</span>  /**<a name="line.2304"></a>
-<span class="sourceLineNo">2305</span>   * {@inheritDoc}<a name="line.2305"></a>
-<span class="sourceLineNo">2306</span>   */<a name="line.2306"></a>
-<span class="sourceLineNo">2307</span>  @Override<a name="line.2307"></a>
-<span class="sourceLineNo">2308</span>  public void split(final TableName tableName)<a name="line.2308"></a>
-<span class="sourceLineNo">2309</span>    throws IOException {<a name="line.2309"></a>
-<span class="sourceLineNo">2310</span>    split(tableName, null);<a name="line.2310"></a>
-<span class="sourceLineNo">2311</span>  }<a name="line.2311"></a>
-<span class="sourceLineNo">2312</span><a name="line.2312"></a>
-<span class="sourceLineNo">2313</span>  /**<a name="line.2313"></a>
-<span class="sourceLineNo">2314</span>   * {@inheritDoc}<a name="line.2314"></a>
-<span class="sourceLineNo">2315</span>   */<a name="line.2315"></a>
-<span class="sourceLineNo">2316</span>  @Override<a name="line.2316"></a>
-<span class="sourceLineNo">2317</span>  public void splitRegion(final byte[] regionName)<a name="line.2317"></a>
-<span class="sourceLineNo">2318</span>    throws IOException {<a name="line.2318"></a>
-<span class="sourceLineNo">2319</span>    splitRegion(regionName, null);<a name="line.2319"></a>
+<span class="sourceLineNo">2270</span>  private boolean isEncodedRegionName(byte[] regionName) throws IOException {<a name="line.2270"></a>
+<span class="sourceLineNo">2271</span>    try {<a name="line.2271"></a>
+<span class="sourceLineNo">2272</span>      HRegionInfo.parseRegionName(regionName);<a name="line.2272"></a>
+<span class="sourceLineNo">2273</span>      return false;<a name="line.2273"></a>
+<span class="sourceLineNo">2274</span>    } catch (IOException e) {<a name="line.2274"></a>
+<span class="sourceLineNo">2275</span>      if (StringUtils.stringifyException(e)<a name="line.2275"></a>
+<span class="sourceLineNo">2276</span>        .contains(HRegionInfo.INVALID_REGION_NAME_FORMAT_MESSAGE)) {<a name="line.2276"></a>
+<span class="sourceLineNo">2277</span>        return true;<a name="line.2277"></a>
+<span class="sourceLineNo">2278</span>      }<a name="line.2278"></a>
+<span class="sourceLineNo">2279</span>      throw e;<a name="line.2279"></a>
+<span class="sourceLineNo">2280</span>    }<a name="line.2280"></a>
+<span class="sourceLineNo">2281</span>  }<a name="line.2281"></a>
+<span class="sourceLineNo">2282</span><a name="line.2282"></a>
+<span class="sourceLineNo">2283</span>  /**<a name="line.2283"></a>
+<span class="sourceLineNo">2284</span>   * Merge two regions. Asynchronous operation.<a name="line.2284"></a>
+<span class="sourceLineNo">2285</span>   * @param nameOfRegionA encoded or full name of region a<a name="line.2285"></a>
+<span class="sourceLineNo">2286</span>   * @param nameOfRegionB encoded or full name of region b<a name="line.2286"></a>
+<span class="sourceLineNo">2287</span>   * @param forcible true if do a compulsory merge, otherwise we will only merge<a name="line.2287"></a>
+<span class="sourceLineNo">2288</span>   *          two adjacent regions<a name="line.2288"></a>
+<span class="sourceLineNo">2289</span>   * @throws IOException<a name="line.2289"></a>
+<span class="sourceLineNo">2290</span>   */<a name="line.2290"></a>
+<span class="sourceLineNo">2291</span>  @Override<a name="line.2291"></a>
+<span class="sourceLineNo">2292</span>  public void mergeRegions(final byte[] nameOfRegionA,<a name="line.2292"></a>
+<span class="sourceLineNo">2293</span>      final byte[] nameOfRegionB, final boolean forcible)<a name="line.2293"></a>
+<span class="sourceLineNo">2294</span>      throws IOException {<a name="line.2294"></a>
+<span class="sourceLineNo">2295</span>    final byte[] encodedNameOfRegionA = isEncodedRegionName(nameOfRegionA) ?<a name="line.2295"></a>
+<span class="sourceLineNo">2296</span>      nameOfRegionA : HRegionInfo.encodeRegionName(nameOfRegionA).getBytes();<a name="line.2296"></a>
+<span class="sourceLineNo">2297</span>    final byte[] encodedNameOfRegionB = isEncodedRegionName(nameOfRegionB) ?<a name="line.2297"></a>
+<span class="sourceLineNo">2298</span>      nameOfRegionB : HRegionInfo.encodeRegionName(nameOfRegionB).getBytes();<a name="line.2298"></a>
+<span class="sourceLineNo">2299</span><a name="line.2299"></a>
+<span class="sourceLineNo">2300</span>    Pair&lt;HRegionInfo, ServerName&gt; pair = getRegion(nameOfRegionA);<a name="line.2300"></a>
+<span class="sourceLineNo">2301</span>    if (pair != null &amp;&amp; pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID)<a name="line.2301"></a>
+<span class="sourceLineNo">2302</span>      throw new IllegalArgumentException("Can't invoke merge on non-default regions directly");<a name="line.2302"></a>
+<span class="sourceLineNo">2303</span>    pair = getRegion(nameOfRegionB);<a name="line.2303"></a>
+<span class="sourceLineNo">2304</span>    if (pair != null &amp;&amp; pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID)<a name="line.2304"></a>
+<span class="sourceLineNo">2305</span>      throw new IllegalArgumentException("Can't invoke merge on non-default regions directly");<a name="line.2305"></a>
+<span class="sourceLineNo">2306</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2306"></a>
+<span class="sourceLineNo">2307</span>      @Override<a name="line.2307"></a>
+<span class="sourceLineNo">2308</span>      public Void call(int callTimeout) throws ServiceException {<a name="line.2308"></a>
+<span class="sourceLineNo">2309</span>        try {<a name="line.2309"></a>
+<span class="sourceLineNo">2310</span>          DispatchMergingRegionsRequest request = RequestConverter<a name="line.2310"></a>
+<span class="sourceLineNo">2311</span>              .buildDispatchMergingRegionsRequest(encodedNameOfRegionA,<a name="line.2311"></a>
+<span class="sourceLineNo">2312</span>                encodedNameOfRegionB, forcible);<a name="line.2312"></a>
+<span class="sourceLineNo">2313</span>          master.dispatchMergingRegions(null, request);<a name="line.2313"></a>
+<span class="sourceLineNo">2314</span>        } catch (DeserializationException de) {<a name="line.2314"></a>
+<span class="sourceLineNo">2315</span>          LOG.error("Could not parse destination server name: " + de);<a name="line.2315"></a>
+<span class="sourceLineNo">2316</span>        }<a name="line.2316"></a>
+<span class="sourceLineNo">2317</span>        return null;<a name="line.2317"></a>
+<span class="sourceLineNo">2318</span>      }<a name="line.2318"></a>
+<span class="sourceLineNo">2319</span>    });<a name="line.2319"></a>
 <span class="sourceLineNo">2320</span>  }<a name="line.2320"></a>
 <span class="sourceLineNo">2321</span><a name="line.2321"></a>
 <span class="sourceLineNo">2322</span>  /**<a name="line.2322"></a>
 <span class="sourceLineNo">2323</span>   * {@inheritDoc}<a name="line.2323"></a>
 <span class="sourceLineNo">2324</span>   */<a name="line.2324"></a>
 <span class="sourceLineNo">2325</span>  @Override<a name="line.2325"></a>
-<span class="sourceLineNo">2326</span>  public void split(final TableName tableName, final byte [] splitPoint)<a name="line.2326"></a>
-<span class="sourceLineNo">2327</span>  throws IOException {<a name="line.2327"></a>
-<span class="sourceLineNo">2328</span>    ZooKeeperWatcher zookeeper = null;<a name="line.2328"></a>
-<span class="sourceLineNo">2329</span>    try {<a name="line.2329"></a>
-<span class="sourceLineNo">2330</span>      checkTableExists(tableName);<a name="line.2330"></a>
-<span class="sourceLineNo">2331</span>      zookeeper = new ZooKeeperWatcher(conf, ZK_IDENTIFIER_PREFIX + connection.toString(),<a name="line.2331"></a>
-<span class="sourceLineNo">2332</span>        new ThrowableAbortable());<a name="line.2332"></a>
-<span class="sourceLineNo">2333</span>      List&lt;Pair&lt;HRegionInfo, ServerName&gt;&gt; pairs;<a name="line.2333"></a>
-<span class="sourceLineNo">2334</span>      if (TableName.META_TABLE_NAME.equals(tableName)) {<a name="line.2334"></a>
-<span class="sourceLineNo">2335</span>        pairs = new MetaTableLocator().getMetaRegionsAndLocations(zookeeper);<a name="line.2335"></a>
-<span class="sourceLineNo">2336</span>      } else {<a name="line.2336"></a>
-<span class="sourceLineNo">2337</span>        pairs = MetaTableAccessor.getTableRegionsAndLocations(connection, tableName);<a name="line.2337"></a>
-<span class="sourceLineNo">2338</span>      }<a name="line.2338"></a>
-<span class="sourceLineNo">2339</span>      for (Pair&lt;HRegionInfo, ServerName&gt; pair: pairs) {<a name="line.2339"></a>
-<span class="sourceLineNo">2340</span>        // May not be a server for a particular row<a name="line.2340"></a>
-<span class="sourceLineNo">2341</span>        if (pair.getSecond() == null) continue;<a name="line.2341"></a>
-<span class="sourceLineNo">2342</span>        HRegionInfo r = pair.getFirst();<a name="line.2342"></a>
-<span class="sourceLineNo">2343</span>        // check for parents<a name="line.2343"></a>
-<span class="sourceLineNo">2344</span>        if (r.isSplitParent()) continue;<a name="line.2344"></a>
-<span class="sourceLineNo">2345</span>        // if a split point given, only split that particular region<a name="line.2345"></a>
-<span class="sourceLineNo">2346</span>        if (r.getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID ||<a name="line.2346"></a>
-<span class="sourceLineNo">2347</span>           (splitPoint != null &amp;&amp; !r.containsRow(splitPoint))) continue;<a name="line.2347"></a>
-<span class="sourceLineNo">2348</span>        // call out to region server to do split now<a name="line.2348"></a>
-<span class="sourceLineNo">2349</span>        split(pair.getSecond(), pair.getFirst(), splitPoint);<a name="line.2349"></a>
-<span class="sourceLineNo">2350</span>      }<a name="line.2350"></a>
-<span class="sourceLineNo">2351</span>    } finally {<a name="line.2351"></a>
-<span class="sourceLineNo">2352</span>      if (zookeeper != null) {<a name="line.2352"></a>
-<span class="sourceLineNo">2353</span>        zookeeper.close();<a name="line.2353"></a>
-<span class="sourceLineNo">2354</span>      }<a name="line.2354"></a>
-<span class="sourceLineNo">2355</span>    }<a name="line.2355"></a>
-<span class="sourceLineNo">2356</span>  }<a name="line.2356"></a>
-<span class="sourceLineNo">2357</span><a name="line.2357"></a>
-<span class="sourceLineNo">2358</span>  /**<a name="line.2358"></a>
-<span class="sourceLineNo">2359</span>   * {@inheritDoc}<a name="line.2359"></a>
-<span class="sourceLineNo">2360</span>   */<a name="line.2360"></a>
-<span class="sourceLineNo">2361</span>  @Override<a name="line.2361"></a>
-<span class="sourceLineNo">2362</span>  public void splitRegion(final byte[] regionName, final byte [] splitPoint)<a name="line.2362"></a>
-<span class="sourceLineNo">2363</span>  throws IOException {<a name="line.2363"></a>
-<span class="sourceLineNo">2364</span>    Pair&lt;HRegionInfo, ServerName&gt; regionServerPair = getRegion(regionName);<a name="line.2364"></a>
-<span class="sourceLineNo">2365</span>    if (regionServerPair == null) {<a name="line.2365"></a>
-<span class="sourceLineNo">2366</span>      throw new IllegalArgumentException("Invalid region: " + Bytes.toStringBinary(regionName));<a name="line.2366"></a>
-<span class="sourceLineNo">2367</span>    }<a name="line.2367"></a>
-<span class="sourceLineNo">2368</span>    if (regionServerPair.getFirst() != null &amp;&amp;<a name="line.2368"></a>
-<span class="sourceLineNo">2369</span>        regionServerPair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {<a name="line.2369"></a>
-<span class="sourceLineNo">2370</span>      throw new IllegalArgumentException("Can't split replicas directly. "<a name="line.2370"></a>
-<span class="sourceLineNo">2371</span>          + "Replicas are auto-split when their primary is split.");<a name="line.2371"></a>
-<span class="sourceLineNo">2372</span>    }<a name="line.2372"></a>
-<span class="sourceLineNo">2373</span>    if (regionServerPair.getSecond() == null) {<a name="line.2373"></a>
-<span class="sourceLineNo">2374</span>      throw new NoServerForRegionException(Bytes.toStringBinary(regionName));<a name="line.2374"></a>
-<span class="sourceLineNo">2375</span>    }<a name="line.2375"></a>
-<span class="sourceLineNo">2376</span>    split(regionServerPair.getSecond(), regionServerPair.getFirst(), splitPoint);<a name="line.2376"></a>
-<span class="sourceLineNo">2377</span>  }<a name="line.2377"></a>
-<span class="sourceLineNo">2378</span><a name="line.2378"></a>
-<span class="sourceLineNo">2379</span>  @VisibleForTesting<a name="line.2379"></a>
-<span class="sourceLineNo">2380</span>  public void split(final ServerName sn, final HRegionInfo hri,<a name="line.2380"></a>
-<span class="sourceLineNo">2381</span>      byte[] splitPoint) throws IOException {<a name="line.2381"></a>
-<span class="sourceLineNo">2382</span>    if (hri.getStartKey() != null &amp;&amp; splitPoint != null &amp;&amp;<a name="line.2382"></a>
-<span class="sourceLineNo">2383</span>         Bytes.compareTo(hri.getStartKey(), splitPoint) == 0) {<a name="line.2383"></a>
-<span class="sourceLineNo">2384</span>       throw new IOException("should not give a splitkey which equals to startkey!");<a name="line.2384"></a>
+<span class="sourceLineNo">2326</span>  public void split(final TableName tableName)<a name="line.2326"></a>
+<span class="sourceLineNo">2327</span>    throws IOException {<a name="line.2327"></a>
+<span class="sourceLineNo">2328</span>    split(tableName, null);<a name="line.2328"></a>
+<span class="sourceLineNo">2329</span>  }<a name="line.2329"></a>
+<span class="sourceLineNo">2330</span><a name="line.2330"></a>
+<span class="sourceLineNo">2331</span>  /**<a name="line.2331"></a>
+<span class="sourceLineNo">2332</span>   * {@inheritDoc}<a name="line.2332"></a>
+<span class="sourceLineNo">2333</span>   */<a name="line.2333"></a>
+<span class="sourceLineNo">2334</span>  @Override<a name="line.2334"></a>
+<span class="sourceLineNo">2335</span>  public void splitRegion(final byte[] regionName)<a name="line.2335"></a>
+<span class="sourceLineNo">2336</span>    throws IOException {<a name="line.2336"></a>
+<span class="sourceLineNo">2337</span>    splitRegion(regionName, null);<a name="line.2337"></a>
+<span class="sourceLineNo">2338</span>  }<a name="line.2338"></a>
+<span class="sourceLineNo">2339</span><a name="line.2339"></a>
+<span class="sourceLineNo">2340</span>  /**<a name="line.2340"></a>
+<span class="sourceLineNo">2341</span>   * {@inheritDoc}<a name="line.2341"></a>
+<span class="sourceLineNo">2342</span>   */<a name="line.2342"></a>
+<span class="sourceLineNo">2343</span>  @Override<a name="line.2343"></a>
+<span class="sourceLineNo">2344</span>  public void split(final TableName tableName, final byte [] splitPoint)<a name="line.2344"></a>
+<span class="sourceLineNo">2345</span>  throws IOException {<a name="line.2345"></a>
+<span class="sourceLineNo">2346</span>    ZooKeeperWatcher zookeeper = null;<a name="line.2346"></a>
+<span class="sourceLineNo">2347</span>    try {<a name="line.2347"></a>
+<span class="sourceLineNo">2348</span>      checkTableExists(tableName);<a name="line.2348"></a>
+<span class="sourceLineNo">2349</span>      zookeeper = new ZooKeeperWatcher(conf, ZK_IDENTIFIER_PREFIX + connection.toString(),<a name="line.2349"></a>
+<span class="sourceLineNo">2350</span>        new ThrowableAbortable());<a name="line.2350"></a>
+<span class="sourceLineNo">2351</span>      List&lt;Pair&lt;HRegionInfo, ServerName&gt;&gt; pairs;<a name="line.2351"></a>
+<span class="sourceLineNo">2352</span>      if (TableName.META_TABLE_NAME.equals(tableName)) {<a name="line.2352"></a>
+<span class="sourceLineNo">2353</span>        pairs = new MetaTableLocator().getMetaRegionsAndLocations(zookeeper);<a name="line.2353"></a>
+<span class="sourceLineNo">2354</span>      } else {<a name="line.2354"></a>
+<span class="sourceLineNo">2355</span>        pairs = MetaTableAccessor.getTableRegionsAndLocations(connection, tableName);<a name="line.2355"></a>
+<span class="sourceLineNo">2356</span>      }<a name="line.2356"></a>
+<span class="sourceLineNo">2357</span>      for (Pair&lt;HRegionInfo, ServerName&gt; pair: pairs) {<a name="line.2357"></a>
+<span class="sourceLineNo">2358</span>        // May not be a server for a particular row<a name="line.2358"></a>
+<span class="sourceLineNo">2359</span>        if (pair.getSecond() == null) continue;<a name="line.2359"></a>
+<span class="sourceLineNo">2360</span>        HRegionInfo r = pair.getFirst();<a name="line.2360"></a>
+<span class="sourceLineNo">2361</span>        // check for parents<a name="line.2361"></a>
+<span class="sourceLineNo">2362</span>        if (r.isSplitParent()) continue;<a name="line.2362"></a>
+<span class="sourceLineNo">2363</span>        // if a split point given, only split that particular region<a name="line.2363"></a>
+<span class="sourceLineNo">2364</span>        if (r.getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID ||<a name="line.2364"></a>
+<span class="sourceLineNo">2365</span>           (splitPoint != null &amp;&amp; !r.containsRow(splitPoint))) continue;<a name="line.2365"></a>
+<span class="sourceLineNo">2366</span>        // call out to region server to do split now<a name="line.2366"></a>
+<span class="sourceLineNo">2367</span>        split(pair.getSecond(), pair.getFirst(), splitPoint);<a name="line.2367"></a>
+<span class="sourceLineNo">2368</span>      }<a name="line.2368"></a>
+<span class="sourceLineNo">2369</span>    } finally {<a name="line.2369"></a>
+<span class="sourceLineNo">2370</span>      if (zookeeper != null) {<a name="line.2370"></a>
+<span class="sourceLineNo">2371</span>        zookeeper.close();<a name="line.2371"></a>
+<span class="sourceLineNo">2372</span>      }<a name="line.2372"></a>
+<span class="sourceLineNo">2373</span>    }<a name="line.2373"></a>
+<span class="sourceLineNo">2374</span>  }<a name="line.2374"></a>
+<span class="sourceLineNo">2375</span><a name="line.2375"></a>
+<span class="sourceLineNo">2376</span>  /**<a name="line.2376"></a>
+<span class="sourceLineNo">2377</span>   * {@inheritDoc}<a name="line.2377"></a>
+<span class="sourceLineNo">2378</span>   */<a name="line.2378"></a>
+<span class="sourceLineNo">2379</span>  @Override<a name="line.2379"></a>
+<span class="sourceLineNo">2380</span>  public void splitRegion(final byte[] regionName, final byte [] splitPoint)<a name="line.2380"></a>
+<span class="sourceLineNo">2381</span>  throws IOException {<a name="line.2381"></a>
+<span class="sourceLineNo">2382</span>    Pair&lt;HRegionInfo, ServerName&gt; regionServerPair = getRegion(regionName);<a name="line.2382"></a>
+<span class="sourceLineNo">2383</span>    if (regionServerPair == null) {<a name="line.2383"></a>
+<span class="sourceLineNo">2384</span>      throw new IllegalArgumentException("Invalid region: " + Bytes.toStringBinary(regionName));<a name="line.2384"></a>
 <span class="sourceLineNo">2385</span>    }<a name="line.2385"></a>
-<span class="sourceLineNo">2386</span>    // TODO: This is not executed via retries<a name="line.2386"></a>
-<span class="sourceLineNo">2387</span>    AdminService.BlockingInterface admin = this.connection.getAdmin(sn);<a name="line.2387"></a>
-<span class="sourceLineNo">2388</span>    ProtobufUtil.split(admin, hri, splitPoint);<a name="line.2388"></a>
-<span class="sourceLineNo">2389</span>  }<a name="line.2389"></a>
-<span class="sourceLineNo">2390</span><a name="line.2390"></a>
-<span class="sourceLineNo">2391</span>  /**<a name="line.2391"></a>
-<span class="sourceLineNo">2392</span>   * Modify an existing table, more IRB friendly version. Asynchronous operation.<a name="line.2392"></a>
-<span class="sourceLineNo">2393</span>   * This means that it may be a while before your schema change is updated across all of the<a name="line.2393"></a>
-<span class="sourceLineNo">2394</span>   * table. You can use Future.get(long, TimeUnit) to wait on the operation to complete.<a name="line.2394"></a>
-<span class="sourceLineNo">2395</span>   * It may throw ExecutionException if there was an error while executing the operation<a name="line.2395"></a>
-<span class="sourceLineNo">2396</span>   * or TimeoutException in case the wait timeout was not long enough to allow the<a name="line.2396"></a>
-<span class="sourceLineNo">2397</span>   * operation to complete.<a name="line.2397"></a>
-<span class="sourceLineNo">2398</span>   *<a name="line.2398"></a>
-<span class="sourceLineNo">2399</span>   * @param tableName name of table.<a name="line.2399"></a>
-<span class="sourceLineNo">2400</span>   * @param htd modified description of the table<a name="line.2400"></a>
-<span class="sourceLineNo">2401</span>   * @throws IOException if a remote or network exception occurs<a name="line.2401"></a>
-<span class="sourceLineNo">2402</span>   * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the<a name="line.2402"></a>
-<span class="sourceLineNo">2403</span>   *     operation to complete.<a name="line.2403"></a>
-<span class="sourceLineNo">2404</span>   */<a name="line.2404"></a>
-<span class="sourceLineNo">2405</span>  @Override<a name="line.2405"></a>
-<span class="sourceLineNo">2406</span>  public Future&lt;Void&gt; modifyTable(final TableName tableName, final HTableDescriptor htd)<a name="line.2406"></a>
-<span class="sourceLineNo">2407</span>  throws IOException {<a name="line.2407"></a>
-<span class="sourceLineNo">2408</span>    if (!tableName.equals(htd.getTableName())) {<a name="line.2408"></a>
-<span class="sourceLineNo">2409</span>      throw new IllegalArgumentException("the specified table name '" + tableName +<a name="line.2409"></a>
-<span class="sourceLineNo">2410</span>        "' doesn't match with the HTD one: " + htd.getTableName());<a name="line.2410"></a>
-<span class="sourceLineNo">2411</span>    }<a name="line.2411"></a>
-<span class="sourceLineNo">2412</span><a name="line.2412"></a>
-<span class="sourceLineNo">2413</span>    ModifyTableResponse response = executeCallable(<a name="line.2413"></a>
-<span class="sourceLineNo">2414</span>        new MasterCallable&lt;ModifyTableResponse&gt;(getConnection()) {<a name="line.2414"></a>
-<span class="sourceLineNo">2415</span>      @Override<a name="line.2415"></a>
-<span class="sourceLineNo">2416</span>      public ModifyTableResponse call(int callTimeout) throws ServiceException {<a name="line.2416"></a>
-<span class="sourceLineNo">2417</span>        ModifyTableRequest request = RequestConverter.buildModifyTableRequest(<a name="line.2417"></a>
-<span class="sourceLineNo">2418</span>          tableName, htd, ng.getNonceGroup(), ng.newNonce());<a name="line.2418"></a>
-<span class="sourceLineNo">2419</span>        return master.modifyTable(null, request);<a name="line.2419"></a>
-<span class="sourceLineNo">2420</span>      }<a name="line.2420"></a>
-<span class="sourceLineNo">2421</span>    });<a name="line.2421"></a>
-<span class="sourceLineNo">2422</span><a name="line.2422"></a>
-<span class="sourceLineNo">2423</span>    return new ModifyTableFuture(this, tableName, response);<a name="line.2423"></a>
-<span class="sourceLineNo">2424</span>  }<a name="line.2424"></a>
-<span class="sourceLineNo">2425</span><a name="line.2425"></a>
-<span class="sourceLineNo">2426</span>  private static class ModifyTableFuture extends TableFuture&lt;Void&gt; {<a name="line.2426"></a>
-<span class="sourceLineNo">2427</span>    public ModifyTableFuture(final HBaseAdmin admin, final TableName tableName,<a name="line.2427"></a>
-<span class="sourceLineNo">2428</span>        final ModifyTableResponse response) {<a name="line.2428"></a>
-<span class="sourceLineNo">2429</span>      super(admin, tableName,<a name="line.2429"></a>
-<span class="sourceLineNo">2430</span>          (response != null &amp;&amp; response.hasProcId()) ? response.getProcId() : null);<a name="line.2430"></a>
-<span class="sourceLineNo">2431</span>    }<a name="line.2431"></a>
-<span class="sourceLineNo">2432</span><a name="line.2432"></a>
-<span class="sourceLineNo">2433</span>    public ModifyTableFuture(final HBaseAdmin admin, final TableName tableName, final Long procId) {<a name="line.2433"></a>
-<span class="sourceLineNo">2434</span>      super(admin, tableName, procId);<a name="line.2434"></a>
-<span class="sourceLineNo">2435</span>    }<a name="line.2435"></a>
-<span class="sourceLineNo">2436</span><a name="line.2436"></a>
-<span class="sourceLineNo">2437</span>    @Override<a name="line.2437"></a>
-<span class="sourceLineNo">2438</span>    public String getOperationType() {<a name="line.2438"></a>
-<span class="sourceLineNo">2439</span>      return "MODIFY";<a name="line.2439"></a>
-<span class="sourceLineNo">2440</span>    }<a name="line.2440"></a>
-<span class="sourceLineNo">2441</span><a name="line.2441"></a>
-<span class="sourceLineNo">2442</span>    @Override<a name="line.2442"></a>
-<span class="sourceLineNo">2443</span>    protected Void postOperationResult(final Void result, final long deadlineTs)<a name="line.2443"></a>
-<span class="sourceLineNo">2444</span>        throws IOException, TimeoutException {<a name="line.2444"></a>
-<span class="sourceLineNo">2445</span>      // The modify operation on the table is asynchronous on the server side irrespective<a name="line.2445"></a>
-<span class="sourceLineNo">2446</span>      // of whether Procedure V2 is supported or not. So, we wait in the client till<a name="line.2446"></a>
-<span class="sourceLineNo">2447</span>      // all regions get updated.<a name="line.2447"></a>
-<span class="sourceLineNo">2448</span>      waitForSchemaUpdate(deadlineTs);<a name="line.2448"></a>
-<span class="sourceLineNo">2449</span>      return result;<a name="line.2449"></a>
-<span class="sourceLineNo">2450</span>    }<a name="line.2450"></a>
-<span class="sourceLineNo">2451</span>  }<a name="line.2451"></a>
-<span class="sourceLineNo">2452</span><a name="line.2452"></a>
-<span class="sourceLineNo">2453</span>  public void modifyTable(final byte[] tableName, final HTableDescriptor htd)<a name="line.2453"></a>
-<span class="sourceLineNo">2454</span>  throws IOException {<a name="line.2454"></a>
-<span class="sourceLineNo">2455</span>    modifyTable(TableName.valueOf(tableName), htd);<a name="line.2455"></a>
-<span class="sourceLineNo">2456</span>  }<a name="line.2456"></a>
-<span class="sourceLineNo">2457</span><a name="line.2457"></a>
-<span class="sourceLineNo">2458</span>  public void modifyTable(final String tableName, final HTableDescriptor htd)<a name="line.2458"></a>
-<span class="sourceLineNo">2459</span>  throws IOException {<a name="line.2459"></a>
-<span class="sourceLineNo">2460</span>    modifyTable(TableName.valueOf(tableName), htd);<a name="line.2460"></a>
-<span class="sourceLineNo">2461</span>  }<a name="line.2461"></a>
-<span class="sourceLineNo">2462</span><a name="line.2462"></a>
-<span class="sourceLineNo">2463</span>  /**<a name="line.2463"></a>
-<span class="sourceLineNo">2464</span>   * @param regionName Name of a region.<a name="line.2464"></a>
-<span class="sourceLineNo">2465</span>   * @return a pair of HRegionInfo and ServerName if &lt;code&gt;regionName&lt;/code&gt; is<a name="line.2465"></a>
-<span class="sourceLineNo">2466</span>   *  a verified region name (we call {@link<a name="line.2466"></a>
-<span class="sourceLineNo">2467</span>   *  MetaTableAccessor#getRegion(HConnection, byte[])}<a name="line.2467"></a>
-<span class="sourceLineNo">2468</span>   *  else null.<a name="line.2468"></a>
-<span class="sourceLineNo">2469</span>   * Throw IllegalArgumentException if &lt;code&gt;regionName&lt;/code&gt; is null.<a name="line.2469"></a>
-<span class="sourceLineNo">2470</span>   * @throws IOException<a name="line.2470"></a>
-<span class="sourceLineNo">2471</span>   */<a name="line.2471"></a>
-<span class="sourceLineNo">2472</span>  Pair&lt;HRegionInfo, ServerName&gt; getRegion(final byte[] regionName) throws IOException {<a name="line.2472"></a>
-<span class="sourceLineNo">2473</span>    if (regionName == null) {<a name="line.2473"></a>
-<span class="sourceLineNo">2474</span>      throw new IllegalArgumentException("Pass a table name or region name");<a name="line.2474"></a>
-<span class="sourceLineNo">2475</span>    }<a name="line.2475"></a>
-<span class="sourceLineNo">2476</span>    Pair&lt;HRegionInfo, ServerName&gt; pair =<a name="line.2476"></a>
-<span class="sourceLineNo">2477</span>      MetaTableAccessor.getRegion(connection, regionName);<a name="line.2477"></a>
-<span class="sourceLineNo">2478</span>    if (pair == null) {<a name="line.2478"></a>
-<span class="sourceLineNo">2479</span>      final AtomicReference&lt;Pair&lt;HRegionInfo, ServerName&gt;&gt; result =<a name="line.2479"></a>
-<span class="sourceLineNo">2480</span>        new AtomicReference&lt;Pair&lt;HRegionInfo, ServerName&gt;&gt;(null);<a name="line.2480"></a>
-<span class="sourceLineNo">2481</span>      final String encodedName = Bytes.toString(regionName);<a name="line.2481"></a>
-<span class="sourceLineNo">2482</span>      MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() {<a name="line.2482"></a>
-<span class="sourceLineNo">2483</span>        @Override<a name="line.2483"></a>
-<span class="sourceLineNo">2484</span>        public boolean visit(Result data) throws IOException {<a name="line.2484"></a>
-<span class="sourceLineNo">2485</span>          HRegionInfo info = MetaTableAccessor.getHRegionInfo(data);<a name="line.2485"></a>
-<span class="sourceLineNo">2486</span>          if (info == null) {<a name="line.2486"></a>
-<span class="sourceLineNo">2487</span>            LOG.warn("No serialized HRegionInfo in " + data);<a name="line.2487"></a>
-<span class="sourceLineNo">2488</span>            return true;<a name="line.2488"></a>
-<span class="sourceLineNo">2489</span>          }<a name="line.2489"></a>
-<span class="sourceLineNo">2490</span>          RegionLocations rl = MetaTableAccessor.getRegionLocations(data);<a name="line.2490"></a>
-<span class="sourceLineNo">2491</span>          boolean matched = false;<a name="line.2491"></a>
-<span class="sourceLineNo">2492</span>          ServerName sn = null;<a name="line.2492"></a>
-<span class="sourceLineNo">2493</span>          if (rl != null) {<a name="line.2493"></a>
-<span class="sourceLineNo">2494</span>            for (HRegionLocation h : rl.getRegionLocations()) {<a name="line.2494"></a>
-<span class="sourceLineNo">2495</span>              if (h != null &amp;&amp; encodedName.equals(h.getRegionInfo().getEncodedName())) {<a name="line.2495"></a>
-<span class="sourceLineNo">2496</span>                sn = h.getServerName();<a name="line.2496"></a>
-<span class="sourceLineNo">2497</span>                info = h.getRegionInfo();<a name="line.2497"></a>
-<span class="sourceLineNo">2498</span>                matched = true;<a name="line.2498"></a>
-<span class="sourceLineNo">2499</span>              }<a name="line.2499"></a>
-<span class="sourceLineNo">2500</span>            }<a name="line.2500"></a>
-<span class="sourceLineNo">2501</span>          }<a name="line.2501"></a>
-<span class="sourceLineNo">2502</span>          if (!matched) return true;<a name="line.2502"></a>
-<span class="sourceLineNo">2503</span>          result.set(new Pair&lt;HRegionInfo, ServerName&gt;(info, sn));<a name="line.2503"></a>
-<span class="sourceLineNo">2504</span>          return false; // found the region, stop<a name="line.2504"></a>
-<span class="sourceLineNo">2505</span>        }<a name="line.2505"></a>
-<span class="sourceLineNo">2506</span>      };<a name="line.2506"></a>
-<span class="sourceLineNo">2507</span><a name="line.2507"></a>
-<span class="sourceLineNo">2508</span>      MetaTableAccessor.fullScanRegions(connection, visitor);<a name="line.2508"></a>
-<span class="sourceLineNo">2509</span>      pair = result.get();<a name="line.2509"></a>
-<span class="sourceLineNo">2510</span>    }<a name="line.2510"></a>
-<span class="sourceLineNo">2511</span>    return pair;<a name="line.2511"></a>
-<span class="sourceLineNo">2512</span>  }<a name="line.2512"></a>
-<span class="sourceLineNo">2513</span><a name="line.2513"></a>
-<span class="sourceLineNo">2514</span>  /**<a name="line.2514"></a>
-<span class="sourceLineNo">2515</span>   * If the input is a region name, it is returned as is. If it's an<a name="line.2515"></a>
-<span class="sourceLineNo">2516</span>   * encoded region name, the corresponding region is found from meta<a name="line.2516"></a>
-<span class="sourceLineNo">2517</span>   * and its region name is returned. If we can't find any region in<a name="line.2517"></a>
-<span class="sourceLineNo">2518</span>   * meta matching the input as either region name or encoded region<a name="line.2518"></a>
-<span class="sourceLineNo">2519</span>   * name, the input is returned as is. We don't throw unknown<a name="line.2519"></a>
-<span class="sourceLineNo">2520</span>   * region exception.<a name="line.2520"></a>
-<span class="sourceLineNo">2521</span>   */<a name="line.2521"></a>
-<span class="sourceLineNo">2522</span>  private byte[] getRegionName(<a name="line.2522"></a>
-<span class="sourceLineNo">2523</span>      final byte[] regionNameOrEncodedRegionName) throws IOException {<a name="line.2523"></a>
-<span class="sourceLineNo">2524</span>    if (Bytes.equals(regionNameOrEncodedRegionName,<a name="line.2524"></a>
-<span class="sourceLineNo">2525</span>        HRegionInfo.FIRST_META_REGIONINFO.getRegionName())<a name="line.2525"></a>
-<span class="sourceLineNo">2526</span>          || Bytes.equals(regionNameOrEncodedRegionName,<a name="line.2526"></a>
-<span class="sourceLineNo">2527</span>            HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes())) {<a name="line.2527"></a>
-<span class="sourceLineNo">2528</span>      return HRegionInfo.FIRST_META_REGIONINFO.getRegionName();<a name="line.2528"></a>
-<span class="sourceLineNo">2529</span>    }<a name="line.2529"></a>
-<span class="sourceLineNo">2530</span>    byte[] tmp = regionNameOrEncodedRegionName;<a name="line.2530"></a>
-<span class="sourceLineNo">2531</span>    Pair&lt;HRegionInfo, ServerName&gt; regionServerPair = getRegion(regionNameOrEncodedRegionName);<a name="line.2531"></a>
-<span class="sourceLineNo">2532</span>    if (regionServerPair != null &amp;&amp; regionServerPair.getFirst() != null) {<a name="line.2532"></a>
-<span class="sourceLineNo">2533</span>      tmp = regionServerPair.getFirst().getRegionName();<a name="line.2533"></a>
-<span class="sourceLineNo">2534</span>    }<a name="line.2534"></a>
-<span class="sourceLineNo">2535</span>    return tmp;<a name="line.2535"></a>
-<span class="sourceLineNo">2536</span>  }<a name="line.2536"></a>
-<span class="sourceLineNo">2537</span><a name="line.2537"></a>
-<span class="sourceLineNo">2538</span>  /**<a name="line.2538"></a>
-<span class="sourceLineNo">2539</span>   * Check if table exists or not<a name="line.2539"></a>
-<span class="sourceLineNo">2540</span>   * @param tableName Name of a table.<a name="line.2540"></a>
-<span class="sourceLineNo">2541</span>   * @return tableName instance<a name="line.2541"></a>
-<span class="sourceLineNo">2542</span>   * @throws IOException if a remote or network exception occurs.<a name="line.2542"></a>
-<span class="sourceLineNo">2543</span>   * @throws TableNotFoundException if table does not exist.<a name="line.2543"></a>
-<span class="sourceLineNo">2544</span>   */<a name="line.2544"></a>
-<span class="sourceLineNo">2545</span>  private TableName checkTableExists(final TableName tableName)<a name="line.2545"></a>
-<span class="sourceLineNo">2546</span>      throws IOException {<a name="line.2546"></a>
-<span class="sourceLineNo">2547</span>    return executeCallable(new ConnectionCallable&lt;TableName&gt;(getConnection()) {<a name="line.2547"></a>
-<span class="sourceLineNo">2548</span>      @Override<a name="line.2548"></a>
-<span class="sourceLineNo">2549</span>      public TableName call(int callTimeout) throws ServiceException, IOException {<a name="line.2549"></a>
-<span class="sourceLineNo">2550</span>        if (!MetaTableAccessor.tableExists(connection, tableName)) {<a name="line.2550"></a>
-<span class="sourceLineNo">2551</span>          throw new TableNotFoundException(tableName);<a name="line.2551"></a>
-<span class="sourceLineNo">2552</span>        }<a name="line.2552"></a>
-<span class="sourceLineNo">2553</span>        return tableName;<a name="line.2553"></a>
-<span class="sourceLineNo">2554</span>      }<a name="line.2554"></a>
-<span class="sourceLineNo">2555</span>    });<a name="line.2555"></a>
-<span class="sourceLineNo">2556</span>  }<a name="line.2556"></a>
-<span class="sourceLineNo">2557</span><a name="line.2557"></a>
-<span class="sourceLineNo">2558</span>  /**<a name="line.2558"></a>
-<span class="sourceLineNo">2559</span>   * Shuts down the HBase cluster<a name="line.2559"></a>
-<span class="sourceLineNo">2560</span>   * @throws IOException if a remote or network exception occurs<a name="line.2560"></a>
-<span class="sourceLineNo">2561</span>   */<a name="line.2561"></a>
-<span class="sourceLineNo">2562</span>  @Override<a name="line.2562"></a>
-<span class="sourceLineNo">2563</span>  public synchronized void shutdown() throws IOException {<a name="line.2563"></a>
-<span class="sourceLineNo">2564</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2564"></a>
-<span class="sourceLineNo">2565</span>      @Override<a name="line.2565"></a>
-<span class="sourceLineNo">2566</span>      public Void call(int callTimeout) throws ServiceException {<a name="line.2566"></a>
-<span class="sourceLineNo">2567</span>        master.shutdown(null,ShutdownRequest.newBuilder().build());<a name="line.2567"></a>
-<span class="sourceLineNo">2568</span>        return null;<a name="line.2568"></a>
-<span class="sourceLineNo">2569</span>      }<a name="line.2569"></a>
-<span class="sourceLineNo">2570</span>    });<a name="line.2570"></a>
-<span class="sourceLineNo">2571</span>  }<a name="line.2571"></a>
-<span class="sourceLineNo">2572</span><a name="line.2572"></a>
-<span class="sourceLineNo">2573</span>  /**<a name="line.2573"></a>
-<span class="sourceLineNo">2574</span>   * Shuts down the current HBase master only.<a name="line.2574"></a>
-<span class="sourceLineNo">2575</span>   * Does not shutdown the cluster.<a name="line.2575"></a>
-<span class="sourceLineNo">2576</span>   * @see #shutdown()<a name="line.2576"></a>
-<span class="sourceLineNo">2577</span>   * @throws IOException if a remote or network exception occurs<a name="line.2577"></a>
-<span class="sourceLineNo">2578</span>   */<a name="line.2578"></a>
-<span class="sourceLineNo">2579</span>  @Override<a name="line.2579"></a>
-<span class="sourceLineNo">2580</span>  public synchronized void stopMaster() throws IOException {<a name="line.2580"></a>
-<span class="sourceLineNo">2581</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2581"></a>
-<span class="sourceLineNo">2582</span>      @Override<a name="line.2582"></a>
-<span class="sourceLineNo">2583</span>      public Void call(int callTimeout) throws ServiceException {<a name="line.2583"></a>
-<span class="sourceLineNo">2584</span>        master.stopMaster(null, StopMasterRequest.newBuilder().build());<a name="line.2584"></a>
-<span class="sourceLineNo">2585</span>        return null;<a name="line.2585"></a>
-<span class="sourceLineNo">2586</span>      }<a name="line.2586"></a>
-<span class="sourceLineNo">2587</span>    });<a name="line.2587"></a>
-<span class="sourceLineNo">2588</span>  }<a name="line.2588"></a>
-<span class="sourceLineNo">2589</span><a name="line.2589"></a>
-<span class="sourceLineNo">2590</span>  /**<a name="line.2590"></a>
-<span class="sourceLineNo">2591</span>   * Stop the designated regionserver<a name="line.2591"></a>
-<span class="sourceLineNo">2592</span>   * @param hostnamePort Hostname and port delimited by a &lt;code&gt;:&lt;/code&gt; as in<a name="line.2592"></a>
-<span class="sourceLineNo">2593</span>   * &lt;code&gt;example.org:1234&lt;/code&gt;<a name="line.2593"></a>
-<span class="sourceLineNo">2594</span>   * @throws IOException if a remote or network exception occurs<a name="line.2594"></a>
-<span class="sourceLineNo">2595</span>   */<a name="line.2595"></a>
-<span class="sourceLineNo">2596</span>  @Override<a name="line.2596"></a>
-<span class="sourceLineNo">2597</span>  public synchronized void stopRegionServer(final String hostnamePort)<a name="line.2597"></a>
-<span class="sourceLineNo">2598</span>  throws IOException {<a name="line.2598"></a>
-<span class="sourceLineNo">2599</span>    String hostname = Addressing.parseHostname(hostnamePort);<a name="line.2599"></a>
-<span class="sourceLineNo">2600</span>    int port = Addressing.parsePort(hostnamePort);<a name="line.2600"></a>
-<span class="sourceLineNo">2601</span>    AdminService.BlockingInterface admin =<a name="line.2601"></a>
-<span class="sourceLineNo">2602</span>      this.connection.getAdmin(ServerName.valueOf(hostname, port, 0));<a name="line.2602"></a>
-<span class="sourceLineNo">2603</span>    StopServerRequest request = RequestConverter.buildStopServerRequest(<a name="line.2603"></a>
-<span class="sourceLineNo">2604</span>      "Called by admin client " + this.connection.toString());<a name="line.2604"></a>
-<span class="sourceLineNo">2605</span>    try {<a name="line.2605"></a>
-<span class="sourceLineNo">2606</span>      admin.stopServer(null, request);<a name="line.2606"></a>
-<span class="sourceLineNo">2607</span>    } catch (ServiceException se) {<a name="line.2607"></a>
-<span class="sourceLineNo">2608</span>      throw ProtobufUtil.getRemoteException(se);<a name="line.2608"></a>
-<span class="sourceLineNo">2609</span>    }<a name="line.2609"></a>
-<span class="sourceLineNo">2610</span>  }<a name="line.2610"></a>
-<span class="sourceLineNo">2611</span><a name="line.2611"></a>
-<span class="sourceLineNo">2612</span><a name="line.2612"></a>
-<span class="sourceLineNo">2613</span>  /**<a name="line.2613"></a>
-<span class="sourceLineNo">2614</span>   * @return cluster status<a name="line.2614"></a>
-<span class="sourceLineNo">2615</span>   * @throws IOException if a remote or network exception occurs<a name="line.2615"></a>
-<span class="sourceLineNo">2616</span>   */<a name="line.2616"></a>
-<span class="sourceLineNo">2617</span>  @Override<a name="line.2617"></a>
-<span class="sourceLineNo">2618</span>  public ClusterStatus getClusterStatus() throws IOException {<a name="line.2618"></a>
-<span class="sourceLineNo">2619</span>    return executeCallable(new MasterCallable&lt;ClusterStatus&gt;(getConnection()) {<a name="line.2619"></a>
-<span class="sourceLineNo">2620</span>      @Override<a name="line.2620"></a>
-<span class="sourceLineNo">2621</span>      public ClusterStatus call(int callTimeout) throws ServiceException {<a name="line.2621"></a>
-<span class="sourceLineNo">2622</span>        GetClusterStatusRequest req = RequestConverter.buildGetClusterStatusRequest();<a name="line.2622"></a>
-<span class="sourceLineNo">2623</span>        return ClusterStatus.convert(master.getClusterStatus(null, req).getClusterStatus());<a name="line.2623"></a>
-<span class="sourceLineNo">2624</span>      }<a name="line.2624"></a>
-<span class="sourceLineNo">2625</span>    });<a name="line.2625"></a>
-<span class="sourceLineNo">2626</span>  }<a name="line.2626"></a>
-<span class="sourceLineNo">2627</span><a name="line.2627"></a>
-<span class="sourceLineNo">2628</span>  /**<a name="line.2628"></a>
-<span class="sourceLineNo">2629</span>   * @return Configuration used by the instance.<a name="line.2629"></a>
-<span class="sourceLineNo">2630</span>   */<a name="line.2630"></a>
-<span class="sourceLineNo">2631</span>  @Override<a name="line.2631"></a>
-<span class="sourceLineNo">2632</span>  public Configuration getConfiguration() {<a name="line.2632"></a>
-<span class="sourceLineNo">2633</span>    return this.conf;<a name="line.2633"></a>
-<span class="sourceLineNo">2634</span>  }<a name="line.2634"></a>
-<span class="sourceLineNo">2635</span><a name="line.2635"></a>
-<span class="sourceLineNo">2636</span>  /**<a name="line.2636"></a>
-<span class="sourceLineNo">2637</span>   * Create a new namespace<a name="line.2637"></a>
-<span class="sourceLineNo">2638</span>   * @param descriptor descriptor which describes the new namespace<a name="line.2638"></a>
-<span class="sourceLineNo">2639</span>   * @throws IOException<a name="line.2639"></a>
-<span class="sourceLineNo">2640</span>   */<a name="line.2640"></a>
-<span class="sourceLineNo">2641</span>  @Override<a name="line.2641"></a>
-<span class="sourceLineNo">2642</span>  public void createNamespace(final NamespaceDescriptor descriptor) throws IOException {<a name="line.2642"></a>
-<span class="sourceLineNo">2643</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2643"></a>
-<span class="sourceLineNo">2644</span>      @Override<a name="line.2644"></a>
-<span class="sourceLineNo">2645</span>      public Void call(int callTimeout) throws Exception {<a name="line.2645"></a>
-<span class="sourceLineNo">2646</span>        master.createNamespace(null,<a name="line.2646"></a>
-<span class="sourceLineNo">2647</span>          CreateNamespaceRequest.newBuilder()<a name="line.2647"></a>
-<span class="sourceLineNo">2648</span>            .setNamespaceDescriptor(ProtobufUtil<a name="line.2648"></a>
-<span class="sourceLineNo">2649</span>              .toProtoNamespaceDescriptor(descriptor)).build()<a name="line.2649"></a>
-<span class="sourceLineNo">2650</span>        );<a name="line.2650"></a>
-<span class="sourceLineNo">2651</span>        return null;<a name="line.2651"></a>
-<span class="sourceLineNo">2652</span>      }<a name="line.2652"></a>
-<span class="sourceLineNo">2653</span>    });<a name="line.2653"></a>
-<span class="sourceLineNo">2654</span>  }<a name="line.2654"></a>
-<span class="sourceLineNo">2655</span><a name="line.2655"></a>
-<span class="sourceLineNo">2656</span>  /**<a name="line.2656"></a>
-<span class="sourceLineNo">2657</span>   * Modify an existing namespace<a name="line.2657"></a>
-<span class="sourceLineNo">2658</span>   * @param descriptor descriptor which describes the new namespace<a name="line.2658"></a>
-<span class="sourceLineNo">2659</span>   * @throws IOException<a name="line.2659"></a>
-<span class="sourceLineNo">2660</span>   */<a name="line.2660"></a>
-<span class="sourceLineNo">2661</span>  @Override<a name="line.2661"></a>
-<span class="sourceLineNo">2662</span>  public void modifyNamespace(final NamespaceDescriptor descriptor) throws IOException {<a name="line.2662"></a>
-<span class="sourceLineNo">2663</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2663"></a>
-<span class="sourceLineNo">2664</span>      @Override<a name="line.2664"></a>
-<span class="sourceLineNo">2665</span>      public Void call(int callTimeout) throws Exception {<a name="line.2665"></a>
-<span class="sourceLineNo">2666</span>        master.modifyNamespace(null, ModifyNamespaceRequest.newBuilder().<a name="line.2666"></a>
-<span class="sourceLineNo">2667</span>          setNamespaceDescriptor(ProtobufUtil.toProtoNamespaceDescriptor(descriptor)).build());<a name="line.2667"></a>
-<span class="sourceLineNo">2668</span>        return null;<a name="line.2668"></a>
-<span class="sourceLineNo">2669</span>      }<a name="line.2669"></a>
-<span class="sourceLineNo">2670</span>    });<a name="line.2670"></a>
-<span class="sourceLineNo">2671</span>  }<a name="line.2671"></a>
-<span class="sourceLineNo">2672</span><a name="line.2672"></a>
-<span class="sourceLineNo">2673</span>  /**<a name="line.2673"></a>
-<span class="sourceLineNo">2674</span>   * Delete an existing namespace. Only empty namespaces (no tables) can be removed.<a name="line.2674"></a>
-<span class="sourceLineNo">2675</span>   * @param name namespace name<a name="line.2675"></a>
-<span class="sourceLineNo">2676</span>   * @throws IOException<a name="line.2676"></a>
-<span class="sourceLineNo">2677</span>   */<a name="line.2677"></a>
-<span class="sourceLineNo">2678</span>  @Override<a name="line.2678"></a>
-<span class="sourceLineNo">2679</span>  public void deleteNamespace(final String name) throws IOException {<a name="line.2679"></a>
-<span class="sourceLineNo">2680</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2680"></a>
-<span class="sourceLineNo">2681</span>      @Override<a name="line.2681"></a>
-<span class="sourceLineNo">2682</span>      public Void call(int callTimeout) throws Exception {<a name="line.2682"></a>
-<span class="sourceLineNo">2683</span>        master.deleteNamespace(null, DeleteNamespaceRequest.newBuilder().<a name="line.2683"></a>
-<span class="sourceLineNo">2684</span>          setNamespaceName(name).build());<a name="line.2684"></a>
-<span class="sourceLineNo">2685</span>        return null;<a name="line.2685"></a>
-<span class="sourceLineNo">2686</span>      }<a name="line.2686"></a>
-<span class="sourceLineNo">2687</span>    });<a name="line.2687"></a>
-<span class="sourceLineNo">2688</span>  }<a name="line.2688"></a>
-<span class="sourceLineNo">2689</span><a name="line.2689"></a>
-<span class="sourceLineNo">2690</span>  /**<a name="line.2690"></a>
-<span class="sourceLineNo">2691</span>   * Get a namespace descriptor by name<a name="line.2691"></a>
-<span class="sourceLineNo">2692</span>   * @param name name of namespace descriptor<a name="line.2692"></a>
-<span class="sourceLineNo">2693</span>   * @return A descriptor<a name="line.2693"></a>
+<span class="sourceLineNo">2386</span>    if (regionServerPair.getFirst() != null &amp;&amp;<a name="line.2386"></a>
+<span class="sourceLineNo">2387</span>        regionServerPair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {<a name="line.2387"></a>
+<span class="sourceLineNo">2388</span>      throw new IllegalArgumentException("Can't split replicas directly. "<a name="line.2388"></a>
+<span class="sourceLineNo">2389</span>          + "Replicas are auto-split when their primary is split.");<a name="line.2389"></a>
+<span class="sourceLineNo">2390</span>    }<a name="line.2390"></a>
+<span class="sourceLineNo">2391</span>    if (regionServerPair.getSecond() == null) {<a name="line.2391"></a>
+<span class="sourceLineNo">2392</span>      throw new NoServerForRegionException(Bytes.toStringBinary(regionName));<a name="line.2392"></a>
+<span class="sourceLineNo">2393</span>    }<a name="line.2393"></a>
+<span class="sourceLineNo">2394</span>    split(regionServerPair.getSecond(), regionServerPair.getFirst(), splitPoint);<a name="line.2394"></a>
+<span class="sourceLineNo">2395</span>  }<a name="line.2395"></a>
+<span class="sourceLineNo">2396</span><a name="line.2396"></a>
+<span class="sourceLineNo">2397</span>  @VisibleForTesting<a name="line.2397"></a>
+<span class="sourceLineNo">2398</span>  public void split(final ServerName sn, final HRegionInfo hri,<a name="line.2398"></a>
+<span class="sourceLineNo">2399</span>      byte[] splitPoint) throws IOException {<a name="line.2399"></a>
+<span class="sourceLineNo">2400</span>    if (hri.getStartKey() != null &amp;&amp; splitPoint != null &amp;&amp;<a name="line.2400"></a>
+<span class="sourceLineNo">2401</span>         Bytes.compareTo(hri.getStartKey(), splitPoint) == 0) {<a name="line.2401"></a>
+<span class="sourceLineNo">2402</span>       throw new IOException("should not give a splitkey which equals to startkey!");<a name="line.2402"></a>
+<span class="sourceLineNo">2403</span>    }<a name="line.2403"></a>
+<span class="sourceLineNo">2404</span>    // TODO: This is not executed via retries<a name="line.2404"></a>
+<span class="sourceLineNo">2405</span>    AdminService.BlockingInterface admin = this.connection.getAdmin(sn);<a name="line.2405"></a>
+<span class="sourceLineNo">2406</span>    ProtobufUtil.split(admin, hri, splitPoint);<a name="line.2406"></a>
+<span class="sourceLineNo">2407</span>  }<a name="line.2407"></a>
+<span class="sourceLineNo">2408</span><a name="line.2408"></a>
+<span class="sourceLineNo">2409</span>  /**<a name="line.2409"></a>
+<span class="sourceLineNo">2410</span>   * Modify an existing table, more IRB friendly version. Asynchronous operation.<a name="line.2410"></a>
+<span class="sourceLineNo">2411</span>   * This means that it may be a while before your schema change is updated across all of the<a name="line.2411"></a>
+<span class="sourceLineNo">2412</span>   * table. You can use Future.get(long, TimeUnit) to wait on the operation to complete.<a name="line.2412"></a>
+<span class="sourceLineNo">2413</span>   * It may throw ExecutionException if there was an error while executing the operation<a name="line.2413"></a>
+<span class="sourceLineNo">2414</span>   * or TimeoutException in case the wait timeout was not long enough to allow the<a name="line.2414"></a>
+<span class="sourceLineNo">2415</span>   * operation to complete.<a name="line.2415"></a>
+<span class="sourceLineNo">2416</span>   *<a name="line.2416"></a>
+<span class="sourceLineNo">2417</span>   * @param tableName name of table.<a name="line.2417"></a>
+<span class="sourceLineNo">2418</span>   * @param htd modified description of the table<a name="line.2418"></a>
+<span class="sourceLineNo">2419</span>   * @throws IOException if a remote or network exception occurs<a name="line.2419"></a>
+<span class="sourceLineNo">2420</span>   * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the<a name="line.2420"></a>
+<span class="sourceLineNo">2421</span>   *     operation to complete.<a name="line.2421"></a>
+<span class="sourceLineNo">2422</span>   */<a name="line.2422"></a>
+<span class="sourceLineNo">2423</span>  @Override<a name="line.2423"></a>
+<span class="sourceLineNo">2424</span>  public Future&lt;Void&gt; modifyTable(final TableName tableName, final HTableDescriptor htd)<a name="line.2424"></a>
+<span class="sourceLineNo">2425</span>  throws IOException {<a name="line.2425"></a>
+<span class="sourceLineNo">2426</span>    if (!tableName.equals(htd.getTableName())) {<a name="line.2426"></a>
+<span class="sourceLineNo">2427</span>      throw new IllegalArgumentException("the specified table name '" + tableName +<a name="line.2427"></a>
+<span class="sourceLineNo">2428</span>        "' doesn't match with the HTD one: " + htd.getTableName());<a name="line.2428"></a>
+<span class="sourceLineNo">2429</span>    }<a name="line.2429"></a>
+<span class="sourceLineNo">2430</span><a name="line.2430"></a>
+<span class="sourceLineNo">2431</span>    ModifyTableResponse response = executeCallable(<a name="line.2431"></a>
+<span class="sourceLineNo">2432</span>        new MasterCallable&lt;ModifyTableResponse&gt;(getConnection()) {<a name="line.2432"></a>
+<span class="sourceLineNo">2433</span>      @Override<a name="line.2433"></a>
+<span class="sourceLineNo">2434</span>      public ModifyTableResponse call(int callTimeout) throws ServiceException {<a name="line.2434"></a>
+<span class="sourceLineNo">2435</span>        ModifyTableRequest request = RequestConverter.buildModifyTableRequest(<a name="line.2435"></a>
+<span class="sourceLineNo">2436</span>          tableName, htd, ng.getNonceGroup(), ng.newNonce());<a name="line.2436"></a>
+<span class="sourceLineNo">2437</span>        return master.modifyTable(null, request);<a name="line.2437"></a>
+<span class="sourceLineNo">2438</span>      }<a name="line.2438"></a>
+<span class="sourceLineNo">2439</span>    });<a name="line.2439"></a>
+<span class="sourceLineNo">2440</span><a name="line.2440"></a>
+<span class="sourceLineNo">2441</span>    return new ModifyTableFuture(this, tableName, response);<a name="line.2441"></a>
+<span class="sourceLineNo">2442</span>  }<a name="line.2442"></a>
+<span class="sourceLineNo">2443</span><a name="line.2443"></a>
+<span class="sourceLineNo">2444</span>  private static class ModifyTableFuture extends TableFuture&lt;Void&gt; {<a name="line.2444"></a>
+<span class="sourceLineNo">2445</span>    public ModifyTableFuture(final HBaseAdmin admin, final TableName tableName,<a name="line.2445"></a>
+<span class="sourceLineNo">2446</span>        final ModifyTableResponse response) {<a name="line.2446"></a>
+<span class="sourceLineNo">2447</span>      super(admin, tableName,<a name="line.2447"></a>
+<span class="sourceLineNo">2448</span>          (response != null &amp;&amp; response.hasProcId()) ? response.getProcId() : null);<a name="line.2448"></a>
+<span class="sourceLineNo">2449</span>    }<a name="line.2449"></a>
+<span class="sourceLineNo">2450</span><a name="line.2450"></a>
+<span class="sourceLineNo">2451</span>    public ModifyTableFuture(final HBaseAdmin admin, final TableName tableName, final Long procId) {<a name="line.2451"></a>
+<span class="sourceLineNo">2452</span>      super(admin, tableName, procId);<a name="line.2452"></a>
+<span class="sourceLineNo">2453</span>    }<a name="line.2453"></a>
+<span class="sourceLineNo">2454</span><a name="line.2454"></a>
+<span class="sourceLineNo">2455</span>    @Override<a name="line.2455"></a>
+<span class="sourceLineNo">2456</span>    public String getOperationType() {<a name="line.2456"></a>
+<span class="sourceLineNo">2457</span>      return "MODIFY";<a name="line.2457"></a>
+<span class="sourceLineNo">2458</span>    }<a name="line.2458"></a>
+<span class="sourceLineNo">2459</span><a name="line.2459"></a>
+<span class="sourceLineNo">2460</span>    @Override<a name="line.2460"></a>
+<span class="sourceLineNo">2461</span>    protected Void postOperationResult(final Void result, final long deadlineTs)<a name="line.2461"></a>
+<span class="sourceLineNo">2462</span>        throws IOException, TimeoutException {<a name="line.2462"></a>
+<span class="sourceLineNo">2463</span>      // The modify operation on the table is asynchronous on the server side irrespective<a name="line.2463"></a>
+<span class="sourceLineNo">2464</span>      // of whether Procedure V2 is supported or not. So, we wait in the client till<a name="line.2464"></a>
+<span class="sourceLineNo">2465</span>      // all regions get updated.<a name="line.2465"></a>
+<span class="sourceLineNo">2466</span>      waitForSchemaUpdate(deadlineTs);<a name="line.2466"></a>
+<span class="sourceLineNo">2467</span>      return result;<a name="line.2467"></a>
+<span class="sourceLineNo">2468</span>    }<a name="line.2468"></a>
+<span class="sourceLineNo">2469</span>  }<a name="line.2469"></a>
+<span class="sourceLineNo">2470</span><a name="line.2470"></a>
+<span class="sourceLineNo">2471</span>  public void modifyTable(final byte[] tableName, final HTableDescriptor htd)<a name="line.2471"></a>
+<span class="sourceLineNo">2472</span>  throws IOException {<a name="line.2472"></a>
+<span class="sourceLineNo">2473</span>    modifyTable(TableName.valueOf(tableName), htd);<a name="line.2473"></a>
+<span class="sourceLineNo">2474</span>  }<a name="line.2474"></a>
+<span class="sourceLineNo">2475</span><a name="line.2475"></a>
+<span class="sourceLineNo">2476</span>  public void modifyTable(final String tableName, final HTableDescriptor htd)<a name="line.2476"></a>
+<span class="sourceLineNo">2477</span>  throws IOException {<a name="line.2477"></a>
+<span class="sourceLineNo">2478</span>    modifyTable(TableName.valueOf(tableName), htd);<a name="line.2478"></a>
+<span class="sourceLineNo">2479</span>  }<a name="line.2479"></a>
+<span class="sourceLineNo">2480</span><a name="line.2480"></a>
+<span class="sourceLineNo">2481</span>  /**<a name="line.2481"></a>
+<span class="sourceLineNo">2482</span>   * @param regionName Name of a region.<a name="line.2482"></a>
+<span class="sourceLineNo">2483</span>   * @return a pair of HRegionInfo and ServerName if &lt;code&gt;regionName&lt;/code&gt; is<a name="line.2483"></a>
+<span class="sourceLineNo">2484</span>   *  a verified region name (we call {@link<a name="line.2484"></a>
+<span class="sourceLineNo">2485</span>   *  MetaTableAccessor#getRegion(HConnection, byte[])}<a name="line.2485"></a>
+<span class="sourceLineNo">2486</span>   *  else null.<a name="line.2486"></a>
+<span class="sourceLineNo">2487</span>   * Throw IllegalArgumentException if &lt;code&gt;regionName&lt;/code&gt; is null.<a name="line.2487"></a>
+<span class="sourceLineNo">2488</span>   * @throws IOException<a name="line.2488"></a>
+<span class="sourceLineNo">2489</span>   */<a name="line.2489"></a>
+<span class="sourceLineNo">2490</span>  Pair&lt;HRegionInfo, ServerName&gt; getRegion(final byte[] regionName) throws IOException {<a name="line.2490"></a>
+<span class="sourceLineNo">2491</span>    if (regionName == null) {<a name="line.2491"></a>
+<span class="sourceLineNo">2492</span>      throw new IllegalArgumentException("Pass a table name or region name");<a name="line.2492"></a>
+<span class="sourceLineNo">2493</span>    }<a name="line.2493"></a>
+<span class="sourceLineNo">2494</span>    Pair&lt;HRegionInfo, ServerName&gt; pair =<a name="line.2494"></a>
+<span class="sourceLineNo">2495</span>      MetaTableAccessor.getRegion(connection, regionName);<a name="line.2495"></a>
+<span class="sourceLineNo">2496</span>    if (pair == null) {<a name="line.2496"></a>
+<span class="sourceLineNo">2497</span>      final AtomicReference&lt;Pair&lt;HRegionInfo, ServerName&gt;&gt; result =<a name="line.2497"></a>
+<span class="sourceLineNo">2498</span>        new AtomicReference&lt;Pair&lt;HRegionInfo, ServerName&gt;&gt;(null);<a name="line.2498"></a>
+<span class="sourceLineNo">2499</span>      final String encodedName = Bytes.toString(regionName);<a name="line.2499"></a>
+<span class="sourceLineNo">2500</span>      MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() {<a name="line.2500"></a>
+<span class="sourceLineNo">2501</span>        @Override<a name="line.2501"></a>
+<span class="sourceLineNo">2502</span>        public boolean visit(Result data) throws IOException {<a name="line.2502"></a>
+<span class="sourceLineNo">2503</span>          HRegionInfo info = MetaTableAccessor.getHRegionInfo(data);<a name="line.2503"></a>
+<span class="sourceLineNo">2504</span>          if (info == null) {<a name="line.2504"></a>
+<span class="sourceLineNo">2505</span>            LOG.warn("No serialized HRegionInfo in " + data);<a name="line.2505"></a>
+<span class="sourceLineNo">2506</span>            return true;<a name="line.2506"></a>
+<span class="sourceLineNo">2507</span>          }<a name="line.2507"></a>
+<span class="sourceLineNo">2508</span>          RegionLocations rl = MetaTableAccessor.getRegionLocations(data);<a name="line.2508"></a>
+<span class="sourceLineNo">2509</span>          boolean matched = false;<a name="line.2509"></a>
+<span class="sourceLineNo">2510</span>          ServerName sn = null;<a name="line.2510"></a>
+<span class="sourceLineNo">2511</span>          if (rl != null) {<a name="line.2511"></a>
+<span class="sourceLineNo">2512</span>            for (HRegionLocation h : rl.getRegionLocations()) {<a name="line.2512"></a>
+<span class="sourceLineNo">2513</span>              if (h != null &amp;&amp; encodedName.equals(h.getRegionInfo().getEncodedName())) {<a name="line.2513"></a>
+<span class="sourceLineNo">2514</span>                sn = h.getServerName();<a name="line.2514"></a>
+<span class="sourceLineNo">2515</span>                info = h.getRegionInfo();<a name="line.2515"></a>
+<span class="sourceLineNo">2516</span>                matched = true;<a name="line.2516"></a>
+<span class="sourceLineNo">2517</span>              }<a name="line.2517"></a>
+<span class="sourceLineNo">2518</span>            }<a name="line.2518"></a>
+<span class="sourceLineNo">2519</span>          }<a name="line.2519"></a>
+<span class="sourceLineNo">2520</span>          if (!matched) return true;<a name="line.2520"></a>
+<span class="sourceLineNo">2521</span>          result.set(new Pair&lt;HRegionInfo, ServerName&gt;(info, sn));<a name="line.2521"></a>
+<span class="sourceLineNo">2522</span>          return false; // found the region, stop<a name="line.2522"></a>
+<span class="sourceLineNo">2523</span>        }<a name="line.2523"></a>
+<span class="sourceLineNo">2524</span>      };<a name="line.2524"></a>
+<span class="sourceLineNo">2525</span><a name="line.2525"></a>
+<span class="sourceLineNo">2526</span>      MetaTableAccessor.fullScanRegions(connection, visitor);<a name="line.2526"></a>
+<span class="sourceLineNo">2527</span>      pair = result.get();<a name="line.2527"></a>
+<span class="sourceLineNo">2528</span>    }<a name="line.2528"></a>
+<span class="sourceLineNo">2529</span>    return pair;<a name="line.2529"></a>
+<span class="sourceLineNo">2530</span>  }<a name="line.2530"></a>
+<span class="sourceLineNo">2531</span><a name="line.2531"></a>
+<span class="sourceLineNo">2532</span>  /**<a name="line.2532"></a>
+<span class="sourceLineNo">2533</span>   * If the input is a region name, it is returned as is. If it's an<a name="line.2533"></a>
+<span class="sourceLineNo">2534</span>   * encoded region name, the corresponding region is found from meta<a name="line.2534"></a>
+<span class="sourceLineNo">2535</span>   * and its region name is returned. If we can't find any region in<a name="line.2535"></a>
+<span class="sourceLineNo">2536</span>   * meta matching the input as either region name or encoded region<a name="line.2536"></a>
+<span class="sourceLineNo">2537</span>   * name, the input is returned as is. We don't throw unknown<a name="line.2537"></a>
+<span class="sourceLineNo">2538</span>   * region exception.<a name="line.2538"></a>
+<span class="sourceLineNo">2539</span>   */<a name="line.2539"></a>
+<span class="sourceLineNo">2540</span>  private byte[] getRegionName(<a name="line.2540"></a>
+<span class="sourceLineNo">2541</span>      final byte[] regionNameOrEncodedRegionName) throws IOException {<a name="line.2541"></a>
+<span class="sourceLineNo">2542</span>    if (Bytes.equals(regionNameOrEncodedRegionName,<a name="line.2542"></a>
+<span class="sourceLineNo">2543</span>        HRegionInfo.FIRST_META_REGIONINFO.getRegionName())<a name="line.2543"></a>
+<span class="sourceLineNo">2544</span>          || Bytes.equals(regionNameOrEncodedRegionName,<a name="line.2544"></a>
+<span class="sourceLineNo">2545</span>            HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes())) {<a name="line.2545"></a>
+<span class="sourceLineNo">2546</span>      return HRegionInfo.FIRST_META_REGIONINFO.getRegionName();<a name="line.2546"></a>
+<span class="sourceLineNo">2547</span>    }<a name="line.2547"></a>
+<span class="sourceLineNo">2548</span>    byte[] tmp = regionNameOrEncodedRegionName;<a name="line.2548"></a>
+<span class="sourceLineNo">2549</span>    Pair&lt;HRegionInfo, ServerName&gt; regionServerPair = getRegion(regionNameOrEncodedRegionName);<a name="line.2549"></a>
+<span class="sourceLineNo">2550</span>    if (regionServerPair != null &amp;&amp; regionServerPair.getFirst() != null) {<a name="line.2550"></a>
+<span class="sourceLineNo">2551</span>      tmp = regionServerPair.getFirst().getRegionName();<a name="line.2551"></a>
+<span class="sourceLineNo">2552</span>    }<a name="line.2552"></a>
+<span class="sourceLineNo">2553</span>    return tmp;<a name="line.2553"></a>
+<span class="sourceLineNo">2554</span>  }<a name="line.2554"></a>
+<span class="sourceLineNo">2555</span><a name="line.2555"></a>
+<span class="sourceLineNo">2556</span>  /**<a name="line.2556"></a>
+<span class="sourceLineNo">2557</span>   * Check if table exists or not<a name="line.2557"></a>
+<span class="sourceLineNo">2558</span>   * @param tableName Name of a table.<a name="line.2558"></a>
+<span class="sourceLineNo">2559</span>   * @return tableName instance<a name="line.2559"></a>
+<span class="sourceLineNo">2560</span>   * @throws IOException if a remote or network exception occurs.<a name="line.2560"></a>
+<span class="sourceLineNo">2561</span>   * @throws TableNotFoundException if table does not exist.<a name="line.2561"></a>
+<span class="sourceLineNo">2562</span>   */<a name="line.2562"></a>
+<span class="sourceLineNo">2563</span>  private TableName checkTableExists(final TableName tableName)<a name="line.2563"></a>
+<span class="sourceLineNo">2564</span>      throws IOException {<a name="line.2564"></a>
+<span class="sourceLineNo">2565</span>    return executeCallable(new ConnectionCallable&lt;TableName&gt;(getConnection()) {<a name="line.2565"></a>
+<span class="sourceLineNo">2566</span>      @Override<a name="line.2566"></a>
+<span class="sourceLineNo">2567</span>      public TableName call(int callTimeout) throws ServiceException, IOException {<a name="line.2567"></a>
+<span class="sourceLineNo">2568</span>        if (!MetaTableAccessor.tableExists(connection, tableName)) {<a name="line.2568"></a>
+<span class="sourceLineNo">2569</span>          throw new TableNotFoundException(tableName);<a name="line.2569"></a>
+<span class="sourceLineNo">2570</span>        }<a name="line.2570"></a>
+<span class="sourceLineNo">2571</span>        return tableName;<a name="line.2571"></a>
+<span class="sourceLineNo">2572</span>      }<a name="line.2572"></a>
+<span class="sourceLineNo">2573</span>    });<a name="line.2573"></a>
+<span class="sourceLineNo">2574</span>  }<a name="line.2574"></a>
+<span class="sourceLineNo">2575</span><a name="line.2575"></a>
+<span class="sourceLineNo">2576</span>  /**<a name="line.2576"></a>
+<span class="sourceLineNo">2577</span>   * Shuts down the HBase cluster<a name="line.2577"></a>
+<span class="sourceLineNo">2578</span>   * @throws IOException if a remote or network exception occurs<a name="line.2578"></a>
+<span class="sourceLineNo">2579</span>   */<a name="line.2579"></a>
+<span class="sourceLineNo">2580</span>  @Override<a name="line.2580"></a>
+<span class="sourceLineNo">2581</span>  public synchronized void shutdown() throws IOException {<a name="line.2581"></a>
+<span class="sourceLineNo">2582</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2582"></a>
+<span class="sourceLineNo">2583</span>      @Override<a name="line.2583"></a>
+<span class="sourceLineNo">2584</span>      public Void call(int callTimeout) throws ServiceException {<a name="line.2584"></a>
+<span class="sourceLineNo">2585</span>        master.shutdown(null,ShutdownRequest.newBuilder().build());<a name="line.2585"></a>
+<span class="sourceLineNo">2586</span>        return null;<a name="line.2586"></a>
+<span class="sourceLineNo">2587</span>      }<a name="line.2587"></a>
+<span class="sourceLineNo">2588</span>    });<a name="line.2588"></a>
+<span class="sourceLineNo">2589</span>  }<a name="line.2589"></a>
+<span class="sourceLineNo">2590</span><a name="line.2590"></a>
+<span class="sourceLineNo">2591</span>  /**<a name="line.2591"></a>
+<span class="sourceLineNo">2592</span>   * Shuts down the current HBase master only.<a name="line.2592"></a>
+<span class="sourceLineNo">2593</span>   * Does not shutdown the cluster.<a name="line.2593"></a>
+<span class="sourceLineNo">2594</span>   * @see #shutdown()<a name="line.2594"></a>
+<span class="sourceLineNo">2595</span>   * @throws IOException if a remote or network exception occurs<a name="line.2595"></a>
+<span class="sourceLineNo">2596</span>   */<a name="line.2596"></a>
+<span class="sourceLineNo">2597</span>  @Override<a name="line.2597"></a>
+<span class="sourceLineNo">2598</span>  public synchronized void stopMaster() throws IOException {<a name="line.2598"></a>
+<span class="sourceLineNo">2599</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2599"></a>
+<span class="sourceLineNo">2600</span>      @Override<a name="line.2600"></a>
+<span class="sourceLineNo">2601</span>      public Void call(int callTimeout) throws ServiceException {<a name="line.2601"></a>
+<span class="sourceLineNo">2602</span>        master.stopMaster(null, StopMasterRequest.newBuilder().build());<a name="line.2602"></a>
+<span class="sourceLineNo">2603</span>        return null;<a name="line.2603"></a>
+<span class="sourceLineNo">2604</span>      }<a name="line.2604"></a>
+<span class="sourceLineNo">2605</span>    });<a name="line.2605"></a>
+<span class="sourceLineNo">2606</span>  }<a name="line.2606"></a>
+<span class="sourceLineNo">2607</span><a name="line.2607"></a>
+<span class="sourceLineNo">2608</span>  /**<a name="line.2608"></a>
+<span class="sourceLineNo">2609</span>   * Stop the designated regionserver<a name="line.2609"></a>
+<span class="sourceLineNo">2610</span>   * @param hostnamePort Hostname and port delimited by a &lt;code&gt;:&lt;/code&gt; as in<a name="line.2610"></a>
+<span class="sourceLineNo">2611</span>   * &lt;code&gt;example.org:1234&lt;/code&gt;<a name="line.2611"></a>
+<span class="sourceLineNo">2612</span>   * @throws IOException if a remote or network exception occurs<a name="line.2612"></a>
+<span class="sourceLineNo">2613</span>   */<a name="line.2613"></a>
+<span class="sourceLineNo">2614</span>  @Override<a name="line.2614"></a>
+<span class="sourceLineNo">2615</span>  public synchronized void stopRegionServer(final String hostnamePort)<a name="line.2615"></a>
+<span class="sourceLineNo">2616</span>  throws IOException {<a name="line.2616"></a>
+<span class="sourceLineNo">2617</span>    String hostname = Addressing.parseHostname(hostnamePort);<a name="line.2617"></a>
+<span class="sourceLineNo">2618</span>    int port = Addressing.parsePort(hostnamePort);<a name="line.2618"></a>
+<span class="sourceLineNo">2619</span>    AdminService.BlockingInterface admin =<a name="line.2619"></a>
+<span class="sourceLineNo">2620</span>      this.connection.getAdmin(ServerName.valueOf(hostname, port, 0));<a name="line.2620"></a>
+<span class="sourceLineNo">2621</span>    StopServerRequest request = RequestConverter.buildStopServerRequest(<a name="line.2621"></a>
+<span class="sourceLineNo">2622</span>      "Called by admin client " + this.connection.toString());<a name="line.2622"></a>
+<span class="sourceLineNo">2623</span>    try {<a name="line.2623"></a>
+<span class="sourceLineNo">2624</span>      admin.stopServer(null, request);<a name="line.2624"></a>
+<span class="sourceLineNo">2625</span>    } catch (ServiceException se) {<a name="line.2625"></a>
+<span class="sourceLineNo">2626</span>      throw ProtobufUtil.getRemoteException(se);<a name="line.2626"></a>
+<span class="sourceLineNo">2627</span>    }<a name="line.2627"></a>
+<span class="sourceLineNo">2628</span>  }<a name="line.2628"></a>
+<span class="sourceLineNo">2629</span><a name="line.2629"></a>
+<span class="sourceLineNo">2630</span><a name="line.2630"></a>
+<span class="sourceLineNo">2631</span>  /**<a name="line.2631"></a>
+<span class="sourceLineNo">2632</span>   * @return cluster status<a name="line.2632"></a>
+<span class="sourceLineNo">2633</span>   * @throws IOException if a remote or network exception occurs<a name="line.2633"></a>
+<span class="sourceLineNo">2634</span>   */<a name="line.2634"></a>
+<span class="sourceLineNo">2635</span>  @Override<a name="line.2635"></a>
+<span class="sourceLineNo">2636</span>  public ClusterStatus getClusterStatus() throws IOException {<a name="line.2636"></a>
+<span class="sourceLineNo">2637</span>    return executeCallable(new MasterCallable&lt;ClusterStatus&gt;(getConnection()) {<a name="line.2637"></a>
+<span class="sourceLineNo">2638</span>      @Override<a name="line.2638"></a>
+<span class="sourceLineNo">2639</span>      public ClusterStatus call(int callTimeout) throws ServiceException {<a name="line.2639"></a>
+<span class="sourceLineNo">2640</span>        GetClusterStatusRequest req = RequestConverter.buildGetClusterStatusRequest();<a name="line.2640"></a>
+<span class="sourceLineNo">2641</span>        return ClusterStatus.convert(master.getClusterStatus(null, req).getClusterStatus());<a name="line.2641"></a>
+<span class="sourceLineNo">2642</span>      }<a name="line.2642"></a>
+<span class="sourceLineNo">2643</span>    });<a name="line.2643"></a>
+<span class="sourceLineNo">2644</span>  }<a name="line.2644"></a>
+<span class="sourceLineNo">2645</span><a name="line.2645"></a>
+<span class="sourceLineNo">2646</span>  /**<a name="line.2646"></a>
+<span class="sourceLineNo">2647</span>   * @return Configuration used by the instance.<a name="line.2647"></a>
+<span class="sourceLineNo">2648</span>   */<a name="line.2648"></a>
+<span class="sourceLineNo">2649</span>  @Override<a name="line.2649"></a>
+<span class="sourceLineNo">2650</span>  public Configuration getConfiguration() {<a name="line.2650"></a>
+<span class="sourceLineNo">2651</span>    return this.conf;<a name="line.2651"></a>
+<span class="sourceLineNo">2652</span>  }<a name="line.2652"></a>
+<span class="sourceLineNo">2653</span><a name="line.2653"></a>
+<span class="sourceLineNo">2654</span>  /**<a name="line.2654"></a>
+<span class="sourceLineNo">2655</span>   * Create a new namespace<a name="line.2655"></a>
+<span class="sourceLineNo">2656</span>   * @param descriptor descriptor which describes the new namespace<a name="line.2656"></a>
+<span class="sourceLineNo">2657</span>   * @throws IOException<a name="line.2657"></a>
+<span class="sourceLineNo">2658</span>   */<a name="line.2658"></a>
+<span class="sourceLineNo">2659</span>  @Override<a name="line.2659"></a>
+<span class="sourceLineNo">2660</span>  public void createNamespace(final NamespaceDescriptor descriptor) throws IOException {<a name="line.2660"></a>
+<span class="sourceLineNo">2661</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2661"></a>
+<span class="sourceLineNo">2662</span>      @Override<a name="line.2662"></a>
+<span class="sourceLineNo">2663</span>      public Void call(int callTimeout) throws Exception {<a name="line.2663"></a>
+<span class="sourceLineNo">2664</span>        master.createNamespace(null,<a name="line.2664"></a>
+<span class="sourceLineNo">2665</span>          CreateNamespaceRequest.newBuilder()<a name="line.2665"></a>
+<span class="sourceLineNo">2666</span>            .setNamespaceDescriptor(ProtobufUtil<a name="line.2666"></a>
+<span class="sourceLineNo">2667</span>              .toProtoNamespaceDescriptor(descriptor)).build()<a name="line.2667"></a>
+<span class="sourceLineNo">2668</span>        );<a name="line.2668"></a>
+<span class="sourceLineNo">2669</span>        return null;<a name="line.2669"></a>
+<span class="sourceLineNo">2670</span>      }<a name="line.2670"></a>
+<span class="sourceLineNo">2671</span>    });<a name="line.2671"></a>
+<span class="sourceLineNo">2672</span>  }<a name="line.2672"></a>
+<span class="sourceLineNo">2673</span><a name="line.2673"></a>
+<span class="sourceLineNo">2674</span>  /**<a name="line.2674"></a>
+<span class="sourceLineNo">2675</span>   * Modify an existing namespace<a name="line.2675"></a>
+<span class="sourceLineNo">2676</span>   * @param descriptor descriptor which describes the new namespace<a name="line.2676"></a>
+<span class="sourceLineNo">2677</span>   * @throws IOException<a name="line.2677"></a>
+<span class="sourceLineNo">2678</span>   */<a name="line.2678"></a>
+<span class="sourceLineNo">2679</span>  @Override<a name="line.2679"></a>
+<span class="sourceLineNo">2680</span>  public void modifyNamespace(final NamespaceDescriptor descriptor) throws IOException {<a name="line.2680"></a>
+<span class="sourceLineNo">2681</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2681"></a>
+<span class="sourceLineNo">2682</span>      @Override<a name="line.2682"></a>
+<span class="sourceLineNo">2683</span>      public Void call(int callTimeout) throws Exception {<a name="line.2683"></a>
+<span class="sourceLineNo">2684</span>        master.modifyNamespace(null, ModifyNamespaceRequest.newBuilder().<a name="line.2684"></a>
+<span class="sourceLineNo">2685</span>          setNamespaceDescriptor(ProtobufUtil.toProtoNamespaceDescriptor(descriptor)).build());<a name="line.2685"></a>
+<span class="sourceLineNo">2686</span>        return null;<a name="line.2686"></a>
+<span class="sourceLineNo">2687</span>      }<a name="line.2687"></a>
+<span class="sourceLineNo">2688</span>    });<a name="line.2688"></a>
+<span class="sourceLineNo">2689</span>  }<a name="line.2689"></a>
+<span class="sourceLineNo">2690</span><a name="line.2690"></a>
+<span class="sourceLineNo">2691</span>  /**<a name="line.2691"></a>
+<span class="sourceLineNo">2692</span>   * Delete an existing namespace. Only empty namespaces (no tables) can be removed.<a name="line.2692"></a>
+<span class="sourceLineNo">2693</span>   * @param name namespace name<a name="line.2693"></a>
 <span class="sourceLineNo">2694</span>   * @throws IOException<a name="line.2694"></a>
 <span class="sourceLineNo">2695</span>   */<a name="line.2695"></a>
 <span class="sourceLineNo">2696</span>  @Override<a name="line.2696"></a>
-<span class="sourceLineNo">2697</span>  public NamespaceDescriptor getNamespaceDescriptor(final String name) throws IOException {<a name="line.2697"></a>
-<span class="sourceLineNo">2698</span>    return<a name="line.2698"></a>
-<span class="sourceLineNo">2699</span>        executeCallable(new MasterCallable&lt;NamespaceDescriptor&gt;(getConnection()) {<a name="line.2699"></a>
-<span class="sourceLineNo">2700</span>          @Override<a name="line.2700"></a>
-<span class="sourceLineNo">2701</span>          public NamespaceDescriptor call(int callTimeout) throws Exception {<a name="line.2701"></a>
-<span class="sourceLineNo">2702</span>            return ProtobufUtil.toNamespaceDescriptor(<a name="line.2702"></a>
-<span class="sourceLineNo">2703</span>              master.getNamespaceDescriptor(null, GetNamespaceDescriptorRequest.newBuilder().<a name="line.2703"></a>
-<span class="sourceLineNo">2704</span>                setNamespaceName(name).build()).getNamespaceDescriptor());<a name="line.2704"></a>
-<span class="sourceLineNo">2705</span>          }<a name="line.2705"></a>
-<span class="sourceLineNo">2706</span>        });<a name="line.2706"></a>
-<span class="sourceLineNo">2707</span>  }<a name="line.2707"></a>
-<span class="sourceLineNo">2708</span><a name="line.2708"></a>
-<span class="sourceLineNo">2709</span>  /**<a name="line.2709"></a>
-<span class="sourceLineNo">2710</span>   * List available namespace descriptors<a name="line.2710"></a>
-<span class="sourceLineNo">2711</span>   * @return List of descriptors<a name="line.2711"></a>
+<span class="sourceLineNo">2697</span>  public void deleteNamespace(final String name) throws IOException {<a name="line.2697"></a>
+<span class="sourceLineNo">2698</span>    executeCallable(new MasterCallable&lt;Void&gt;(getConnection()) {<a name="line.2698"></a>
+<span class="sourceLineNo">2699</span>      @Override<a name="line.2699"></a>
+<span class="sourceLineNo">2700</span>      public Void call(int callTimeout) throws Exception {<a name="line.2700"></a>
+<span class="sourceLineNo">2701</span>        master.deleteNamespace(null, DeleteNamespaceRequest.newBuilder().<a name="line.2701"></a>
+<span class="sourceLineNo">2702</span>          setNamespaceName(name).build());<a name="line.2702"></a>
+<span class="sourceLineNo">2703</span>        return null;<a name="line.2703"></a>
+<span class="sourceLineNo">2704</span>      }<a name="line.2704"></a>
+<span class="sourceLineNo">2705</span>    });<a name="line.2705"></a>
+<span class="sourceLineNo">2706</span>  }<a name="line.2706"></a>
+<span class="sourceLineNo">2707</span><a name="line.2707"></a>
+<span class="sourceLineNo">2708</span>  /**<a name="line.2708"></a>
+<span class="sourceLineNo">2709</span>   * Get a namespace descriptor by name<a name="line.2709"></a>
+<span class="sourceLineNo">2710</span>   * @param name name of namespace descriptor<a name="line.2710"></a>
+<span class="sourceLineNo">2711</span>   * @return A descriptor<a name="line.2711"></a>
 <span class="sourceLineNo">2712</span>   * @throws IOException<a name="line.2712"></a>
 <span class="sourceLineNo">2713</span>   */<a name="line.2713"></a>
 <span class="sourceLineNo">2714</span>  @Override<a name="line.2714"></a>
-<span class="sourceLineNo">2715</span>  public NamespaceDescriptor[] listNamespaceDescriptors() throws IOException {<a name="line.2715"></a>
+<span class="sourceLineNo">2715</span>  public NamespaceDescriptor getNamespaceDescriptor(final String name) throws IOException {<a name="line.2715"></a>
 <span class="sourceLineNo">2716</span>    return<a name="line.2716"></a>
-<span class="sourceLineNo">2717</span>        executeCallable(new MasterCallable&l

<TRUNCATED>

Mime
View raw message