hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [13/32] hbase-site git commit: Published site at a07e755625382d3904c935c21a4f240ede6d2f43.
Date Mon, 13 Aug 2018 14:49:46 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/75e49c45/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.TableStateNotFoundException.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.TableStateNotFoundException.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.TableStateNotFoundException.html
index 623d575..f0acbc8 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.TableStateNotFoundException.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.TableStateNotFoundException.html
@@ -241,151 +241,152 @@
 <span class="sourceLineNo">233</span>    try {<a name="line.233"></a>
 <span class="sourceLineNo">234</span>      MetaTableAccessor.updateTableState(master.getConnection(), tableName, newState);<a name="line.234"></a>
 <span class="sourceLineNo">235</span>      tableName2State.put(tableName, newState);<a name="line.235"></a>
-<span class="sourceLineNo">236</span>    } finally {<a name="line.236"></a>
-<span class="sourceLineNo">237</span>      if (!succ) {<a name="line.237"></a>
-<span class="sourceLineNo">238</span>        tableName2State.remove(tableName);<a name="line.238"></a>
-<span class="sourceLineNo">239</span>      }<a name="line.239"></a>
-<span class="sourceLineNo">240</span>    }<a name="line.240"></a>
-<span class="sourceLineNo">241</span>    metaStateUpdated(tableName, newState);<a name="line.241"></a>
-<span class="sourceLineNo">242</span>  }<a name="line.242"></a>
-<span class="sourceLineNo">243</span><a name="line.243"></a>
-<span class="sourceLineNo">244</span>  protected void metaStateUpdated(TableName tableName, TableState.State newState)<a name="line.244"></a>
-<span class="sourceLineNo">245</span>      throws IOException {<a name="line.245"></a>
-<span class="sourceLineNo">246</span>  }<a name="line.246"></a>
-<span class="sourceLineNo">247</span><a name="line.247"></a>
-<span class="sourceLineNo">248</span>  protected void metaStateDeleted(TableName tableName) throws IOException {<a name="line.248"></a>
-<span class="sourceLineNo">249</span>  }<a name="line.249"></a>
-<span class="sourceLineNo">250</span><a name="line.250"></a>
-<span class="sourceLineNo">251</span>  @Nullable<a name="line.251"></a>
-<span class="sourceLineNo">252</span>  private TableState readMetaState(TableName tableName) throws IOException {<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    TableState.State state = tableName2State.get(tableName);<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    if (state != null) {<a name="line.254"></a>
-<span class="sourceLineNo">255</span>      return new TableState(tableName, state);<a name="line.255"></a>
-<span class="sourceLineNo">256</span>    }<a name="line.256"></a>
-<span class="sourceLineNo">257</span>    TableState tableState = MetaTableAccessor.getTableState(master.getConnection(), tableName);<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    if (tableState != null) {<a name="line.258"></a>
-<span class="sourceLineNo">259</span>      tableName2State.putIfAbsent(tableName, tableState.getState());<a name="line.259"></a>
-<span class="sourceLineNo">260</span>    }<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    return tableState;<a name="line.261"></a>
-<span class="sourceLineNo">262</span>  }<a name="line.262"></a>
-<span class="sourceLineNo">263</span><a name="line.263"></a>
-<span class="sourceLineNo">264</span>  public void start() throws IOException {<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    TableDescriptors tableDescriptors = master.getTableDescriptors();<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    migrateZooKeeper();<a name="line.266"></a>
-<span class="sourceLineNo">267</span>    Connection connection = master.getConnection();<a name="line.267"></a>
-<span class="sourceLineNo">268</span>    fixTableStates(tableDescriptors, connection);<a name="line.268"></a>
-<span class="sourceLineNo">269</span>  }<a name="line.269"></a>
-<span class="sourceLineNo">270</span><a name="line.270"></a>
-<span class="sourceLineNo">271</span>  private void fixTableStates(TableDescriptors tableDescriptors, Connection connection)<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      throws IOException {<a name="line.272"></a>
-<span class="sourceLineNo">273</span>    Map&lt;String, TableDescriptor&gt; allDescriptors = tableDescriptors.getAll();<a name="line.273"></a>
-<span class="sourceLineNo">274</span>    Map&lt;String, TableState&gt; states = new HashMap&lt;&gt;();<a name="line.274"></a>
-<span class="sourceLineNo">275</span>    // NOTE: Ful hbase:meta table scan!<a name="line.275"></a>
-<span class="sourceLineNo">276</span>    MetaTableAccessor.fullScanTables(connection, new MetaTableAccessor.Visitor() {<a name="line.276"></a>
-<span class="sourceLineNo">277</span>      @Override<a name="line.277"></a>
-<span class="sourceLineNo">278</span>      public boolean visit(Result r) throws IOException {<a name="line.278"></a>
-<span class="sourceLineNo">279</span>        TableState state = MetaTableAccessor.getTableState(r);<a name="line.279"></a>
-<span class="sourceLineNo">280</span>        states.put(state.getTableName().getNameAsString(), state);<a name="line.280"></a>
-<span class="sourceLineNo">281</span>        return true;<a name="line.281"></a>
-<span class="sourceLineNo">282</span>      }<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    });<a name="line.283"></a>
-<span class="sourceLineNo">284</span>    for (Map.Entry&lt;String, TableDescriptor&gt; entry : allDescriptors.entrySet()) {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>      TableName tableName = TableName.valueOf(entry.getKey());<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      if (TableName.isMetaTableName(tableName)) {<a name="line.286"></a>
-<span class="sourceLineNo">287</span>        // This table is always enabled. No fixup needed. No entry in hbase:meta needed.<a name="line.287"></a>
-<span class="sourceLineNo">288</span>        // Call through to fixTableState though in case a super class wants to do something.<a name="line.288"></a>
-<span class="sourceLineNo">289</span>        fixTableState(new TableState(tableName, TableState.State.ENABLED));<a name="line.289"></a>
-<span class="sourceLineNo">290</span>        continue;<a name="line.290"></a>
-<span class="sourceLineNo">291</span>      }<a name="line.291"></a>
-<span class="sourceLineNo">292</span>      TableState tableState = states.get(entry.getKey());<a name="line.292"></a>
-<span class="sourceLineNo">293</span>      if (tableState == null) {<a name="line.293"></a>
-<span class="sourceLineNo">294</span>        LOG.warn(tableName + " has no table state in hbase:meta, assuming ENABLED");<a name="line.294"></a>
-<span class="sourceLineNo">295</span>        MetaTableAccessor.updateTableState(connection, tableName, TableState.State.ENABLED);<a name="line.295"></a>
-<span class="sourceLineNo">296</span>        fixTableState(new TableState(tableName, TableState.State.ENABLED));<a name="line.296"></a>
-<span class="sourceLineNo">297</span>        tableName2State.put(tableName, TableState.State.ENABLED);<a name="line.297"></a>
-<span class="sourceLineNo">298</span>      } else {<a name="line.298"></a>
-<span class="sourceLineNo">299</span>        fixTableState(tableState);<a name="line.299"></a>
-<span class="sourceLineNo">300</span>        tableName2State.put(tableName, tableState.getState());<a name="line.300"></a>
-<span class="sourceLineNo">301</span>      }<a name="line.301"></a>
-<span class="sourceLineNo">302</span>    }<a name="line.302"></a>
-<span class="sourceLineNo">303</span>  }<a name="line.303"></a>
-<span class="sourceLineNo">304</span><a name="line.304"></a>
-<span class="sourceLineNo">305</span>  /**<a name="line.305"></a>
-<span class="sourceLineNo">306</span>   * For subclasses in case they want to do fixup post hbase:meta.<a name="line.306"></a>
-<span class="sourceLineNo">307</span>   */<a name="line.307"></a>
-<span class="sourceLineNo">308</span>  protected void fixTableState(TableState tableState) throws IOException {<a name="line.308"></a>
-<span class="sourceLineNo">309</span>  }<a name="line.309"></a>
-<span class="sourceLineNo">310</span><a name="line.310"></a>
-<span class="sourceLineNo">311</span>  /**<a name="line.311"></a>
-<span class="sourceLineNo">312</span>   * This code is for case where a hbase2 Master is starting for the first time. ZooKeeper is where<a name="line.312"></a>
-<span class="sourceLineNo">313</span>   * we used to keep table state. On first startup, read zookeeper and update hbase:meta with the<a name="line.313"></a>
-<span class="sourceLineNo">314</span>   * table states found in zookeeper. This is tricky as we'll do this check every time we startup<a name="line.314"></a>
-<span class="sourceLineNo">315</span>   * until mirroring is disabled. See the {@link #MIGRATE_TABLE_STATE_FROM_ZK_KEY} flag. Original<a name="line.315"></a>
-<span class="sourceLineNo">316</span>   * form of this migration came in with HBASE-13032. It deleted all znodes when done. We can't do<a name="line.316"></a>
-<span class="sourceLineNo">317</span>   * that if we want to support hbase-1.x clients who need to be able to read table state out of zk.<a name="line.317"></a>
-<span class="sourceLineNo">318</span>   * See {@link MirroringTableStateManager}.<a name="line.318"></a>
-<span class="sourceLineNo">319</span>   * @deprecated Since 2.0.0. Remove in hbase-3.0.0.<a name="line.319"></a>
-<span class="sourceLineNo">320</span>   */<a name="line.320"></a>
-<span class="sourceLineNo">321</span>  @Deprecated<a name="line.321"></a>
-<span class="sourceLineNo">322</span>  private void migrateZooKeeper() throws IOException {<a name="line.322"></a>
-<span class="sourceLineNo">323</span>    if (!this.master.getConfiguration().getBoolean(MIGRATE_TABLE_STATE_FROM_ZK_KEY, true)) {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>      return;<a name="line.324"></a>
-<span class="sourceLineNo">325</span>    }<a name="line.325"></a>
-<span class="sourceLineNo">326</span>    try {<a name="line.326"></a>
-<span class="sourceLineNo">327</span>      for (Map.Entry&lt;TableName, TableState.State&gt; entry : ZKDataMigrator<a name="line.327"></a>
-<span class="sourceLineNo">328</span>        .queryForTableStates(this.master.getZooKeeper()).entrySet()) {<a name="line.328"></a>
-<span class="sourceLineNo">329</span>        if (this.master.getTableDescriptors().get(entry.getKey()) == null) {<a name="line.329"></a>
-<span class="sourceLineNo">330</span>          deleteZooKeeper(entry.getKey());<a name="line.330"></a>
-<span class="sourceLineNo">331</span>          LOG.info("Purged table state entry from zookeepr for table not in hbase:meta: " +<a name="line.331"></a>
-<span class="sourceLineNo">332</span>            entry.getKey());<a name="line.332"></a>
-<span class="sourceLineNo">333</span>          continue;<a name="line.333"></a>
-<span class="sourceLineNo">334</span>        }<a name="line.334"></a>
-<span class="sourceLineNo">335</span>        TableState ts = null;<a name="line.335"></a>
-<span class="sourceLineNo">336</span>        try {<a name="line.336"></a>
-<span class="sourceLineNo">337</span>          ts = getTableState(entry.getKey());<a name="line.337"></a>
-<span class="sourceLineNo">338</span>        } catch (TableStateNotFoundException e) {<a name="line.338"></a>
-<span class="sourceLineNo">339</span>          // This can happen; table exists but no TableState.<a name="line.339"></a>
-<span class="sourceLineNo">340</span>        }<a name="line.340"></a>
-<span class="sourceLineNo">341</span>        if (ts == null) {<a name="line.341"></a>
-<span class="sourceLineNo">342</span>          TableState.State zkstate = entry.getValue();<a name="line.342"></a>
-<span class="sourceLineNo">343</span>          // Only migrate if it is an enable or disabled table. If in-between -- ENABLING or<a name="line.343"></a>
-<span class="sourceLineNo">344</span>          // DISABLING then we have a problem; we are starting up an hbase-2 on a cluster with<a name="line.344"></a>
-<span class="sourceLineNo">345</span>          // RIT. It is going to be rough!<a name="line.345"></a>
-<span class="sourceLineNo">346</span>          if (zkstate.equals(TableState.State.ENABLED) ||<a name="line.346"></a>
-<span class="sourceLineNo">347</span>            zkstate.equals(TableState.State.DISABLED)) {<a name="line.347"></a>
-<span class="sourceLineNo">348</span>            LOG.info("Migrating table state from zookeeper to hbase:meta; tableName=" +<a name="line.348"></a>
-<span class="sourceLineNo">349</span>              entry.getKey() + ", state=" + entry.getValue());<a name="line.349"></a>
-<span class="sourceLineNo">350</span>            updateMetaState(entry.getKey(), entry.getValue());<a name="line.350"></a>
-<span class="sourceLineNo">351</span>          } else {<a name="line.351"></a>
-<span class="sourceLineNo">352</span>            LOG.warn("Table={} has no state and zookeeper state is in-between={} (neither " +<a name="line.352"></a>
-<span class="sourceLineNo">353</span>              "ENABLED or DISABLED); NOT MIGRATING table state", entry.getKey(), zkstate);<a name="line.353"></a>
-<span class="sourceLineNo">354</span>          }<a name="line.354"></a>
-<span class="sourceLineNo">355</span>        }<a name="line.355"></a>
-<span class="sourceLineNo">356</span>        // What if the table states disagree? Defer to the hbase:meta setting rather than have the<a name="line.356"></a>
-<span class="sourceLineNo">357</span>        // hbase-1.x support prevail.<a name="line.357"></a>
-<span class="sourceLineNo">358</span>      }<a name="line.358"></a>
-<span class="sourceLineNo">359</span>    } catch (KeeperException | InterruptedException e) {<a name="line.359"></a>
-<span class="sourceLineNo">360</span>      LOG.warn("Failed reading table state from zookeeper", e);<a name="line.360"></a>
-<span class="sourceLineNo">361</span>    }<a name="line.361"></a>
-<span class="sourceLineNo">362</span>  }<a name="line.362"></a>
-<span class="sourceLineNo">363</span><a name="line.363"></a>
-<span class="sourceLineNo">364</span>  /**<a name="line.364"></a>
-<span class="sourceLineNo">365</span>   * Utility method that knows how to delete the old hbase-1.x table state znode. Used also by the<a name="line.365"></a>
-<span class="sourceLineNo">366</span>   * Mirroring subclass.<a name="line.366"></a>
-<span class="sourceLineNo">367</span>   * @deprecated Since 2.0.0. To be removed in hbase-3.0.0.<a name="line.367"></a>
-<span class="sourceLineNo">368</span>   */<a name="line.368"></a>
-<span class="sourceLineNo">369</span>  @Deprecated<a name="line.369"></a>
-<span class="sourceLineNo">370</span>  protected void deleteZooKeeper(TableName tableName) {<a name="line.370"></a>
-<span class="sourceLineNo">371</span>    try {<a name="line.371"></a>
-<span class="sourceLineNo">372</span>      // Delete from ZooKeeper<a name="line.372"></a>
-<span class="sourceLineNo">373</span>      String znode = ZNodePaths.joinZNode(this.master.getZooKeeper().getZNodePaths().tableZNode,<a name="line.373"></a>
-<span class="sourceLineNo">374</span>        tableName.getNameAsString());<a name="line.374"></a>
-<span class="sourceLineNo">375</span>      ZKUtil.deleteNodeFailSilent(this.master.getZooKeeper(), znode);<a name="line.375"></a>
-<span class="sourceLineNo">376</span>    } catch (KeeperException e) {<a name="line.376"></a>
-<span class="sourceLineNo">377</span>      LOG.warn("Failed deleting table state from zookeeper", e);<a name="line.377"></a>
-<span class="sourceLineNo">378</span>    }<a name="line.378"></a>
-<span class="sourceLineNo">379</span>  }<a name="line.379"></a>
-<span class="sourceLineNo">380</span>}<a name="line.380"></a>
+<span class="sourceLineNo">236</span>      succ = true;<a name="line.236"></a>
+<span class="sourceLineNo">237</span>    } finally {<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      if (!succ) {<a name="line.238"></a>
+<span class="sourceLineNo">239</span>        tableName2State.remove(tableName);<a name="line.239"></a>
+<span class="sourceLineNo">240</span>      }<a name="line.240"></a>
+<span class="sourceLineNo">241</span>    }<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    metaStateUpdated(tableName, newState);<a name="line.242"></a>
+<span class="sourceLineNo">243</span>  }<a name="line.243"></a>
+<span class="sourceLineNo">244</span><a name="line.244"></a>
+<span class="sourceLineNo">245</span>  protected void metaStateUpdated(TableName tableName, TableState.State newState)<a name="line.245"></a>
+<span class="sourceLineNo">246</span>      throws IOException {<a name="line.246"></a>
+<span class="sourceLineNo">247</span>  }<a name="line.247"></a>
+<span class="sourceLineNo">248</span><a name="line.248"></a>
+<span class="sourceLineNo">249</span>  protected void metaStateDeleted(TableName tableName) throws IOException {<a name="line.249"></a>
+<span class="sourceLineNo">250</span>  }<a name="line.250"></a>
+<span class="sourceLineNo">251</span><a name="line.251"></a>
+<span class="sourceLineNo">252</span>  @Nullable<a name="line.252"></a>
+<span class="sourceLineNo">253</span>  private TableState readMetaState(TableName tableName) throws IOException {<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    TableState.State state = tableName2State.get(tableName);<a name="line.254"></a>
+<span class="sourceLineNo">255</span>    if (state != null) {<a name="line.255"></a>
+<span class="sourceLineNo">256</span>      return new TableState(tableName, state);<a name="line.256"></a>
+<span class="sourceLineNo">257</span>    }<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    TableState tableState = MetaTableAccessor.getTableState(master.getConnection(), tableName);<a name="line.258"></a>
+<span class="sourceLineNo">259</span>    if (tableState != null) {<a name="line.259"></a>
+<span class="sourceLineNo">260</span>      tableName2State.putIfAbsent(tableName, tableState.getState());<a name="line.260"></a>
+<span class="sourceLineNo">261</span>    }<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    return tableState;<a name="line.262"></a>
+<span class="sourceLineNo">263</span>  }<a name="line.263"></a>
+<span class="sourceLineNo">264</span><a name="line.264"></a>
+<span class="sourceLineNo">265</span>  public void start() throws IOException {<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    TableDescriptors tableDescriptors = master.getTableDescriptors();<a name="line.266"></a>
+<span class="sourceLineNo">267</span>    migrateZooKeeper();<a name="line.267"></a>
+<span class="sourceLineNo">268</span>    Connection connection = master.getConnection();<a name="line.268"></a>
+<span class="sourceLineNo">269</span>    fixTableStates(tableDescriptors, connection);<a name="line.269"></a>
+<span class="sourceLineNo">270</span>  }<a name="line.270"></a>
+<span class="sourceLineNo">271</span><a name="line.271"></a>
+<span class="sourceLineNo">272</span>  private void fixTableStates(TableDescriptors tableDescriptors, Connection connection)<a name="line.272"></a>
+<span class="sourceLineNo">273</span>      throws IOException {<a name="line.273"></a>
+<span class="sourceLineNo">274</span>    Map&lt;String, TableDescriptor&gt; allDescriptors = tableDescriptors.getAll();<a name="line.274"></a>
+<span class="sourceLineNo">275</span>    Map&lt;String, TableState&gt; states = new HashMap&lt;&gt;();<a name="line.275"></a>
+<span class="sourceLineNo">276</span>    // NOTE: Ful hbase:meta table scan!<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    MetaTableAccessor.fullScanTables(connection, new MetaTableAccessor.Visitor() {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      @Override<a name="line.278"></a>
+<span class="sourceLineNo">279</span>      public boolean visit(Result r) throws IOException {<a name="line.279"></a>
+<span class="sourceLineNo">280</span>        TableState state = MetaTableAccessor.getTableState(r);<a name="line.280"></a>
+<span class="sourceLineNo">281</span>        states.put(state.getTableName().getNameAsString(), state);<a name="line.281"></a>
+<span class="sourceLineNo">282</span>        return true;<a name="line.282"></a>
+<span class="sourceLineNo">283</span>      }<a name="line.283"></a>
+<span class="sourceLineNo">284</span>    });<a name="line.284"></a>
+<span class="sourceLineNo">285</span>    for (Map.Entry&lt;String, TableDescriptor&gt; entry : allDescriptors.entrySet()) {<a name="line.285"></a>
+<span class="sourceLineNo">286</span>      TableName tableName = TableName.valueOf(entry.getKey());<a name="line.286"></a>
+<span class="sourceLineNo">287</span>      if (TableName.isMetaTableName(tableName)) {<a name="line.287"></a>
+<span class="sourceLineNo">288</span>        // This table is always enabled. No fixup needed. No entry in hbase:meta needed.<a name="line.288"></a>
+<span class="sourceLineNo">289</span>        // Call through to fixTableState though in case a super class wants to do something.<a name="line.289"></a>
+<span class="sourceLineNo">290</span>        fixTableState(new TableState(tableName, TableState.State.ENABLED));<a name="line.290"></a>
+<span class="sourceLineNo">291</span>        continue;<a name="line.291"></a>
+<span class="sourceLineNo">292</span>      }<a name="line.292"></a>
+<span class="sourceLineNo">293</span>      TableState tableState = states.get(entry.getKey());<a name="line.293"></a>
+<span class="sourceLineNo">294</span>      if (tableState == null) {<a name="line.294"></a>
+<span class="sourceLineNo">295</span>        LOG.warn(tableName + " has no table state in hbase:meta, assuming ENABLED");<a name="line.295"></a>
+<span class="sourceLineNo">296</span>        MetaTableAccessor.updateTableState(connection, tableName, TableState.State.ENABLED);<a name="line.296"></a>
+<span class="sourceLineNo">297</span>        fixTableState(new TableState(tableName, TableState.State.ENABLED));<a name="line.297"></a>
+<span class="sourceLineNo">298</span>        tableName2State.put(tableName, TableState.State.ENABLED);<a name="line.298"></a>
+<span class="sourceLineNo">299</span>      } else {<a name="line.299"></a>
+<span class="sourceLineNo">300</span>        fixTableState(tableState);<a name="line.300"></a>
+<span class="sourceLineNo">301</span>        tableName2State.put(tableName, tableState.getState());<a name="line.301"></a>
+<span class="sourceLineNo">302</span>      }<a name="line.302"></a>
+<span class="sourceLineNo">303</span>    }<a name="line.303"></a>
+<span class="sourceLineNo">304</span>  }<a name="line.304"></a>
+<span class="sourceLineNo">305</span><a name="line.305"></a>
+<span class="sourceLineNo">306</span>  /**<a name="line.306"></a>
+<span class="sourceLineNo">307</span>   * For subclasses in case they want to do fixup post hbase:meta.<a name="line.307"></a>
+<span class="sourceLineNo">308</span>   */<a name="line.308"></a>
+<span class="sourceLineNo">309</span>  protected void fixTableState(TableState tableState) throws IOException {<a name="line.309"></a>
+<span class="sourceLineNo">310</span>  }<a name="line.310"></a>
+<span class="sourceLineNo">311</span><a name="line.311"></a>
+<span class="sourceLineNo">312</span>  /**<a name="line.312"></a>
+<span class="sourceLineNo">313</span>   * This code is for case where a hbase2 Master is starting for the first time. ZooKeeper is where<a name="line.313"></a>
+<span class="sourceLineNo">314</span>   * we used to keep table state. On first startup, read zookeeper and update hbase:meta with the<a name="line.314"></a>
+<span class="sourceLineNo">315</span>   * table states found in zookeeper. This is tricky as we'll do this check every time we startup<a name="line.315"></a>
+<span class="sourceLineNo">316</span>   * until mirroring is disabled. See the {@link #MIGRATE_TABLE_STATE_FROM_ZK_KEY} flag. Original<a name="line.316"></a>
+<span class="sourceLineNo">317</span>   * form of this migration came in with HBASE-13032. It deleted all znodes when done. We can't do<a name="line.317"></a>
+<span class="sourceLineNo">318</span>   * that if we want to support hbase-1.x clients who need to be able to read table state out of zk.<a name="line.318"></a>
+<span class="sourceLineNo">319</span>   * See {@link MirroringTableStateManager}.<a name="line.319"></a>
+<span class="sourceLineNo">320</span>   * @deprecated Since 2.0.0. Remove in hbase-3.0.0.<a name="line.320"></a>
+<span class="sourceLineNo">321</span>   */<a name="line.321"></a>
+<span class="sourceLineNo">322</span>  @Deprecated<a name="line.322"></a>
+<span class="sourceLineNo">323</span>  private void migrateZooKeeper() throws IOException {<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    if (!this.master.getConfiguration().getBoolean(MIGRATE_TABLE_STATE_FROM_ZK_KEY, true)) {<a name="line.324"></a>
+<span class="sourceLineNo">325</span>      return;<a name="line.325"></a>
+<span class="sourceLineNo">326</span>    }<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    try {<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      for (Map.Entry&lt;TableName, TableState.State&gt; entry : ZKDataMigrator<a name="line.328"></a>
+<span class="sourceLineNo">329</span>        .queryForTableStates(this.master.getZooKeeper()).entrySet()) {<a name="line.329"></a>
+<span class="sourceLineNo">330</span>        if (this.master.getTableDescriptors().get(entry.getKey()) == null) {<a name="line.330"></a>
+<span class="sourceLineNo">331</span>          deleteZooKeeper(entry.getKey());<a name="line.331"></a>
+<span class="sourceLineNo">332</span>          LOG.info("Purged table state entry from zookeepr for table not in hbase:meta: " +<a name="line.332"></a>
+<span class="sourceLineNo">333</span>            entry.getKey());<a name="line.333"></a>
+<span class="sourceLineNo">334</span>          continue;<a name="line.334"></a>
+<span class="sourceLineNo">335</span>        }<a name="line.335"></a>
+<span class="sourceLineNo">336</span>        TableState ts = null;<a name="line.336"></a>
+<span class="sourceLineNo">337</span>        try {<a name="line.337"></a>
+<span class="sourceLineNo">338</span>          ts = getTableState(entry.getKey());<a name="line.338"></a>
+<span class="sourceLineNo">339</span>        } catch (TableStateNotFoundException e) {<a name="line.339"></a>
+<span class="sourceLineNo">340</span>          // This can happen; table exists but no TableState.<a name="line.340"></a>
+<span class="sourceLineNo">341</span>        }<a name="line.341"></a>
+<span class="sourceLineNo">342</span>        if (ts == null) {<a name="line.342"></a>
+<span class="sourceLineNo">343</span>          TableState.State zkstate = entry.getValue();<a name="line.343"></a>
+<span class="sourceLineNo">344</span>          // Only migrate if it is an enable or disabled table. If in-between -- ENABLING or<a name="line.344"></a>
+<span class="sourceLineNo">345</span>          // DISABLING then we have a problem; we are starting up an hbase-2 on a cluster with<a name="line.345"></a>
+<span class="sourceLineNo">346</span>          // RIT. It is going to be rough!<a name="line.346"></a>
+<span class="sourceLineNo">347</span>          if (zkstate.equals(TableState.State.ENABLED) ||<a name="line.347"></a>
+<span class="sourceLineNo">348</span>            zkstate.equals(TableState.State.DISABLED)) {<a name="line.348"></a>
+<span class="sourceLineNo">349</span>            LOG.info("Migrating table state from zookeeper to hbase:meta; tableName=" +<a name="line.349"></a>
+<span class="sourceLineNo">350</span>              entry.getKey() + ", state=" + entry.getValue());<a name="line.350"></a>
+<span class="sourceLineNo">351</span>            updateMetaState(entry.getKey(), entry.getValue());<a name="line.351"></a>
+<span class="sourceLineNo">352</span>          } else {<a name="line.352"></a>
+<span class="sourceLineNo">353</span>            LOG.warn("Table={} has no state and zookeeper state is in-between={} (neither " +<a name="line.353"></a>
+<span class="sourceLineNo">354</span>              "ENABLED or DISABLED); NOT MIGRATING table state", entry.getKey(), zkstate);<a name="line.354"></a>
+<span class="sourceLineNo">355</span>          }<a name="line.355"></a>
+<span class="sourceLineNo">356</span>        }<a name="line.356"></a>
+<span class="sourceLineNo">357</span>        // What if the table states disagree? Defer to the hbase:meta setting rather than have the<a name="line.357"></a>
+<span class="sourceLineNo">358</span>        // hbase-1.x support prevail.<a name="line.358"></a>
+<span class="sourceLineNo">359</span>      }<a name="line.359"></a>
+<span class="sourceLineNo">360</span>    } catch (KeeperException | InterruptedException e) {<a name="line.360"></a>
+<span class="sourceLineNo">361</span>      LOG.warn("Failed reading table state from zookeeper", e);<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    }<a name="line.362"></a>
+<span class="sourceLineNo">363</span>  }<a name="line.363"></a>
+<span class="sourceLineNo">364</span><a name="line.364"></a>
+<span class="sourceLineNo">365</span>  /**<a name="line.365"></a>
+<span class="sourceLineNo">366</span>   * Utility method that knows how to delete the old hbase-1.x table state znode. Used also by the<a name="line.366"></a>
+<span class="sourceLineNo">367</span>   * Mirroring subclass.<a name="line.367"></a>
+<span class="sourceLineNo">368</span>   * @deprecated Since 2.0.0. To be removed in hbase-3.0.0.<a name="line.368"></a>
+<span class="sourceLineNo">369</span>   */<a name="line.369"></a>
+<span class="sourceLineNo">370</span>  @Deprecated<a name="line.370"></a>
+<span class="sourceLineNo">371</span>  protected void deleteZooKeeper(TableName tableName) {<a name="line.371"></a>
+<span class="sourceLineNo">372</span>    try {<a name="line.372"></a>
+<span class="sourceLineNo">373</span>      // Delete from ZooKeeper<a name="line.373"></a>
+<span class="sourceLineNo">374</span>      String znode = ZNodePaths.joinZNode(this.master.getZooKeeper().getZNodePaths().tableZNode,<a name="line.374"></a>
+<span class="sourceLineNo">375</span>        tableName.getNameAsString());<a name="line.375"></a>
+<span class="sourceLineNo">376</span>      ZKUtil.deleteNodeFailSilent(this.master.getZooKeeper(), znode);<a name="line.376"></a>
+<span class="sourceLineNo">377</span>    } catch (KeeperException e) {<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      LOG.warn("Failed deleting table state from zookeeper", e);<a name="line.378"></a>
+<span class="sourceLineNo">379</span>    }<a name="line.379"></a>
+<span class="sourceLineNo">380</span>  }<a name="line.380"></a>
+<span class="sourceLineNo">381</span>}<a name="line.381"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/75e49c45/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.html
index 623d575..f0acbc8 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/TableStateManager.html
@@ -241,151 +241,152 @@
 <span class="sourceLineNo">233</span>    try {<a name="line.233"></a>
 <span class="sourceLineNo">234</span>      MetaTableAccessor.updateTableState(master.getConnection(), tableName, newState);<a name="line.234"></a>
 <span class="sourceLineNo">235</span>      tableName2State.put(tableName, newState);<a name="line.235"></a>
-<span class="sourceLineNo">236</span>    } finally {<a name="line.236"></a>
-<span class="sourceLineNo">237</span>      if (!succ) {<a name="line.237"></a>
-<span class="sourceLineNo">238</span>        tableName2State.remove(tableName);<a name="line.238"></a>
-<span class="sourceLineNo">239</span>      }<a name="line.239"></a>
-<span class="sourceLineNo">240</span>    }<a name="line.240"></a>
-<span class="sourceLineNo">241</span>    metaStateUpdated(tableName, newState);<a name="line.241"></a>
-<span class="sourceLineNo">242</span>  }<a name="line.242"></a>
-<span class="sourceLineNo">243</span><a name="line.243"></a>
-<span class="sourceLineNo">244</span>  protected void metaStateUpdated(TableName tableName, TableState.State newState)<a name="line.244"></a>
-<span class="sourceLineNo">245</span>      throws IOException {<a name="line.245"></a>
-<span class="sourceLineNo">246</span>  }<a name="line.246"></a>
-<span class="sourceLineNo">247</span><a name="line.247"></a>
-<span class="sourceLineNo">248</span>  protected void metaStateDeleted(TableName tableName) throws IOException {<a name="line.248"></a>
-<span class="sourceLineNo">249</span>  }<a name="line.249"></a>
-<span class="sourceLineNo">250</span><a name="line.250"></a>
-<span class="sourceLineNo">251</span>  @Nullable<a name="line.251"></a>
-<span class="sourceLineNo">252</span>  private TableState readMetaState(TableName tableName) throws IOException {<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    TableState.State state = tableName2State.get(tableName);<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    if (state != null) {<a name="line.254"></a>
-<span class="sourceLineNo">255</span>      return new TableState(tableName, state);<a name="line.255"></a>
-<span class="sourceLineNo">256</span>    }<a name="line.256"></a>
-<span class="sourceLineNo">257</span>    TableState tableState = MetaTableAccessor.getTableState(master.getConnection(), tableName);<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    if (tableState != null) {<a name="line.258"></a>
-<span class="sourceLineNo">259</span>      tableName2State.putIfAbsent(tableName, tableState.getState());<a name="line.259"></a>
-<span class="sourceLineNo">260</span>    }<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    return tableState;<a name="line.261"></a>
-<span class="sourceLineNo">262</span>  }<a name="line.262"></a>
-<span class="sourceLineNo">263</span><a name="line.263"></a>
-<span class="sourceLineNo">264</span>  public void start() throws IOException {<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    TableDescriptors tableDescriptors = master.getTableDescriptors();<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    migrateZooKeeper();<a name="line.266"></a>
-<span class="sourceLineNo">267</span>    Connection connection = master.getConnection();<a name="line.267"></a>
-<span class="sourceLineNo">268</span>    fixTableStates(tableDescriptors, connection);<a name="line.268"></a>
-<span class="sourceLineNo">269</span>  }<a name="line.269"></a>
-<span class="sourceLineNo">270</span><a name="line.270"></a>
-<span class="sourceLineNo">271</span>  private void fixTableStates(TableDescriptors tableDescriptors, Connection connection)<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      throws IOException {<a name="line.272"></a>
-<span class="sourceLineNo">273</span>    Map&lt;String, TableDescriptor&gt; allDescriptors = tableDescriptors.getAll();<a name="line.273"></a>
-<span class="sourceLineNo">274</span>    Map&lt;String, TableState&gt; states = new HashMap&lt;&gt;();<a name="line.274"></a>
-<span class="sourceLineNo">275</span>    // NOTE: Ful hbase:meta table scan!<a name="line.275"></a>
-<span class="sourceLineNo">276</span>    MetaTableAccessor.fullScanTables(connection, new MetaTableAccessor.Visitor() {<a name="line.276"></a>
-<span class="sourceLineNo">277</span>      @Override<a name="line.277"></a>
-<span class="sourceLineNo">278</span>      public boolean visit(Result r) throws IOException {<a name="line.278"></a>
-<span class="sourceLineNo">279</span>        TableState state = MetaTableAccessor.getTableState(r);<a name="line.279"></a>
-<span class="sourceLineNo">280</span>        states.put(state.getTableName().getNameAsString(), state);<a name="line.280"></a>
-<span class="sourceLineNo">281</span>        return true;<a name="line.281"></a>
-<span class="sourceLineNo">282</span>      }<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    });<a name="line.283"></a>
-<span class="sourceLineNo">284</span>    for (Map.Entry&lt;String, TableDescriptor&gt; entry : allDescriptors.entrySet()) {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>      TableName tableName = TableName.valueOf(entry.getKey());<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      if (TableName.isMetaTableName(tableName)) {<a name="line.286"></a>
-<span class="sourceLineNo">287</span>        // This table is always enabled. No fixup needed. No entry in hbase:meta needed.<a name="line.287"></a>
-<span class="sourceLineNo">288</span>        // Call through to fixTableState though in case a super class wants to do something.<a name="line.288"></a>
-<span class="sourceLineNo">289</span>        fixTableState(new TableState(tableName, TableState.State.ENABLED));<a name="line.289"></a>
-<span class="sourceLineNo">290</span>        continue;<a name="line.290"></a>
-<span class="sourceLineNo">291</span>      }<a name="line.291"></a>
-<span class="sourceLineNo">292</span>      TableState tableState = states.get(entry.getKey());<a name="line.292"></a>
-<span class="sourceLineNo">293</span>      if (tableState == null) {<a name="line.293"></a>
-<span class="sourceLineNo">294</span>        LOG.warn(tableName + " has no table state in hbase:meta, assuming ENABLED");<a name="line.294"></a>
-<span class="sourceLineNo">295</span>        MetaTableAccessor.updateTableState(connection, tableName, TableState.State.ENABLED);<a name="line.295"></a>
-<span class="sourceLineNo">296</span>        fixTableState(new TableState(tableName, TableState.State.ENABLED));<a name="line.296"></a>
-<span class="sourceLineNo">297</span>        tableName2State.put(tableName, TableState.State.ENABLED);<a name="line.297"></a>
-<span class="sourceLineNo">298</span>      } else {<a name="line.298"></a>
-<span class="sourceLineNo">299</span>        fixTableState(tableState);<a name="line.299"></a>
-<span class="sourceLineNo">300</span>        tableName2State.put(tableName, tableState.getState());<a name="line.300"></a>
-<span class="sourceLineNo">301</span>      }<a name="line.301"></a>
-<span class="sourceLineNo">302</span>    }<a name="line.302"></a>
-<span class="sourceLineNo">303</span>  }<a name="line.303"></a>
-<span class="sourceLineNo">304</span><a name="line.304"></a>
-<span class="sourceLineNo">305</span>  /**<a name="line.305"></a>
-<span class="sourceLineNo">306</span>   * For subclasses in case they want to do fixup post hbase:meta.<a name="line.306"></a>
-<span class="sourceLineNo">307</span>   */<a name="line.307"></a>
-<span class="sourceLineNo">308</span>  protected void fixTableState(TableState tableState) throws IOException {<a name="line.308"></a>
-<span class="sourceLineNo">309</span>  }<a name="line.309"></a>
-<span class="sourceLineNo">310</span><a name="line.310"></a>
-<span class="sourceLineNo">311</span>  /**<a name="line.311"></a>
-<span class="sourceLineNo">312</span>   * This code is for case where a hbase2 Master is starting for the first time. ZooKeeper is where<a name="line.312"></a>
-<span class="sourceLineNo">313</span>   * we used to keep table state. On first startup, read zookeeper and update hbase:meta with the<a name="line.313"></a>
-<span class="sourceLineNo">314</span>   * table states found in zookeeper. This is tricky as we'll do this check every time we startup<a name="line.314"></a>
-<span class="sourceLineNo">315</span>   * until mirroring is disabled. See the {@link #MIGRATE_TABLE_STATE_FROM_ZK_KEY} flag. Original<a name="line.315"></a>
-<span class="sourceLineNo">316</span>   * form of this migration came in with HBASE-13032. It deleted all znodes when done. We can't do<a name="line.316"></a>
-<span class="sourceLineNo">317</span>   * that if we want to support hbase-1.x clients who need to be able to read table state out of zk.<a name="line.317"></a>
-<span class="sourceLineNo">318</span>   * See {@link MirroringTableStateManager}.<a name="line.318"></a>
-<span class="sourceLineNo">319</span>   * @deprecated Since 2.0.0. Remove in hbase-3.0.0.<a name="line.319"></a>
-<span class="sourceLineNo">320</span>   */<a name="line.320"></a>
-<span class="sourceLineNo">321</span>  @Deprecated<a name="line.321"></a>
-<span class="sourceLineNo">322</span>  private void migrateZooKeeper() throws IOException {<a name="line.322"></a>
-<span class="sourceLineNo">323</span>    if (!this.master.getConfiguration().getBoolean(MIGRATE_TABLE_STATE_FROM_ZK_KEY, true)) {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>      return;<a name="line.324"></a>
-<span class="sourceLineNo">325</span>    }<a name="line.325"></a>
-<span class="sourceLineNo">326</span>    try {<a name="line.326"></a>
-<span class="sourceLineNo">327</span>      for (Map.Entry&lt;TableName, TableState.State&gt; entry : ZKDataMigrator<a name="line.327"></a>
-<span class="sourceLineNo">328</span>        .queryForTableStates(this.master.getZooKeeper()).entrySet()) {<a name="line.328"></a>
-<span class="sourceLineNo">329</span>        if (this.master.getTableDescriptors().get(entry.getKey()) == null) {<a name="line.329"></a>
-<span class="sourceLineNo">330</span>          deleteZooKeeper(entry.getKey());<a name="line.330"></a>
-<span class="sourceLineNo">331</span>          LOG.info("Purged table state entry from zookeepr for table not in hbase:meta: " +<a name="line.331"></a>
-<span class="sourceLineNo">332</span>            entry.getKey());<a name="line.332"></a>
-<span class="sourceLineNo">333</span>          continue;<a name="line.333"></a>
-<span class="sourceLineNo">334</span>        }<a name="line.334"></a>
-<span class="sourceLineNo">335</span>        TableState ts = null;<a name="line.335"></a>
-<span class="sourceLineNo">336</span>        try {<a name="line.336"></a>
-<span class="sourceLineNo">337</span>          ts = getTableState(entry.getKey());<a name="line.337"></a>
-<span class="sourceLineNo">338</span>        } catch (TableStateNotFoundException e) {<a name="line.338"></a>
-<span class="sourceLineNo">339</span>          // This can happen; table exists but no TableState.<a name="line.339"></a>
-<span class="sourceLineNo">340</span>        }<a name="line.340"></a>
-<span class="sourceLineNo">341</span>        if (ts == null) {<a name="line.341"></a>
-<span class="sourceLineNo">342</span>          TableState.State zkstate = entry.getValue();<a name="line.342"></a>
-<span class="sourceLineNo">343</span>          // Only migrate if it is an enable or disabled table. If in-between -- ENABLING or<a name="line.343"></a>
-<span class="sourceLineNo">344</span>          // DISABLING then we have a problem; we are starting up an hbase-2 on a cluster with<a name="line.344"></a>
-<span class="sourceLineNo">345</span>          // RIT. It is going to be rough!<a name="line.345"></a>
-<span class="sourceLineNo">346</span>          if (zkstate.equals(TableState.State.ENABLED) ||<a name="line.346"></a>
-<span class="sourceLineNo">347</span>            zkstate.equals(TableState.State.DISABLED)) {<a name="line.347"></a>
-<span class="sourceLineNo">348</span>            LOG.info("Migrating table state from zookeeper to hbase:meta; tableName=" +<a name="line.348"></a>
-<span class="sourceLineNo">349</span>              entry.getKey() + ", state=" + entry.getValue());<a name="line.349"></a>
-<span class="sourceLineNo">350</span>            updateMetaState(entry.getKey(), entry.getValue());<a name="line.350"></a>
-<span class="sourceLineNo">351</span>          } else {<a name="line.351"></a>
-<span class="sourceLineNo">352</span>            LOG.warn("Table={} has no state and zookeeper state is in-between={} (neither " +<a name="line.352"></a>
-<span class="sourceLineNo">353</span>              "ENABLED or DISABLED); NOT MIGRATING table state", entry.getKey(), zkstate);<a name="line.353"></a>
-<span class="sourceLineNo">354</span>          }<a name="line.354"></a>
-<span class="sourceLineNo">355</span>        }<a name="line.355"></a>
-<span class="sourceLineNo">356</span>        // What if the table states disagree? Defer to the hbase:meta setting rather than have the<a name="line.356"></a>
-<span class="sourceLineNo">357</span>        // hbase-1.x support prevail.<a name="line.357"></a>
-<span class="sourceLineNo">358</span>      }<a name="line.358"></a>
-<span class="sourceLineNo">359</span>    } catch (KeeperException | InterruptedException e) {<a name="line.359"></a>
-<span class="sourceLineNo">360</span>      LOG.warn("Failed reading table state from zookeeper", e);<a name="line.360"></a>
-<span class="sourceLineNo">361</span>    }<a name="line.361"></a>
-<span class="sourceLineNo">362</span>  }<a name="line.362"></a>
-<span class="sourceLineNo">363</span><a name="line.363"></a>
-<span class="sourceLineNo">364</span>  /**<a name="line.364"></a>
-<span class="sourceLineNo">365</span>   * Utility method that knows how to delete the old hbase-1.x table state znode. Used also by the<a name="line.365"></a>
-<span class="sourceLineNo">366</span>   * Mirroring subclass.<a name="line.366"></a>
-<span class="sourceLineNo">367</span>   * @deprecated Since 2.0.0. To be removed in hbase-3.0.0.<a name="line.367"></a>
-<span class="sourceLineNo">368</span>   */<a name="line.368"></a>
-<span class="sourceLineNo">369</span>  @Deprecated<a name="line.369"></a>
-<span class="sourceLineNo">370</span>  protected void deleteZooKeeper(TableName tableName) {<a name="line.370"></a>
-<span class="sourceLineNo">371</span>    try {<a name="line.371"></a>
-<span class="sourceLineNo">372</span>      // Delete from ZooKeeper<a name="line.372"></a>
-<span class="sourceLineNo">373</span>      String znode = ZNodePaths.joinZNode(this.master.getZooKeeper().getZNodePaths().tableZNode,<a name="line.373"></a>
-<span class="sourceLineNo">374</span>        tableName.getNameAsString());<a name="line.374"></a>
-<span class="sourceLineNo">375</span>      ZKUtil.deleteNodeFailSilent(this.master.getZooKeeper(), znode);<a name="line.375"></a>
-<span class="sourceLineNo">376</span>    } catch (KeeperException e) {<a name="line.376"></a>
-<span class="sourceLineNo">377</span>      LOG.warn("Failed deleting table state from zookeeper", e);<a name="line.377"></a>
-<span class="sourceLineNo">378</span>    }<a name="line.378"></a>
-<span class="sourceLineNo">379</span>  }<a name="line.379"></a>
-<span class="sourceLineNo">380</span>}<a name="line.380"></a>
+<span class="sourceLineNo">236</span>      succ = true;<a name="line.236"></a>
+<span class="sourceLineNo">237</span>    } finally {<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      if (!succ) {<a name="line.238"></a>
+<span class="sourceLineNo">239</span>        tableName2State.remove(tableName);<a name="line.239"></a>
+<span class="sourceLineNo">240</span>      }<a name="line.240"></a>
+<span class="sourceLineNo">241</span>    }<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    metaStateUpdated(tableName, newState);<a name="line.242"></a>
+<span class="sourceLineNo">243</span>  }<a name="line.243"></a>
+<span class="sourceLineNo">244</span><a name="line.244"></a>
+<span class="sourceLineNo">245</span>  protected void metaStateUpdated(TableName tableName, TableState.State newState)<a name="line.245"></a>
+<span class="sourceLineNo">246</span>      throws IOException {<a name="line.246"></a>
+<span class="sourceLineNo">247</span>  }<a name="line.247"></a>
+<span class="sourceLineNo">248</span><a name="line.248"></a>
+<span class="sourceLineNo">249</span>  protected void metaStateDeleted(TableName tableName) throws IOException {<a name="line.249"></a>
+<span class="sourceLineNo">250</span>  }<a name="line.250"></a>
+<span class="sourceLineNo">251</span><a name="line.251"></a>
+<span class="sourceLineNo">252</span>  @Nullable<a name="line.252"></a>
+<span class="sourceLineNo">253</span>  private TableState readMetaState(TableName tableName) throws IOException {<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    TableState.State state = tableName2State.get(tableName);<a name="line.254"></a>
+<span class="sourceLineNo">255</span>    if (state != null) {<a name="line.255"></a>
+<span class="sourceLineNo">256</span>      return new TableState(tableName, state);<a name="line.256"></a>
+<span class="sourceLineNo">257</span>    }<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    TableState tableState = MetaTableAccessor.getTableState(master.getConnection(), tableName);<a name="line.258"></a>
+<span class="sourceLineNo">259</span>    if (tableState != null) {<a name="line.259"></a>
+<span class="sourceLineNo">260</span>      tableName2State.putIfAbsent(tableName, tableState.getState());<a name="line.260"></a>
+<span class="sourceLineNo">261</span>    }<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    return tableState;<a name="line.262"></a>
+<span class="sourceLineNo">263</span>  }<a name="line.263"></a>
+<span class="sourceLineNo">264</span><a name="line.264"></a>
+<span class="sourceLineNo">265</span>  public void start() throws IOException {<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    TableDescriptors tableDescriptors = master.getTableDescriptors();<a name="line.266"></a>
+<span class="sourceLineNo">267</span>    migrateZooKeeper();<a name="line.267"></a>
+<span class="sourceLineNo">268</span>    Connection connection = master.getConnection();<a name="line.268"></a>
+<span class="sourceLineNo">269</span>    fixTableStates(tableDescriptors, connection);<a name="line.269"></a>
+<span class="sourceLineNo">270</span>  }<a name="line.270"></a>
+<span class="sourceLineNo">271</span><a name="line.271"></a>
+<span class="sourceLineNo">272</span>  private void fixTableStates(TableDescriptors tableDescriptors, Connection connection)<a name="line.272"></a>
+<span class="sourceLineNo">273</span>      throws IOException {<a name="line.273"></a>
+<span class="sourceLineNo">274</span>    Map&lt;String, TableDescriptor&gt; allDescriptors = tableDescriptors.getAll();<a name="line.274"></a>
+<span class="sourceLineNo">275</span>    Map&lt;String, TableState&gt; states = new HashMap&lt;&gt;();<a name="line.275"></a>
+<span class="sourceLineNo">276</span>    // NOTE: Ful hbase:meta table scan!<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    MetaTableAccessor.fullScanTables(connection, new MetaTableAccessor.Visitor() {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      @Override<a name="line.278"></a>
+<span class="sourceLineNo">279</span>      public boolean visit(Result r) throws IOException {<a name="line.279"></a>
+<span class="sourceLineNo">280</span>        TableState state = MetaTableAccessor.getTableState(r);<a name="line.280"></a>
+<span class="sourceLineNo">281</span>        states.put(state.getTableName().getNameAsString(), state);<a name="line.281"></a>
+<span class="sourceLineNo">282</span>        return true;<a name="line.282"></a>
+<span class="sourceLineNo">283</span>      }<a name="line.283"></a>
+<span class="sourceLineNo">284</span>    });<a name="line.284"></a>
+<span class="sourceLineNo">285</span>    for (Map.Entry&lt;String, TableDescriptor&gt; entry : allDescriptors.entrySet()) {<a name="line.285"></a>
+<span class="sourceLineNo">286</span>      TableName tableName = TableName.valueOf(entry.getKey());<a name="line.286"></a>
+<span class="sourceLineNo">287</span>      if (TableName.isMetaTableName(tableName)) {<a name="line.287"></a>
+<span class="sourceLineNo">288</span>        // This table is always enabled. No fixup needed. No entry in hbase:meta needed.<a name="line.288"></a>
+<span class="sourceLineNo">289</span>        // Call through to fixTableState though in case a super class wants to do something.<a name="line.289"></a>
+<span class="sourceLineNo">290</span>        fixTableState(new TableState(tableName, TableState.State.ENABLED));<a name="line.290"></a>
+<span class="sourceLineNo">291</span>        continue;<a name="line.291"></a>
+<span class="sourceLineNo">292</span>      }<a name="line.292"></a>
+<span class="sourceLineNo">293</span>      TableState tableState = states.get(entry.getKey());<a name="line.293"></a>
+<span class="sourceLineNo">294</span>      if (tableState == null) {<a name="line.294"></a>
+<span class="sourceLineNo">295</span>        LOG.warn(tableName + " has no table state in hbase:meta, assuming ENABLED");<a name="line.295"></a>
+<span class="sourceLineNo">296</span>        MetaTableAccessor.updateTableState(connection, tableName, TableState.State.ENABLED);<a name="line.296"></a>
+<span class="sourceLineNo">297</span>        fixTableState(new TableState(tableName, TableState.State.ENABLED));<a name="line.297"></a>
+<span class="sourceLineNo">298</span>        tableName2State.put(tableName, TableState.State.ENABLED);<a name="line.298"></a>
+<span class="sourceLineNo">299</span>      } else {<a name="line.299"></a>
+<span class="sourceLineNo">300</span>        fixTableState(tableState);<a name="line.300"></a>
+<span class="sourceLineNo">301</span>        tableName2State.put(tableName, tableState.getState());<a name="line.301"></a>
+<span class="sourceLineNo">302</span>      }<a name="line.302"></a>
+<span class="sourceLineNo">303</span>    }<a name="line.303"></a>
+<span class="sourceLineNo">304</span>  }<a name="line.304"></a>
+<span class="sourceLineNo">305</span><a name="line.305"></a>
+<span class="sourceLineNo">306</span>  /**<a name="line.306"></a>
+<span class="sourceLineNo">307</span>   * For subclasses in case they want to do fixup post hbase:meta.<a name="line.307"></a>
+<span class="sourceLineNo">308</span>   */<a name="line.308"></a>
+<span class="sourceLineNo">309</span>  protected void fixTableState(TableState tableState) throws IOException {<a name="line.309"></a>
+<span class="sourceLineNo">310</span>  }<a name="line.310"></a>
+<span class="sourceLineNo">311</span><a name="line.311"></a>
+<span class="sourceLineNo">312</span>  /**<a name="line.312"></a>
+<span class="sourceLineNo">313</span>   * This code is for case where a hbase2 Master is starting for the first time. ZooKeeper is where<a name="line.313"></a>
+<span class="sourceLineNo">314</span>   * we used to keep table state. On first startup, read zookeeper and update hbase:meta with the<a name="line.314"></a>
+<span class="sourceLineNo">315</span>   * table states found in zookeeper. This is tricky as we'll do this check every time we startup<a name="line.315"></a>
+<span class="sourceLineNo">316</span>   * until mirroring is disabled. See the {@link #MIGRATE_TABLE_STATE_FROM_ZK_KEY} flag. Original<a name="line.316"></a>
+<span class="sourceLineNo">317</span>   * form of this migration came in with HBASE-13032. It deleted all znodes when done. We can't do<a name="line.317"></a>
+<span class="sourceLineNo">318</span>   * that if we want to support hbase-1.x clients who need to be able to read table state out of zk.<a name="line.318"></a>
+<span class="sourceLineNo">319</span>   * See {@link MirroringTableStateManager}.<a name="line.319"></a>
+<span class="sourceLineNo">320</span>   * @deprecated Since 2.0.0. Remove in hbase-3.0.0.<a name="line.320"></a>
+<span class="sourceLineNo">321</span>   */<a name="line.321"></a>
+<span class="sourceLineNo">322</span>  @Deprecated<a name="line.322"></a>
+<span class="sourceLineNo">323</span>  private void migrateZooKeeper() throws IOException {<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    if (!this.master.getConfiguration().getBoolean(MIGRATE_TABLE_STATE_FROM_ZK_KEY, true)) {<a name="line.324"></a>
+<span class="sourceLineNo">325</span>      return;<a name="line.325"></a>
+<span class="sourceLineNo">326</span>    }<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    try {<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      for (Map.Entry&lt;TableName, TableState.State&gt; entry : ZKDataMigrator<a name="line.328"></a>
+<span class="sourceLineNo">329</span>        .queryForTableStates(this.master.getZooKeeper()).entrySet()) {<a name="line.329"></a>
+<span class="sourceLineNo">330</span>        if (this.master.getTableDescriptors().get(entry.getKey()) == null) {<a name="line.330"></a>
+<span class="sourceLineNo">331</span>          deleteZooKeeper(entry.getKey());<a name="line.331"></a>
+<span class="sourceLineNo">332</span>          LOG.info("Purged table state entry from zookeepr for table not in hbase:meta: " +<a name="line.332"></a>
+<span class="sourceLineNo">333</span>            entry.getKey());<a name="line.333"></a>
+<span class="sourceLineNo">334</span>          continue;<a name="line.334"></a>
+<span class="sourceLineNo">335</span>        }<a name="line.335"></a>
+<span class="sourceLineNo">336</span>        TableState ts = null;<a name="line.336"></a>
+<span class="sourceLineNo">337</span>        try {<a name="line.337"></a>
+<span class="sourceLineNo">338</span>          ts = getTableState(entry.getKey());<a name="line.338"></a>
+<span class="sourceLineNo">339</span>        } catch (TableStateNotFoundException e) {<a name="line.339"></a>
+<span class="sourceLineNo">340</span>          // This can happen; table exists but no TableState.<a name="line.340"></a>
+<span class="sourceLineNo">341</span>        }<a name="line.341"></a>
+<span class="sourceLineNo">342</span>        if (ts == null) {<a name="line.342"></a>
+<span class="sourceLineNo">343</span>          TableState.State zkstate = entry.getValue();<a name="line.343"></a>
+<span class="sourceLineNo">344</span>          // Only migrate if it is an enable or disabled table. If in-between -- ENABLING or<a name="line.344"></a>
+<span class="sourceLineNo">345</span>          // DISABLING then we have a problem; we are starting up an hbase-2 on a cluster with<a name="line.345"></a>
+<span class="sourceLineNo">346</span>          // RIT. It is going to be rough!<a name="line.346"></a>
+<span class="sourceLineNo">347</span>          if (zkstate.equals(TableState.State.ENABLED) ||<a name="line.347"></a>
+<span class="sourceLineNo">348</span>            zkstate.equals(TableState.State.DISABLED)) {<a name="line.348"></a>
+<span class="sourceLineNo">349</span>            LOG.info("Migrating table state from zookeeper to hbase:meta; tableName=" +<a name="line.349"></a>
+<span class="sourceLineNo">350</span>              entry.getKey() + ", state=" + entry.getValue());<a name="line.350"></a>
+<span class="sourceLineNo">351</span>            updateMetaState(entry.getKey(), entry.getValue());<a name="line.351"></a>
+<span class="sourceLineNo">352</span>          } else {<a name="line.352"></a>
+<span class="sourceLineNo">353</span>            LOG.warn("Table={} has no state and zookeeper state is in-between={} (neither " +<a name="line.353"></a>
+<span class="sourceLineNo">354</span>              "ENABLED or DISABLED); NOT MIGRATING table state", entry.getKey(), zkstate);<a name="line.354"></a>
+<span class="sourceLineNo">355</span>          }<a name="line.355"></a>
+<span class="sourceLineNo">356</span>        }<a name="line.356"></a>
+<span class="sourceLineNo">357</span>        // What if the table states disagree? Defer to the hbase:meta setting rather than have the<a name="line.357"></a>
+<span class="sourceLineNo">358</span>        // hbase-1.x support prevail.<a name="line.358"></a>
+<span class="sourceLineNo">359</span>      }<a name="line.359"></a>
+<span class="sourceLineNo">360</span>    } catch (KeeperException | InterruptedException e) {<a name="line.360"></a>
+<span class="sourceLineNo">361</span>      LOG.warn("Failed reading table state from zookeeper", e);<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    }<a name="line.362"></a>
+<span class="sourceLineNo">363</span>  }<a name="line.363"></a>
+<span class="sourceLineNo">364</span><a name="line.364"></a>
+<span class="sourceLineNo">365</span>  /**<a name="line.365"></a>
+<span class="sourceLineNo">366</span>   * Utility method that knows how to delete the old hbase-1.x table state znode. Used also by the<a name="line.366"></a>
+<span class="sourceLineNo">367</span>   * Mirroring subclass.<a name="line.367"></a>
+<span class="sourceLineNo">368</span>   * @deprecated Since 2.0.0. To be removed in hbase-3.0.0.<a name="line.368"></a>
+<span class="sourceLineNo">369</span>   */<a name="line.369"></a>
+<span class="sourceLineNo">370</span>  @Deprecated<a name="line.370"></a>
+<span class="sourceLineNo">371</span>  protected void deleteZooKeeper(TableName tableName) {<a name="line.371"></a>
+<span class="sourceLineNo">372</span>    try {<a name="line.372"></a>
+<span class="sourceLineNo">373</span>      // Delete from ZooKeeper<a name="line.373"></a>
+<span class="sourceLineNo">374</span>      String znode = ZNodePaths.joinZNode(this.master.getZooKeeper().getZNodePaths().tableZNode,<a name="line.374"></a>
+<span class="sourceLineNo">375</span>        tableName.getNameAsString());<a name="line.375"></a>
+<span class="sourceLineNo">376</span>      ZKUtil.deleteNodeFailSilent(this.master.getZooKeeper(), znode);<a name="line.376"></a>
+<span class="sourceLineNo">377</span>    } catch (KeeperException e) {<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      LOG.warn("Failed deleting table state from zookeeper", e);<a name="line.378"></a>
+<span class="sourceLineNo">379</span>    }<a name="line.379"></a>
+<span class="sourceLineNo">380</span>  }<a name="line.380"></a>
+<span class="sourceLineNo">381</span>}<a name="line.381"></a>
 
 
 


Mime
View raw message