http://git-wip-us.apache.org/repos/asf/hbase-site/blob/65565d77/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.TableVisitorBase.html
----------------------------------------------------------------------
diff --git 
a/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.TableVisitorBase.html
 
b/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.TableVisitorBase.html
index fea2b5a..c7a6cc4 100644
--- 
a/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.TableVisitorBase.html
+++ 
b/devapidocs/src-html/org/apache/hadoop/hbase/MetaTableAccessor.TableVisitorBase.html
@@ -1354,816 +1354,824 @@
 <span class="sourceLineNo">1346</span>   */<a name="line.1346"></a>
 <span class="sourceLineNo">1347</span>  public static void 
putsToMetaTable(final Connection connection, final List&lt;Put&gt; ps)<a 
name="line.1347"></a>
 <span class="sourceLineNo">1348</span>      throws IOException {<a 
name="line.1348"></a>
-<span class="sourceLineNo">1349</span>    try (Table t = 
getMetaHTable(connection)) {<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>      debugLogMutations(ps);<a 
name="line.1350"></a>
-<span class="sourceLineNo">1351</span>      t.put(ps);<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>    }<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>  }<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span><a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>  /**<a name="line.1355"></a>
-<span class="sourceLineNo">1356</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.1356"></a>
-<span class="sourceLineNo">1357</span>   * @param connection connection we're 
using<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>   * @param d Delete to add to 
hbase:meta<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span>   */<a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>  private static void 
deleteFromMetaTable(final Connection connection, final Delete d)<a 
name="line.1360"></a>
-<span class="sourceLineNo">1361</span>      throws IOException {<a 
name="line.1361"></a>
-<span class="sourceLineNo">1362</span>    List&lt;Delete&gt; dels = new 
ArrayList&lt;&gt;(1);<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>    dels.add(d);<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>    deleteFromMetaTable(connection, 
dels);<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>   * Delete the passed 
&lt;code&gt;deletes&lt;/code&gt; from the &lt;code&gt;hbase:meta&lt;/code&gt; 
table.<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>   * @param connection connection we're 
using<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>   * @param deletes Deletes to add to 
hbase:meta  This list should support #remove.<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>   */<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>  private static void 
deleteFromMetaTable(final Connection connection, final List&lt;Delete&gt; 
deletes)<a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>      throws IOException {<a 
name="line.1373"></a>
-<span class="sourceLineNo">1374</span>    try (Table t = 
getMetaHTable(connection)) {<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>      debugLogMutations(deletes);<a 
name="line.1375"></a>
-<span class="sourceLineNo">1376</span>      t.delete(deletes);<a 
name="line.1376"></a>
-<span class="sourceLineNo">1377</span>    }<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>  }<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span><a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>  /**<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>   * Deletes some replica columns 
corresponding to replicas for the passed rows<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>   * @param metaRows rows in 
hbase:meta<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>   * @param replicaIndexToDeleteFrom the 
replica ID we would start deleting from<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>   * @param numReplicasToRemove how many 
replicas to remove<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>   * @param connection connection we're 
using to access meta table<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>   */<a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>  public static void 
removeRegionReplicasFromMeta(Set&lt;byte[]&gt; metaRows,<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span>    int replicaIndexToDeleteFrom, int 
numReplicasToRemove, Connection connection)<a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>      throws IOException {<a 
name="line.1389"></a>
-<span class="sourceLineNo">1390</span>    int absoluteIndex = 
replicaIndexToDeleteFrom + numReplicasToRemove;<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>    for (byte[] row : metaRows) {<a 
name="line.1391"></a>
-<span class="sourceLineNo">1392</span>      long now = 
EnvironmentEdgeManager.currentTime();<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>      Delete deleteReplicaLocations = 
new Delete(row);<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>      for (int i = 
replicaIndexToDeleteFrom; i &lt; absoluteIndex; i++) {<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>        
deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>          getServerColumn(i), now);<a 
name="line.1396"></a>
-<span class="sourceLineNo">1397</span>        
deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>          getSeqNumColumn(i), now);<a 
name="line.1398"></a>
-<span class="sourceLineNo">1399</span>        
deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>          getStartCodeColumn(i), now);<a 
name="line.1400"></a>
-<span class="sourceLineNo">1401</span>      }<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>      deleteFromMetaTable(connection, 
deleteReplicaLocations);<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span>    }<a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>  }<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span><a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>  /**<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>   * Execute the passed 
&lt;code&gt;mutations&lt;/code&gt; against &lt;code&gt;hbase:meta&lt;/code&gt; 
table.<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span>   * @param connection connection we're 
using<a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>   * @param mutations Puts and Deletes 
to execute on hbase:meta<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>   * @throws IOException<a 
name="line.1410"></a>
-<span class="sourceLineNo">1411</span>   */<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>  public static void 
mutateMetaTable(final Connection connection,<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span>                                     
final List&lt;Mutation&gt; mutations)<a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>    throws IOException {<a 
name="line.1414"></a>
-<span class="sourceLineNo">1415</span>    Table t = 
getMetaHTable(connection);<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>    try {<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>      debugLogMutations(mutations);<a 
name="line.1417"></a>
-<span class="sourceLineNo">1418</span>      t.batch(mutations, null);<a 
name="line.1418"></a>
-<span class="sourceLineNo">1419</span>    } catch (InterruptedException e) {<a 
name="line.1419"></a>
-<span class="sourceLineNo">1420</span>      InterruptedIOException ie = new 
InterruptedIOException(e.getMessage());<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>      ie.initCause(e);<a 
name="line.1421"></a>
-<span class="sourceLineNo">1422</span>      throw ie;<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>    } finally {<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>      t.close();<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>    }<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>  }<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span><a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>  private static void 
addRegionStateToPut(Put put, RegionState.State state) throws IOException {<a 
name="line.1428"></a>
-<span class="sourceLineNo">1429</span>    
put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a 
name="line.1429"></a>
-<span class="sourceLineNo">1430</span>        .setRow(put.getRow())<a 
name="line.1430"></a>
-<span class="sourceLineNo">1431</span>        
.setFamily(HConstants.CATALOG_FAMILY)<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>        
.setQualifier(getRegionStateColumn())<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span>        
.setTimestamp(put.getTimestamp())<a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>        .setType(Cell.Type.Put)<a 
name="line.1434"></a>
-<span class="sourceLineNo">1435</span>        
.setValue(Bytes.toBytes(state.name()))<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>        .build());<a 
name="line.1436"></a>
-<span class="sourceLineNo">1437</span>  }<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span><a name="line.1438"></a>
-<span class="sourceLineNo">1439</span>  /**<a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>   * Adds daughter region infos to 
hbase:meta row for the specified region. Note that this does not<a 
name="line.1440"></a>
-<span class="sourceLineNo">1441</span>   * add its daughter's as different 
rows, but adds information about the daughters in the same row<a 
name="line.1441"></a>
-<span class="sourceLineNo">1442</span>   * as the parent. Use<a 
name="line.1442"></a>
-<span class="sourceLineNo">1443</span>   * {@link #splitRegion(Connection, 
RegionInfo, long, RegionInfo, RegionInfo, ServerName, int)}<a 
name="line.1443"></a>
-<span class="sourceLineNo">1444</span>   * if you want to do that.<a 
name="line.1444"></a>
-<span class="sourceLineNo">1445</span>   * @param connection connection we're 
using<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>   * @param regionInfo RegionInfo of 
parent region<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>   * @param splitA first split daughter 
of the parent regionInfo<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>   * @param splitB second split daughter 
of the parent regionInfo<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>   * @throws IOException if problem 
connecting or updating meta<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>   */<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>  public static void 
addSplitsToParent(Connection connection, RegionInfo regionInfo,<a 
name="line.1451"></a>
-<span class="sourceLineNo">1452</span>      RegionInfo splitA, RegionInfo 
splitB) throws IOException {<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>    Table meta = 
getMetaHTable(connection);<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>    try {<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>      Put put = 
makePutFromRegionInfo(regionInfo, EnvironmentEdgeManager.currentTime());<a 
name="line.1455"></a>
-<span class="sourceLineNo">1456</span>      addDaughtersToPut(put, splitA, 
splitB);<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>      meta.put(put);<a 
name="line.1457"></a>
-<span class="sourceLineNo">1458</span>      debugLogMutation(put);<a 
name="line.1458"></a>
-<span class="sourceLineNo">1459</span>      LOG.debug("Added region {}", 
regionInfo.getRegionNameAsString());<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>    } finally {<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span>      meta.close();<a 
name="line.1461"></a>
-<span class="sourceLineNo">1462</span>    }<a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>  }<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span><a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>  /**<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>   * Adds a (single) hbase:meta row for 
the specified new region and its daughters. Note that this<a 
name="line.1466"></a>
-<span class="sourceLineNo">1467</span>   * does not add its daughter's as 
different rows, but adds information about the daughters<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>   * in the same row as the parent. 
Use<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>   * {@link #splitRegion(Connection, 
RegionInfo, long, RegionInfo, RegionInfo, ServerName, int)}<a 
name="line.1469"></a>
-<span class="sourceLineNo">1470</span>   * if you want to do that.<a 
name="line.1470"></a>
-<span class="sourceLineNo">1471</span>   * @param connection connection we're 
using<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>   * @param regionInfo region 
information<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>   * @throws IOException if problem 
connecting or updating meta<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>   */<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>  @VisibleForTesting<a 
name="line.1475"></a>
-<span class="sourceLineNo">1476</span>  public static void 
addRegionToMeta(Connection connection, RegionInfo regionInfo)<a 
name="line.1476"></a>
-<span class="sourceLineNo">1477</span>      throws IOException {<a 
name="line.1477"></a>
-<span class="sourceLineNo">1478</span>    addRegionsToMeta(connection, 
Collections.singletonList(regionInfo), 1);<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>  }<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span><a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>  /**<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>   * Adds a hbase:meta row for each of 
the specified new regions. Initial state for new regions<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>   * is CLOSED.<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>   * @param connection connection we're 
using<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>   * @param regionInfos region 
information list<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>   * @throws IOException if problem 
connecting or updating meta<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>   */<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>  public static void 
addRegionsToMeta(Connection connection, List&lt;RegionInfo&gt; regionInfos,<a 
name="line.1488"></a>
-<span class="sourceLineNo">1489</span>      int regionReplication) throws 
IOException {<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>    addRegionsToMeta(connection, 
regionInfos, regionReplication,<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>      
EnvironmentEdgeManager.currentTime());<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 hbase:meta row for each of 
the specified new regions. Initial state for new regions<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>   * is CLOSED.<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>   * @param connection connection we're 
using<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>   * @param regionInfos region 
information list<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>   * @param regionReplication<a 
name="line.1499"></a>
-<span class="sourceLineNo">1500</span>   * @param ts desired timestamp<a 
name="line.1500"></a>
-<span class="sourceLineNo">1501</span>   * @throws IOException if problem 
connecting or updating meta<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>   */<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>  private static void 
addRegionsToMeta(Connection connection, List&lt;RegionInfo&gt; regionInfos,<a 
name="line.1503"></a>
-<span class="sourceLineNo">1504</span>      int regionReplication, long ts) 
throws IOException {<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>    List&lt;Put&gt; puts = new 
ArrayList&lt;&gt;();<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>    for (RegionInfo regionInfo : 
regionInfos) {<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>      if 
(RegionReplicaUtil.isDefaultReplica(regionInfo)) {<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>        Put put = 
makePutFromRegionInfo(regionInfo, ts);<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>        // New regions are added with 
initial state of CLOSED.<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>        addRegionStateToPut(put, 
RegionState.State.CLOSED);<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>        // Add empty locations for 
region replicas so that number of replicas can be cached<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>        // whenever the primary region 
is looked up from meta<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>        for (int i = 1; i &lt; 
regionReplication; i++) {<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>          addEmptyLocation(put, i);<a 
name="line.1514"></a>
-<span class="sourceLineNo">1515</span>        }<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>        puts.add(put);<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>    putsToMetaTable(connection, puts);<a 
name="line.1519"></a>
-<span class="sourceLineNo">1520</span>    LOG.info("Added {} regions to 
meta.", puts.size());<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>  }<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span><a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>  /**<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>   * Merge the two regions into one in 
an atomic operation. Deletes the two merging regions in<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>   * hbase:meta and adds the merged 
region with the information of two merging regions.<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>   * @param connection connection we're 
using<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>   * @param mergedRegion the merged 
region<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>   * @param regionA merge parent region 
A<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>   * @param regionAOpenSeqNum the next 
open sequence id for region A, used by serial replication. -1<a 
name="line.1529"></a>
-<span class="sourceLineNo">1530</span>   *          if not necessary.<a 
name="line.1530"></a>
-<span class="sourceLineNo">1531</span>   * @param regionB merge parent region 
B<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>   * @param regionBOpenSeqNum the next 
open sequence id for region B, used by serial replication. -1<a 
name="line.1532"></a>
-<span class="sourceLineNo">1533</span>   *          if not necessary.<a 
name="line.1533"></a>
-<span class="sourceLineNo">1534</span>   * @param sn the location of the 
region<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>   */<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>  public static void 
mergeRegions(Connection connection, RegionInfo mergedRegion,<a 
name="line.1536"></a>
-<span class="sourceLineNo">1537</span>      RegionInfo regionA, long 
regionAOpenSeqNum, RegionInfo regionB, long regionBOpenSeqNum,<a 
name="line.1537"></a>
-<span class="sourceLineNo">1538</span>      ServerName sn, int 
regionReplication) throws IOException {<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>    try (Table meta = 
getMetaHTable(connection)) {<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>      long time = 
EnvironmentEdgeManager.currentTime();<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>      List&lt;Mutation&gt; mutations = 
new ArrayList&lt;&gt;();<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span><a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>      List&lt;RegionInfo&gt; 
replicationParents = new ArrayList&lt;&gt;(2);<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>      // Deletes for merging regions<a 
name="line.1544"></a>
-<span class="sourceLineNo">1545</span>      
mutations.add(makeDeleteFromRegionInfo(regionA, time));<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span>      if (regionAOpenSeqNum &gt; 0) {<a 
name="line.1546"></a>
-<span class="sourceLineNo">1547</span>        
mutations.add(makePutForReplicationBarrier(regionA, regionAOpenSeqNum, 
time));<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>        
replicationParents.add(regionA);<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>      }<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>      
mutations.add(makeDeleteFromRegionInfo(regionB, time));<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>      if (regionBOpenSeqNum &gt; 0) {<a 
name="line.1551"></a>
-<span class="sourceLineNo">1552</span>        
mutations.add(makePutForReplicationBarrier(regionB, regionBOpenSeqNum, 
time));<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>        
replicationParents.add(regionB);<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>      }<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span><a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>      // Put for parent<a 
name="line.1556"></a>
-<span class="sourceLineNo">1557</span>      Put putOfMerged = 
makePutFromRegionInfo(mergedRegion, time);<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>      
putOfMerged.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a 
name="line.1558"></a>
-<span class="sourceLineNo">1559</span>              
.setRow(putOfMerged.getRow())<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>              
.setFamily(HConstants.CATALOG_FAMILY)<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>              
.setQualifier(HConstants.MERGEA_QUALIFIER)<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>              
.setTimestamp(putOfMerged.getTimestamp())<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>              .setType(Type.Put)<a 
name="line.1563"></a>
-<span class="sourceLineNo">1564</span>              
.setValue(RegionInfo.toByteArray(regionA))<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>              .build())<a 
name="line.1565"></a>
-<span class="sourceLineNo">1566</span>          
.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a 
name="line.1566"></a>
+<span class="sourceLineNo">1349</span>    if (ps.isEmpty()) {<a 
name="line.1349"></a>
+<span class="sourceLineNo">1350</span>      return;<a name="line.1350"></a>
+<span class="sourceLineNo">1351</span>    }<a name="line.1351"></a>
+<span class="sourceLineNo">1352</span>    try (Table t = 
getMetaHTable(connection)) {<a name="line.1352"></a>
+<span class="sourceLineNo">1353</span>      debugLogMutations(ps);<a 
name="line.1353"></a>
+<span class="sourceLineNo">1354</span>      // the implementation for putting 
a single Put is much simpler so here we do a check first.<a 
name="line.1354"></a>
+<span class="sourceLineNo">1355</span>      if (ps.size() == 1) {<a 
name="line.1355"></a>
+<span class="sourceLineNo">1356</span>        t.put(ps.get(0));<a 
name="line.1356"></a>
+<span class="sourceLineNo">1357</span>      } else {<a name="line.1357"></a>
+<span class="sourceLineNo">1358</span>        t.put(ps);<a 
name="line.1358"></a>
+<span class="sourceLineNo">1359</span>      }<a name="line.1359"></a>
+<span class="sourceLineNo">1360</span>    }<a name="line.1360"></a>
+<span class="sourceLineNo">1361</span>  }<a name="line.1361"></a>
+<span class="sourceLineNo">1362</span><a name="line.1362"></a>
+<span class="sourceLineNo">1363</span>  /**<a name="line.1363"></a>
+<span class="sourceLineNo">1364</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.1364"></a>
+<span class="sourceLineNo">1365</span>   * @param connection connection we're 
using<a name="line.1365"></a>
+<span class="sourceLineNo">1366</span>   * @param d Delete to add to 
hbase:meta<a name="line.1366"></a>
+<span class="sourceLineNo">1367</span>   */<a name="line.1367"></a>
+<span class="sourceLineNo">1368</span>  private static void 
deleteFromMetaTable(final Connection connection, final Delete d)<a 
name="line.1368"></a>
+<span class="sourceLineNo">1369</span>      throws IOException {<a 
name="line.1369"></a>
+<span class="sourceLineNo">1370</span>    List&lt;Delete&gt; dels = new 
ArrayList&lt;&gt;(1);<a name="line.1370"></a>
+<span class="sourceLineNo">1371</span>    dels.add(d);<a name="line.1371"></a>
+<span class="sourceLineNo">1372</span>    deleteFromMetaTable(connection, 
dels);<a name="line.1372"></a>
+<span class="sourceLineNo">1373</span>  }<a name="line.1373"></a>
+<span class="sourceLineNo">1374</span><a name="line.1374"></a>
+<span class="sourceLineNo">1375</span>  /**<a name="line.1375"></a>
+<span class="sourceLineNo">1376</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.1376"></a>
+<span class="sourceLineNo">1377</span>   * @param connection connection we're 
using<a name="line.1377"></a>
+<span class="sourceLineNo">1378</span>   * @param deletes Deletes to add to 
hbase:meta  This list should support #remove.<a name="line.1378"></a>
+<span class="sourceLineNo">1379</span>   */<a name="line.1379"></a>
+<span class="sourceLineNo">1380</span>  private static void 
deleteFromMetaTable(final Connection connection, final List&lt;Delete&gt; 
deletes)<a name="line.1380"></a>
+<span class="sourceLineNo">1381</span>      throws IOException {<a 
name="line.1381"></a>
+<span class="sourceLineNo">1382</span>    try (Table t = 
getMetaHTable(connection)) {<a name="line.1382"></a>
+<span class="sourceLineNo">1383</span>      debugLogMutations(deletes);<a 
name="line.1383"></a>
+<span class="sourceLineNo">1384</span>      t.delete(deletes);<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>  /**<a name="line.1388"></a>
+<span class="sourceLineNo">1389</span>   * Deletes some replica columns 
corresponding to replicas for the passed rows<a name="line.1389"></a>
+<span class="sourceLineNo">1390</span>   * @param metaRows rows in 
hbase:meta<a name="line.1390"></a>
+<span class="sourceLineNo">1391</span>   * @param replicaIndexToDeleteFrom the 
replica ID we would start deleting from<a name="line.1391"></a>
+<span class="sourceLineNo">1392</span>   * @param numReplicasToRemove how many 
replicas to remove<a name="line.1392"></a>
+<span class="sourceLineNo">1393</span>   * @param connection connection we're 
using to access meta table<a name="line.1393"></a>
+<span class="sourceLineNo">1394</span>   */<a name="line.1394"></a>
+<span class="sourceLineNo">1395</span>  public static void 
removeRegionReplicasFromMeta(Set&lt;byte[]&gt; metaRows,<a name="line.1395"></a>
+<span class="sourceLineNo">1396</span>    int replicaIndexToDeleteFrom, int 
numReplicasToRemove, Connection connection)<a name="line.1396"></a>
+<span class="sourceLineNo">1397</span>      throws IOException {<a 
name="line.1397"></a>
+<span class="sourceLineNo">1398</span>    int absoluteIndex = 
replicaIndexToDeleteFrom + numReplicasToRemove;<a name="line.1398"></a>
+<span class="sourceLineNo">1399</span>    for (byte[] row : metaRows) {<a 
name="line.1399"></a>
+<span class="sourceLineNo">1400</span>      long now = 
EnvironmentEdgeManager.currentTime();<a name="line.1400"></a>
+<span class="sourceLineNo">1401</span>      Delete deleteReplicaLocations = 
new Delete(row);<a name="line.1401"></a>
+<span class="sourceLineNo">1402</span>      for (int i = 
replicaIndexToDeleteFrom; i &lt; absoluteIndex; i++) {<a name="line.1402"></a>
+<span class="sourceLineNo">1403</span>        
deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1403"></a>
+<span class="sourceLineNo">1404</span>          getServerColumn(i), now);<a 
name="line.1404"></a>
+<span class="sourceLineNo">1405</span>        
deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1405"></a>
+<span class="sourceLineNo">1406</span>          getSeqNumColumn(i), now);<a 
name="line.1406"></a>
+<span class="sourceLineNo">1407</span>        
deleteReplicaLocations.addColumns(getCatalogFamily(),<a name="line.1407"></a>
+<span class="sourceLineNo">1408</span>          getStartCodeColumn(i), now);<a 
name="line.1408"></a>
+<span class="sourceLineNo">1409</span>      }<a name="line.1409"></a>
+<span class="sourceLineNo">1410</span>      deleteFromMetaTable(connection, 
deleteReplicaLocations);<a name="line.1410"></a>
+<span class="sourceLineNo">1411</span>    }<a name="line.1411"></a>
+<span class="sourceLineNo">1412</span>  }<a name="line.1412"></a>
+<span class="sourceLineNo">1413</span><a name="line.1413"></a>
+<span class="sourceLineNo">1414</span>  /**<a name="line.1414"></a>
+<span class="sourceLineNo">1415</span>   * Execute the passed 
&lt;code&gt;mutations&lt;/code&gt; against &lt;code&gt;hbase:meta&lt;/code&gt; 
table.<a name="line.1415"></a>
+<span class="sourceLineNo">1416</span>   * @param connection connection we're 
using<a name="line.1416"></a>
+<span class="sourceLineNo">1417</span>   * @param mutations Puts and Deletes 
to execute on hbase:meta<a name="line.1417"></a>
+<span class="sourceLineNo">1418</span>   * @throws IOException<a 
name="line.1418"></a>
+<span class="sourceLineNo">1419</span>   */<a name="line.1419"></a>
+<span class="sourceLineNo">1420</span>  public static void 
mutateMetaTable(final Connection connection,<a name="line.1420"></a>
+<span class="sourceLineNo">1421</span>                                     
final List&lt;Mutation&gt; mutations)<a name="line.1421"></a>
+<span class="sourceLineNo">1422</span>    throws IOException {<a 
name="line.1422"></a>
+<span class="sourceLineNo">1423</span>    Table t = 
getMetaHTable(connection);<a name="line.1423"></a>
+<span class="sourceLineNo">1424</span>    try {<a name="line.1424"></a>
+<span class="sourceLineNo">1425</span>      debugLogMutations(mutations);<a 
name="line.1425"></a>
+<span class="sourceLineNo">1426</span>      t.batch(mutations, null);<a 
name="line.1426"></a>
+<span class="sourceLineNo">1427</span>    } catch (InterruptedException e) {<a 
name="line.1427"></a>
+<span class="sourceLineNo">1428</span>      InterruptedIOException ie = new 
InterruptedIOException(e.getMessage());<a name="line.1428"></a>
+<span class="sourceLineNo">1429</span>      ie.initCause(e);<a 
name="line.1429"></a>
+<span class="sourceLineNo">1430</span>      throw ie;<a name="line.1430"></a>
+<span class="sourceLineNo">1431</span>    } finally {<a name="line.1431"></a>
+<span class="sourceLineNo">1432</span>      t.close();<a name="line.1432"></a>
+<span class="sourceLineNo">1433</span>    }<a name="line.1433"></a>
+<span class="sourceLineNo">1434</span>  }<a name="line.1434"></a>
+<span class="sourceLineNo">1435</span><a name="line.1435"></a>
+<span class="sourceLineNo">1436</span>  private static void 
addRegionStateToPut(Put put, RegionState.State state) throws IOException {<a 
name="line.1436"></a>
+<span class="sourceLineNo">1437</span>    
put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a 
name="line.1437"></a>
+<span class="sourceLineNo">1438</span>        .setRow(put.getRow())<a 
name="line.1438"></a>
+<span class="sourceLineNo">1439</span>        
.setFamily(HConstants.CATALOG_FAMILY)<a name="line.1439"></a>
+<span class="sourceLineNo">1440</span>        
.setQualifier(getRegionStateColumn())<a name="line.1440"></a>
+<span class="sourceLineNo">1441</span>        
.setTimestamp(put.getTimestamp())<a name="line.1441"></a>
+<span class="sourceLineNo">1442</span>        .setType(Cell.Type.Put)<a 
name="line.1442"></a>
+<span class="sourceLineNo">1443</span>        
.setValue(Bytes.toBytes(state.name()))<a name="line.1443"></a>
+<span class="sourceLineNo">1444</span>        .build());<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>  /**<a name="line.1447"></a>
+<span class="sourceLineNo">1448</span>   * Adds daughter region infos to 
hbase:meta row for the specified region. Note that this does not<a 
name="line.1448"></a>
+<span class="sourceLineNo">1449</span>   * add its daughter's as different 
rows, but adds information about the daughters in the same row<a 
name="line.1449"></a>
+<span class="sourceLineNo">1450</span>   * as the parent. Use<a 
name="line.1450"></a>
+<span class="sourceLineNo">1451</span>   * {@link #splitRegion(Connection, 
RegionInfo, long, RegionInfo, RegionInfo, ServerName, int)}<a 
name="line.1451"></a>
+<span class="sourceLineNo">1452</span>   * if you want to do that.<a 
name="line.1452"></a>
+<span class="sourceLineNo">1453</span>   * @param connection connection we're 
using<a name="line.1453"></a>
+<span class="sourceLineNo">1454</span>   * @param regionInfo RegionInfo of 
parent region<a name="line.1454"></a>
+<span class="sourceLineNo">1455</span>   * @param splitA first split daughter 
of the parent regionInfo<a name="line.1455"></a>
+<span class="sourceLineNo">1456</span>   * @param splitB second split daughter 
of the parent regionInfo<a name="line.1456"></a>
+<span class="sourceLineNo">1457</span>   * @throws IOException if problem 
connecting or updating meta<a name="line.1457"></a>
+<span class="sourceLineNo">1458</span>   */<a name="line.1458"></a>
+<span class="sourceLineNo">1459</span>  public static void 
addSplitsToParent(Connection connection, RegionInfo regionInfo,<a 
name="line.1459"></a>
+<span class="sourceLineNo">1460</span>      RegionInfo splitA, RegionInfo 
splitB) throws IOException {<a name="line.1460"></a>
+<span class="sourceLineNo">1461</span>    Table meta = 
getMetaHTable(connection);<a name="line.1461"></a>
+<span class="sourceLineNo">1462</span>    try {<a name="line.1462"></a>
+<span class="sourceLineNo">1463</span>      Put put = 
makePutFromRegionInfo(regionInfo, EnvironmentEdgeManager.currentTime());<a 
name="line.1463"></a>
+<span class="sourceLineNo">1464</span>      addDaughtersToPut(put, splitA, 
splitB);<a name="line.1464"></a>
+<span class="sourceLineNo">1465</span>      meta.put(put);<a 
name="line.1465"></a>
+<span class="sourceLineNo">1466</span>      debugLogMutation(put);<a 
name="line.1466"></a>
+<span class="sourceLineNo">1467</span>      LOG.debug("Added region {}", 
regionInfo.getRegionNameAsString());<a name="line.1467"></a>
+<span class="sourceLineNo">1468</span>    } finally {<a name="line.1468"></a>
+<span class="sourceLineNo">1469</span>      meta.close();<a 
name="line.1469"></a>
+<span class="sourceLineNo">1470</span>    }<a name="line.1470"></a>
+<span class="sourceLineNo">1471</span>  }<a name="line.1471"></a>
+<span class="sourceLineNo">1472</span><a name="line.1472"></a>
+<span class="sourceLineNo">1473</span>  /**<a name="line.1473"></a>
+<span class="sourceLineNo">1474</span>   * Adds a (single) hbase:meta row for 
the specified new region and its daughters. Note that this<a 
name="line.1474"></a>
+<span class="sourceLineNo">1475</span>   * does not add its daughter's as 
different rows, but adds information about the daughters<a name="line.1475"></a>
+<span class="sourceLineNo">1476</span>   * in the same row as the parent. 
Use<a name="line.1476"></a>
+<span class="sourceLineNo">1477</span>   * {@link #splitRegion(Connection, 
RegionInfo, long, RegionInfo, RegionInfo, ServerName, int)}<a 
name="line.1477"></a>
+<span class="sourceLineNo">1478</span>   * if you want to do that.<a 
name="line.1478"></a>
+<span class="sourceLineNo">1479</span>   * @param connection connection we're 
using<a name="line.1479"></a>
+<span class="sourceLineNo">1480</span>   * @param regionInfo region 
information<a name="line.1480"></a>
+<span class="sourceLineNo">1481</span>   * @throws IOException if problem 
connecting or updating meta<a name="line.1481"></a>
+<span class="sourceLineNo">1482</span>   */<a name="line.1482"></a>
+<span class="sourceLineNo">1483</span>  @VisibleForTesting<a 
name="line.1483"></a>
+<span class="sourceLineNo">1484</span>  public static void 
addRegionToMeta(Connection connection, RegionInfo regionInfo)<a 
name="line.1484"></a>
+<span class="sourceLineNo">1485</span>      throws IOException {<a 
name="line.1485"></a>
+<span class="sourceLineNo">1486</span>    addRegionsToMeta(connection, 
Collections.singletonList(regionInfo), 1);<a name="line.1486"></a>
+<span class="sourceLineNo">1487</span>  }<a name="line.1487"></a>
+<span class="sourceLineNo">1488</span><a name="line.1488"></a>
+<span class="sourceLineNo">1489</span>  /**<a name="line.1489"></a>
+<span class="sourceLineNo">1490</span>   * Adds a hbase:meta row for each of 
the specified new regions. Initial state for new regions<a name="line.1490"></a>
+<span class="sourceLineNo">1491</span>   * is CLOSED.<a name="line.1491"></a>
+<span class="sourceLineNo">1492</span>   * @param connection connection we're 
using<a name="line.1492"></a>
+<span class="sourceLineNo">1493</span>   * @param regionInfos region 
information list<a name="line.1493"></a>
+<span class="sourceLineNo">1494</span>   * @throws IOException if problem 
connecting or updating meta<a name="line.1494"></a>
+<span class="sourceLineNo">1495</span>   */<a name="line.1495"></a>
+<span class="sourceLineNo">1496</span>  public static void 
addRegionsToMeta(Connection connection, List&lt;RegionInfo&gt; regionInfos,<a 
name="line.1496"></a>
+<span class="sourceLineNo">1497</span>      int regionReplication) throws 
IOException {<a name="line.1497"></a>
+<span class="sourceLineNo">1498</span>    addRegionsToMeta(connection, 
regionInfos, regionReplication,<a name="line.1498"></a>
+<span class="sourceLineNo">1499</span>      
EnvironmentEdgeManager.currentTime());<a name="line.1499"></a>
+<span class="sourceLineNo">1500</span>  }<a name="line.1500"></a>
+<span class="sourceLineNo">1501</span><a name="line.1501"></a>
+<span class="sourceLineNo">1502</span>  /**<a name="line.1502"></a>
+<span class="sourceLineNo">1503</span>   * Adds a hbase:meta row for each of 
the specified new regions. Initial state for new regions<a name="line.1503"></a>
+<span class="sourceLineNo">1504</span>   * is CLOSED.<a name="line.1504"></a>
+<span class="sourceLineNo">1505</span>   * @param connection connection we're 
using<a name="line.1505"></a>
+<span class="sourceLineNo">1506</span>   * @param regionInfos region 
information list<a name="line.1506"></a>
+<span class="sourceLineNo">1507</span>   * @param regionReplication<a 
name="line.1507"></a>
+<span class="sourceLineNo">1508</span>   * @param ts desired timestamp<a 
name="line.1508"></a>
+<span class="sourceLineNo">1509</span>   * @throws IOException if problem 
connecting or updating meta<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span>   */<a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>  private static void 
addRegionsToMeta(Connection connection, List&lt;RegionInfo&gt; regionInfos,<a 
name="line.1511"></a>
+<span class="sourceLineNo">1512</span>      int regionReplication, long ts) 
throws IOException {<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>    List&lt;Put&gt; puts = new 
ArrayList&lt;&gt;();<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>    for (RegionInfo regionInfo : 
regionInfos) {<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>      if 
(RegionReplicaUtil.isDefaultReplica(regionInfo)) {<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span>        Put put = 
makePutFromRegionInfo(regionInfo, ts);<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span>        // New regions are added with 
initial state of CLOSED.<a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>        addRegionStateToPut(put, 
RegionState.State.CLOSED);<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>        // Add empty locations for 
region replicas so that number of replicas can be cached<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>        // whenever the primary region 
is looked up from meta<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>        for (int i = 1; i &lt; 
regionReplication; i++) {<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>          addEmptyLocation(put, i);<a 
name="line.1522"></a>
+<span class="sourceLineNo">1523</span>        }<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>        puts.add(put);<a 
name="line.1524"></a>
+<span class="sourceLineNo">1525</span>      }<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>    }<a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>    putsToMetaTable(connection, puts);<a 
name="line.1527"></a>
+<span class="sourceLineNo">1528</span>    LOG.info("Added {} regions to 
meta.", puts.size());<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>  }<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span><a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>  /**<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>   * Merge the two regions into one in 
an atomic operation. Deletes the two merging regions in<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>   * hbase:meta and adds the merged 
region with the information of two merging regions.<a name="line.1533"></a>
+<span class="sourceLineNo">1534</span>   * @param connection connection we're 
using<a name="line.1534"></a>
+<span class="sourceLineNo">1535</span>   * @param mergedRegion the merged 
region<a name="line.1535"></a>
+<span class="sourceLineNo">1536</span>   * @param regionA merge parent region 
A<a name="line.1536"></a>
+<span class="sourceLineNo">1537</span>   * @param regionAOpenSeqNum the next 
open sequence id for region A, used by serial replication. -1<a 
name="line.1537"></a>
+<span class="sourceLineNo">1538</span>   *          if not necessary.<a 
name="line.1538"></a>
+<span class="sourceLineNo">1539</span>   * @param regionB merge parent region 
B<a name="line.1539"></a>
+<span class="sourceLineNo">1540</span>   * @param regionBOpenSeqNum the next 
open sequence id for region B, used by serial replication. -1<a 
name="line.1540"></a>
+<span class="sourceLineNo">1541</span>   *          if not necessary.<a 
name="line.1541"></a>
+<span class="sourceLineNo">1542</span>   * @param sn the location of the 
region<a name="line.1542"></a>
+<span class="sourceLineNo">1543</span>   */<a name="line.1543"></a>
+<span class="sourceLineNo">1544</span>  public static void 
mergeRegions(Connection connection, RegionInfo mergedRegion,<a 
name="line.1544"></a>
+<span class="sourceLineNo">1545</span>      RegionInfo regionA, long 
regionAOpenSeqNum, RegionInfo regionB, long regionBOpenSeqNum,<a 
name="line.1545"></a>
+<span class="sourceLineNo">1546</span>      ServerName sn, int 
regionReplication) throws IOException {<a name="line.1546"></a>
+<span class="sourceLineNo">1547</span>    try (Table meta = 
getMetaHTable(connection)) {<a name="line.1547"></a>
+<span class="sourceLineNo">1548</span>      long time = 
EnvironmentEdgeManager.currentTime();<a name="line.1548"></a>
+<span class="sourceLineNo">1549</span>      List&lt;Mutation&gt; mutations = 
new ArrayList&lt;&gt;();<a name="line.1549"></a>
+<span class="sourceLineNo">1550</span><a name="line.1550"></a>
+<span class="sourceLineNo">1551</span>      List&lt;RegionInfo&gt; 
replicationParents = new ArrayList&lt;&gt;(2);<a name="line.1551"></a>
+<span class="sourceLineNo">1552</span>      // Deletes for merging regions<a 
name="line.1552"></a>
+<span class="sourceLineNo">1553</span>      
mutations.add(makeDeleteFromRegionInfo(regionA, time));<a name="line.1553"></a>
+<span class="sourceLineNo">1554</span>      if (regionAOpenSeqNum &gt; 0) {<a 
name="line.1554"></a>
+<span class="sourceLineNo">1555</span>        
mutations.add(makePutForReplicationBarrier(regionA, regionAOpenSeqNum, 
time));<a name="line.1555"></a>
+<span class="sourceLineNo">1556</span>        
replicationParents.add(regionA);<a name="line.1556"></a>
+<span class="sourceLineNo">1557</span>      }<a name="line.1557"></a>
+<span class="sourceLineNo">1558</span>      
mutations.add(makeDeleteFromRegionInfo(regionB, time));<a name="line.1558"></a>
+<span class="sourceLineNo">1559</span>      if (regionBOpenSeqNum &gt; 0) {<a 
name="line.1559"></a>
+<span class="sourceLineNo">1560</span>        
mutations.add(makePutForReplicationBarrier(regionB, regionBOpenSeqNum, 
time));<a name="line.1560"></a>
+<span class="sourceLineNo">1561</span>        
replicationParents.add(regionB);<a name="line.1561"></a>
+<span class="sourceLineNo">1562</span>      }<a name="line.1562"></a>
+<span class="sourceLineNo">1563</span><a name="line.1563"></a>
+<span class="sourceLineNo">1564</span>      // Put for parent<a 
name="line.1564"></a>
+<span class="sourceLineNo">1565</span>      Put putOfMerged = 
makePutFromRegionInfo(mergedRegion, time);<a name="line.1565"></a>
+<span class="sourceLineNo">1566</span>      
putOfMerged.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a 
name="line.1566"></a>
 <span class="sourceLineNo">1567</span>              
.setRow(putOfMerged.getRow())<a name="line.1567"></a>
 <span class="sourceLineNo">1568</span>              
.setFamily(HConstants.CATALOG_FAMILY)<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span>              
.setQualifier(HConstants.MERGEB_QUALIFIER)<a name="line.1569"></a>
+<span class="sourceLineNo">1569</span>              
.setQualifier(HConstants.MERGEA_QUALIFIER)<a name="line.1569"></a>
 <span class="sourceLineNo">1570</span>              
.setTimestamp(putOfMerged.getTimestamp())<a name="line.1570"></a>
 <span class="sourceLineNo">1571</span>              .setType(Type.Put)<a 
name="line.1571"></a>
-<span class="sourceLineNo">1572</span>              
.setValue(RegionInfo.toByteArray(regionB))<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>              .build());<a 
name="line.1573"></a>
-<span class="sourceLineNo">1574</span>      // Set initial state to CLOSED<a 
name="line.1574"></a>
-<span class="sourceLineNo">1575</span>      // NOTE: If initial state is not 
set to CLOSED then merged region gets added with the<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>      // default OFFLINE state. If 
Master gets restarted after this step, start up sequence of<a 
name="line.1576"></a>
-<span class="sourceLineNo">1577</span>      // master tries to assign this 
offline region. This is followed by re-assignments of the<a 
name="line.1577"></a>
-<span class="sourceLineNo">1578</span>      // merged region from resumed 
{@link MergeTableRegionsProcedure}<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>      addRegionStateToPut(putOfMerged, 
RegionState.State.CLOSED);<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>      mutations.add(putOfMerged);<a 
name="line.1580"></a>
-<span class="sourceLineNo">1581</span>      // The merged is a new region, 
openSeqNum = 1 is fine. ServerName may be null<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>      // if crash after merge happened 
but before we got to here.. means in-memory<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>      // locations of offlined merged, 
now-closed, regions is lost. Should be ok. We<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>      // assign the merged region 
later.<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>      if (sn != null) {<a 
name="line.1585"></a>
-<span class="sourceLineNo">1586</span>        addLocation(putOfMerged, sn, 1, 
mergedRegion.getReplicaId());<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>      }<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span><a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>      // Add empty locations for region 
replicas of the merged region so that number of replicas can<a 
name="line.1589"></a>
-<span class="sourceLineNo">1590</span>      // be cached whenever the primary 
region is looked up from meta<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>      for (int i = 1; i &lt; 
regionReplication; i++) {<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>        addEmptyLocation(putOfMerged, 
i);<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>      }<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>      // add parent reference for serial 
replication<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>      if (!replicationParents.isEmpty()) 
{<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>        
addReplicationParent(putOfMerged, replicationParents);<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>      }<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>      byte[] tableRow = 
Bytes.toBytes(mergedRegion.getRegionNameAsString() + HConstants.DELIMITER);<a 
name="line.1598"></a>
-<span class="sourceLineNo">1599</span>      multiMutate(connection, meta, 
tableRow, mutations);<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>    }<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span>  }<a name="line.1601"></a>
-<span class="sourceLineNo">1602</span><a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>  /**<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>   * Splits the region into two in an 
atomic operation. Offlines the parent region with the<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>   * information that it is split into 
two, and also adds the daughter regions. Does not add the<a 
name="line.1605"></a>
-<span class="sourceLineNo">1606</span>   * location information to the 
daughter regions since they are not open yet.<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>   * @param connection connection we're 
using<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>   * @param parent the parent region 
which is split<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>   * @param parentOpenSeqNum the next 
open sequence id for parent region, used by serial<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>   *          replication. -1 if not 
necessary.<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>   * @param splitA Split daughter region 
A<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>   * @param splitB Split daughter region 
B<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>   * @param sn the location of the 
region<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>   */<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>  public static void 
splitRegion(Connection connection, RegionInfo parent, long parentOpenSeqNum,<a 
name="line.1615"></a>
-<span class="sourceLineNo">1616</span>      RegionInfo splitA, RegionInfo 
splitB, ServerName sn, int regionReplication)<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>      throws IOException {<a 
name="line.1617"></a>
-<span class="sourceLineNo">1618</span>    try (Table meta = 
getMetaHTable(connection)) {<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>      long time = 
EnvironmentEdgeManager.currentTime();<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>      // Put for parent<a 
name="line.1620"></a>
-<span class="sourceLineNo">1621</span>      Put putParent = 
makePutFromRegionInfo(RegionInfoBuilder.newBuilder(parent)<a 
name="line.1621"></a>
-<span class="sourceLineNo">1622</span>                        
.setOffline(true)<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>                        
.setSplit(true).build(), time);<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span>      addDaughtersToPut(putParent, 
splitA, splitB);<a name="line.1624"></a>
-<span class="sourceLineNo">1625</span><a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>      // Puts for daughters<a 
name="line.1626"></a>
-<span class="sourceLineNo">1627</span>      Put putA = 
makePutFromRegionInfo(splitA, time);<a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>      Put putB = 
makePutFromRegionInfo(splitB, time);<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>      if (parentOpenSeqNum &gt; 0) {<a 
name="line.1629"></a>
-<span class="sourceLineNo">1630</span>        addReplicationBarrier(putParent, 
parentOpenSeqNum);<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>        addReplicationParent(putA, 
Collections.singletonList(parent));<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span>        addReplicationParent(putB, 
Collections.singletonList(parent));<a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>      }<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>      // Set initial state to CLOSED<a 
name="line.1634"></a>
-<span class="sourceLineNo">1635</span>      // NOTE: If initial state is not 
set to CLOSED then daughter regions get added with the<a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>      // default OFFLINE state. If 
Master gets restarted after this step, start up sequence of<a 
name="line.1636"></a>
-<span class="sourceLineNo">1637</span>      // master tries to assign these 
offline regions. This is followed by re-assignments of the<a 
name="line.1637"></a>
-<span class="sourceLineNo">1638</span>      // daughter regions from resumed 
{@link SplitTableRegionProcedure}<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>      addRegionStateToPut(putA, 
RegionState.State.CLOSED);<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span>      addRegionStateToPut(putB, 
RegionState.State.CLOSED);<a name="line.1640"></a>
-<span class="sourceLineNo">1641</span><a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>      addSequenceNum(putA, 1, 
splitA.getReplicaId()); // new regions, openSeqNum = 1 is fine.<a 
name="line.1642"></a>
-<span class="sourceLineNo">1643</span>      addSequenceNum(putB, 1, 
splitB.getReplicaId());<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span><a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>      // Add empty locations for region 
replicas of daughters so that number of replicas can be<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>      // cached whenever the primary 
region is looked up from meta<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>      for (int i = 1; i &lt; 
regionReplication; i++) {<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span>        addEmptyLocation(putA, i);<a 
name="line.1648"></a>
-<span class="sourceLineNo">1649</span>        addEmptyLocation(putB, i);<a 
name="line.1649"></a>
-<span class="sourceLineNo">1650</span>      }<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span><a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>      byte[] tableRow = 
Bytes.toBytes(parent.getRegionNameAsString() + HConstants.DELIMITER);<a 
name="line.1652"></a>
-<span class="sourceLineNo">1653</span>      multiMutate(connection, meta, 
tableRow, putParent, putA, putB);<a name="line.1653"></a>
-<span class="sourceLineNo">1654</span>    }<a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>  }<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span><a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>  /**<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span>   * Update state of the table in 
meta.<a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>   * @param connection what we use for 
update<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>   * @param state new state<a 
name="line.1660"></a>
-<span class="sourceLineNo">1661</span>   */<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span>  private static void 
updateTableState(Connection connection, TableState state) throws IOException 
{<a name="line.1662"></a>
-<span class="sourceLineNo">1663</span>    Put put = 
makePutFromTableState(state, EnvironmentEdgeManager.currentTime());<a 
name="line.1663"></a>
-<span class="sourceLineNo">1664</span>    putToMetaTable(connection, put);<a 
name="line.1664"></a>
-<span class="sourceLineNo">1665</span>    LOG.info("Updated {} in hbase:meta", 
state);<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>  }<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span><a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>  /**<a name="line.1668"></a>
-<span class="sourceLineNo">1669</span>   * Construct PUT for given state<a 
name="line.1669"></a>
-<span class="sourceLineNo">1670</span>   * @param state new state<a 
name="line.1670"></a>
-<span class="sourceLineNo">1671</span>   */<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>  public static Put 
makePutFromTableState(TableState state, long ts) {<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span>    Put put = new 
Put(state.getTableName().getName(), ts);<a name="line.1673"></a>
-<span class="sourceLineNo">1674</span>    put.addColumn(getTableFamily(), 
getTableStateColumn(), state.convert().toByteArray());<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>    return put;<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span>  }<a name="line.1676"></a>
-<span class="sourceLineNo">1677</span><a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>  /**<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span>   * Remove state for table from meta<a 
name="line.1679"></a>
-<span class="sourceLineNo">1680</span>   * @param connection to use for 
deletion<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>   * @param table to delete state for<a 
name="line.1681"></a>
-<span class="sourceLineNo">1682</span>   */<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>  public static void 
deleteTableState(Connection connection, TableName table)<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span>      throws IOException {<a 
name="line.1684"></a>
-<span class="sourceLineNo">1685</span>    long time = 
EnvironmentEdgeManager.currentTime();<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>    Delete delete = new 
Delete(table.getName());<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span>    delete.addColumns(getTableFamily(), 
getTableStateColumn(), time);<a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>    deleteFromMetaTable(connection, 
delete);<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>    LOG.info("Deleted table " + table + 
" state from META");<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>  }<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span><a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>  private static void 
multiMutate(Connection connection, Table table, byte[] row,<a 
name="line.1692"></a>
-<span class="sourceLineNo">1693</span>      Mutation... mutations) throws 
IOException {<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span>    multiMutate(connection, table, row, 
Arrays.asList(mutations));<a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>  }<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span><a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>  /**<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>   * Performs an atomic multi-mutate 
operation against the given table.<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>   */<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>  private static void 
multiMutate(Connection connection, final Table table, byte[] row,<a 
name="line.1700"></a>
-<span class="sourceLineNo">1701</span>      final List&lt;Mutation&gt; 
mutations) throws IOException {<a name="line.1701"></a>
-<span class="sourceLineNo">1702</span>    debugLogMutations(mutations);<a 
name="line.1702"></a>
-<span class="sourceLineNo">1703</span>    // TODO: Need rollback!!!!<a 
name="line.1703"></a>
-<span class="sourceLineNo">1704</span>    // TODO: Need Retry!!!<a 
name="line.1704"></a>
-<span class="sourceLineNo">1705</span>    // TODO: What for a timeout? Default 
write timeout? GET FROM HTABLE?<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>    // TODO: Review when we come through 
with ProcedureV2.<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>    
RegionServerCallable&lt;MutateRowsResponse,<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>        
MultiRowMutationProtos.MultiRowMutationService.BlockingInterface&gt; callable 
=<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>        new 
RegionServerCallable&lt;MutateRowsResponse,<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>          
MultiRowMutationProtos.MultiRowMutationService.BlockingInterface&gt;(<a 
name="line.1710"></a>
-<span class="sourceLineNo">1711</span>              connection, 
table.getName(), row, null/*RpcController not used in this CPEP!*/) {<a 
name="line.1711"></a>
-<span class="sourceLineNo">1712</span>      @Override<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span>      protected MutateRowsResponse 
rpcCall() throws Exception {<a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>        final MutateRowsRequest.Builder 
builder = MutateRowsRequest.newBuilder();<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span>        for (Mutation mutation : 
mutations) {<a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>          if (mutation instanceof Put) 
{<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>            
builder.addMutationRequest(ProtobufUtil.toMutation(<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span>              
ClientProtos.MutationProto.MutationType.PUT, mutation));<a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>          } else if (mutation instanceof 
Delete) {<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>            
builder.addMutationRequest(ProtobufUtil.toMutation(<a name="line.1720"></a>
-<span class="sourceLineNo">1721</span>              
ClientProtos.MutationProto.MutationType.DELETE, mutation));<a 
name="line.1721"></a>
-<span class="sourceLineNo">1722</span>          } else {<a 
name="line.1722"></a>
-<span class="sourceLineNo">1723</span>            throw new 
DoNotRetryIOException("multi in MetaEditor doesn't support "<a 
name="line.1723"></a>
-<span class="sourceLineNo">1724</span>              + 
mutation.getClass().getName());<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>          }<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>        }<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span>        // The call to #prepare that ran 
before this invocation will have populated HRegionLocation.<a 
name="line.1727"></a>
-<span class="sourceLineNo">1728</span>        HRegionLocation hrl = 
getLocation();<a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>        RegionSpecifier region = 
ProtobufUtil.buildRegionSpecifier(<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>            
RegionSpecifierType.REGION_NAME, hrl.getRegion().getRegionName());<a 
name="line.1730"></a>
-<span class="sourceLineNo">1731</span>        builder.setRegion(region);<a 
name="line.1731"></a>
-<span class="sourceLineNo">1732</span>        // The rpcController here is 
awkward. The Coprocessor Endpoint wants an instance of a<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>        // com.google.protobuf but we 
are going over an rpc that is all shaded protobuf so it<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>        // wants a 
org.apache.h.h.shaded.com.google.protobuf.RpcController. Set up a factory<a 
name="line.1734"></a>
-<span class="sourceLineNo">1735</span>        // that makes 
com.google.protobuf.RpcController and then copy into it configs.<a 
name="line.1735"></a>
-<span class="sourceLineNo">1736</span>        return 
getStub().mutateRows(null, builder.build());<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>      }<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span><a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>      @Override<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>      // Called on the end of the 
super.prepare call. Set the stub.<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span>      protected void 
setStubByServiceName(ServerName serviceName/*Ignored*/) throws IOException {<a 
name="line.1741"></a>
-<span class="sourceLineNo">1742</span>        CoprocessorRpcChannel channel = 
table.coprocessorService(getRow());<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>        
setStub(MultiRowMutationProtos.MultiRowMutationService.newBlockingStub(channel));<a
 name="line.1743"></a>
-<span class="sourceLineNo">1744</span>      }<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>    };<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span>    int writeTimeout = 
connection.getConfiguration().getInt(HConstants.HBASE_RPC_WRITE_TIMEOUT_KEY,<a 
name="line.1746"></a>
-<span class="sourceLineNo">1747</span>        
connection.getConfiguration().getInt(HConstants.HBASE_RPC_TIMEOUT_KEY,<a 
name="line.1747"></a>
-<span class="sourceLineNo">1748</span>            
HConstants.DEFAULT_HBASE_RPC_TIMEOUT));<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>    // The region location should be 
cached in connection. Call prepare so this callable picks<a 
name="line.1749"></a>
-<span class="sourceLineNo">1750</span>    // up the region location (see 
super.prepare method).<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>    callable.prepare(false);<a 
name="line.1751"></a>
-<span class="sourceLineNo">1752</span>    callable.call(writeTimeout);<a 
name="line.1752"></a>
-<span class="sourceLineNo">1753</span>  }<a name="line.1753"></a>
-<span class="sourceLineNo">1754</span><a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>  /**<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>   * Updates the location of the 
specified region in hbase:meta to be the specified server hostname<a 
name="line.1756"></a>
-<span class="sourceLineNo">1757</span>   * and startcode.<a 
name="line.1757"></a>
-<span class="sourceLineNo">1758</span>   * &lt;p&gt;<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>   * Uses passed catalog tracker to get 
a connection to the server hosting hbase:meta and makes<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>   * edits to that region.<a 
name="line.1760"></a>
-<span class="sourceLineNo">1761</span>   * @param connection connection we're 
using<a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>   * @param regionInfo region to update 
location of<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>   * @param openSeqNum the latest 
sequence number obtained when the region was open<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>   * @param sn Server name<a 
name="line.1764"></a>
-<span class="sourceLineNo">1765</span>   * @param masterSystemTime wall clock 
time from master if passed in the open region RPC<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>   */<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>  @VisibleForTesting<a 
name="line.1767"></a>
-<span class="sourceLineNo">1768</span>  public static void 
updateRegionLocation(Connection connection, RegionInfo regionInfo,<a 
name="line.1768"></a>
-<span class="sourceLineNo">1769</span>      ServerName sn, long openSeqNum, 
long masterSystemTime) throws IOException {<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span>    updateLocation(connection, 
regionInfo, sn, openSeqNum, masterSystemTime);<a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>  }<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span><a name="line.1772"></a>
-<span class="sourceLineNo">1773</span>  /**<a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>   * Updates the location of the 
specified region to be the specified server.<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span>   * &lt;p&gt;<a name="line.1775"></a>
-<span class="sourceLineNo">1776</span>   * Connects to the specified server 
which should be hosting the specified catalog region name to<a 
name="line.1776"></a>
-<span class="sourceLineNo">1777</span>   * perform the edit.<a 
name="line.1777"></a>
-<span class="sourceLineNo">1778</span>   * @param connection connection we're 
using<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>   * @param regionInfo region to update 
location of<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>   * @param sn Server name<a 
name="line.1780"></a>
-<span class="sourceLineNo">1781</span>   * @param openSeqNum the latest 
sequence number obtained when the region was open<a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>   * @param masterSystemTime wall clock 
time from master if passed in the open region RPC<a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>   * @throws IOException In particular 
could throw {@link java.net.ConnectException} if the server<a 
name="line.1783"></a>
-<span class="sourceLineNo">1784</span>   *           is down on other end.<a 
name="line.1784"></a>
-<span class="sourceLineNo">1785</span>   */<a name="line.1785"></a>
-<span class="sourceLineNo">1786</span>  private static void 
updateLocation(Connection connection, RegionInfo regionInfo, ServerName sn,<a 
name="line.1786"></a>
-<span class="sourceLineNo">1787</span>      long openSeqNum, long 
masterSystemTime) throws IOException {<a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>    // region replicas are kept in the 
primary region's row<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>    Put put = new 
Put(getMetaKeyForRegion(regionInfo), masterSystemTime);<a name="line.1789"></a>
-<span class="sourceLineNo">1790</span>    addRegionInfo(put, regionInfo);<a 
name="line.1790"></a>
-<span class="sourceLineNo">1791</span>    addLocation(put, sn, openSeqNum, 
regionInfo.getReplicaId());<a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>    putToMetaTable(connection, put);<a 
name="line.1792"></a>
-<span class="sourceLineNo">1793</span>    LOG.info("Updated row {} with 
server=", regionInfo.getRegionNameAsString(), sn);<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span>  }<a name="line.1794"></a>
-<span class="sourceLineNo">1795</span><a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>  /**<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span>   * Deletes the specified region from 
META.<a name="line.1797"></a>
-<span class="sourceLineNo">1798</span>   * @param connection connection we're 
using<a name="line.1798"></a>
-<span class="sourceLineNo">1799</span>   * @param regionInfo region to be 
deleted from META<a name="line.1799"></a>
-<span class="sourceLineNo">1800</span>   * @throws IOException<a 
name="line.1800"></a>
-<span class="sourceLineNo">1801</span>   */<a name="line.1801"></a>
-<span class="sourceLineNo">1802</span>  public static void 
deleteRegion(Connection connection, RegionInfo regionInfo) throws IOException 
{<a name="line.1802"></a>
-<span class="sourceLineNo">1803</span>    long time = 
EnvironmentEdgeManager.currentTime();<a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>    Delete delete = new 
Delete(regionInfo.getRegionName());<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>    delete.addFamily(getCatalogFamily(), 
time);<a name="line.1805"></a>
-<span class="sourceLineNo">1806</span>    deleteFromMetaTable(connection, 
delete);<a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>    LOG.info("Deleted " + 
regionInfo.getRegionNameAsString());<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span>  }<a name="line.1808"></a>
-<span class="sourceLineNo">1809</span><a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>  /**<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span>   * Deletes the specified regions from 
META.<a name="line.1811"></a>
-<span class="sourceLineNo">1812</span>   * @param connection connection we're 
using<a name="line.1812"></a>
-<span class="sourceLineNo">1813</span>   * @param regionsInfo list of regions 
to be deleted from META<a name="line.1813"></a>
-<span class="sourceLineNo">1814</span>   */<a name="line.1814"></a>
-<span class="sourceLineNo">1815</span>  public static void 
deleteRegions(Connection connection, List&lt;RegionInfo&gt; regionsInfo)<a 
name="line.1815"></a>
-<span class="sourceLineNo">1816</span>      throws IOException {<a 
name="line.1816"></a>
-<span class="sourceLineNo">1817</span>    deleteRegions(connection, 
regionsInfo, EnvironmentEdgeManager.currentTime());<a name="line.1817"></a>
-<span class="sourceLineNo">1818</span>  }<a name="line.1818"></a>
-<span class="sourceLineNo">1819</span>  /**<a name="line.1819"></a>
-<span class="sourceLineNo">1820</span>   * Deletes the specified regions from 
META.<a name="line.1820"></a>
-<span class="sourceLineNo">1821</span>   * @param connection connection we're 
using<a name="line.1821"></a>
-<span class="sourceLineNo">1822</span>   * @param regionsInfo list of regions 
to be deleted from META<a name="line.1822"></a>
-<span class="sourceLineNo">1823</span>   */<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span>  public static void 
deleteRegions(Connection connection, List&lt;RegionInfo&gt; regionsInfo, long 
ts)<a name="line.1824"></a>
-<span class="sourceLineNo">1825</span>      throws IOException {<a 
name="line.1825"></a>
-<span class="sourceLineNo">1826</span>    List&lt;Delete&gt; deletes = new 
ArrayList&lt;&gt;(regionsInfo.size());<a name="line.1826"></a>
-<span class="sourceLineNo">1827</span>    for (RegionInfo hri : regionsInfo) 
{<a name="line.1827"></a>
-<span class="sourceLineNo">1828</span>      Delete e = new 
Delete(hri.getRegionName());<a name="line.1828"></a>
-<span class="sourceLineNo">1829</span>      e.addFamily(getCatalogFamily(), 
ts);<a name="line.1829"></a>
-<span class="sourceLineNo">1830</span>      deletes.add(e);<a 
name="line.1830"></a>
-<span class="sourceLineNo">1831</span>    }<a name="line.1831"></a>
-<span class="sourceLineNo">1832</span>    deleteFromMetaTable(connection, 
deletes);<a name="line.1832"></a>
-<span class="sourceLineNo">1833</span>    LOG.info("Deleted {} regions from 
META", regionsInfo.size());<a name="line.1833"></a>
-<span class="sourceLineNo">1834</span>    LOG.debug("Deleted regions: {}", 
regionsInfo);<a name="line.1834"></a>
-<span class="sourceLineNo">1835</span>  }<a name="line.1835"></a>
-<span class="sourceLineNo">1836</span><a name="line.1836"></a>
-<span class="sourceLineNo">1837</span>  /**<a name="line.1837"></a>
-<span class="sourceLineNo">1838</span>   * Overwrites the specified regions 
from hbase:meta. Deletes old rows for the given regions and<a 
name="line.1838"></a>
-<span class="sourceLineNo">1839</span>   * adds new ones. Regions added back 
have state CLOSED.<a name="line.1839"></a>
-<span class="sourceLineNo">1840</span>   * @param connection connection we're 
using<a name="line.1840"></a>
-<span class="sourceLineNo">1841</span>   * @param regionInfos list of regions 
to be added to META<a name="line.1841"></a>
-<span class="sourceLineNo">1842</span>   */<a name="line.1842"></a>
-<span class="sourceLineNo">1843</span>  public static void 
overwriteRegions(Connection connection,<a name="line.1843"></a>
-<span class="sourceLineNo">1844</span>      List&lt;RegionInfo&gt; 
regionInfos, int regionReplication) throws IOException {<a name="line.1844"></a>
-<span class="sourceLineNo">1845</span>    // use master time for delete marker 
and the Put<a name="line.1845"></a>
-<span class="sourceLineNo">1846</span>    long now = 
EnvironmentEdgeManager.currentTime();<a name="line.1846"></a>
-<span class="sourceLineNo">1847</span>    deleteRegions(connection, 
regionInfos, now);<a name="line.1847"></a>
-<span class="sourceLineNo">1848</span>    // Why sleep? This is the easiest 
way to ensure that the previous deletes does not<a name="line.1848"></a>
-<span class="sourceLineNo">1849</span>    // eclipse the following puts, that 
might happen in the same ts from the server.<a name="line.1849"></a>
-<span class="sourceLineNo">1850</span>    // See HBASE-9906, and HBASE-9879. 
Once either HBASE-9879, HBASE-8770 is fixed,<a name="line.1850"></a>
-<span class="sourceLineNo">1851</span>    // or HBASE-9905 is fixed and meta 
uses seqIds, we do not need the sleep.<a name="line.1851"></a>
-<span class="sourceLineNo">1852</span>    //<a name="line.1852"></a>
-<span class="sourceLineNo">1853</span>    // HBASE-13875 uses master timestamp 
for the mutations. The 20ms sleep is not needed<a name="line.1853"></a>
-<span class="sourceLineNo">1854</span>    addRegionsToMeta(connection, 
regionInfos, regionReplication, now + 1);<a name="line.1854"></a>
-<span class="sourceLineNo">1855</span>    LOG.info("Overwritten " + 
regionInfos.size() + " regions to Meta");<a name="line.1855"></a>
-<span class="sourceLineNo">1856</span>    LOG.debug("Overwritten regions: {} 
", regionInfos);<a name="line.1856"></a>
-<span class="sourceLineNo">1857</span>  }<a name="line.1857"></a>
-<span class="sourceLineNo">1858</span><a name="line.1858"></a>
-<span class="sourceLineNo">1859</span>  /**<a name="line.1859"></a>
-<span class="sourceLineNo">1860</span>   * Deletes merge qualifiers for the 
specified merged region.<a name="line.1860"></a>
-<span class="sourceLineNo">1861</span>   * @param connection connection we're 
using<a name="line.1861"></a>
-<span class="sourceLineNo">1862</span>   * @param mergedRegion the merged 
region<a name="line.1862"></a>
-<span class="sourceLineNo">1863</span>   */<a name="line.1863"></a>
-<span class="sourceLineNo">1864</span>  public static void 
deleteMergeQualifiers(Connection connection, final RegionInfo mergedRegion)<a 
name="line.1864"></a>
-<span class="sourceLineNo">1865</span>      throws IOException {<a 
name="line.1865"></a>
-<span class="sourceLineNo">1866</span>    long time = 
EnvironmentEdgeManager.currentTime();<a name="line.1866"></a>
-<span class="sourceLineNo">1867</span>    Delete delete = new 
Delete(mergedRegion.getRegionName());<a name="line.1867"></a>
-<span class="sourceLineNo">1868</span>    
delete.addColumns(getCatalogFamily(), HConstants.MERGEA_QUALIFIER, time);<a 
name="line.1868"></a>
-<span class="sourceLineNo">1869</span>    
delete.addColumns(getCatalogFamily(), HConstants.MERGEB_QUALIFIER, time);<a 
name="line.1869"></a>
-<span class="sourceLineNo">1870</span>    deleteFromMetaTable(connection, 
delete);<a name="line.1870"></a>
-<span class="sourceLineNo">1871</span>    LOG.info("Deleted references in 
merged region "<a name="line.1871"></a>
-<span class="sourceLineNo">1872</span>      + 
mergedRegion.getRegionNameAsString() + ", qualifier="<a name="line.1872"></a>
-<span class="sourceLineNo">1873</span>      + 
Bytes.toStringBinary(HConstants.MERGEA_QUALIFIER) + " and qualifier="<a 
name="line.1873"></a>
-<span class="sourceLineNo">1874</span>      + 
Bytes.toStringBinary(HConstants.MERGEB_QUALIFIER));<a name="line.1874"></a>
-<span class="sourceLineNo">1875</span>  }<a name="line.1875"></a>
-<span class="sourceLineNo">1876</span><a name="line.1876"></a>
-<span class="sourceLineNo">1877</span>  public static Put addRegionInfo(final 
Put p, final RegionInfo hri)<a name="line.1877"></a>
-<span class="sourceLineNo">1878</span>    throws IOException {<a 
name="line.1878"></a>
-<span class="sourceLineNo">1879</span>    
p.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a 
name="line.1879"></a>
-<span class="sourceLineNo">1880</span>        .setRow(p.getRow())<a 
name="line.1880"></a>
-<span class="sourceLineNo">1881</span>        .setFamily(getCatalogFamily())<a 
name="line.1881"></a>
-<span class="sourceLineNo">1882</span>        
.setQualifier(HConstants.REGIONINFO_QUALIFIER)<a name="line.1882"></a>
-<span class="sourceLineNo">1883</span>        
.setTimestamp(p.getTimestamp())<a name="line.1883"></a>
-<span class="sourceLineNo">1884</span>        .setType(Type.Put)<a 
name="line.1884"></a>
-<span class="sourceLineNo">1885</span>        
.setValue(RegionInfo.toByteArray(hri))<a name="line.1885"></a>
-<span class="sourceLineNo">1886</span>        .build());<a 
name="line.1886"></a>
-<span class="sourceLineNo">1887</span>    return p;<a name="line.1887"></a>
-<span class="sourceLineNo">1888</span>  }<a name="line.1888"></a>
-<span class="sourceLineNo">1889</span><a name="line.1889"></a>
-<span class="sourceLineNo">1890</span>  public static Put addLocation(Put p, 
ServerName sn, long openSeqNum, int replicaId)<a name="line.1890"></a>
-<span class="sourceLineNo">1891</span>      throws IOException {<a 
name="line.1891"></a>
-<span class="sourceLineNo">1892</span>    CellBuilder builder = 
CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY);<a name="line.1892"></a>
-<span class="sourceLineNo">1893</span>    return p.add(builder.clear()<a 
name="line.1893"></a>
-<span class="sourceLineNo">1894</span>              .setRow(p.getRow())<a 
name="line.1894"></a>
-<span class="sourceLineNo">1895</span>              
.setFamily(getCatalogFamily())<a name="line.1895"></a>
-<span class="sourceLineNo">1896</span>              
.setQualifier(getServerColumn(replicaId))<a name="line.1896"></a>
-<span class="sourceLineNo">1897</span>              
.setTimestamp(p.getTimestamp())<a name="line.1897"></a>
-<span class="sourceLineNo">1898</span>              .setType(Cell.Type.Put)<a 
name="line.1898"></a>
-<span class="sourceLineNo">1899</span>              
.setValue(Bytes.toBytes(sn.getAddress().toString()))<a name="line.1899"></a>
-<span class="sourceLineNo">1900</span>              .build())<a 
name="line.1900"></a>
-<span class="sourceLineNo">1901</span>            .add(builder.clear()<a 
name="line.1901"></a>
+<span class="sourceLineNo">1572</span>              
.setValue(RegionInfo.toByteArray(regionA))<a name="line.1572"></a>
+<span class="sourceLineNo">1573</span>              .build())<a 
name="line.1573"></a>
+<span class="sourceLineNo">1574</span>          
.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a 
name="line.1574"></a>
+<span class="sourceLineNo">1575</span>              
.setRow(putOfMerged.getRow())<a name="line.1575"></a>
+<span class="sourceLineNo">1576</span>              
.setFamily(HConstants.CATALOG_FAMILY)<a name="line.1576"></a>
+<span class="sourceLineNo">1577</span>              
.setQualifier(HConstants.MERGEB_QUALIFIER)<a name="line.1577"></a>
+<span class="sourceLineNo">1578</span>              
.setTimestamp(putOfMerged.getTimestamp())<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span>              .setType(Type.Put)<a 
name="line.1579"></a>
+<span class="sourceLineNo">1580</span>              
.setValue(RegionInfo.toByteArray(regionB))<a name="line.1580"></a>
+<span class="sourceLineNo">1581</span>              .build());<a 
name="line.1581"></a>
+<span class="sourceLineNo">1582</span>      // Set initial state to CLOSED<a 
name="line.1582"></a>
+<span class="sourceLineNo">1583</span>      // NOTE: If initial state is not 
set to CLOSED then merged region gets added with the<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span>      // default OFFLINE state. If 
Master gets restarted after this step, start up sequence of<a 
name="line.1584"></a>
+<span class="sourceLineNo">1585</span>      // master tries to assign this 
offline region. This is followed by re-assignments of the<a 
name="line.1585"></a>
+<span class="sourceLineNo">1586</span>      // merged region from resumed 
{@link MergeTableRegionsProcedure}<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>      addRegionStateToPut(putOfMerged, 
RegionState.State.CLOSED);<a name="line.1587"></a>
+<span class="sourceLineNo">1588</span>      mutations.add(putOfMerged);<a 
name="line.1588"></a>
+<span class="sourceLineNo">1589</span>      // The merged is a new region, 
openSeqNum = 1 is fine. ServerName may be null<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span>      // if crash after merge happened 
but before we got to here.. means in-memory<a name="line.1590"></a>
+<span class="sourceLineNo">1591</span>      // locations of offlined merged, 
now-closed, regions is lost. Should be ok. We<a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>      // assign the merged region 
later.<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>      if (sn != null) {<a 
name="line.1593"></a>
+<span class="sourceLineNo">1594</span>        addLocation(putOfMerged, sn, 1, 
mergedRegion.getReplicaId());<a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>      }<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span><a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>      // Add empty locations for region 
replicas of the merged region so that number of replicas can<a 
name="line.1597"></a>
+<span class="sourceLineNo">1598</span>      // be cached whenever the primary 
region is looked up from meta<a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>      for (int i = 1; i &lt; 
regionReplication; i++) {<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span>        addEmptyLocation(putOfMerged, 
i);<a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>      }<a name="line.1601"></a>
+<span class="sourceLineNo">1602</span>      // add parent reference for serial 
replication<a name="line.1602"></a>
+<span class="sourceLineNo">1603</span>      if (!replicationParents.isEmpty()) 
{<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>        
addReplicationParent(putOfMerged, replicationParents);<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span>      }<a name="line.1605"></a>
+<span class="sourceLineNo">1606</span>      byte[] tableRow = 
Bytes.toBytes(mergedRegion.getRegionNameAsString() + HConstants.DELIMITER);<a 
name="line.1606"></a>
+<span class="sourceLineNo">1607</span>      multiMutate(connection, meta, 
tableRow, mutations);<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>    }<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span>  }<a name="line.1609"></a>
+<span class="sourceLineNo">1610</span><a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>  /**<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span>   * Splits the region into two in an 
atomic operation. Offlines the parent region with the<a name="line.1612"></a>
+<span class="sourceLineNo">1613</span>   * information that it is split into 
two, and also adds the daughter regions. Does not add the<a 
name="line.1613"></a>
+<span class="sourceLineNo">1614</span>   * location information to the 
daughter regions since they are not open yet.<a name="line.1614"></a>
+<span class="sourceLineNo">1615</span>   * @param connection connection we're 
using<a name="line.1615"></a>
+<span class="sourceLineNo">1616</span>   * @param parent the parent region 
which is split<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>   * @param parentOpenSeqNum the next 
open sequence id for parent region, used by serial<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span>   *          replication. -1 if not 
necessary.<a name="line.1618"></a>
+<span class="sourceL

<TRUNCATED>

Reply via email to