hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [50/51] [partial] hbase-site git commit: Published site at 07b623670647686084f8f5fd2038e2bafcfdac54.
Date Wed, 30 Dec 2015 22:16:11 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e5c3dcd1/apidocs/src-html/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.html b/apidocs/src-html/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.html
index 3ae9c04..bd2ad61 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.html
@@ -607,126 +607,137 @@
 <span class="sourceLineNo">599</span>    if (repPeers == null || repPeers.size() &lt;= 0) {<a name="line.599"></a>
 <span class="sourceLineNo">600</span>      throw new IllegalArgumentException("Found no peer cluster for replication.");<a name="line.600"></a>
 <span class="sourceLineNo">601</span>    }<a name="line.601"></a>
-<span class="sourceLineNo">602</span>    for (ReplicationPeer repPeer : repPeers) {<a name="line.602"></a>
-<span class="sourceLineNo">603</span>      Configuration peerConf = repPeer.getConfiguration();<a name="line.603"></a>
-<span class="sourceLineNo">604</span>      HTableDescriptor htd = null;<a name="line.604"></a>
-<span class="sourceLineNo">605</span>      try (Connection conn = ConnectionFactory.createConnection(peerConf);<a name="line.605"></a>
-<span class="sourceLineNo">606</span>          Admin admin = this.connection.getAdmin();<a name="line.606"></a>
-<span class="sourceLineNo">607</span>          Admin repHBaseAdmin = conn.getAdmin()) {<a name="line.607"></a>
-<span class="sourceLineNo">608</span>        htd = admin.getTableDescriptor(tableName);<a name="line.608"></a>
-<span class="sourceLineNo">609</span>        HTableDescriptor peerHtd = null;<a name="line.609"></a>
-<span class="sourceLineNo">610</span>        if (!repHBaseAdmin.tableExists(tableName)) {<a name="line.610"></a>
-<span class="sourceLineNo">611</span>          repHBaseAdmin.createTable(htd, splits);<a name="line.611"></a>
-<span class="sourceLineNo">612</span>        } else {<a name="line.612"></a>
-<span class="sourceLineNo">613</span>          peerHtd = repHBaseAdmin.getTableDescriptor(tableName);<a name="line.613"></a>
-<span class="sourceLineNo">614</span>          if (peerHtd == null) {<a name="line.614"></a>
-<span class="sourceLineNo">615</span>            throw new IllegalArgumentException("Failed to get table descriptor for table "<a name="line.615"></a>
-<span class="sourceLineNo">616</span>                + tableName.getNameAsString() + " from peer cluster " + repPeer.getId());<a name="line.616"></a>
-<span class="sourceLineNo">617</span>          } else if (!peerHtd.equals(htd)) {<a name="line.617"></a>
-<span class="sourceLineNo">618</span>            throw new IllegalArgumentException("Table " + tableName.getNameAsString()<a name="line.618"></a>
-<span class="sourceLineNo">619</span>                + " exists in peer cluster " + repPeer.getId()<a name="line.619"></a>
-<span class="sourceLineNo">620</span>                + ", but the table descriptors are not same when comapred with source cluster."<a name="line.620"></a>
-<span class="sourceLineNo">621</span>                + " Thus can not enable the table's replication switch.");<a name="line.621"></a>
-<span class="sourceLineNo">622</span>          }<a name="line.622"></a>
-<span class="sourceLineNo">623</span>        }<a name="line.623"></a>
-<span class="sourceLineNo">624</span>      }<a name="line.624"></a>
-<span class="sourceLineNo">625</span>    }<a name="line.625"></a>
-<span class="sourceLineNo">626</span>  }<a name="line.626"></a>
-<span class="sourceLineNo">627</span><a name="line.627"></a>
-<span class="sourceLineNo">628</span>  @VisibleForTesting<a name="line.628"></a>
-<span class="sourceLineNo">629</span>  List&lt;ReplicationPeer&gt; listValidReplicationPeers() {<a name="line.629"></a>
-<span class="sourceLineNo">630</span>    Map&lt;String, ReplicationPeerConfig&gt; peers = listPeerConfigs();<a name="line.630"></a>
-<span class="sourceLineNo">631</span>    if (peers == null || peers.size() &lt;= 0) {<a name="line.631"></a>
-<span class="sourceLineNo">632</span>      return null;<a name="line.632"></a>
-<span class="sourceLineNo">633</span>    }<a name="line.633"></a>
-<span class="sourceLineNo">634</span>    List&lt;ReplicationPeer&gt; validPeers = new ArrayList&lt;ReplicationPeer&gt;(peers.size());<a name="line.634"></a>
-<span class="sourceLineNo">635</span>    for (Entry&lt;String, ReplicationPeerConfig&gt; peerEntry : peers.entrySet()) {<a name="line.635"></a>
-<span class="sourceLineNo">636</span>      String peerId = peerEntry.getKey();<a name="line.636"></a>
-<span class="sourceLineNo">637</span>      Stat s = null;<a name="line.637"></a>
-<span class="sourceLineNo">638</span>      try {<a name="line.638"></a>
-<span class="sourceLineNo">639</span>        Pair&lt;ReplicationPeerConfig, Configuration&gt; pair = this.replicationPeers.getPeerConf(peerId);<a name="line.639"></a>
-<span class="sourceLineNo">640</span>        Configuration peerConf = pair.getSecond();<a name="line.640"></a>
-<span class="sourceLineNo">641</span>        ReplicationPeer peer = new ReplicationPeerZKImpl(peerConf, peerId, pair.getFirst());<a name="line.641"></a>
-<span class="sourceLineNo">642</span>        s =<a name="line.642"></a>
-<span class="sourceLineNo">643</span>            zkw.getRecoverableZooKeeper().exists(peerConf.get(HConstants.ZOOKEEPER_ZNODE_PARENT),<a name="line.643"></a>
-<span class="sourceLineNo">644</span>              null);<a name="line.644"></a>
-<span class="sourceLineNo">645</span>        if (null == s) {<a name="line.645"></a>
-<span class="sourceLineNo">646</span>          LOG.info(peerId + ' ' + pair.getFirst().getClusterKey() + " is invalid now.");<a name="line.646"></a>
-<span class="sourceLineNo">647</span>          continue;<a name="line.647"></a>
-<span class="sourceLineNo">648</span>        }<a name="line.648"></a>
-<span class="sourceLineNo">649</span>        validPeers.add(peer);<a name="line.649"></a>
-<span class="sourceLineNo">650</span>      } catch (ReplicationException e) {<a name="line.650"></a>
-<span class="sourceLineNo">651</span>        LOG.warn("Failed to get valid replication peers. "<a name="line.651"></a>
-<span class="sourceLineNo">652</span>            + "Error connecting to peer cluster with peerId=" + peerId);<a name="line.652"></a>
-<span class="sourceLineNo">653</span>        LOG.debug("Failure details to get valid replication peers.", e);<a name="line.653"></a>
-<span class="sourceLineNo">654</span>        continue;<a name="line.654"></a>
-<span class="sourceLineNo">655</span>      } catch (KeeperException e) {<a name="line.655"></a>
-<span class="sourceLineNo">656</span>        LOG.warn("Failed to get valid replication peers. KeeperException code="<a name="line.656"></a>
-<span class="sourceLineNo">657</span>            + e.code().intValue());<a name="line.657"></a>
-<span class="sourceLineNo">658</span>        LOG.debug("Failure details to get valid replication peers.", e);<a name="line.658"></a>
-<span class="sourceLineNo">659</span>        continue;<a name="line.659"></a>
-<span class="sourceLineNo">660</span>      } catch (InterruptedException e) {<a name="line.660"></a>
-<span class="sourceLineNo">661</span>        LOG.warn("Failed to get valid replication peers due to InterruptedException.");<a name="line.661"></a>
-<span class="sourceLineNo">662</span>        LOG.debug("Failure details to get valid replication peers.", e);<a name="line.662"></a>
-<span class="sourceLineNo">663</span>        Thread.currentThread().interrupt();<a name="line.663"></a>
-<span class="sourceLineNo">664</span>        continue;<a name="line.664"></a>
-<span class="sourceLineNo">665</span>      }<a name="line.665"></a>
-<span class="sourceLineNo">666</span>    }<a name="line.666"></a>
-<span class="sourceLineNo">667</span>    return validPeers;<a name="line.667"></a>
-<span class="sourceLineNo">668</span>  }<a name="line.668"></a>
-<span class="sourceLineNo">669</span><a name="line.669"></a>
-<span class="sourceLineNo">670</span>  /**<a name="line.670"></a>
-<span class="sourceLineNo">671</span>   * Set the table's replication switch if the table's replication switch is already not set.<a name="line.671"></a>
-<span class="sourceLineNo">672</span>   * @param tableName name of the table<a name="line.672"></a>
-<span class="sourceLineNo">673</span>   * @param isRepEnabled is replication switch enable or disable<a name="line.673"></a>
-<span class="sourceLineNo">674</span>   * @throws IOException if a remote or network exception occurs<a name="line.674"></a>
-<span class="sourceLineNo">675</span>   */<a name="line.675"></a>
-<span class="sourceLineNo">676</span>  private void setTableRep(final TableName tableName, boolean isRepEnabled) throws IOException {<a name="line.676"></a>
-<span class="sourceLineNo">677</span>    Admin admin = null;<a name="line.677"></a>
-<span class="sourceLineNo">678</span>    try {<a name="line.678"></a>
-<span class="sourceLineNo">679</span>      admin = this.connection.getAdmin();<a name="line.679"></a>
-<span class="sourceLineNo">680</span>      HTableDescriptor htd = admin.getTableDescriptor(tableName);<a name="line.680"></a>
-<span class="sourceLineNo">681</span>      if (isTableRepEnabled(htd) ^ isRepEnabled) {<a name="line.681"></a>
-<span class="sourceLineNo">682</span>        boolean isOnlineSchemaUpdateEnabled =<a name="line.682"></a>
-<span class="sourceLineNo">683</span>            this.connection.getConfiguration()<a name="line.683"></a>
-<span class="sourceLineNo">684</span>                .getBoolean("hbase.online.schema.update.enable", true);<a name="line.684"></a>
-<span class="sourceLineNo">685</span>        if (!isOnlineSchemaUpdateEnabled) {<a name="line.685"></a>
-<span class="sourceLineNo">686</span>          admin.disableTable(tableName);<a name="line.686"></a>
-<span class="sourceLineNo">687</span>        }<a name="line.687"></a>
-<span class="sourceLineNo">688</span>        for (HColumnDescriptor hcd : htd.getFamilies()) {<a name="line.688"></a>
-<span class="sourceLineNo">689</span>          hcd.setScope(isRepEnabled ? HConstants.REPLICATION_SCOPE_GLOBAL<a name="line.689"></a>
-<span class="sourceLineNo">690</span>              : HConstants.REPLICATION_SCOPE_LOCAL);<a name="line.690"></a>
-<span class="sourceLineNo">691</span>        }<a name="line.691"></a>
-<span class="sourceLineNo">692</span>        admin.modifyTable(tableName, htd);<a name="line.692"></a>
-<span class="sourceLineNo">693</span>        if (!isOnlineSchemaUpdateEnabled) {<a name="line.693"></a>
-<span class="sourceLineNo">694</span>          admin.enableTable(tableName);<a name="line.694"></a>
-<span class="sourceLineNo">695</span>        }<a name="line.695"></a>
-<span class="sourceLineNo">696</span>      }<a name="line.696"></a>
-<span class="sourceLineNo">697</span>    } finally {<a name="line.697"></a>
-<span class="sourceLineNo">698</span>      if (admin != null) {<a name="line.698"></a>
-<span class="sourceLineNo">699</span>        try {<a name="line.699"></a>
-<span class="sourceLineNo">700</span>          admin.close();<a name="line.700"></a>
-<span class="sourceLineNo">701</span>        } catch (IOException e) {<a name="line.701"></a>
-<span class="sourceLineNo">702</span>          LOG.warn("Failed to close admin connection.");<a name="line.702"></a>
-<span class="sourceLineNo">703</span>          LOG.debug("Details on failure to close admin connection.", e);<a name="line.703"></a>
-<span class="sourceLineNo">704</span>        }<a name="line.704"></a>
-<span class="sourceLineNo">705</span>      }<a name="line.705"></a>
-<span class="sourceLineNo">706</span>    }<a name="line.706"></a>
-<span class="sourceLineNo">707</span>  }<a name="line.707"></a>
-<span class="sourceLineNo">708</span><a name="line.708"></a>
-<span class="sourceLineNo">709</span>  /**<a name="line.709"></a>
-<span class="sourceLineNo">710</span>   * @param htd table descriptor details for the table to check<a name="line.710"></a>
-<span class="sourceLineNo">711</span>   * @return true if table's replication switch is enabled<a name="line.711"></a>
-<span class="sourceLineNo">712</span>   */<a name="line.712"></a>
-<span class="sourceLineNo">713</span>  private boolean isTableRepEnabled(HTableDescriptor htd) {<a name="line.713"></a>
-<span class="sourceLineNo">714</span>    for (HColumnDescriptor hcd : htd.getFamilies()) {<a name="line.714"></a>
-<span class="sourceLineNo">715</span>      if (hcd.getScope() != HConstants.REPLICATION_SCOPE_GLOBAL) {<a name="line.715"></a>
-<span class="sourceLineNo">716</span>        return false;<a name="line.716"></a>
-<span class="sourceLineNo">717</span>      }<a name="line.717"></a>
-<span class="sourceLineNo">718</span>    }<a name="line.718"></a>
-<span class="sourceLineNo">719</span>    return true;<a name="line.719"></a>
-<span class="sourceLineNo">720</span>  }<a name="line.720"></a>
-<span class="sourceLineNo">721</span>}<a name="line.721"></a>
+<span class="sourceLineNo">602</span>    <a name="line.602"></a>
+<span class="sourceLineNo">603</span>    final TableName onlyTableNameQualifier = TableName.valueOf(tableName.getQualifierAsString());<a name="line.603"></a>
+<span class="sourceLineNo">604</span>    <a name="line.604"></a>
+<span class="sourceLineNo">605</span>    for (ReplicationPeer repPeer : repPeers) {<a name="line.605"></a>
+<span class="sourceLineNo">606</span>      Map&lt;TableName, List&lt;String&gt;&gt; tableCFMap = repPeer.getTableCFs();<a name="line.606"></a>
+<span class="sourceLineNo">607</span>      // TODO Currently peer TableCFs will not include namespace so we need to check only for table<a name="line.607"></a>
+<span class="sourceLineNo">608</span>      // name without namespace in it. Need to correct this logic once we fix HBASE-11386.<a name="line.608"></a>
+<span class="sourceLineNo">609</span>      if (tableCFMap != null &amp;&amp; !tableCFMap.containsKey(onlyTableNameQualifier)) {<a name="line.609"></a>
+<span class="sourceLineNo">610</span>        continue;<a name="line.610"></a>
+<span class="sourceLineNo">611</span>      }<a name="line.611"></a>
+<span class="sourceLineNo">612</span><a name="line.612"></a>
+<span class="sourceLineNo">613</span>      Configuration peerConf = repPeer.getConfiguration();<a name="line.613"></a>
+<span class="sourceLineNo">614</span>      HTableDescriptor htd = null;<a name="line.614"></a>
+<span class="sourceLineNo">615</span>      try (Connection conn = ConnectionFactory.createConnection(peerConf);<a name="line.615"></a>
+<span class="sourceLineNo">616</span>          Admin admin = this.connection.getAdmin();<a name="line.616"></a>
+<span class="sourceLineNo">617</span>          Admin repHBaseAdmin = conn.getAdmin()) {<a name="line.617"></a>
+<span class="sourceLineNo">618</span>        htd = admin.getTableDescriptor(tableName);<a name="line.618"></a>
+<span class="sourceLineNo">619</span>        HTableDescriptor peerHtd = null;<a name="line.619"></a>
+<span class="sourceLineNo">620</span>        if (!repHBaseAdmin.tableExists(tableName)) {<a name="line.620"></a>
+<span class="sourceLineNo">621</span>          repHBaseAdmin.createTable(htd, splits);<a name="line.621"></a>
+<span class="sourceLineNo">622</span>        } else {<a name="line.622"></a>
+<span class="sourceLineNo">623</span>          peerHtd = repHBaseAdmin.getTableDescriptor(tableName);<a name="line.623"></a>
+<span class="sourceLineNo">624</span>          if (peerHtd == null) {<a name="line.624"></a>
+<span class="sourceLineNo">625</span>            throw new IllegalArgumentException("Failed to get table descriptor for table "<a name="line.625"></a>
+<span class="sourceLineNo">626</span>                + tableName.getNameAsString() + " from peer cluster " + repPeer.getId());<a name="line.626"></a>
+<span class="sourceLineNo">627</span>          } else if (!peerHtd.equals(htd)) {<a name="line.627"></a>
+<span class="sourceLineNo">628</span>            throw new IllegalArgumentException("Table " + tableName.getNameAsString()<a name="line.628"></a>
+<span class="sourceLineNo">629</span>                + " exists in peer cluster " + repPeer.getId()<a name="line.629"></a>
+<span class="sourceLineNo">630</span>                + ", but the table descriptors are not same when comapred with source cluster."<a name="line.630"></a>
+<span class="sourceLineNo">631</span>                + " Thus can not enable the table's replication switch.");<a name="line.631"></a>
+<span class="sourceLineNo">632</span>          }<a name="line.632"></a>
+<span class="sourceLineNo">633</span>        }<a name="line.633"></a>
+<span class="sourceLineNo">634</span>      }<a name="line.634"></a>
+<span class="sourceLineNo">635</span>    }<a name="line.635"></a>
+<span class="sourceLineNo">636</span>  }<a name="line.636"></a>
+<span class="sourceLineNo">637</span><a name="line.637"></a>
+<span class="sourceLineNo">638</span>  @VisibleForTesting<a name="line.638"></a>
+<span class="sourceLineNo">639</span>  List&lt;ReplicationPeer&gt; listValidReplicationPeers() {<a name="line.639"></a>
+<span class="sourceLineNo">640</span>    Map&lt;String, ReplicationPeerConfig&gt; peers = listPeerConfigs();<a name="line.640"></a>
+<span class="sourceLineNo">641</span>    if (peers == null || peers.size() &lt;= 0) {<a name="line.641"></a>
+<span class="sourceLineNo">642</span>      return null;<a name="line.642"></a>
+<span class="sourceLineNo">643</span>    }<a name="line.643"></a>
+<span class="sourceLineNo">644</span>    List&lt;ReplicationPeer&gt; validPeers = new ArrayList&lt;ReplicationPeer&gt;(peers.size());<a name="line.644"></a>
+<span class="sourceLineNo">645</span>    for (Entry&lt;String, ReplicationPeerConfig&gt; peerEntry : peers.entrySet()) {<a name="line.645"></a>
+<span class="sourceLineNo">646</span>      String peerId = peerEntry.getKey();<a name="line.646"></a>
+<span class="sourceLineNo">647</span>      Stat s = null;<a name="line.647"></a>
+<span class="sourceLineNo">648</span>      try {<a name="line.648"></a>
+<span class="sourceLineNo">649</span>        Pair&lt;ReplicationPeerConfig, Configuration&gt; pair = this.replicationPeers.getPeerConf(peerId);<a name="line.649"></a>
+<span class="sourceLineNo">650</span>        Configuration peerConf = pair.getSecond();<a name="line.650"></a>
+<span class="sourceLineNo">651</span>        ReplicationPeer peer = new ReplicationPeerZKImpl(peerConf, peerId, pair.getFirst(),<a name="line.651"></a>
+<span class="sourceLineNo">652</span>            parseTableCFsFromConfig(this.getPeerTableCFs(peerId)));<a name="line.652"></a>
+<span class="sourceLineNo">653</span>        s =<a name="line.653"></a>
+<span class="sourceLineNo">654</span>            zkw.getRecoverableZooKeeper().exists(peerConf.get(HConstants.ZOOKEEPER_ZNODE_PARENT),<a name="line.654"></a>
+<span class="sourceLineNo">655</span>              null);<a name="line.655"></a>
+<span class="sourceLineNo">656</span>        if (null == s) {<a name="line.656"></a>
+<span class="sourceLineNo">657</span>          LOG.info(peerId + ' ' + pair.getFirst().getClusterKey() + " is invalid now.");<a name="line.657"></a>
+<span class="sourceLineNo">658</span>          continue;<a name="line.658"></a>
+<span class="sourceLineNo">659</span>        }<a name="line.659"></a>
+<span class="sourceLineNo">660</span>        validPeers.add(peer);<a name="line.660"></a>
+<span class="sourceLineNo">661</span>      } catch (ReplicationException e) {<a name="line.661"></a>
+<span class="sourceLineNo">662</span>        LOG.warn("Failed to get valid replication peers. "<a name="line.662"></a>
+<span class="sourceLineNo">663</span>            + "Error connecting to peer cluster with peerId=" + peerId);<a name="line.663"></a>
+<span class="sourceLineNo">664</span>        LOG.debug("Failure details to get valid replication peers.", e);<a name="line.664"></a>
+<span class="sourceLineNo">665</span>        continue;<a name="line.665"></a>
+<span class="sourceLineNo">666</span>      } catch (KeeperException e) {<a name="line.666"></a>
+<span class="sourceLineNo">667</span>        LOG.warn("Failed to get valid replication peers. KeeperException code="<a name="line.667"></a>
+<span class="sourceLineNo">668</span>            + e.code().intValue());<a name="line.668"></a>
+<span class="sourceLineNo">669</span>        LOG.debug("Failure details to get valid replication peers.", e);<a name="line.669"></a>
+<span class="sourceLineNo">670</span>        continue;<a name="line.670"></a>
+<span class="sourceLineNo">671</span>      } catch (InterruptedException e) {<a name="line.671"></a>
+<span class="sourceLineNo">672</span>        LOG.warn("Failed to get valid replication peers due to InterruptedException.");<a name="line.672"></a>
+<span class="sourceLineNo">673</span>        LOG.debug("Failure details to get valid replication peers.", e);<a name="line.673"></a>
+<span class="sourceLineNo">674</span>        Thread.currentThread().interrupt();<a name="line.674"></a>
+<span class="sourceLineNo">675</span>        continue;<a name="line.675"></a>
+<span class="sourceLineNo">676</span>      }<a name="line.676"></a>
+<span class="sourceLineNo">677</span>    }<a name="line.677"></a>
+<span class="sourceLineNo">678</span>    return validPeers;<a name="line.678"></a>
+<span class="sourceLineNo">679</span>  }<a name="line.679"></a>
+<span class="sourceLineNo">680</span><a name="line.680"></a>
+<span class="sourceLineNo">681</span>  /**<a name="line.681"></a>
+<span class="sourceLineNo">682</span>   * Set the table's replication switch if the table's replication switch is already not set.<a name="line.682"></a>
+<span class="sourceLineNo">683</span>   * @param tableName name of the table<a name="line.683"></a>
+<span class="sourceLineNo">684</span>   * @param isRepEnabled is replication switch enable or disable<a name="line.684"></a>
+<span class="sourceLineNo">685</span>   * @throws IOException if a remote or network exception occurs<a name="line.685"></a>
+<span class="sourceLineNo">686</span>   */<a name="line.686"></a>
+<span class="sourceLineNo">687</span>  private void setTableRep(final TableName tableName, boolean isRepEnabled) throws IOException {<a name="line.687"></a>
+<span class="sourceLineNo">688</span>    Admin admin = null;<a name="line.688"></a>
+<span class="sourceLineNo">689</span>    try {<a name="line.689"></a>
+<span class="sourceLineNo">690</span>      admin = this.connection.getAdmin();<a name="line.690"></a>
+<span class="sourceLineNo">691</span>      HTableDescriptor htd = admin.getTableDescriptor(tableName);<a name="line.691"></a>
+<span class="sourceLineNo">692</span>      if (isTableRepEnabled(htd) ^ isRepEnabled) {<a name="line.692"></a>
+<span class="sourceLineNo">693</span>        boolean isOnlineSchemaUpdateEnabled =<a name="line.693"></a>
+<span class="sourceLineNo">694</span>            this.connection.getConfiguration()<a name="line.694"></a>
+<span class="sourceLineNo">695</span>                .getBoolean("hbase.online.schema.update.enable", true);<a name="line.695"></a>
+<span class="sourceLineNo">696</span>        if (!isOnlineSchemaUpdateEnabled) {<a name="line.696"></a>
+<span class="sourceLineNo">697</span>          admin.disableTable(tableName);<a name="line.697"></a>
+<span class="sourceLineNo">698</span>        }<a name="line.698"></a>
+<span class="sourceLineNo">699</span>        for (HColumnDescriptor hcd : htd.getFamilies()) {<a name="line.699"></a>
+<span class="sourceLineNo">700</span>          hcd.setScope(isRepEnabled ? HConstants.REPLICATION_SCOPE_GLOBAL<a name="line.700"></a>
+<span class="sourceLineNo">701</span>              : HConstants.REPLICATION_SCOPE_LOCAL);<a name="line.701"></a>
+<span class="sourceLineNo">702</span>        }<a name="line.702"></a>
+<span class="sourceLineNo">703</span>        admin.modifyTable(tableName, htd);<a name="line.703"></a>
+<span class="sourceLineNo">704</span>        if (!isOnlineSchemaUpdateEnabled) {<a name="line.704"></a>
+<span class="sourceLineNo">705</span>          admin.enableTable(tableName);<a name="line.705"></a>
+<span class="sourceLineNo">706</span>        }<a name="line.706"></a>
+<span class="sourceLineNo">707</span>      }<a name="line.707"></a>
+<span class="sourceLineNo">708</span>    } finally {<a name="line.708"></a>
+<span class="sourceLineNo">709</span>      if (admin != null) {<a name="line.709"></a>
+<span class="sourceLineNo">710</span>        try {<a name="line.710"></a>
+<span class="sourceLineNo">711</span>          admin.close();<a name="line.711"></a>
+<span class="sourceLineNo">712</span>        } catch (IOException e) {<a name="line.712"></a>
+<span class="sourceLineNo">713</span>          LOG.warn("Failed to close admin connection.");<a name="line.713"></a>
+<span class="sourceLineNo">714</span>          LOG.debug("Details on failure to close admin connection.", e);<a name="line.714"></a>
+<span class="sourceLineNo">715</span>        }<a name="line.715"></a>
+<span class="sourceLineNo">716</span>      }<a name="line.716"></a>
+<span class="sourceLineNo">717</span>    }<a name="line.717"></a>
+<span class="sourceLineNo">718</span>  }<a name="line.718"></a>
+<span class="sourceLineNo">719</span><a name="line.719"></a>
+<span class="sourceLineNo">720</span>  /**<a name="line.720"></a>
+<span class="sourceLineNo">721</span>   * @param htd table descriptor details for the table to check<a name="line.721"></a>
+<span class="sourceLineNo">722</span>   * @return true if table's replication switch is enabled<a name="line.722"></a>
+<span class="sourceLineNo">723</span>   */<a name="line.723"></a>
+<span class="sourceLineNo">724</span>  private boolean isTableRepEnabled(HTableDescriptor htd) {<a name="line.724"></a>
+<span class="sourceLineNo">725</span>    for (HColumnDescriptor hcd : htd.getFamilies()) {<a name="line.725"></a>
+<span class="sourceLineNo">726</span>      if (hcd.getScope() != HConstants.REPLICATION_SCOPE_GLOBAL) {<a name="line.726"></a>
+<span class="sourceLineNo">727</span>        return false;<a name="line.727"></a>
+<span class="sourceLineNo">728</span>      }<a name="line.728"></a>
+<span class="sourceLineNo">729</span>    }<a name="line.729"></a>
+<span class="sourceLineNo">730</span>    return true;<a name="line.730"></a>
+<span class="sourceLineNo">731</span>  }<a name="line.731"></a>
+<span class="sourceLineNo">732</span>}<a name="line.732"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e5c3dcd1/apidocs/src-html/org/apache/hadoop/hbase/filter/FuzzyRowFilter.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/filter/FuzzyRowFilter.html b/apidocs/src-html/org/apache/hadoop/hbase/filter/FuzzyRowFilter.html
index cc8885d..ff3addc 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/filter/FuzzyRowFilter.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/filter/FuzzyRowFilter.html
@@ -102,7 +102,7 @@
 <span class="sourceLineNo">094</span>  }<a name="line.94"></a>
 <span class="sourceLineNo">095</span><a name="line.95"></a>
 <span class="sourceLineNo">096</span>  private void preprocessSearchKey(Pair&lt;byte[], byte[]&gt; p) {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    if (UnsafeAccess.isAvailable() == false) {<a name="line.97"></a>
+<span class="sourceLineNo">097</span>    if (UnsafeAccess.unaligned() == false) {<a name="line.97"></a>
 <span class="sourceLineNo">098</span>      // do nothing<a name="line.98"></a>
 <span class="sourceLineNo">099</span>      return;<a name="line.99"></a>
 <span class="sourceLineNo">100</span>    }<a name="line.100"></a>
@@ -121,7 +121,7 @@
 <span class="sourceLineNo">113</span>   * @return mask array<a name="line.113"></a>
 <span class="sourceLineNo">114</span>   */<a name="line.114"></a>
 <span class="sourceLineNo">115</span>  private byte[] preprocessMask(byte[] mask) {<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    if (UnsafeAccess.isAvailable() == false) {<a name="line.116"></a>
+<span class="sourceLineNo">116</span>    if (UnsafeAccess.unaligned() == false) {<a name="line.116"></a>
 <span class="sourceLineNo">117</span>      // do nothing<a name="line.117"></a>
 <span class="sourceLineNo">118</span>      return mask;<a name="line.118"></a>
 <span class="sourceLineNo">119</span>    }<a name="line.119"></a>
@@ -330,7 +330,7 @@
 <span class="sourceLineNo">322</span>  static SatisfiesCode satisfies(boolean reverse, byte[] row, int offset, int length,<a name="line.322"></a>
 <span class="sourceLineNo">323</span>      byte[] fuzzyKeyBytes, byte[] fuzzyKeyMeta) {<a name="line.323"></a>
 <span class="sourceLineNo">324</span><a name="line.324"></a>
-<span class="sourceLineNo">325</span>    if (UnsafeAccess.isAvailable() == false) {<a name="line.325"></a>
+<span class="sourceLineNo">325</span>    if (UnsafeAccess.unaligned() == false) {<a name="line.325"></a>
 <span class="sourceLineNo">326</span>      return satisfiesNoUnsafe(reverse, row, offset, length, fuzzyKeyBytes, fuzzyKeyMeta);<a name="line.326"></a>
 <span class="sourceLineNo">327</span>    }<a name="line.327"></a>
 <span class="sourceLineNo">328</span><a name="line.328"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e5c3dcd1/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html
index 7c00453..f955098 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html
@@ -911,177 +911,178 @@
 <span class="sourceLineNo">903</span>                                  .withBytesPerCheckSum(HStore.getBytesPerChecksum(conf))<a name="line.903"></a>
 <span class="sourceLineNo">904</span>                                  .withBlockSize(blocksize)<a name="line.904"></a>
 <span class="sourceLineNo">905</span>                                  .withDataBlockEncoding(familyDescriptor.getDataBlockEncoding())<a name="line.905"></a>
-<span class="sourceLineNo">906</span>                                  .build();<a name="line.906"></a>
-<span class="sourceLineNo">907</span>      halfWriter = new StoreFile.WriterBuilder(conf, cacheConf,<a name="line.907"></a>
-<span class="sourceLineNo">908</span>          fs)<a name="line.908"></a>
-<span class="sourceLineNo">909</span>              .withFilePath(outFile)<a name="line.909"></a>
-<span class="sourceLineNo">910</span>              .withBloomType(bloomFilterType)<a name="line.910"></a>
-<span class="sourceLineNo">911</span>              .withFileContext(hFileContext)<a name="line.911"></a>
-<span class="sourceLineNo">912</span>              .build();<a name="line.912"></a>
-<span class="sourceLineNo">913</span>      HFileScanner scanner = halfReader.getScanner(false, false, false);<a name="line.913"></a>
-<span class="sourceLineNo">914</span>      scanner.seekTo();<a name="line.914"></a>
-<span class="sourceLineNo">915</span>      do {<a name="line.915"></a>
-<span class="sourceLineNo">916</span>        halfWriter.append(scanner.getCell());<a name="line.916"></a>
-<span class="sourceLineNo">917</span>      } while (scanner.next());<a name="line.917"></a>
-<span class="sourceLineNo">918</span><a name="line.918"></a>
-<span class="sourceLineNo">919</span>      for (Map.Entry&lt;byte[],byte[]&gt; entry : fileInfo.entrySet()) {<a name="line.919"></a>
-<span class="sourceLineNo">920</span>        if (shouldCopyHFileMetaKey(entry.getKey())) {<a name="line.920"></a>
-<span class="sourceLineNo">921</span>          halfWriter.appendFileInfo(entry.getKey(), entry.getValue());<a name="line.921"></a>
-<span class="sourceLineNo">922</span>        }<a name="line.922"></a>
-<span class="sourceLineNo">923</span>      }<a name="line.923"></a>
-<span class="sourceLineNo">924</span>    } finally {<a name="line.924"></a>
-<span class="sourceLineNo">925</span>      if (halfWriter != null) halfWriter.close();<a name="line.925"></a>
-<span class="sourceLineNo">926</span>      if (halfReader != null) halfReader.close(cacheConf.shouldEvictOnClose());<a name="line.926"></a>
-<span class="sourceLineNo">927</span>    }<a name="line.927"></a>
-<span class="sourceLineNo">928</span>  }<a name="line.928"></a>
-<span class="sourceLineNo">929</span><a name="line.929"></a>
-<span class="sourceLineNo">930</span>  private static boolean shouldCopyHFileMetaKey(byte[] key) {<a name="line.930"></a>
-<span class="sourceLineNo">931</span>    return !HFile.isReservedFileInfoKey(key);<a name="line.931"></a>
-<span class="sourceLineNo">932</span>  }<a name="line.932"></a>
-<span class="sourceLineNo">933</span><a name="line.933"></a>
-<span class="sourceLineNo">934</span>  /*<a name="line.934"></a>
-<span class="sourceLineNo">935</span>   * Infers region boundaries for a new table.<a name="line.935"></a>
-<span class="sourceLineNo">936</span>   * Parameter:<a name="line.936"></a>
-<span class="sourceLineNo">937</span>   *   bdryMap is a map between keys to an integer belonging to {+1, -1}<a name="line.937"></a>
-<span class="sourceLineNo">938</span>   *     If a key is a start key of a file, then it maps to +1<a name="line.938"></a>
-<span class="sourceLineNo">939</span>   *     If a key is an end key of a file, then it maps to -1<a name="line.939"></a>
-<span class="sourceLineNo">940</span>   * Algo:<a name="line.940"></a>
-<span class="sourceLineNo">941</span>   * 1) Poll on the keys in order:<a name="line.941"></a>
-<span class="sourceLineNo">942</span>   *    a) Keep adding the mapped values to these keys (runningSum)<a name="line.942"></a>
-<span class="sourceLineNo">943</span>   *    b) Each time runningSum reaches 0, add the start Key from when the runningSum had started to<a name="line.943"></a>
-<span class="sourceLineNo">944</span>   *       a boundary list.<a name="line.944"></a>
-<span class="sourceLineNo">945</span>   * 2) Return the boundary list.<a name="line.945"></a>
-<span class="sourceLineNo">946</span>   */<a name="line.946"></a>
-<span class="sourceLineNo">947</span>  public static byte[][] inferBoundaries(TreeMap&lt;byte[], Integer&gt; bdryMap) {<a name="line.947"></a>
-<span class="sourceLineNo">948</span>    ArrayList&lt;byte[]&gt; keysArray = new ArrayList&lt;byte[]&gt;();<a name="line.948"></a>
-<span class="sourceLineNo">949</span>    int runningValue = 0;<a name="line.949"></a>
-<span class="sourceLineNo">950</span>    byte[] currStartKey = null;<a name="line.950"></a>
-<span class="sourceLineNo">951</span>    boolean firstBoundary = true;<a name="line.951"></a>
-<span class="sourceLineNo">952</span><a name="line.952"></a>
-<span class="sourceLineNo">953</span>    for (Map.Entry&lt;byte[], Integer&gt; item: bdryMap.entrySet()) {<a name="line.953"></a>
-<span class="sourceLineNo">954</span>      if (runningValue == 0) currStartKey = item.getKey();<a name="line.954"></a>
-<span class="sourceLineNo">955</span>      runningValue += item.getValue();<a name="line.955"></a>
-<span class="sourceLineNo">956</span>      if (runningValue == 0) {<a name="line.956"></a>
-<span class="sourceLineNo">957</span>        if (!firstBoundary) keysArray.add(currStartKey);<a name="line.957"></a>
-<span class="sourceLineNo">958</span>        firstBoundary = false;<a name="line.958"></a>
-<span class="sourceLineNo">959</span>      }<a name="line.959"></a>
-<span class="sourceLineNo">960</span>    }<a name="line.960"></a>
-<span class="sourceLineNo">961</span><a name="line.961"></a>
-<span class="sourceLineNo">962</span>    return keysArray.toArray(new byte[0][0]);<a name="line.962"></a>
-<span class="sourceLineNo">963</span>  }<a name="line.963"></a>
-<span class="sourceLineNo">964</span><a name="line.964"></a>
-<span class="sourceLineNo">965</span>  /*<a name="line.965"></a>
-<span class="sourceLineNo">966</span>   * If the table is created for the first time, then "completebulkload" reads the files twice.<a name="line.966"></a>
-<span class="sourceLineNo">967</span>   * More modifications necessary if we want to avoid doing it.<a name="line.967"></a>
-<span class="sourceLineNo">968</span>   */<a name="line.968"></a>
-<span class="sourceLineNo">969</span>  private void createTable(TableName tableName, String dirPath, Admin admin) throws Exception {<a name="line.969"></a>
-<span class="sourceLineNo">970</span>    final Path hfofDir = new Path(dirPath);<a name="line.970"></a>
-<span class="sourceLineNo">971</span>    final FileSystem fs = hfofDir.getFileSystem(getConf());<a name="line.971"></a>
-<span class="sourceLineNo">972</span><a name="line.972"></a>
-<span class="sourceLineNo">973</span>    // Add column families<a name="line.973"></a>
-<span class="sourceLineNo">974</span>    // Build a set of keys<a name="line.974"></a>
-<span class="sourceLineNo">975</span>    final HTableDescriptor htd = new HTableDescriptor(tableName);<a name="line.975"></a>
-<span class="sourceLineNo">976</span>    final TreeMap&lt;byte[], Integer&gt; map = new TreeMap&lt;byte[], Integer&gt;(Bytes.BYTES_COMPARATOR);<a name="line.976"></a>
-<span class="sourceLineNo">977</span>    visitBulkHFiles(fs, hfofDir, new BulkHFileVisitor&lt;HColumnDescriptor&gt;() {<a name="line.977"></a>
-<span class="sourceLineNo">978</span>      @Override<a name="line.978"></a>
-<span class="sourceLineNo">979</span>      public HColumnDescriptor bulkFamily(final byte[] familyName) {<a name="line.979"></a>
-<span class="sourceLineNo">980</span>        HColumnDescriptor hcd = new HColumnDescriptor(familyName);<a name="line.980"></a>
-<span class="sourceLineNo">981</span>        htd.addFamily(hcd);<a name="line.981"></a>
-<span class="sourceLineNo">982</span>        return hcd;<a name="line.982"></a>
-<span class="sourceLineNo">983</span>      }<a name="line.983"></a>
-<span class="sourceLineNo">984</span>      @Override<a name="line.984"></a>
-<span class="sourceLineNo">985</span>      public void bulkHFile(final HColumnDescriptor hcd, final FileStatus hfileStatus)<a name="line.985"></a>
-<span class="sourceLineNo">986</span>          throws IOException {<a name="line.986"></a>
-<span class="sourceLineNo">987</span>        Path hfile = hfileStatus.getPath();<a name="line.987"></a>
-<span class="sourceLineNo">988</span>        HFile.Reader reader = HFile.createReader(fs, hfile,<a name="line.988"></a>
-<span class="sourceLineNo">989</span>            new CacheConfig(getConf()), getConf());<a name="line.989"></a>
-<span class="sourceLineNo">990</span>        try {<a name="line.990"></a>
-<span class="sourceLineNo">991</span>          if (hcd.getCompressionType() != reader.getFileContext().getCompression()) {<a name="line.991"></a>
-<span class="sourceLineNo">992</span>            hcd.setCompressionType(reader.getFileContext().getCompression());<a name="line.992"></a>
-<span class="sourceLineNo">993</span>            LOG.info("Setting compression " + hcd.getCompressionType().name() +<a name="line.993"></a>
-<span class="sourceLineNo">994</span>                     " for family " + hcd.toString());<a name="line.994"></a>
-<span class="sourceLineNo">995</span>          }<a name="line.995"></a>
-<span class="sourceLineNo">996</span>          reader.loadFileInfo();<a name="line.996"></a>
-<span class="sourceLineNo">997</span>          byte[] first = reader.getFirstRowKey();<a name="line.997"></a>
-<span class="sourceLineNo">998</span>          byte[] last  = reader.getLastRowKey();<a name="line.998"></a>
-<span class="sourceLineNo">999</span><a name="line.999"></a>
-<span class="sourceLineNo">1000</span>          LOG.info("Trying to figure out region boundaries hfile=" + hfile +<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>            " first=" + Bytes.toStringBinary(first) +<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>            " last="  + Bytes.toStringBinary(last));<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span><a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>          // To eventually infer start key-end key boundaries<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>          Integer value = map.containsKey(first)? map.get(first):0;<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>          map.put(first, value+1);<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span><a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>          value = map.containsKey(last)? map.get(last):0;<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>          map.put(last, value-1);<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>        } finally {<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>          reader.close();<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>        }<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>      }<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>    });<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span><a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>    byte[][] keys = LoadIncrementalHFiles.inferBoundaries(map);<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>    admin.createTable(htd, keys);<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span><a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>    LOG.info("Table "+ tableName +" is available!!");<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>  }<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span><a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>  @Override<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>  public int run(String[] args) throws Exception {<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>    if (args.length != 2) {<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>      usage();<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>      return -1;<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>    }<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span><a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>    initialize();<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>    try (Connection connection = ConnectionFactory.createConnection(getConf());<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>        Admin admin = connection.getAdmin()) {<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>      String dirPath = args[0];<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>      TableName tableName = TableName.valueOf(args[1]);<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span><a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>      boolean tableExists = admin.tableExists(tableName);<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>      if (!tableExists) {<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>        if ("yes".equalsIgnoreCase(getConf().get(CREATE_TABLE_CONF_KEY, "yes"))) {<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>          this.createTable(tableName, dirPath, admin);<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>        } else {<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>          String errorMsg = format("Table '%s' does not exist.", tableName);<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>          LOG.error(errorMsg);<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>          throw new TableNotFoundException(errorMsg);<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>        }<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>      }<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span><a name="line.1045"></a>
-<span class="sourceLineNo">1046</span>      Path hfofDir = new Path(dirPath);<a name="line.1046"></a>
-<span class="sourceLineNo">1047</span><a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>      try (Table table = connection.getTable(tableName);<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>          RegionLocator locator = connection.getRegionLocator(tableName)) {<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>          doBulkLoad(hfofDir, admin, table, locator);<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>      }<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>    }<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span><a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>    return 0;<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>  }<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span><a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>  public static void main(String[] args) throws Exception {<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>    Configuration conf = HBaseConfiguration.create();<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>    int ret = ToolRunner.run(conf, new LoadIncrementalHFiles(), args);<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span>    System.exit(ret);<a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>  }<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span><a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>  /**<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>   * Called from replication sink, where it manages bulkToken(staging directory) by itself. This is<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>   * used only when {@link SecureBulkLoadEndpoint} is configured in hbase.coprocessor.region.classes<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>   * property. This directory is used as a temporary directory where all files are initially<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>   * copied/moved from user given directory, set all the required file permissions and then from<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>   * their it is finally loaded into a table. This should be set only when, one would like to manage<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>   * the staging directory by itself. Otherwise this tool will handle this by itself.<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>   * @param stagingDir staging directory path<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>   */<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span>  public void setBulkToken(String stagingDir) {<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>    this.bulkToken = stagingDir;<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>  }<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span><a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>}<a name="line.1076"></a>
+<span class="sourceLineNo">906</span>                                  .withIncludesTags(true)<a name="line.906"></a>
+<span class="sourceLineNo">907</span>                                  .build();<a name="line.907"></a>
+<span class="sourceLineNo">908</span>      halfWriter = new StoreFile.WriterBuilder(conf, cacheConf,<a name="line.908"></a>
+<span class="sourceLineNo">909</span>          fs)<a name="line.909"></a>
+<span class="sourceLineNo">910</span>              .withFilePath(outFile)<a name="line.910"></a>
+<span class="sourceLineNo">911</span>              .withBloomType(bloomFilterType)<a name="line.911"></a>
+<span class="sourceLineNo">912</span>              .withFileContext(hFileContext)<a name="line.912"></a>
+<span class="sourceLineNo">913</span>              .build();<a name="line.913"></a>
+<span class="sourceLineNo">914</span>      HFileScanner scanner = halfReader.getScanner(false, false, false);<a name="line.914"></a>
+<span class="sourceLineNo">915</span>      scanner.seekTo();<a name="line.915"></a>
+<span class="sourceLineNo">916</span>      do {<a name="line.916"></a>
+<span class="sourceLineNo">917</span>        halfWriter.append(scanner.getCell());<a name="line.917"></a>
+<span class="sourceLineNo">918</span>      } while (scanner.next());<a name="line.918"></a>
+<span class="sourceLineNo">919</span><a name="line.919"></a>
+<span class="sourceLineNo">920</span>      for (Map.Entry&lt;byte[],byte[]&gt; entry : fileInfo.entrySet()) {<a name="line.920"></a>
+<span class="sourceLineNo">921</span>        if (shouldCopyHFileMetaKey(entry.getKey())) {<a name="line.921"></a>
+<span class="sourceLineNo">922</span>          halfWriter.appendFileInfo(entry.getKey(), entry.getValue());<a name="line.922"></a>
+<span class="sourceLineNo">923</span>        }<a name="line.923"></a>
+<span class="sourceLineNo">924</span>      }<a name="line.924"></a>
+<span class="sourceLineNo">925</span>    } finally {<a name="line.925"></a>
+<span class="sourceLineNo">926</span>      if (halfWriter != null) halfWriter.close();<a name="line.926"></a>
+<span class="sourceLineNo">927</span>      if (halfReader != null) halfReader.close(cacheConf.shouldEvictOnClose());<a name="line.927"></a>
+<span class="sourceLineNo">928</span>    }<a name="line.928"></a>
+<span class="sourceLineNo">929</span>  }<a name="line.929"></a>
+<span class="sourceLineNo">930</span><a name="line.930"></a>
+<span class="sourceLineNo">931</span>  private static boolean shouldCopyHFileMetaKey(byte[] key) {<a name="line.931"></a>
+<span class="sourceLineNo">932</span>    return !HFile.isReservedFileInfoKey(key);<a name="line.932"></a>
+<span class="sourceLineNo">933</span>  }<a name="line.933"></a>
+<span class="sourceLineNo">934</span><a name="line.934"></a>
+<span class="sourceLineNo">935</span>  /*<a name="line.935"></a>
+<span class="sourceLineNo">936</span>   * Infers region boundaries for a new table.<a name="line.936"></a>
+<span class="sourceLineNo">937</span>   * Parameter:<a name="line.937"></a>
+<span class="sourceLineNo">938</span>   *   bdryMap is a map between keys to an integer belonging to {+1, -1}<a name="line.938"></a>
+<span class="sourceLineNo">939</span>   *     If a key is a start key of a file, then it maps to +1<a name="line.939"></a>
+<span class="sourceLineNo">940</span>   *     If a key is an end key of a file, then it maps to -1<a name="line.940"></a>
+<span class="sourceLineNo">941</span>   * Algo:<a name="line.941"></a>
+<span class="sourceLineNo">942</span>   * 1) Poll on the keys in order:<a name="line.942"></a>
+<span class="sourceLineNo">943</span>   *    a) Keep adding the mapped values to these keys (runningSum)<a name="line.943"></a>
+<span class="sourceLineNo">944</span>   *    b) Each time runningSum reaches 0, add the start Key from when the runningSum had started to<a name="line.944"></a>
+<span class="sourceLineNo">945</span>   *       a boundary list.<a name="line.945"></a>
+<span class="sourceLineNo">946</span>   * 2) Return the boundary list.<a name="line.946"></a>
+<span class="sourceLineNo">947</span>   */<a name="line.947"></a>
+<span class="sourceLineNo">948</span>  public static byte[][] inferBoundaries(TreeMap&lt;byte[], Integer&gt; bdryMap) {<a name="line.948"></a>
+<span class="sourceLineNo">949</span>    ArrayList&lt;byte[]&gt; keysArray = new ArrayList&lt;byte[]&gt;();<a name="line.949"></a>
+<span class="sourceLineNo">950</span>    int runningValue = 0;<a name="line.950"></a>
+<span class="sourceLineNo">951</span>    byte[] currStartKey = null;<a name="line.951"></a>
+<span class="sourceLineNo">952</span>    boolean firstBoundary = true;<a name="line.952"></a>
+<span class="sourceLineNo">953</span><a name="line.953"></a>
+<span class="sourceLineNo">954</span>    for (Map.Entry&lt;byte[], Integer&gt; item: bdryMap.entrySet()) {<a name="line.954"></a>
+<span class="sourceLineNo">955</span>      if (runningValue == 0) currStartKey = item.getKey();<a name="line.955"></a>
+<span class="sourceLineNo">956</span>      runningValue += item.getValue();<a name="line.956"></a>
+<span class="sourceLineNo">957</span>      if (runningValue == 0) {<a name="line.957"></a>
+<span class="sourceLineNo">958</span>        if (!firstBoundary) keysArray.add(currStartKey);<a name="line.958"></a>
+<span class="sourceLineNo">959</span>        firstBoundary = false;<a name="line.959"></a>
+<span class="sourceLineNo">960</span>      }<a name="line.960"></a>
+<span class="sourceLineNo">961</span>    }<a name="line.961"></a>
+<span class="sourceLineNo">962</span><a name="line.962"></a>
+<span class="sourceLineNo">963</span>    return keysArray.toArray(new byte[0][0]);<a name="line.963"></a>
+<span class="sourceLineNo">964</span>  }<a name="line.964"></a>
+<span class="sourceLineNo">965</span><a name="line.965"></a>
+<span class="sourceLineNo">966</span>  /*<a name="line.966"></a>
+<span class="sourceLineNo">967</span>   * If the table is created for the first time, then "completebulkload" reads the files twice.<a name="line.967"></a>
+<span class="sourceLineNo">968</span>   * More modifications necessary if we want to avoid doing it.<a name="line.968"></a>
+<span class="sourceLineNo">969</span>   */<a name="line.969"></a>
+<span class="sourceLineNo">970</span>  private void createTable(TableName tableName, String dirPath, Admin admin) throws Exception {<a name="line.970"></a>
+<span class="sourceLineNo">971</span>    final Path hfofDir = new Path(dirPath);<a name="line.971"></a>
+<span class="sourceLineNo">972</span>    final FileSystem fs = hfofDir.getFileSystem(getConf());<a name="line.972"></a>
+<span class="sourceLineNo">973</span><a name="line.973"></a>
+<span class="sourceLineNo">974</span>    // Add column families<a name="line.974"></a>
+<span class="sourceLineNo">975</span>    // Build a set of keys<a name="line.975"></a>
+<span class="sourceLineNo">976</span>    final HTableDescriptor htd = new HTableDescriptor(tableName);<a name="line.976"></a>
+<span class="sourceLineNo">977</span>    final TreeMap&lt;byte[], Integer&gt; map = new TreeMap&lt;byte[], Integer&gt;(Bytes.BYTES_COMPARATOR);<a name="line.977"></a>
+<span class="sourceLineNo">978</span>    visitBulkHFiles(fs, hfofDir, new BulkHFileVisitor&lt;HColumnDescriptor&gt;() {<a name="line.978"></a>
+<span class="sourceLineNo">979</span>      @Override<a name="line.979"></a>
+<span class="sourceLineNo">980</span>      public HColumnDescriptor bulkFamily(final byte[] familyName) {<a name="line.980"></a>
+<span class="sourceLineNo">981</span>        HColumnDescriptor hcd = new HColumnDescriptor(familyName);<a name="line.981"></a>
+<span class="sourceLineNo">982</span>        htd.addFamily(hcd);<a name="line.982"></a>
+<span class="sourceLineNo">983</span>        return hcd;<a name="line.983"></a>
+<span class="sourceLineNo">984</span>      }<a name="line.984"></a>
+<span class="sourceLineNo">985</span>      @Override<a name="line.985"></a>
+<span class="sourceLineNo">986</span>      public void bulkHFile(final HColumnDescriptor hcd, final FileStatus hfileStatus)<a name="line.986"></a>
+<span class="sourceLineNo">987</span>          throws IOException {<a name="line.987"></a>
+<span class="sourceLineNo">988</span>        Path hfile = hfileStatus.getPath();<a name="line.988"></a>
+<span class="sourceLineNo">989</span>        HFile.Reader reader = HFile.createReader(fs, hfile,<a name="line.989"></a>
+<span class="sourceLineNo">990</span>            new CacheConfig(getConf()), getConf());<a name="line.990"></a>
+<span class="sourceLineNo">991</span>        try {<a name="line.991"></a>
+<span class="sourceLineNo">992</span>          if (hcd.getCompressionType() != reader.getFileContext().getCompression()) {<a name="line.992"></a>
+<span class="sourceLineNo">993</span>            hcd.setCompressionType(reader.getFileContext().getCompression());<a name="line.993"></a>
+<span class="sourceLineNo">994</span>            LOG.info("Setting compression " + hcd.getCompressionType().name() +<a name="line.994"></a>
+<span class="sourceLineNo">995</span>                     " for family " + hcd.toString());<a name="line.995"></a>
+<span class="sourceLineNo">996</span>          }<a name="line.996"></a>
+<span class="sourceLineNo">997</span>          reader.loadFileInfo();<a name="line.997"></a>
+<span class="sourceLineNo">998</span>          byte[] first = reader.getFirstRowKey();<a name="line.998"></a>
+<span class="sourceLineNo">999</span>          byte[] last  = reader.getLastRowKey();<a name="line.999"></a>
+<span class="sourceLineNo">1000</span><a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>          LOG.info("Trying to figure out region boundaries hfile=" + hfile +<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>            " first=" + Bytes.toStringBinary(first) +<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>            " last="  + Bytes.toStringBinary(last));<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span><a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>          // To eventually infer start key-end key boundaries<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>          Integer value = map.containsKey(first)? map.get(first):0;<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>          map.put(first, value+1);<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span><a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>          value = map.containsKey(last)? map.get(last):0;<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>          map.put(last, value-1);<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>        } finally {<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>          reader.close();<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>        }<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>      }<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>    });<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span><a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>    byte[][] keys = LoadIncrementalHFiles.inferBoundaries(map);<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span>    admin.createTable(htd, keys);<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span><a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>    LOG.info("Table "+ tableName +" is available!!");<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>  }<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span><a name="line.1022"></a>
+<span class="sourceLineNo">1023</span>  @Override<a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>  public int run(String[] args) throws Exception {<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>    if (args.length != 2) {<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>      usage();<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>      return -1;<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>    }<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span><a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>    initialize();<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>    try (Connection connection = ConnectionFactory.createConnection(getConf());<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>        Admin admin = connection.getAdmin()) {<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>      String dirPath = args[0];<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>      TableName tableName = TableName.valueOf(args[1]);<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span><a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>      boolean tableExists = admin.tableExists(tableName);<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>      if (!tableExists) {<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>        if ("yes".equalsIgnoreCase(getConf().get(CREATE_TABLE_CONF_KEY, "yes"))) {<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>          this.createTable(tableName, dirPath, admin);<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span>        } else {<a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>          String errorMsg = format("Table '%s' does not exist.", tableName);<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>          LOG.error(errorMsg);<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>          throw new TableNotFoundException(errorMsg);<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>        }<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>      }<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span><a name="line.1046"></a>
+<span class="sourceLineNo">1047</span>      Path hfofDir = new Path(dirPath);<a name="line.1047"></a>
+<span class="sourceLineNo">1048</span><a name="line.1048"></a>
+<span class="sourceLineNo">1049</span>      try (Table table = connection.getTable(tableName);<a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>          RegionLocator locator = connection.getRegionLocator(tableName)) {<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>          doBulkLoad(hfofDir, admin, table, locator);<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span>      }<a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>    }<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span><a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>    return 0;<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span>  }<a name="line.1056"></a>
+<span class="sourceLineNo">1057</span><a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>  public static void main(String[] args) throws Exception {<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>    Configuration conf = HBaseConfiguration.create();<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>    int ret = ToolRunner.run(conf, new LoadIncrementalHFiles(), args);<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span>    System.exit(ret);<a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>  }<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span><a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>  /**<a name="line.1064"></a>
+<span class="sourceLineNo">1065</span>   * Called from replication sink, where it manages bulkToken(staging directory) by itself. This is<a name="line.1065"></a>
+<span class="sourceLineNo">1066</span>   * used only when {@link SecureBulkLoadEndpoint} is configured in hbase.coprocessor.region.classes<a name="line.1066"></a>
+<span class="sourceLineNo">1067</span>   * property. This directory is used as a temporary directory where all files are initially<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>   * copied/moved from user given directory, set all the required file permissions and then from<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span>   * their it is finally loaded into a table. This should be set only when, one would like to manage<a name="line.1069"></a>
+<span class="sourceLineNo">1070</span>   * the staging directory by itself. Otherwise this tool will handle this by itself.<a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>   * @param stagingDir staging directory path<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span>   */<a name="line.1072"></a>
+<span class="sourceLineNo">1073</span>  public void setBulkToken(String stagingDir) {<a name="line.1073"></a>
+<span class="sourceLineNo">1074</span>    this.bulkToken = stagingDir;<a name="line.1074"></a>
+<span class="sourceLineNo">1075</span>  }<a name="line.1075"></a>
+<span class="sourceLineNo">1076</span><a name="line.1076"></a>
+<span class="sourceLineNo">1077</span>}<a name="line.1077"></a>
 
 
 


Mime
View raw message