http://git-wip-us.apache.org/repos/asf/hbase-site/blob/2b11656f/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.RedirectServlet.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.RedirectServlet.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.RedirectServlet.html index 74bacd8..546d2b6 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.RedirectServlet.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.RedirectServlet.html @@ -2249,1468 +2249,1484 @@ <span class="sourceLineNo">2241</span> }<a name="line.2241"></a> <span class="sourceLineNo">2242</span><a name="line.2242"></a> <span class="sourceLineNo">2243</span> @Override<a name="line.2243"></a> -<span class="sourceLineNo">2244</span> public long addColumn(<a name="line.2244"></a> -<span class="sourceLineNo">2245</span> final TableName tableName,<a name="line.2245"></a> -<span class="sourceLineNo">2246</span> final ColumnFamilyDescriptor column,<a name="line.2246"></a> -<span class="sourceLineNo">2247</span> final long nonceGroup,<a name="line.2247"></a> -<span class="sourceLineNo">2248</span> final long nonce)<a name="line.2248"></a> -<span class="sourceLineNo">2249</span> throws IOException {<a name="line.2249"></a> -<span class="sourceLineNo">2250</span> checkInitialized();<a name="line.2250"></a> -<span class="sourceLineNo">2251</span> checkTableExists(tableName);<a name="line.2251"></a> -<span class="sourceLineNo">2252</span><a name="line.2252"></a> -<span class="sourceLineNo">2253</span> TableDescriptor old = getTableDescriptors().get(tableName);<a name="line.2253"></a> -<span class="sourceLineNo">2254</span> if (old.hasColumnFamily(column.getName())) {<a name="line.2254"></a> -<span class="sourceLineNo">2255</span> throw new InvalidFamilyOperationException("Column family '" + column.getNameAsString()<a name="line.2255"></a> -<span class="sourceLineNo">2256</span> + "' in table '" + tableName + "' already exists so cannot be added");<a name="line.2256"></a> -<span class="sourceLineNo">2257</span> }<a name="line.2257"></a> +<span class="sourceLineNo">2244</span> public long addColumn(final TableName tableName, final ColumnFamilyDescriptor column,<a name="line.2244"></a> +<span class="sourceLineNo">2245</span> final long nonceGroup, final long nonce) throws IOException {<a name="line.2245"></a> +<span class="sourceLineNo">2246</span> checkInitialized();<a name="line.2246"></a> +<span class="sourceLineNo">2247</span> checkTableExists(tableName);<a name="line.2247"></a> +<span class="sourceLineNo">2248</span><a name="line.2248"></a> +<span class="sourceLineNo">2249</span> return modifyTable(tableName, new TableDescriptorGetter() {<a name="line.2249"></a> +<span class="sourceLineNo">2250</span><a name="line.2250"></a> +<span class="sourceLineNo">2251</span> @Override<a name="line.2251"></a> +<span class="sourceLineNo">2252</span> public TableDescriptor get() throws IOException {<a name="line.2252"></a> +<span class="sourceLineNo">2253</span> TableDescriptor old = getTableDescriptors().get(tableName);<a name="line.2253"></a> +<span class="sourceLineNo">2254</span> if (old.hasColumnFamily(column.getName())) {<a name="line.2254"></a> +<span class="sourceLineNo">2255</span> throw new InvalidFamilyOperationException("Column family '" + column.getNameAsString()<a name="line.2255"></a> +<span class="sourceLineNo">2256</span> + "' in table '" + tableName + "' already exists so cannot be added");<a name="line.2256"></a> +<span class="sourceLineNo">2257</span> }<a name="line.2257"></a> <span class="sourceLineNo">2258</span><a name="line.2258"></a> -<span class="sourceLineNo">2259</span> TableDescriptor newDesc = TableDescriptorBuilder<a name="line.2259"></a> -<span class="sourceLineNo">2260</span> .newBuilder(old).setColumnFamily(column).build();<a name="line.2260"></a> -<span class="sourceLineNo">2261</span> return modifyTable(tableName, newDesc, nonceGroup, nonce);<a name="line.2261"></a> +<span class="sourceLineNo">2259</span> return TableDescriptorBuilder.newBuilder(old).setColumnFamily(column).build();<a name="line.2259"></a> +<span class="sourceLineNo">2260</span> }<a name="line.2260"></a> +<span class="sourceLineNo">2261</span> }, nonceGroup, nonce);<a name="line.2261"></a> <span class="sourceLineNo">2262</span> }<a name="line.2262"></a> <span class="sourceLineNo">2263</span><a name="line.2263"></a> -<span class="sourceLineNo">2264</span> @Override<a name="line.2264"></a> -<span class="sourceLineNo">2265</span> public long modifyColumn(<a name="line.2265"></a> -<span class="sourceLineNo">2266</span> final TableName tableName,<a name="line.2266"></a> -<span class="sourceLineNo">2267</span> final ColumnFamilyDescriptor descriptor,<a name="line.2267"></a> -<span class="sourceLineNo">2268</span> final long nonceGroup,<a name="line.2268"></a> -<span class="sourceLineNo">2269</span> final long nonce)<a name="line.2269"></a> -<span class="sourceLineNo">2270</span> throws IOException {<a name="line.2270"></a> -<span class="sourceLineNo">2271</span> checkInitialized();<a name="line.2271"></a> -<span class="sourceLineNo">2272</span> checkTableExists(tableName);<a name="line.2272"></a> -<span class="sourceLineNo">2273</span><a name="line.2273"></a> -<span class="sourceLineNo">2274</span> TableDescriptor old = getTableDescriptors().get(tableName);<a name="line.2274"></a> -<span class="sourceLineNo">2275</span> if (! old.hasColumnFamily(descriptor.getName())) {<a name="line.2275"></a> -<span class="sourceLineNo">2276</span> throw new InvalidFamilyOperationException("Family '" + descriptor.getNameAsString()<a name="line.2276"></a> -<span class="sourceLineNo">2277</span> + "' does not exist, so it cannot be modified");<a name="line.2277"></a> -<span class="sourceLineNo">2278</span> }<a name="line.2278"></a> -<span class="sourceLineNo">2279</span><a name="line.2279"></a> -<span class="sourceLineNo">2280</span> TableDescriptor td = TableDescriptorBuilder<a name="line.2280"></a> -<span class="sourceLineNo">2281</span> .newBuilder(old)<a name="line.2281"></a> -<span class="sourceLineNo">2282</span> .modifyColumnFamily(descriptor)<a name="line.2282"></a> -<span class="sourceLineNo">2283</span> .build();<a name="line.2283"></a> -<span class="sourceLineNo">2284</span><a name="line.2284"></a> -<span class="sourceLineNo">2285</span> return modifyTable(tableName, td, nonceGroup, nonce);<a name="line.2285"></a> -<span class="sourceLineNo">2286</span> }<a name="line.2286"></a> -<span class="sourceLineNo">2287</span><a name="line.2287"></a> -<span class="sourceLineNo">2288</span> @Override<a name="line.2288"></a> -<span class="sourceLineNo">2289</span> public long deleteColumn(<a name="line.2289"></a> -<span class="sourceLineNo">2290</span> final TableName tableName,<a name="line.2290"></a> -<span class="sourceLineNo">2291</span> final byte[] columnName,<a name="line.2291"></a> -<span class="sourceLineNo">2292</span> final long nonceGroup,<a name="line.2292"></a> -<span class="sourceLineNo">2293</span> final long nonce)<a name="line.2293"></a> -<span class="sourceLineNo">2294</span> throws IOException {<a name="line.2294"></a> -<span class="sourceLineNo">2295</span> checkInitialized();<a name="line.2295"></a> -<span class="sourceLineNo">2296</span> checkTableExists(tableName);<a name="line.2296"></a> -<span class="sourceLineNo">2297</span><a name="line.2297"></a> -<span class="sourceLineNo">2298</span> TableDescriptor old = getTableDescriptors().get(tableName);<a name="line.2298"></a> -<span class="sourceLineNo">2299</span><a name="line.2299"></a> -<span class="sourceLineNo">2300</span> if (! old.hasColumnFamily(columnName)) {<a name="line.2300"></a> -<span class="sourceLineNo">2301</span> throw new InvalidFamilyOperationException("Family '" + Bytes.toString(columnName)<a name="line.2301"></a> -<span class="sourceLineNo">2302</span> + "' does not exist, so it cannot be deleted");<a name="line.2302"></a> -<span class="sourceLineNo">2303</span> }<a name="line.2303"></a> -<span class="sourceLineNo">2304</span> if (old.getColumnFamilyCount() == 1) {<a name="line.2304"></a> -<span class="sourceLineNo">2305</span> throw new InvalidFamilyOperationException("Family '" + Bytes.toString(columnName)<a name="line.2305"></a> -<span class="sourceLineNo">2306</span> + "' is the only column family in the table, so it cannot be deleted");<a name="line.2306"></a> -<span class="sourceLineNo">2307</span> }<a name="line.2307"></a> -<span class="sourceLineNo">2308</span><a name="line.2308"></a> -<span class="sourceLineNo">2309</span> TableDescriptor td = TableDescriptorBuilder<a name="line.2309"></a> -<span class="sourceLineNo">2310</span> .newBuilder(old).removeColumnFamily(columnName).build();<a name="line.2310"></a> -<span class="sourceLineNo">2311</span> return modifyTable(tableName, td, nonceGroup, nonce);<a name="line.2311"></a> -<span class="sourceLineNo">2312</span> }<a name="line.2312"></a> -<span class="sourceLineNo">2313</span><a name="line.2313"></a> -<span class="sourceLineNo">2314</span> @Override<a name="line.2314"></a> -<span class="sourceLineNo">2315</span> public long enableTable(final TableName tableName, final long nonceGroup, final long nonce)<a name="line.2315"></a> -<span class="sourceLineNo">2316</span> throws IOException {<a name="line.2316"></a> -<span class="sourceLineNo">2317</span> checkInitialized();<a name="line.2317"></a> -<span class="sourceLineNo">2318</span><a name="line.2318"></a> -<span class="sourceLineNo">2319</span> return MasterProcedureUtil.submitProcedure(<a name="line.2319"></a> -<span class="sourceLineNo">2320</span> new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.2320"></a> -<span class="sourceLineNo">2321</span> @Override<a name="line.2321"></a> -<span class="sourceLineNo">2322</span> protected void run() throws IOException {<a name="line.2322"></a> -<span class="sourceLineNo">2323</span> getMaster().getMasterCoprocessorHost().preEnableTable(tableName);<a name="line.2323"></a> -<span class="sourceLineNo">2324</span><a name="line.2324"></a> -<span class="sourceLineNo">2325</span> // Normally, it would make sense for this authorization check to exist inside<a name="line.2325"></a> -<span class="sourceLineNo">2326</span> // AccessController, but because the authorization check is done based on internal state<a name="line.2326"></a> -<span class="sourceLineNo">2327</span> // (rather than explicit permissions) we'll do the check here instead of in the<a name="line.2327"></a> -<span class="sourceLineNo">2328</span> // coprocessor.<a name="line.2328"></a> -<span class="sourceLineNo">2329</span> MasterQuotaManager quotaManager = getMasterQuotaManager();<a name="line.2329"></a> -<span class="sourceLineNo">2330</span> if (quotaManager != null) {<a name="line.2330"></a> -<span class="sourceLineNo">2331</span> if (quotaManager.isQuotaInitialized()) {<a name="line.2331"></a> -<span class="sourceLineNo">2332</span> Quotas quotaForTable = QuotaUtil.getTableQuota(getConnection(), tableName);<a name="line.2332"></a> -<span class="sourceLineNo">2333</span> if (quotaForTable != null && quotaForTable.hasSpace()) {<a name="line.2333"></a> -<span class="sourceLineNo">2334</span> SpaceViolationPolicy policy = quotaForTable.getSpace().getViolationPolicy();<a name="line.2334"></a> -<span class="sourceLineNo">2335</span> if (SpaceViolationPolicy.DISABLE == policy) {<a name="line.2335"></a> -<span class="sourceLineNo">2336</span> throw new AccessDeniedException("Enabling the table '" + tableName<a name="line.2336"></a> -<span class="sourceLineNo">2337</span> + "' is disallowed due to a violated space quota.");<a name="line.2337"></a> -<span class="sourceLineNo">2338</span> }<a name="line.2338"></a> -<span class="sourceLineNo">2339</span> }<a name="line.2339"></a> -<span class="sourceLineNo">2340</span> } else if (LOG.isTraceEnabled()) {<a name="line.2340"></a> -<span class="sourceLineNo">2341</span> LOG.trace("Unable to check for space quotas as the MasterQuotaManager is not enabled");<a name="line.2341"></a> -<span class="sourceLineNo">2342</span> }<a name="line.2342"></a> -<span class="sourceLineNo">2343</span> }<a name="line.2343"></a> -<span class="sourceLineNo">2344</span><a name="line.2344"></a> -<span class="sourceLineNo">2345</span> LOG.info(getClientIdAuditPrefix() + " enable " + tableName);<a name="line.2345"></a> +<span class="sourceLineNo">2264</span> /**<a name="line.2264"></a> +<span class="sourceLineNo">2265</span> * Implement to return TableDescriptor after pre-checks<a name="line.2265"></a> +<span class="sourceLineNo">2266</span> */<a name="line.2266"></a> +<span class="sourceLineNo">2267</span> protected interface TableDescriptorGetter {<a name="line.2267"></a> +<span class="sourceLineNo">2268</span> TableDescriptor get() throws IOException;<a name="line.2268"></a> +<span class="sourceLineNo">2269</span> }<a name="line.2269"></a> +<span class="sourceLineNo">2270</span><a name="line.2270"></a> +<span class="sourceLineNo">2271</span> @Override<a name="line.2271"></a> +<span class="sourceLineNo">2272</span> public long modifyColumn(final TableName tableName, final ColumnFamilyDescriptor descriptor,<a name="line.2272"></a> +<span class="sourceLineNo">2273</span> final long nonceGroup, final long nonce) throws IOException {<a name="line.2273"></a> +<span class="sourceLineNo">2274</span> checkInitialized();<a name="line.2274"></a> +<span class="sourceLineNo">2275</span> checkTableExists(tableName);<a name="line.2275"></a> +<span class="sourceLineNo">2276</span> return modifyTable(tableName, new TableDescriptorGetter() {<a name="line.2276"></a> +<span class="sourceLineNo">2277</span><a name="line.2277"></a> +<span class="sourceLineNo">2278</span> @Override<a name="line.2278"></a> +<span class="sourceLineNo">2279</span> public TableDescriptor get() throws IOException {<a name="line.2279"></a> +<span class="sourceLineNo">2280</span> TableDescriptor old = getTableDescriptors().get(tableName);<a name="line.2280"></a> +<span class="sourceLineNo">2281</span> if (!old.hasColumnFamily(descriptor.getName())) {<a name="line.2281"></a> +<span class="sourceLineNo">2282</span> throw new InvalidFamilyOperationException("Family '" + descriptor.getNameAsString()<a name="line.2282"></a> +<span class="sourceLineNo">2283</span> + "' does not exist, so it cannot be modified");<a name="line.2283"></a> +<span class="sourceLineNo">2284</span> }<a name="line.2284"></a> +<span class="sourceLineNo">2285</span><a name="line.2285"></a> +<span class="sourceLineNo">2286</span> return TableDescriptorBuilder.newBuilder(old).modifyColumnFamily(descriptor).build();<a name="line.2286"></a> +<span class="sourceLineNo">2287</span> }<a name="line.2287"></a> +<span class="sourceLineNo">2288</span> }, nonceGroup, nonce);<a name="line.2288"></a> +<span class="sourceLineNo">2289</span> }<a name="line.2289"></a> +<span class="sourceLineNo">2290</span><a name="line.2290"></a> +<span class="sourceLineNo">2291</span> @Override<a name="line.2291"></a> +<span class="sourceLineNo">2292</span> public long deleteColumn(final TableName tableName, final byte[] columnName,<a name="line.2292"></a> +<span class="sourceLineNo">2293</span> final long nonceGroup, final long nonce) throws IOException {<a name="line.2293"></a> +<span class="sourceLineNo">2294</span> checkInitialized();<a name="line.2294"></a> +<span class="sourceLineNo">2295</span> checkTableExists(tableName);<a name="line.2295"></a> +<span class="sourceLineNo">2296</span><a name="line.2296"></a> +<span class="sourceLineNo">2297</span> return modifyTable(tableName, new TableDescriptorGetter() {<a name="line.2297"></a> +<span class="sourceLineNo">2298</span><a name="line.2298"></a> +<span class="sourceLineNo">2299</span> @Override<a name="line.2299"></a> +<span class="sourceLineNo">2300</span> public TableDescriptor get() throws IOException {<a name="line.2300"></a> +<span class="sourceLineNo">2301</span> TableDescriptor old = getTableDescriptors().get(tableName);<a name="line.2301"></a> +<span class="sourceLineNo">2302</span><a name="line.2302"></a> +<span class="sourceLineNo">2303</span> if (!old.hasColumnFamily(columnName)) {<a name="line.2303"></a> +<span class="sourceLineNo">2304</span> throw new InvalidFamilyOperationException("Family '" + Bytes.toString(columnName)<a name="line.2304"></a> +<span class="sourceLineNo">2305</span> + "' does not exist, so it cannot be deleted");<a name="line.2305"></a> +<span class="sourceLineNo">2306</span> }<a name="line.2306"></a> +<span class="sourceLineNo">2307</span> if (old.getColumnFamilyCount() == 1) {<a name="line.2307"></a> +<span class="sourceLineNo">2308</span> throw new InvalidFamilyOperationException("Family '" + Bytes.toString(columnName)<a name="line.2308"></a> +<span class="sourceLineNo">2309</span> + "' is the only column family in the table, so it cannot be deleted");<a name="line.2309"></a> +<span class="sourceLineNo">2310</span> }<a name="line.2310"></a> +<span class="sourceLineNo">2311</span> return TableDescriptorBuilder.newBuilder(old).removeColumnFamily(columnName).build();<a name="line.2311"></a> +<span class="sourceLineNo">2312</span> }<a name="line.2312"></a> +<span class="sourceLineNo">2313</span> }, nonceGroup, nonce);<a name="line.2313"></a> +<span class="sourceLineNo">2314</span> }<a name="line.2314"></a> +<span class="sourceLineNo">2315</span><a name="line.2315"></a> +<span class="sourceLineNo">2316</span> @Override<a name="line.2316"></a> +<span class="sourceLineNo">2317</span> public long enableTable(final TableName tableName, final long nonceGroup, final long nonce)<a name="line.2317"></a> +<span class="sourceLineNo">2318</span> throws IOException {<a name="line.2318"></a> +<span class="sourceLineNo">2319</span> checkInitialized();<a name="line.2319"></a> +<span class="sourceLineNo">2320</span><a name="line.2320"></a> +<span class="sourceLineNo">2321</span> return MasterProcedureUtil.submitProcedure(<a name="line.2321"></a> +<span class="sourceLineNo">2322</span> new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.2322"></a> +<span class="sourceLineNo">2323</span> @Override<a name="line.2323"></a> +<span class="sourceLineNo">2324</span> protected void run() throws IOException {<a name="line.2324"></a> +<span class="sourceLineNo">2325</span> getMaster().getMasterCoprocessorHost().preEnableTable(tableName);<a name="line.2325"></a> +<span class="sourceLineNo">2326</span><a name="line.2326"></a> +<span class="sourceLineNo">2327</span> // Normally, it would make sense for this authorization check to exist inside<a name="line.2327"></a> +<span class="sourceLineNo">2328</span> // AccessController, but because the authorization check is done based on internal state<a name="line.2328"></a> +<span class="sourceLineNo">2329</span> // (rather than explicit permissions) we'll do the check here instead of in the<a name="line.2329"></a> +<span class="sourceLineNo">2330</span> // coprocessor.<a name="line.2330"></a> +<span class="sourceLineNo">2331</span> MasterQuotaManager quotaManager = getMasterQuotaManager();<a name="line.2331"></a> +<span class="sourceLineNo">2332</span> if (quotaManager != null) {<a name="line.2332"></a> +<span class="sourceLineNo">2333</span> if (quotaManager.isQuotaInitialized()) {<a name="line.2333"></a> +<span class="sourceLineNo">2334</span> Quotas quotaForTable = QuotaUtil.getTableQuota(getConnection(), tableName);<a name="line.2334"></a> +<span class="sourceLineNo">2335</span> if (quotaForTable != null && quotaForTable.hasSpace()) {<a name="line.2335"></a> +<span class="sourceLineNo">2336</span> SpaceViolationPolicy policy = quotaForTable.getSpace().getViolationPolicy();<a name="line.2336"></a> +<span class="sourceLineNo">2337</span> if (SpaceViolationPolicy.DISABLE == policy) {<a name="line.2337"></a> +<span class="sourceLineNo">2338</span> throw new AccessDeniedException("Enabling the table '" + tableName<a name="line.2338"></a> +<span class="sourceLineNo">2339</span> + "' is disallowed due to a violated space quota.");<a name="line.2339"></a> +<span class="sourceLineNo">2340</span> }<a name="line.2340"></a> +<span class="sourceLineNo">2341</span> }<a name="line.2341"></a> +<span class="sourceLineNo">2342</span> } else if (LOG.isTraceEnabled()) {<a name="line.2342"></a> +<span class="sourceLineNo">2343</span> LOG.trace("Unable to check for space quotas as the MasterQuotaManager is not enabled");<a name="line.2343"></a> +<span class="sourceLineNo">2344</span> }<a name="line.2344"></a> +<span class="sourceLineNo">2345</span> }<a name="line.2345"></a> <span class="sourceLineNo">2346</span><a name="line.2346"></a> -<span class="sourceLineNo">2347</span> // Execute the operation asynchronously - client will check the progress of the operation<a name="line.2347"></a> -<span class="sourceLineNo">2348</span> // In case the request is from a <1.1 client before returning,<a name="line.2348"></a> -<span class="sourceLineNo">2349</span> // we want to make sure that the table is prepared to be<a name="line.2349"></a> -<span class="sourceLineNo">2350</span> // enabled (the table is locked and the table state is set).<a name="line.2350"></a> -<span class="sourceLineNo">2351</span> // Note: if the procedure throws exception, we will catch it and rethrow.<a name="line.2351"></a> -<span class="sourceLineNo">2352</span> final ProcedurePrepareLatch prepareLatch = ProcedurePrepareLatch.createLatch();<a name="line.2352"></a> -<span class="sourceLineNo">2353</span> submitProcedure(new EnableTableProcedure(procedureExecutor.getEnvironment(),<a name="line.2353"></a> -<span class="sourceLineNo">2354</span> tableName, false, prepareLatch));<a name="line.2354"></a> -<span class="sourceLineNo">2355</span> prepareLatch.await();<a name="line.2355"></a> -<span class="sourceLineNo">2356</span><a name="line.2356"></a> -<span class="sourceLineNo">2357</span> getMaster().getMasterCoprocessorHost().postEnableTable(tableName);<a name="line.2357"></a> -<span class="sourceLineNo">2358</span> }<a name="line.2358"></a> -<span class="sourceLineNo">2359</span><a name="line.2359"></a> -<span class="sourceLineNo">2360</span> @Override<a name="line.2360"></a> -<span class="sourceLineNo">2361</span> protected String getDescription() {<a name="line.2361"></a> -<span class="sourceLineNo">2362</span> return "EnableTableProcedure";<a name="line.2362"></a> -<span class="sourceLineNo">2363</span> }<a name="line.2363"></a> -<span class="sourceLineNo">2364</span> });<a name="line.2364"></a> -<span class="sourceLineNo">2365</span> }<a name="line.2365"></a> -<span class="sourceLineNo">2366</span><a name="line.2366"></a> -<span class="sourceLineNo">2367</span> @Override<a name="line.2367"></a> -<span class="sourceLineNo">2368</span> public long disableTable(final TableName tableName, final long nonceGroup, final long nonce)<a name="line.2368"></a> -<span class="sourceLineNo">2369</span> throws IOException {<a name="line.2369"></a> -<span class="sourceLineNo">2370</span> checkInitialized();<a name="line.2370"></a> -<span class="sourceLineNo">2371</span><a name="line.2371"></a> -<span class="sourceLineNo">2372</span> return MasterProcedureUtil.submitProcedure(<a name="line.2372"></a> -<span class="sourceLineNo">2373</span> new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.2373"></a> -<span class="sourceLineNo">2374</span> @Override<a name="line.2374"></a> -<span class="sourceLineNo">2375</span> protected void run() throws IOException {<a name="line.2375"></a> -<span class="sourceLineNo">2376</span> getMaster().getMasterCoprocessorHost().preDisableTable(tableName);<a name="line.2376"></a> -<span class="sourceLineNo">2377</span><a name="line.2377"></a> -<span class="sourceLineNo">2378</span> LOG.info(getClientIdAuditPrefix() + " disable " + tableName);<a name="line.2378"></a> +<span class="sourceLineNo">2347</span> LOG.info(getClientIdAuditPrefix() + " enable " + tableName);<a name="line.2347"></a> +<span class="sourceLineNo">2348</span><a name="line.2348"></a> +<span class="sourceLineNo">2349</span> // Execute the operation asynchronously - client will check the progress of the operation<a name="line.2349"></a> +<span class="sourceLineNo">2350</span> // In case the request is from a <1.1 client before returning,<a name="line.2350"></a> +<span class="sourceLineNo">2351</span> // we want to make sure that the table is prepared to be<a name="line.2351"></a> +<span class="sourceLineNo">2352</span> // enabled (the table is locked and the table state is set).<a name="line.2352"></a> +<span class="sourceLineNo">2353</span> // Note: if the procedure throws exception, we will catch it and rethrow.<a name="line.2353"></a> +<span class="sourceLineNo">2354</span> final ProcedurePrepareLatch prepareLatch = ProcedurePrepareLatch.createLatch();<a name="line.2354"></a> +<span class="sourceLineNo">2355</span> submitProcedure(new EnableTableProcedure(procedureExecutor.getEnvironment(),<a name="line.2355"></a> +<span class="sourceLineNo">2356</span> tableName, false, prepareLatch));<a name="line.2356"></a> +<span class="sourceLineNo">2357</span> prepareLatch.await();<a name="line.2357"></a> +<span class="sourceLineNo">2358</span><a name="line.2358"></a> +<span class="sourceLineNo">2359</span> getMaster().getMasterCoprocessorHost().postEnableTable(tableName);<a name="line.2359"></a> +<span class="sourceLineNo">2360</span> }<a name="line.2360"></a> +<span class="sourceLineNo">2361</span><a name="line.2361"></a> +<span class="sourceLineNo">2362</span> @Override<a name="line.2362"></a> +<span class="sourceLineNo">2363</span> protected String getDescription() {<a name="line.2363"></a> +<span class="sourceLineNo">2364</span> return "EnableTableProcedure";<a name="line.2364"></a> +<span class="sourceLineNo">2365</span> }<a name="line.2365"></a> +<span class="sourceLineNo">2366</span> });<a name="line.2366"></a> +<span class="sourceLineNo">2367</span> }<a name="line.2367"></a> +<span class="sourceLineNo">2368</span><a name="line.2368"></a> +<span class="sourceLineNo">2369</span> @Override<a name="line.2369"></a> +<span class="sourceLineNo">2370</span> public long disableTable(final TableName tableName, final long nonceGroup, final long nonce)<a name="line.2370"></a> +<span class="sourceLineNo">2371</span> throws IOException {<a name="line.2371"></a> +<span class="sourceLineNo">2372</span> checkInitialized();<a name="line.2372"></a> +<span class="sourceLineNo">2373</span><a name="line.2373"></a> +<span class="sourceLineNo">2374</span> return MasterProcedureUtil.submitProcedure(<a name="line.2374"></a> +<span class="sourceLineNo">2375</span> new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.2375"></a> +<span class="sourceLineNo">2376</span> @Override<a name="line.2376"></a> +<span class="sourceLineNo">2377</span> protected void run() throws IOException {<a name="line.2377"></a> +<span class="sourceLineNo">2378</span> getMaster().getMasterCoprocessorHost().preDisableTable(tableName);<a name="line.2378"></a> <span class="sourceLineNo">2379</span><a name="line.2379"></a> -<span class="sourceLineNo">2380</span> // Execute the operation asynchronously - client will check the progress of the operation<a name="line.2380"></a> -<span class="sourceLineNo">2381</span> // In case the request is from a <1.1 client before returning,<a name="line.2381"></a> -<span class="sourceLineNo">2382</span> // we want to make sure that the table is prepared to be<a name="line.2382"></a> -<span class="sourceLineNo">2383</span> // enabled (the table is locked and the table state is set).<a name="line.2383"></a> -<span class="sourceLineNo">2384</span> // Note: if the procedure throws exception, we will catch it and rethrow.<a name="line.2384"></a> -<span class="sourceLineNo">2385</span> //<a name="line.2385"></a> -<span class="sourceLineNo">2386</span> // We need to wait for the procedure to potentially fail due to "prepare" sanity<a name="line.2386"></a> -<span class="sourceLineNo">2387</span> // checks. This will block only the beginning of the procedure. See HBASE-19953.<a name="line.2387"></a> -<span class="sourceLineNo">2388</span> final ProcedurePrepareLatch prepareLatch = ProcedurePrepareLatch.createBlockingLatch();<a name="line.2388"></a> -<span class="sourceLineNo">2389</span> submitProcedure(new DisableTableProcedure(procedureExecutor.getEnvironment(),<a name="line.2389"></a> -<span class="sourceLineNo">2390</span> tableName, false, prepareLatch));<a name="line.2390"></a> -<span class="sourceLineNo">2391</span> prepareLatch.await();<a name="line.2391"></a> -<span class="sourceLineNo">2392</span><a name="line.2392"></a> -<span class="sourceLineNo">2393</span> getMaster().getMasterCoprocessorHost().postDisableTable(tableName);<a name="line.2393"></a> -<span class="sourceLineNo">2394</span> }<a name="line.2394"></a> -<span class="sourceLineNo">2395</span><a name="line.2395"></a> -<span class="sourceLineNo">2396</span> @Override<a name="line.2396"></a> -<span class="sourceLineNo">2397</span> protected String getDescription() {<a name="line.2397"></a> -<span class="sourceLineNo">2398</span> return "DisableTableProcedure";<a name="line.2398"></a> -<span class="sourceLineNo">2399</span> }<a name="line.2399"></a> -<span class="sourceLineNo">2400</span> });<a name="line.2400"></a> -<span class="sourceLineNo">2401</span> }<a name="line.2401"></a> -<span class="sourceLineNo">2402</span><a name="line.2402"></a> -<span class="sourceLineNo">2403</span> /**<a name="line.2403"></a> -<span class="sourceLineNo">2404</span> * Return the region and current deployment for the region containing<a name="line.2404"></a> -<span class="sourceLineNo">2405</span> * the given row. If the region cannot be found, returns null. If it<a name="line.2405"></a> -<span class="sourceLineNo">2406</span> * is found, but not currently deployed, the second element of the pair<a name="line.2406"></a> -<span class="sourceLineNo">2407</span> * may be null.<a name="line.2407"></a> -<span class="sourceLineNo">2408</span> */<a name="line.2408"></a> -<span class="sourceLineNo">2409</span> @VisibleForTesting // Used by TestMaster.<a name="line.2409"></a> -<span class="sourceLineNo">2410</span> Pair<RegionInfo, ServerName> getTableRegionForRow(<a name="line.2410"></a> -<span class="sourceLineNo">2411</span> final TableName tableName, final byte [] rowKey)<a name="line.2411"></a> -<span class="sourceLineNo">2412</span> throws IOException {<a name="line.2412"></a> -<span class="sourceLineNo">2413</span> final AtomicReference<Pair<RegionInfo, ServerName>> result = new AtomicReference<>(null);<a name="line.2413"></a> -<span class="sourceLineNo">2414</span><a name="line.2414"></a> -<span class="sourceLineNo">2415</span> MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() {<a name="line.2415"></a> -<span class="sourceLineNo">2416</span> @Override<a name="line.2416"></a> -<span class="sourceLineNo">2417</span> public boolean visit(Result data) throws IOException {<a name="line.2417"></a> -<span class="sourceLineNo">2418</span> if (data == null || data.size() <= 0) {<a name="line.2418"></a> -<span class="sourceLineNo">2419</span> return true;<a name="line.2419"></a> -<span class="sourceLineNo">2420</span> }<a name="line.2420"></a> -<span class="sourceLineNo">2421</span> Pair<RegionInfo, ServerName> pair =<a name="line.2421"></a> -<span class="sourceLineNo">2422</span> new Pair<>(MetaTableAccessor.getRegionInfo(data),<a name="line.2422"></a> -<span class="sourceLineNo">2423</span> MetaTableAccessor.getServerName(data,0));<a name="line.2423"></a> -<span class="sourceLineNo">2424</span> if (!pair.getFirst().getTable().equals(tableName)) {<a name="line.2424"></a> -<span class="sourceLineNo">2425</span> return false;<a name="line.2425"></a> -<span class="sourceLineNo">2426</span> }<a name="line.2426"></a> -<span class="sourceLineNo">2427</span> result.set(pair);<a name="line.2427"></a> -<span class="sourceLineNo">2428</span> return true;<a name="line.2428"></a> -<span class="sourceLineNo">2429</span> }<a name="line.2429"></a> -<span class="sourceLineNo">2430</span> };<a name="line.2430"></a> -<span class="sourceLineNo">2431</span><a name="line.2431"></a> -<span class="sourceLineNo">2432</span> MetaTableAccessor.scanMeta(clusterConnection, visitor, tableName, rowKey, 1);<a name="line.2432"></a> -<span class="sourceLineNo">2433</span> return result.get();<a name="line.2433"></a> -<span class="sourceLineNo">2434</span> }<a name="line.2434"></a> -<span class="sourceLineNo">2435</span><a name="line.2435"></a> -<span class="sourceLineNo">2436</span> @Override<a name="line.2436"></a> -<span class="sourceLineNo">2437</span> public long modifyTable(final TableName tableName, final TableDescriptor newDescriptor,<a name="line.2437"></a> -<span class="sourceLineNo">2438</span> final long nonceGroup, final long nonce) throws IOException {<a name="line.2438"></a> -<span class="sourceLineNo">2439</span> checkInitialized();<a name="line.2439"></a> -<span class="sourceLineNo">2440</span> sanityCheckTableDescriptor(newDescriptor);<a name="line.2440"></a> -<span class="sourceLineNo">2441</span><a name="line.2441"></a> -<span class="sourceLineNo">2442</span> return MasterProcedureUtil.submitProcedure(<a name="line.2442"></a> -<span class="sourceLineNo">2443</span> new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.2443"></a> -<span class="sourceLineNo">2444</span> @Override<a name="line.2444"></a> -<span class="sourceLineNo">2445</span> protected void run() throws IOException {<a name="line.2445"></a> -<span class="sourceLineNo">2446</span> TableDescriptor oldDescriptor = getMaster().getTableDescriptors().get(tableName);<a name="line.2446"></a> -<span class="sourceLineNo">2447</span> getMaster().getMasterCoprocessorHost()<a name="line.2447"></a> -<span class="sourceLineNo">2448</span> .preModifyTable(tableName, oldDescriptor, newDescriptor);<a name="line.2448"></a> -<span class="sourceLineNo">2449</span><a name="line.2449"></a> -<span class="sourceLineNo">2450</span> LOG.info(getClientIdAuditPrefix() + " modify " + tableName);<a name="line.2450"></a> -<span class="sourceLineNo">2451</span><a name="line.2451"></a> -<span class="sourceLineNo">2452</span> // Execute the operation synchronously - wait for the operation completes before continuing.<a name="line.2452"></a> -<span class="sourceLineNo">2453</span> //<a name="line.2453"></a> -<span class="sourceLineNo">2454</span> // We need to wait for the procedure to potentially fail due to "prepare" sanity<a name="line.2454"></a> -<span class="sourceLineNo">2455</span> // checks. This will block only the beginning of the procedure. See HBASE-19953.<a name="line.2455"></a> -<span class="sourceLineNo">2456</span> ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();<a name="line.2456"></a> -<span class="sourceLineNo">2457</span> submitProcedure(<a name="line.2457"></a> -<span class="sourceLineNo">2458</span> new ModifyTableProcedure(procedureExecutor.getEnvironment(), newDescriptor, latch));<a name="line.2458"></a> -<span class="sourceLineNo">2459</span> latch.await();<a name="line.2459"></a> -<span class="sourceLineNo">2460</span><a name="line.2460"></a> -<span class="sourceLineNo">2461</span> getMaster().getMasterCoprocessorHost()<a name="line.2461"></a> -<span class="sourceLineNo">2462</span> .postModifyTable(tableName, oldDescriptor, newDescriptor);<a name="line.2462"></a> -<span class="sourceLineNo">2463</span> }<a name="line.2463"></a> -<span class="sourceLineNo">2464</span><a name="line.2464"></a> -<span class="sourceLineNo">2465</span> @Override<a name="line.2465"></a> -<span class="sourceLineNo">2466</span> protected String getDescription() {<a name="line.2466"></a> -<span class="sourceLineNo">2467</span> return "ModifyTableProcedure";<a name="line.2467"></a> -<span class="sourceLineNo">2468</span> }<a name="line.2468"></a> -<span class="sourceLineNo">2469</span> });<a name="line.2469"></a> -<span class="sourceLineNo">2470</span> }<a name="line.2470"></a> -<span class="sourceLineNo">2471</span><a name="line.2471"></a> -<span class="sourceLineNo">2472</span> public long restoreSnapshot(final SnapshotDescription snapshotDesc,<a name="line.2472"></a> -<span class="sourceLineNo">2473</span> final long nonceGroup, final long nonce, final boolean restoreAcl) throws IOException {<a name="line.2473"></a> -<span class="sourceLineNo">2474</span> checkInitialized();<a name="line.2474"></a> -<span class="sourceLineNo">2475</span> getSnapshotManager().checkSnapshotSupport();<a name="line.2475"></a> -<span class="sourceLineNo">2476</span><a name="line.2476"></a> -<span class="sourceLineNo">2477</span> // Ensure namespace exists. Will throw exception if non-known NS.<a name="line.2477"></a> -<span class="sourceLineNo">2478</span> final TableName dstTable = TableName.valueOf(snapshotDesc.getTable());<a name="line.2478"></a> -<span class="sourceLineNo">2479</span> getClusterSchema().getNamespace(dstTable.getNamespaceAsString());<a name="line.2479"></a> -<span class="sourceLineNo">2480</span><a name="line.2480"></a> -<span class="sourceLineNo">2481</span> return MasterProcedureUtil.submitProcedure(<a name="line.2481"></a> -<span class="sourceLineNo">2482</span> new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.2482"></a> -<span class="sourceLineNo">2483</span> @Override<a name="line.2483"></a> -<span class="sourceLineNo">2484</span> protected void run() throws IOException {<a name="line.2484"></a> -<span class="sourceLineNo">2485</span> setProcId(<a name="line.2485"></a> -<span class="sourceLineNo">2486</span> getSnapshotManager().restoreOrCloneSnapshot(snapshotDesc, getNonceKey(), restoreAcl));<a name="line.2486"></a> -<span class="sourceLineNo">2487</span> }<a name="line.2487"></a> -<span class="sourceLineNo">2488</span><a name="line.2488"></a> -<span class="sourceLineNo">2489</span> @Override<a name="line.2489"></a> -<span class="sourceLineNo">2490</span> protected String getDescription() {<a name="line.2490"></a> -<span class="sourceLineNo">2491</span> return "RestoreSnapshotProcedure";<a name="line.2491"></a> -<span class="sourceLineNo">2492</span> }<a name="line.2492"></a> -<span class="sourceLineNo">2493</span> });<a name="line.2493"></a> -<span class="sourceLineNo">2494</span> }<a name="line.2494"></a> -<span class="sourceLineNo">2495</span><a name="line.2495"></a> -<span class="sourceLineNo">2496</span> private void checkTableExists(final TableName tableName)<a name="line.2496"></a> -<span class="sourceLineNo">2497</span> throws IOException, TableNotFoundException {<a name="line.2497"></a> -<span class="sourceLineNo">2498</span> if (!MetaTableAccessor.tableExists(getConnection(), tableName)) {<a name="line.2498"></a> -<span class="sourceLineNo">2499</span> throw new TableNotFoundException(tableName);<a name="line.2499"></a> -<span class="sourceLineNo">2500</span> }<a name="line.2500"></a> -<span class="sourceLineNo">2501</span> }<a name="line.2501"></a> -<span class="sourceLineNo">2502</span><a name="line.2502"></a> -<span class="sourceLineNo">2503</span> @Override<a name="line.2503"></a> -<span class="sourceLineNo">2504</span> public void checkTableModifiable(final TableName tableName)<a name="line.2504"></a> -<span class="sourceLineNo">2505</span> throws IOException, TableNotFoundException, TableNotDisabledException {<a name="line.2505"></a> -<span class="sourceLineNo">2506</span> if (isCatalogTable(tableName)) {<a name="line.2506"></a> -<span class="sourceLineNo">2507</span> throw new IOException("Can't modify catalog tables");<a name="line.2507"></a> -<span class="sourceLineNo">2508</span> }<a name="line.2508"></a> -<span class="sourceLineNo">2509</span> checkTableExists(tableName);<a name="line.2509"></a> -<span class="sourceLineNo">2510</span> TableState ts = getTableStateManager().getTableState(tableName);<a name="line.2510"></a> -<span class="sourceLineNo">2511</span> if (!ts.isDisabled()) {<a name="line.2511"></a> -<span class="sourceLineNo">2512</span> throw new TableNotDisabledException("Not DISABLED; " + ts);<a name="line.2512"></a> -<span class="sourceLineNo">2513</span> }<a name="line.2513"></a> -<span class="sourceLineNo">2514</span> }<a name="line.2514"></a> -<span class="sourceLineNo">2515</span><a name="line.2515"></a> -<span class="sourceLineNo">2516</span> public ClusterMetrics getClusterMetricsWithoutCoprocessor() throws InterruptedIOException {<a name="line.2516"></a> -<span class="sourceLineNo">2517</span> return getClusterMetricsWithoutCoprocessor(EnumSet.allOf(Option.class));<a name="line.2517"></a> -<span class="sourceLineNo">2518</span> }<a name="line.2518"></a> -<span class="sourceLineNo">2519</span><a name="line.2519"></a> -<span class="sourceLineNo">2520</span> public ClusterMetrics getClusterMetricsWithoutCoprocessor(EnumSet<Option> options)<a name="line.2520"></a> -<span class="sourceLineNo">2521</span> throws InterruptedIOException {<a name="line.2521"></a> -<span class="sourceLineNo">2522</span> ClusterMetricsBuilder builder = ClusterMetricsBuilder.newBuilder();<a name="line.2522"></a> -<span class="sourceLineNo">2523</span> // given that hbase1 can't submit the request with Option,<a name="line.2523"></a> -<span class="sourceLineNo">2524</span> // we return all information to client if the list of Option is empty.<a name="line.2524"></a> -<span class="sourceLineNo">2525</span> if (options.isEmpty()) {<a name="line.2525"></a> -<span class="sourceLineNo">2526</span> options = EnumSet.allOf(Option.class);<a name="line.2526"></a> -<span class="sourceLineNo">2527</span> }<a name="line.2527"></a> -<span class="sourceLineNo">2528</span><a name="line.2528"></a> -<span class="sourceLineNo">2529</span> for (Option opt : options) {<a name="line.2529"></a> -<span class="sourceLineNo">2530</span> switch (opt) {<a name="line.2530"></a> -<span class="sourceLineNo">2531</span> case HBASE_VERSION: builder.setHBaseVersion(VersionInfo.getVersion()); break;<a name="line.2531"></a> -<span class="sourceLineNo">2532</span> case CLUSTER_ID: builder.setClusterId(getClusterId()); break;<a name="line.2532"></a> -<span class="sourceLineNo">2533</span> case MASTER: builder.setMasterName(getServerName()); break;<a name="line.2533"></a> -<span class="sourceLineNo">2534</span> case BACKUP_MASTERS: builder.setBackerMasterNames(getBackupMasters()); break;<a name="line.2534"></a> -<span class="sourceLineNo">2535</span> case LIVE_SERVERS: {<a name="line.2535"></a> -<span class="sourceLineNo">2536</span> if (serverManager != null) {<a name="line.2536"></a> -<span class="sourceLineNo">2537</span> builder.setLiveServerMetrics(serverManager.getOnlineServers().entrySet().stream()<a name="line.2537"></a> -<span class="sourceLineNo">2538</span> .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())));<a name="line.2538"></a> -<span class="sourceLineNo">2539</span> }<a name="line.2539"></a> -<span class="sourceLineNo">2540</span> break;<a name="line.2540"></a> -<span class="sourceLineNo">2541</span> }<a name="line.2541"></a> -<span class="sourceLineNo">2542</span> case DEAD_SERVERS: {<a name="line.2542"></a> -<span class="sourceLineNo">2543</span> if (serverManager != null) {<a name="line.2543"></a> -<span class="sourceLineNo">2544</span> builder.setDeadServerNames(new ArrayList<>(<a name="line.2544"></a> -<span class="sourceLineNo">2545</span> serverManager.getDeadServers().copyServerNames()));<a name="line.2545"></a> -<span class="sourceLineNo">2546</span> }<a name="line.2546"></a> -<span class="sourceLineNo">2547</span> break;<a name="line.2547"></a> -<span class="sourceLineNo">2548</span> }<a name="line.2548"></a> -<span class="sourceLineNo">2549</span> case MASTER_COPROCESSORS: {<a name="line.2549"></a> -<span class="sourceLineNo">2550</span> if (cpHost != null) {<a name="line.2550"></a> -<span class="sourceLineNo">2551</span> builder.setMasterCoprocessorNames(Arrays.asList(getMasterCoprocessors()));<a name="line.2551"></a> -<span class="sourceLineNo">2552</span> }<a name="line.2552"></a> -<span class="sourceLineNo">2553</span> break;<a name="line.2553"></a> -<span class="sourceLineNo">2554</span> }<a name="line.2554"></a> -<span class="sourceLineNo">2555</span> case REGIONS_IN_TRANSITION: {<a name="line.2555"></a> -<span class="sourceLineNo">2556</span> if (assignmentManager != null) {<a name="line.2556"></a> -<span class="sourceLineNo">2557</span> builder.setRegionsInTransition(assignmentManager.getRegionStates()<a name="line.2557"></a> -<span class="sourceLineNo">2558</span> .getRegionsStateInTransition());<a name="line.2558"></a> -<span class="sourceLineNo">2559</span> }<a name="line.2559"></a> -<span class="sourceLineNo">2560</span> break;<a name="line.2560"></a> -<span class="sourceLineNo">2561</span> }<a name="line.2561"></a> -<span class="sourceLineNo">2562</span> case BALANCER_ON: {<a name="line.2562"></a> -<span class="sourceLineNo">2563</span> if (loadBalancerTracker != null) {<a name="line.2563"></a> -<span class="sourceLineNo">2564</span> builder.setBalancerOn(loadBalancerTracker.isBalancerOn());<a name="line.2564"></a> -<span class="sourceLineNo">2565</span> }<a name="line.2565"></a> -<span class="sourceLineNo">2566</span> break;<a name="line.2566"></a> -<span class="sourceLineNo">2567</span> }<a name="line.2567"></a> -<span class="sourceLineNo">2568</span> case MASTER_INFO_PORT: {<a name="line.2568"></a> -<span class="sourceLineNo">2569</span> if (infoServer != null) {<a name="line.2569"></a> -<span class="sourceLineNo">2570</span> builder.setMasterInfoPort(infoServer.getPort());<a name="line.2570"></a> -<span class="sourceLineNo">2571</span> }<a name="line.2571"></a> -<span class="sourceLineNo">2572</span> break;<a name="line.2572"></a> -<span class="sourceLineNo">2573</span> }<a name="line.2573"></a> -<span class="sourceLineNo">2574</span> }<a name="line.2574"></a> -<span class="sourceLineNo">2575</span> }<a name="line.2575"></a> -<span class="sourceLineNo">2576</span> return builder.build();<a name="line.2576"></a> -<span class="sourceLineNo">2577</span> }<a name="line.2577"></a> -<span class="sourceLineNo">2578</span><a name="line.2578"></a> -<span class="sourceLineNo">2579</span> /**<a name="line.2579"></a> -<span class="sourceLineNo">2580</span> * @return cluster status<a name="line.2580"></a> -<span class="sourceLineNo">2581</span> */<a name="line.2581"></a> -<span class="sourceLineNo">2582</span> public ClusterMetrics getClusterMetrics() throws IOException {<a name="line.2582"></a> -<span class="sourceLineNo">2583</span> return getClusterMetrics(EnumSet.allOf(Option.class));<a name="line.2583"></a> -<span class="sourceLineNo">2584</span> }<a name="line.2584"></a> -<span class="sourceLineNo">2585</span><a name="line.2585"></a> -<span class="sourceLineNo">2586</span> public ClusterMetrics getClusterMetrics(EnumSet<Option> options) throws IOException {<a name="line.2586"></a> -<span class="sourceLineNo">2587</span> if (cpHost != null) {<a name="line.2587"></a> -<span class="sourceLineNo">2588</span> cpHost.preGetClusterMetrics();<a name="line.2588"></a> -<span class="sourceLineNo">2589</span> }<a name="line.2589"></a> -<span class="sourceLineNo">2590</span> ClusterMetrics status = getClusterMetricsWithoutCoprocessor(options);<a name="line.2590"></a> -<span class="sourceLineNo">2591</span> if (cpHost != null) {<a name="line.2591"></a> -<span class="sourceLineNo">2592</span> cpHost.postGetClusterMetrics(status);<a name="line.2592"></a> -<span class="sourceLineNo">2593</span> }<a name="line.2593"></a> -<span class="sourceLineNo">2594</span> return status;<a name="line.2594"></a> -<span class="sourceLineNo">2595</span> }<a name="line.2595"></a> -<span class="sourceLineNo">2596</span><a name="line.2596"></a> -<span class="sourceLineNo">2597</span> private List<ServerName> getBackupMasters() throws InterruptedIOException {<a name="line.2597"></a> -<span class="sourceLineNo">2598</span> // Build Set of backup masters from ZK nodes<a name="line.2598"></a> -<span class="sourceLineNo">2599</span> List<String> backupMasterStrings;<a name="line.2599"></a> -<span class="sourceLineNo">2600</span> try {<a name="line.2600"></a> -<span class="sourceLineNo">2601</span> backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper,<a name="line.2601"></a> -<span class="sourceLineNo">2602</span> this.zooKeeper.getZNodePaths().backupMasterAddressesZNode);<a name="line.2602"></a> -<span class="sourceLineNo">2603</span> } catch (KeeperException e) {<a name="line.2603"></a> -<span class="sourceLineNo">2604</span> LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e);<a name="line.2604"></a> -<span class="sourceLineNo">2605</span> backupMasterStrings = null;<a name="line.2605"></a> -<span class="sourceLineNo">2606</span> }<a name="line.2606"></a> -<span class="sourceLineNo">2607</span><a name="line.2607"></a> -<span class="sourceLineNo">2608</span> List<ServerName> backupMasters = Collections.emptyList();<a name="line.2608"></a> -<span class="sourceLineNo">2609</span> if (backupMasterStrings != null && !backupMasterStrings.isEmpty()) {<a name="line.2609"></a> -<span class="sourceLineNo">2610</span> backupMasters = new ArrayList<>(backupMasterStrings.size());<a name="line.2610"></a> -<span class="sourceLineNo">2611</span> for (String s: backupMasterStrings) {<a name="line.2611"></a> -<span class="sourceLineNo">2612</span> try {<a name="line.2612"></a> -<span class="sourceLineNo">2613</span> byte [] bytes;<a name="line.2613"></a> -<span class="sourceLineNo">2614</span> try {<a name="line.2614"></a> -<span class="sourceLineNo">2615</span> bytes = ZKUtil.getData(this.zooKeeper, ZNodePaths.joinZNode(<a name="line.2615"></a> -<span class="sourceLineNo">2616</span> this.zooKeeper.getZNodePaths().backupMasterAddressesZNode, s));<a name="line.2616"></a> -<span class="sourceLineNo">2617</span> } catch (InterruptedException e) {<a name="line.2617"></a> -<span class="sourceLineNo">2618</span> throw new InterruptedIOException();<a name="line.2618"></a> -<span class="sourceLineNo">2619</span> }<a name="line.2619"></a> -<span class="sourceLineNo">2620</span> if (bytes != null) {<a name="line.2620"></a> -<span class="sourceLineNo">2621</span> ServerName sn;<a name="line.2621"></a> -<span class="sourceLineNo">2622</span> try {<a name="line.2622"></a> -<span class="sourceLineNo">2623</span> sn = ProtobufUtil.parseServerNameFrom(bytes);<a name="line.2623"></a> -<span class="sourceLineNo">2624</span> } catch (DeserializationException e) {<a name="line.2624"></a> -<span class="sourceLineNo">2625</span> LOG.warn("Failed parse, skipping registering backup server", e);<a name="line.2625"></a> -<span class="sourceLineNo">2626</span> continue;<a name="line.2626"></a> -<span class="sourceLineNo">2627</span> }<a name="line.2627"></a> -<span class="sourceLineNo">2628</span> backupMasters.add(sn);<a name="line.2628"></a> -<span class="sourceLineNo">2629</span> }<a name="line.2629"></a> -<span class="sourceLineNo">2630</span> } catch (KeeperException e) {<a name="line.2630"></a> -<span class="sourceLineNo">2631</span> LOG.warn(this.zooKeeper.prefix("Unable to get information about " +<a name="line.2631"></a> -<span class="sourceLineNo">2632</span> "backup servers"), e);<a name="line.2632"></a> -<span class="sourceLineNo">2633</span> }<a name="line.2633"></a> -<span class="sourceLineNo">2634</span> }<a name="line.2634"></a> -<span class="sourceLineNo">2635</span> Collections.sort(backupMasters, new Comparator<ServerName>() {<a name="line.2635"></a> -<span class="sourceLineNo">2636</span> @Override<a name="line.2636"></a> -<span class="sourceLineNo">2637</span> public int compare(ServerName s1, ServerName s2) {<a name="line.2637"></a> -<span class="sourceLineNo">2638</span> return s1.getServerName().compareTo(s2.getServerName());<a name="line.2638"></a> -<span class="sourceLineNo">2639</span> }});<a name="line.2639"></a> -<span class="sourceLineNo">2640</span> }<a name="line.2640"></a> -<span class="sourceLineNo">2641</span> return backupMasters;<a name="line.2641"></a> -<span class="sourceLineNo">2642</span> }<a name="line.2642"></a> -<span class="sourceLineNo">2643</span><a name="line.2643"></a> -<span class="sourceLineNo">2644</span> /**<a name="line.2644"></a> -<span class="sourceLineNo">2645</span> * The set of loaded coprocessors is stored in a static set. Since it's<a name="line.2645"></a> -<span class="sourceLineNo">2646</span> * statically allocated, it does not require that HMaster's cpHost be<a name="line.2646"></a> -<span class="sourceLineNo">2647</span> * initialized prior to accessing it.<a name="line.2647"></a> -<span class="sourceLineNo">2648</span> * @return a String representation of the set of names of the loaded coprocessors.<a name="line.2648"></a> -<span class="sourceLineNo">2649</span> */<a name="line.2649"></a> -<span class="sourceLineNo">2650</span> public static String getLoadedCoprocessors() {<a name="line.2650"></a> -<span class="sourceLineNo">2651</span> return CoprocessorHost.getLoadedCoprocessors().toString();<a name="line.2651"></a> -<span class="sourceLineNo">2652</span> }<a name="line.2652"></a> -<span class="sourceLineNo">2653</span><a name="line.2653"></a> -<span class="sourceLineNo">2654</span> /**<a name="line.2654"></a> -<span class="sourceLineNo">2655</span> * @return timestamp in millis when HMaster was started.<a name="line.2655"></a> -<span class="sourceLineNo">2656</span> */<a name="line.2656"></a> -<span class="sourceLineNo">2657</span> public long getMasterStartTime() {<a name="line.2657"></a> -<span class="sourceLineNo">2658</span> return startcode;<a name="line.2658"></a> -<span class="sourceLineNo">2659</span> }<a name="line.2659"></a> -<span class="sourceLineNo">2660</span><a name="line.2660"></a> -<span class="sourceLineNo">2661</span> /**<a name="line.2661"></a> -<span class="sourceLineNo">2662</span> * @return timestamp in millis when HMaster became the active master.<a name="line.2662"></a> -<span class="sourceLineNo">2663</span> */<a name="line.2663"></a> -<span class="sourceLineNo">2664</span> public long getMasterActiveTime() {<a name="line.2664"></a> -<span class="sourceLineNo">2665</span> return masterActiveTime;<a name="line.2665"></a> -<span class="sourceLineNo">2666</span> }<a name="line.2666"></a> -<span class="sourceLineNo">2667</span><a name="line.2667"></a> -<span class="sourceLineNo">2668</span> /**<a name="line.2668"></a> -<span class="sourceLineNo">2669</span> * @return timestamp in millis when HMaster finished becoming the active master<a name="line.2669"></a> -<span class="sourceLineNo">2670</span> */<a name="line.2670"></a> -<span class="sourceLineNo">2671</span> public long getMasterFinishedInitializationTime() {<a name="line.2671"></a> -<span class="sourceLineNo">2672</span> return masterFinishedInitializationTime;<a name="line.2672"></a> -<span class="sourceLineNo">2673</span> }<a name="line.2673"></a> -<span class="sourceLineNo">2674</span><a name="line.2674"></a> -<span class="sourceLineNo">2675</span> public int getNumWALFiles() {<a name="line.2675"></a> -<span class="sourceLineNo">2676</span> return procedureStore != null ? procedureStore.getActiveLogs().size() : 0;<a name="line.2676"></a> -<span class="sourceLineNo">2677</span> }<a name="line.2677"></a> -<span class="sourceLineNo">2678</span><a name="line.2678"></a> -<span class="sourceLineNo">2679</span> public WALProcedureStore getWalProcedureStore() {<a name="line.2679"></a> -<span class="sourceLineNo">2680</span> return procedureStore;<a name="line.2680"></a> -<span class="sourceLineNo">2681</span> }<a name="line.2681"></a> -<span class="sourceLineNo">2682</span><a name="line.2682"></a> -<span class="sourceLineNo">2683</span> public int getRegionServerInfoPort(final ServerName sn) {<a name="line.2683"></a> -<span class="sourceLineNo">2684</span> int port = this.serverManager.getInfoPort(sn);<a name="line.2684"></a> -<span class="sourceLineNo">2685</span> return port == 0 ? conf.getInt(HConstants.REGIONSERVER_INFO_PORT,<a name="line.2685"></a> -<span class="sourceLineNo">2686</span> HConstants.DEFAULT_REGIONSERVER_INFOPORT) : port;<a name="line.2686"></a> -<span class="sourceLineNo">2687</span> }<a name="line.2687"></a> -<span class="sourceLineNo">2688</span><a name="line.2688"></a> -<span class="sourceLineNo">2689</span> @Override<a name="line.2689"></a> -<span class="sourceLineNo">2690</span> public String getRegionServerVersion(final ServerName sn) {<a name="line.2690"></a> -<span class="sourceLineNo">2691</span> // Will return 0 if the server is not online to prevent move system region to unknown version<a name="line.2691"></a> -<span class="sourceLineNo">2692</span> // RS.<a name="line.2692"></a> -<span class="sourceLineNo">2693</span> int versionNumber = this.serverManager.getServerVersion(sn);<a name="line.2693"></a> -<span class="sourceLineNo">2694</span> return VersionInfoUtil.versionNumberToString(versionNumber);<a name="line.2694"></a> -<span class="sourceLineNo">2695</span> }<a name="line.2695"></a> -<span class="sourceLineNo">2696</span><a name="line.2696"></a> -<span class="sourceLineNo">2697</span> @Override<a name="line.2697"></a> -<span class="sourceLineNo">2698</span> public void checkIfShouldMoveSystemRegionAsync() {<a name="line.2698"></a> -<span class="sourceLineNo">2699</span> assignmentManager.checkIfShouldMoveSystemRegionAsync();<a name="line.2699"></a> -<span class="sourceLineNo">2700</span> }<a name="line.2700"></a> -<span class="sourceLineNo">2701</span><a name="line.2701"></a> -<span class="sourceLineNo">2702</span> /**<a name="line.2702"></a> -<span class="sourceLineNo">2703</span> * @return array of coprocessor SimpleNames.<a name="line.2703"></a> -<span class="sourceLineNo">2704</span> */<a name="line.2704"></a> -<span class="sourceLineNo">2705</span> public String[] getMasterCoprocessors() {<a name="line.2705"></a> -<span class="sourceLineNo">2706</span> Set<String> masterCoprocessors = getMasterCoprocessorHost().getCoprocessors();<a name="line.2706"></a> -<span class="sourceLineNo">2707</span> return masterCoprocessors.toArray(new String[masterCoprocessors.size()]);<a name="line.2707"></a> -<span class="sourceLineNo">2708</span> }<a name="line.2708"></a> -<span class="sourceLineNo">2709</span><a name="line.2709"></a> -<span class="sourceLineNo">2710</span> @Override<a name="line.2710"></a> -<span class="sourceLineNo">2711</span> public void abort(String reason, Throwable cause) {<a name="line.2711"></a> -<span class="sourceLineNo">2712</span> if (isAborted() || isStopped()) {<a name="line.2712"></a> -<span class="sourceLineNo">2713</span> return;<a name="line.2713"></a> -<span class="sourceLineNo">2714</span> }<a name="line.2714"></a> -<span class="sourceLineNo">2715</span> if (cpHost != null) {<a name="line.2715"></a> -<span class="sourceLineNo">2716</span> // HBASE-4014: dump a list of loaded coprocessors.<a name="line.2716"></a> -<span class="sourceLineNo">2717</span> LOG.error(HBaseMarkers.FATAL, "Master server abort: loaded coprocessors are: " +<a name="line.2717"></a> -<span class="sourceLineNo">2718</span> getLoadedCoprocessors());<a name="line.2718"></a> -<span class="sourceLineNo">2719</span> }<a name="line.2719"></a> -<span class="sourceLineNo">2720</span> String msg = "***** ABORTING master " + this + ": " + reason + " *****";<a name="line.2720"></a> -<span class="sourceLineNo">2721</span> if (cause != null) {<a name="line.2721"></a> -<span class="sourceLineNo">2722</span> LOG.error(HBaseMarkers.FATAL, msg, cause);<a name="line.2722"></a> -<span class="sourceLineNo">2723</span> } else {<a name="line.2723"></a> -<span class="sourceLineNo">2724</span> LOG.error(HBaseMarkers.FATAL, msg);<a name="line.2724"></a> -<span class="sourceLineNo">2725</span> }<a name="line.2725"></a> -<span class="sourceLineNo">2726</span><a name="line.2726"></a> -<span class="sourceLineNo">2727</span> try {<a name="line.2727"></a> -<span class="sourceLineNo">2728</span> stopMaster();<a name="line.2728"></a> -<span class="sourceLineNo">2729</span> } catch (IOException e) {<a name="line.2729"></a> -<span class="sourceLineNo">2730</span> LOG.error("Exception occurred while stopping master", e);<a name="line.2730"></a> -<span class="sourceLineNo">2731</span> }<a name="line.2731"></a> -<span class="sourceLineNo">2732</span> }<a name="line.2732"></a> -<span class="sourceLineNo">2733</span><a name="line.2733"></a> -<span class="sourceLineNo">2734</span> @Override<a name="line.2734"></a> -<span class="sourceLineNo">2735</span> public ZKWatcher getZooKeeper() {<a name="line.2735"></a> -<span class="sourceLineNo">2736</span> return zooKeeper;<a name="line.2736"></a> -<span class="sourceLineNo">2737</span> }<a name="line.2737"></a> -<span class="sourceLineNo">2738</span><a name="line.2738"></a> -<span class="sourceLineNo">2739</span> @Override<a name="line.2739"></a> -<span class="sourceLineNo">2740</span> public MasterCoprocessorHost getMasterCoprocessorHost() {<a name="line.2740"></a> -<span class="sourceLineNo">2741</span> return cpHost;<a name="line.2741"></a> -<span class="sourceLineNo">2742</span> }<a name="line.2742"></a> -<span class="sourceLineNo">2743</span><a name="line.2743"></a> -<span class="sourceLineNo">2744</span> @Override<a name="line.2744"></a> -<span class="sourceLineNo">2745</span> public MasterQuotaManager getMasterQuotaManager() {<a name="line.2745"></a> -<span class="sourceLineNo">2746</span> return quotaManager;<a name="line.2746"></a> -<span class="sourceLineNo">2747</span> }<a name="line.2747"></a> -<span class="sourceLineNo">2748</span><a name="line.2748"></a> -<span class="sourceLineNo">2749</span> @Override<a name="line.2749"></a> -<span class="sourceLineNo">2750</span> public ProcedureExecutor<MasterProcedureEnv> getMasterProcedureExecutor() {<a name="line.2750"></a> -<span class="sourceLineNo">2751</span> return procedureExecutor;<a name="line.2751"></a> -<span class="sourceLineNo">2752</span> }<a name="line.2752"></a> -<span class="sourceLineNo">2753</span><a name="line.2753"></a> -<span class="sourceLineNo">2754</span> @Override<a name="line.2754"></a> -<span class="sourceLineNo">2755</span> public ServerName getServerName() {<a name="line.2755"></a> -<span class="sourceLineNo">2756</span> return this.serverName;<a name="line.2756"></a> -<span class="sourceLineNo">2757</span> }<a name="line.2757"></a> -<span class="sourceLineNo">2758</span><a name="line.2758"></a> -<span class="sourceLineNo">2759</span> @Override<a name="line.2759"></a> -<span class="sourceLineNo">2760</span> public AssignmentManager getAssignmentManager() {<a name="line.2760"></a> -<span class="sourceLineNo">2761</span> return this.assignmentManager;<a name="line.2761"></a> -<span class="sourceLineNo">2762</span> }<a name="line.2762"></a> -<span class="sourceLineNo">2763</span><a name="line.2763"></a> -<span class="sourceLineNo">2764</span> @Override<a name="line.2764"></a> -<span class="sourceLineNo">2765</span> public CatalogJanitor getCatalogJanitor() {<a name="line.2765"></a> -<span class="sourceLineNo">2766</span> return this.catalogJanitorChore;<a name="line.2766"></a> -<span class="sourceLineNo">2767</span> }<a name="line.2767"></a> -<span class="sourceLineNo">2768</span><a name="line.2768"></a> -<span class="sourceLineNo">2769</span> public MemoryBoundedLogMessageBuffer getRegionServerFatalLogBuffer() {<a name="line.2769"></a> -<span class="sourceLineNo">2770</span> return rsFatals;<a name="line.2770"></a> -<span class="sourceLineNo">2771</span> }<a name="line.2771"></a> -<span class="sourceLineNo">2772</span><a name="line.2772"></a> -<span class="sourceLineNo">2773</span> /**<a name="line.2773"></a> -<span class="sourceLineNo">2774</span> * Shutdown the cluster.<a name="line.2774"></a> -<span class="sourceLineNo">2775</span> * Master runs a coordinated stop of all RegionServers and then itself.<a name="line.2775"></a> -<span class="sourceLineNo">2776</span> */<a name="line.2776"></a> -<span class="sourceLineNo">2777</span> public void shutdown() throws IOException {<a name="line.2777"></a> -<span class="sourceLineNo">2778</span> if (cpHost != null) {<a name="line.2778"></a> -<span class="sourceLineNo">2779</span> cpHost.preShutdown();<a name="line.2779"></a> -<span class="sourceLineNo">2780</span> }<a name="line.2780"></a> -<span class="sourceLineNo">2781</span> // Tell the servermanager cluster shutdown has been called. This makes it so when Master is<a name="line.2781"></a> -<span class="sourceLineNo">2782</span> // last running server, it'll stop itself. Next, we broadcast the cluster shutdown by setting<a name="line.2782"></a> -<span class="sourceLineNo">2783</span> // the cluster status as down. RegionServers will notice this change in state and will start<a name="line.2783"></a> -<span class="sourceLineNo">2784</span> // shutting themselves down. When last has exited, Master can go down.<a name="line.2784"></a> -<span class="sourceLineNo">2785</span> if (this.serverManager != null) {<a name="line.2785"></a> -<span class="sourceLineNo">2786</span> this.serverManager.shutdownCluster();<a name="line.2786"></a> -<span class="sourceLineNo">2787</span> }<a name="line.2787"></a> -<span class="sourceLineNo">2788</span> if (this.clusterStatusTracker != null) {<a name="line.2788"></a> -<span class="sourceLineNo">2789</span> try {<a name="line.2789"></a> -<span class="sourceLineNo">2790</span> this.clusterStatusTracker.setClusterDown();<a name="line.2790"></a> -<span class="sourceLineNo">2791</span> } catch (KeeperException e) {<a name="line.2791"></a> -<span class="sourceLineNo">2792</span> LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e);<a name="line.2792"></a> -<span class="sourceLineNo">2793</span> }<a name="line.2793"></a> -<span class="sourceLineNo">2794</span> }<a name="line.2794"></a> -<span class="sourceLineNo">2795</span> // Stop the procedure executor. Will stop any ongoing assign, unassign, server crash etc.,<a name="line.2795"></a> -<span class="sourceLineNo">2796</span> // processing so we can go down.<a name="line.2796"></a> -<span class="sourceLineNo">2797</span> if (this.procedureExecutor != null) {<a name="line.2797"></a> -<span class="sourceLineNo">2798</span> this.procedureExecutor.stop();<a name="line.2798"></a> -<span class="sourceLineNo">2799</span> }<a name="line.2799"></a> -<span class="sourceLineNo">2800</span> // Shutdown our cluster connection. This will kill any hosted RPCs that might be going on;<a name="line.2800"></a> -<span class="sourceLineNo">2801</span> // this is what we want especially if the Master is in startup phase doing call outs to<a name="line.2801"></a> -<span class="sourceLineNo">2802</span> // hbase:meta, etc. when cluster is down. Without ths connection close, we'd have to wait on<a name="line.2802"></a> -<span class="sourceLineNo">2803</span> // the rpc to timeout.<a name="line.2803"></a> -<span class="sourceLineNo">2804</span> if (this.clusterConnection != null) {<a name="line.2804"></a> -<span class="sourceLineNo">2805</span> this.clusterConnection.close();<a name="line.2805"></a> -<span class="sourceLineNo">2806</span> }<a name="line.2806"></a> -<span class="sourceLineNo">2807</span> }<a name="line.2807"></a> -<span class="sourceLineNo">2808</span><a name="line.2808"></a> -<span class="sourceLineNo">2809</span> public void stopMaster() throws IOException {<a name="line.2809"></a> -<span class="sourceLineNo">2810</span> if (cpHost != null) {<a name="line.2810"></a> -<span class="sourceLineNo">2811</span> cpHost.preStopMaster();<a name="line.2811"></a> -<span class="sourceLineNo">2812</span> }<a name="line.2812"></a> -<span class="sourceLineNo">2813</span> stop("Stopped by " + Thread.currentThread().getName());<a name="line.2813"></a> -<span class="sourceLineNo">2814</span> }<a name="line.2814"></a> -<span class="sourceLineNo">2815</span><a name="line.2815"></a> -<span class="sourceLineNo">2816</span> @Override<a name="line.2816"></a> -<span class="sourceLineNo">2817</span> public void stop(String msg) {<a name="line.2817"></a> -<span class="sourceLineNo">2818</span> if (!isStopped()) {<a name="line.2818"></a> -<span class="sourceLineNo">2819</span> super.stop(msg);<a name="line.2819"></a> -<span class="sourceLineNo">2820</span> if (this.activeMasterManager != null) {<a name="line.2820"></a> -<span class="sourceLineNo">2821</span> this.activeMasterManager.stop();<a name="line.2821"></a> -<span class="sourceLineNo">2822</span> }<a name="line.2822"></a> -<span class="sourceLineNo">2823</span> }<a name="line.2823"></a> -<span class="sourceLineNo">2824</span> }<a name="line.2824"></a> -<span class="sourceLineNo">2825</span><a name="line.2825"></a> -<span class="sourceLineNo">2826</span> void checkServiceStarted() throws ServerNotRunningYetException {<a name="line.2826"></a> -<span class="sourceLineNo">2827</span> if (!serviceStarted) {<a name="line.2827"></a> -<span class="sourceLineNo">2828</span> throw new ServerNotRunningYetException("Server is not running yet");<a name="line.2828"></a> -<span class="sourceLineNo">2829</span> }<a name="line.2829"></a> +<span class="sourceLineNo">2380</span> LOG.info(getClientIdAuditPrefix() + " disable " + tableName);<a name="line.2380"></a> +<span class="sourceLineNo">2381</span><a name="line.2381"></a> +<span class="sourceLineNo">2382</span> // Execute the operation asynchronously - client will check the progress of the operation<a name="line.2382"></a> +<span class="sourceLineNo">2383</span> // In case the request is from a <1.1 client before returning,<a name="line.2383"></a> +<span class="sourceLineNo">2384</span> // we want to make sure that the table is prepared to be<a name="line.2384"></a> +<span class="sourceLineNo">2385</span> // enabled (the table is locked and the table state is set).<a name="line.2385"></a> +<span class="sourceLineNo">2386</span> // Note: if the procedure throws exception, we will catch it and rethrow.<a name="line.2386"></a> +<span class="sourceLineNo">2387</span> //<a name="line.2387"></a> +<span class="sourceLineNo">2388</span> // We need to wait for the procedure to potentially fail due to "prepare" sanity<a name="line.2388"></a> +<span class="sourceLineNo">2389</span> // checks. This will block only the beginning of the procedure. See HBASE-19953.<a name="line.2389"></a> +<span class="sourceLineNo">2390</span> final ProcedurePrepareLatch prepareLatch = ProcedurePrepareLatch.createBlockingLatch();<a name="line.2390"></a> +<span class="sourceLineNo">2391</span> submitProcedure(new DisableTableProcedure(procedureExecutor.getEnvironment(),<a name="line.2391"></a> +<span class="sourceLineNo">2392</span> tableName, false, prepareLatch));<a name="line.2392"></a> +<span class="sourceLineNo">2393</span> prepareLatch.await();<a name="line.2393"></a> +<span class="sourceLineNo">2394</span><a name="line.2394"></a> +<span class="sourceLineNo">2395</span> getMaster().getMasterCoprocessorHost().postDisableTable(tableName);<a name="line.2395"></a> +<span class="sourceLineNo">2396</span> }<a name="line.2396"></a> +<span class="sourceLineNo">2397</span><a name="line.2397"></a> +<span class="sourceLineNo">2398</span> @Override<a name="line.2398"></a> +<span class="sourceLineNo">2399</span> protected String getDescription() {<a name="line.2399"></a> +<span class="sourceLineNo">2400</span> return "DisableTableProcedure";<a name="line.2400"></a> +<span class="sourceLineNo">2401</span> }<a name="line.2401"></a> +<span class="sourceLineNo">2402</span> });<a name="line.2402"></a> +<span class="sourceLineNo">2403</span> }<a name="line.2403"></a> +<span class="sourceLineNo">2404</span><a name="line.2404"></a> +<span class="sourceLineNo">2405</span> /**<a name="line.2405"></a> +<span class="sourceLineNo">2406</span> * Return the region and current deployment for the region containing<a name="line.2406"></a> +<span class="sourceLineNo">2407</span> * the given row. If the region cannot be found, returns null. If it<a name="line.2407"></a> +<span class="sourceLineNo">2408</span> * is found, but not currently deployed, the second element of the pair<a name="line.2408"></a> +<span class="sourceLineNo">2409</span> * may be null.<a name="line.2409"></a> +<span class="sourceLineNo">2410</span> */<a name="line.2410"></a> +<span class="sourceLineNo">2411</span> @VisibleForTesting // Used by TestMaster.<a name="line.2411"></a> +<span class="sourceLineNo">2412</span> Pair<RegionInfo, ServerName> getTableRegionForRow(<a name="line.2412"></a> +<span class="sourceLineNo">2413</span> final TableName tableName, final byte [] rowKey)<a name="line.2413"></a> +<span class="sourceLineNo">2414</span> throws IOException {<a name="line.2414"></a> +<span class="sourceLineNo">2415</span> final AtomicReference<Pair<RegionInfo, ServerName>> result = new AtomicReference<>(null);<a name="line.2415"></a> +<span class="sourceLineNo">2416</span><a name="line.2416"></a> +<span class="sourceLineNo">2417</span> MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() {<a name="line.2417"></a> +<span class="sourceLineNo">2418</span> @Override<a name="line.2418"></a> +<span class="sourceLineNo">2419</span> public boolean visit(Result data) throws IOException {<a name="line.2419"></a> +<span class="sourceLineNo">2420</span> if (data == null || data.size() <= 0) {<a name="line.2420"></a> +<span class="sourceLineNo">2421</span> return true;<a name="line.2421"></a> +<span class="sourceLineNo">2422</span> }<a name="line.2422"></a> +<span class="sourceLineNo">2423</span> Pair<RegionInfo, ServerName> pair =<a name="line.2423"></a> +<span class="sourceLineNo">2424</span> new Pair<>(MetaTableAccessor.getRegionInfo(data),<a name="line.2424"></a> +<span class="sourceLineNo">2425</span> MetaTableAccessor.getServerName(data,0));<a name="line.2425"></a> +<span class="sourceLineNo">2426</span> if (!pair.getFirst().getTable().equals(tableName)) {<a name="line.2426"></a> +<span class="sourceLineNo">2427</span> return false;<a name="line.2427"></a> +<span class="sourceLineNo">2428</span> }<a name="line.2428"></a> +<span class="sourceLineNo">2429</span> result.set(pair);<a name="line.2429"></a> +<span class="sourceLineNo">2430</span> return true;<a name="line.2430"></a> +<span class="sourceLineNo">2431</span> }<a name="line.2431"></a> +<span class="sourceLineNo">2432</span> };<a name="line.2432"></a> +<span class="sourceLineNo">2433</span><a name="line.2433"></a> +<span class="sourceLineNo">2434</span> MetaTableAccessor.scanMeta(clusterConnection, visitor, tableName, rowKey, 1);<a name="line.2434"></a> +<span class="sourceLineNo">2435</span> return result.get();<a name="line.2435"></a> +<span class="sourceLineNo">2436</span> }<a name="line.2436"></a> +<span class="sourceLineNo">2437</span><a name="line.2437"></a> +<span class="sourceLineNo">2438</span> private long modifyTable(final TableName tableName,<a name="line.2438"></a> +<span class="sourceLineNo">2439</span> final TableDescriptorGetter newDescriptorGetter, final long nonceGroup, final long nonce)<a name="line.2439"></a> +<span class="sourceLineNo">2440</span> throws IOException {<a name="line.2440"></a> +<span class="sourceLineNo">2441</span> return MasterProcedureUtil<a name="line.2441"></a> +<span class="sourceLineNo">2442</span> .submitProcedure(new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.2442"></a> +<span class="sourceLineNo">2443</span> @Override<a name="line.2443"></a> +<span class="sourceLineNo">2444</span> protected void run() throws IOException {<a name="line.2444"></a> +<span class="sourceLineNo">2445</span> TableDescriptor newDescriptor = newDescriptorGetter.get();<a name="line.2445"></a> +<span class="sourceLineNo">2446</span> sanityCheckTableDescriptor(newDescriptor);<a name="line.2446"></a> +<span class="sourceLineNo">2447</span> TableDescriptor oldDescriptor = getMaster().getTableDescriptors().get(tableName);<a name="line.2447"></a> +<span class="sourceLineNo">2448</span> getMaster().getMasterCoprocessorHost().preModifyTable(tableName, oldDescriptor,<a name="line.2448"></a> +<span class="sourceLineNo">2449</span> newDescriptor);<a name="line.2449"></a> +<span class="sourceLineNo">2450</span><a name="line.2450"></a> +<span class="sourceLineNo">2451</span> LOG.info(getClientIdAuditPrefix() + " modify " + tableName);<a name="line.2451"></a> +<span class="sourceLineNo">2452</span><a name="line.2452"></a> +<span class="sourceLineNo">2453</span> // Execute the operation synchronously - wait for the operation completes before<a name="line.2453"></a> +<span class="sourceLineNo">2454</span> // continuing.<a name="line.2454"></a> +<span class="sourceLineNo">2455</span> //<a name="line.2455"></a> +<span class="sourceLineNo">2456</span> // We need to wait for the procedure to potentially fail due to "prepare" sanity<a name="line.2456"></a> +<span class="sourceLineNo">2457</span> // checks. This will block only the beginning of the procedure. See HBASE-19953.<a name="line.2457"></a> +<span class="sourceLineNo">2458</span> ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();<a name="line.2458"></a> +<span class="sourceLineNo">2459</span> submitProcedure(<a name="line.2459"></a> +<span class="sourceLineNo">2460</span> new ModifyTableProcedure(procedureExecutor.getEnvironment(), newDescriptor, latch));<a name="line.2460"></a> +<span class="sourceLineNo">2461</span> latch.await();<a name="line.2461"></a> +<span class="sourceLineNo">2462</span><a name="line.2462"></a> +<span class="sourceLineNo">2463</span> getMaster().getMasterCoprocessorHost().postModifyTable(tableName, oldDescriptor,<a name="line.2463"></a> +<span class="sourceLineNo">2464</span> newDescriptor);<a name="line.2464"></a> +<span class="sourceLineNo">2465</span> }<a name="line.2465"></a> +<span class="sourceLineNo">2466</span><a name="line.2466"></a> +<span class="sourceLineNo">2467</span> @Override<a name="line.2467"></a> +<span class="sourceLineNo">2468</span> protected String getDescription() {<a name="line.2468"></a> +<span class="sourceLineNo">2469</span> return "ModifyTableProcedure";<a name="line.2469"></a> +<span class="sourceLineNo">2470</span> }<a name="line.2470"></a> +<span class="sourceLineNo">2471</span> });<a name="line.2471"></a> +<span class="sourceLineNo">2472</span><a name="line.2472"></a> +<span class="sourceLineNo">2473</span> }<a name="line.2473"></a> +<span class="sourceLineNo">2474</span><a name="line.2474"></a> +<span class="sourceLineNo">2475</span> @Override<a name="line.2475"></a> +<span class="sourceLineNo">2476</span> public long modifyTable(final TableName tableName, final TableDescriptor newDescriptor,<a name="line.2476"></a> +<span class="sourceLineNo">2477</span> final long nonceGroup, final long nonce) throws IOException {<a name="line.2477"></a> +<span class="sourceLineNo">2478</span> checkInitialized();<a name="line.2478"></a> +<span class="sourceLineNo">2479</span> return modifyTable(tableName, new TableDescriptorGetter() {<a name="line.2479"></a> +<span class="sourceLineNo">2480</span> @Override<a name="line.2480"></a> +<span class="sourceLineNo">2481</span> public TableDescriptor get() throws IOException {<a name="line.2481"></a> +<span class="sourceLineNo">2482</span> return newDescriptor;<a name="line.2482"></a> +<span class="sourceLineNo">2483</span> }<a name="line.2483"></a> +<span class="sourceLineNo">2484</span> }, nonceGroup, nonce);<a name="line.2484"></a> +<span class="sourceLineNo">2485</span><a name="line.2485"></a> +<span class="sourceLineNo">2486</span> }<a name="line.2486"></a> +<span class="sourceLineNo">2487</span><a name="line.2487"></a> +<span class="sourceLineNo">2488</span> public long restoreSnapshot(final SnapshotDescription snapshotDesc,<a name="line.2488"></a> +<span class="sourceLineNo">2489</span> final long nonceGroup, final long nonce, final boolean restoreAcl) throws IOException {<a name="line.2489"></a> +<span class="sourceLineNo">2490</span> checkInitialized();<a name="line.2490"></a> +<span class="sourceLineNo">2491</span> getSnapshotManager().checkSnapshotSupport();<a name="line.2491"></a> +<span class="sourceLineNo">2492</span><a name="line.2492"></a> +<span class="sourceLineNo">2493</span> // Ensure namespace exists. Will throw exception if non-known NS.<a name="line.2493"></a> +<span class="sourceLineNo">2494</span> final TableName dstTable = TableName.valueOf(snapshotDesc.getTable());<a name="line.2494"></a> +<span class="sourceLineNo">2495</span> getClusterSchema().getNamespace(dstTable.getNamespaceAsString());<a name="line.2495"></a> +<span class="sourceLineNo">2496</span><a name="line.2496"></a> +<span class="sourceLineNo">2497</span> return MasterProcedureUtil.submitProcedure(<a name="line.2497"></a> +<span class="sourceLineNo">2498</span> new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.2498"></a> +<span class="sourceLineNo">2499</span> @Override<a name="line.2499"></a> +<span class="sourceLineNo">2500</span> protected void run() throws IOException {<a name="line.2500"></a> +<span class="sourceLineNo">2501</span> setProcId(<a name="line.2501"></a> +<span class="sourceLineNo">2502</span> getSnapshotManager().restoreOrCloneSnapshot(snapshotDesc, getNonceKey(), restoreAcl));<a name="line.2502"></a> +<span class="sourceLineNo">2503</span> }<a name="line.2503"></a> +<span class="sourceLineNo">2504</span><a name="line.2504"></a> +<span class="sourceLineNo">2505</span> @Override<a name="line.2505"></a> +<span class="sourceLineNo">2506</span> protected String getDescription() {<a name="line.2506"></a> +<span class="sourceLineNo">2507</span> return "RestoreSnapshotProcedure";<a name="line.2507"></a> +<span class="sourceLineNo">2508</span> }<a name="line.2508"></a> +<span class="sourceLineNo">2509</span> });<a name="line.2509"></a> +<span class="sourceLineNo">2510</span> }<a name="line.2510"></a> +<span class="sourceLineNo">2511</span><a name="line.2511"></a> +<span class="sourceLineNo">2512</span> private void checkTableExists(final TableName tableName)<a name="line.2512"></a> +<span class="sourceLineNo">2513</span> throws IOException, TableNotFoundException {<a name="line.2513"></a> +<span class="sourceLineNo">2514</span> if (!MetaTableAccessor.tableExists(getConnection(), tableName)) {<a name="line.2514"></a> +<span class="sourceLineNo">2515</span> throw new TableNotFoundException(tableName);<a name="line.2515"></a> +<span class="sourceLineNo">2516</span> }<a name="line.2516"></a> +<span class="sourceLineNo">2517</span> }<a name="line.2517"></a> +<span class="sourceLineNo">2518</span><a name="line.2518"></a> +<span class="sourceLineNo">2519</span> @Override<a name="line.2519"></a> +<span class="sourceLineNo">2520</span> public void checkTableModifiable(final TableName tableName)<a name="line.2520"></a> +<span class="sourceLineNo">2521</span> throws IOException, TableNotFoundException, TableNotDisabledException {<a name="line.2521"></a> +<span class="sourceLineNo">2522</span> if (isCatalogTable(tableName)) {<a name="line.2522"></a> +<span class="sourceLineNo">2523</span> throw new IOException("Can't modify catalog tables");<a name="line.2523"></a> +<span class="sourceLineNo">2524</span> }<a name="line.2524"></a> +<span class="sourceLineNo">2525</span> checkTableExists(tableName);<a name="line.2525"></a> +<span class="sourceLineNo">2526</span> TableState ts = getTableStateManager().getTableState(tableName);<a name="line.2526"></a> +<span class="sourceLineNo">2527</span> if (!ts.isDisabled()) {<a name="line.2527"></a> +<span class="sourceLineNo">2528</span> throw new TableNotDisabledException("Not DISABLED; " + ts);<a name="line.2528"></a> +<span class="sourceLineNo">2529</span> }<a name="line.2529"></a> +<span class="sourceLineNo">2530</span> }<a name="line.2530"></a> +<span class="sourceLineNo">2531</span><a name="line.2531"></a> +<span class="sourceLineNo">2532</span> public ClusterMetrics getClusterMetricsWithoutCoprocessor() throws InterruptedIOException {<a name="line.2532"></a> +<span class="sourceLineNo">2533</span> return getClusterMetricsWithoutCoprocessor(EnumSet.allOf(Option.class));<a name="line.2533"></a> +<span class="sourceLineNo">2534</span> }<a name="line.2534"></a> +<span class="sourceLineNo">2535</span><a name="line.2535"></a> +<span class="sourceLineNo">2536</span> public ClusterMetrics getClusterMetricsWithoutCoprocessor(EnumSet<Option> options)<a name="line.2536"></a> +<span class="sourceLineNo">2537</span> throws InterruptedIOException {<a name="line.2537"></a> +<span class="sourceLineNo">2538</span> ClusterMetricsBuilder builder = ClusterMetricsBuilder.newBuilder();<a name="line.2538"></a> +<span class="sourceLineNo">2539</span> // given that hbase1 can't submit the request with Option,<a name="line.2539"></a> +<span class="sourceLineNo">2540</span> // we return all information to client if the list of Option is empty.<a name="line.2540"></a> +<span class="sourceLineNo">2541</span> if (options.isEmpty()) {<a name="line.2541"></a> +<span class="sourceLineNo">2542</span> options = EnumSet.allOf(Option.class);<a name="line.2542"></a> +<span class="sourceLineNo">2543</span> }<a name="l
<TRUNCATED>