http://git-wip-us.apache.org/repos/asf/hbase-site/blob/670bf1f0/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html index b9f3a92..412b52a 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html @@ -2339,1090 +2339,1094 @@ <span class="sourceLineNo">2331</span> RegionServerStartupResponse result = null;<a name="line.2331"></a> <span class="sourceLineNo">2332</span> try {<a name="line.2332"></a> <span class="sourceLineNo">2333</span> rpcServices.requestCount.set(0);<a name="line.2333"></a> -<span class="sourceLineNo">2334</span> LOG.info("reportForDuty to master=" + masterServerName + " with port="<a name="line.2334"></a> -<span class="sourceLineNo">2335</span> + rpcServices.isa.getPort() + ", startcode=" + this.startcode);<a name="line.2335"></a> -<span class="sourceLineNo">2336</span> long now = EnvironmentEdgeManager.currentTime();<a name="line.2336"></a> -<span class="sourceLineNo">2337</span> int port = rpcServices.isa.getPort();<a name="line.2337"></a> -<span class="sourceLineNo">2338</span> RegionServerStartupRequest.Builder request = RegionServerStartupRequest.newBuilder();<a name="line.2338"></a> -<span class="sourceLineNo">2339</span> if (shouldUseThisHostnameInstead()) {<a name="line.2339"></a> -<span class="sourceLineNo">2340</span> request.setUseThisHostnameInstead(useThisHostnameInstead);<a name="line.2340"></a> -<span class="sourceLineNo">2341</span> }<a name="line.2341"></a> -<span class="sourceLineNo">2342</span> request.setPort(port);<a name="line.2342"></a> -<span class="sourceLineNo">2343</span> request.setServerStartCode(this.startcode);<a name="line.2343"></a> -<span class="sourceLineNo">2344</span> request.setServerCurrentTime(now);<a name="line.2344"></a> -<span class="sourceLineNo">2345</span> result = this.rssStub.regionServerStartup(null, request.build());<a name="line.2345"></a> -<span class="sourceLineNo">2346</span> } catch (ServiceException se) {<a name="line.2346"></a> -<span class="sourceLineNo">2347</span> IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2347"></a> -<span class="sourceLineNo">2348</span> if (ioe instanceof ClockOutOfSyncException) {<a name="line.2348"></a> -<span class="sourceLineNo">2349</span> LOG.fatal("Master rejected startup because clock is out of sync", ioe);<a name="line.2349"></a> -<span class="sourceLineNo">2350</span> // Re-throw IOE will cause RS to abort<a name="line.2350"></a> -<span class="sourceLineNo">2351</span> throw ioe;<a name="line.2351"></a> -<span class="sourceLineNo">2352</span> } else if (ioe instanceof ServerNotRunningYetException) {<a name="line.2352"></a> -<span class="sourceLineNo">2353</span> LOG.debug("Master is not running yet");<a name="line.2353"></a> -<span class="sourceLineNo">2354</span> } else {<a name="line.2354"></a> -<span class="sourceLineNo">2355</span> LOG.warn("error telling master we are up", se);<a name="line.2355"></a> -<span class="sourceLineNo">2356</span> }<a name="line.2356"></a> -<span class="sourceLineNo">2357</span> rssStub = null;<a name="line.2357"></a> -<span class="sourceLineNo">2358</span> }<a name="line.2358"></a> -<span class="sourceLineNo">2359</span> return result;<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> public RegionStoreSequenceIds getLastSequenceId(byte[] encodedRegionName) {<a name="line.2363"></a> -<span class="sourceLineNo">2364</span> try {<a name="line.2364"></a> -<span class="sourceLineNo">2365</span> GetLastFlushedSequenceIdRequest req =<a name="line.2365"></a> -<span class="sourceLineNo">2366</span> RequestConverter.buildGetLastFlushedSequenceIdRequest(encodedRegionName);<a name="line.2366"></a> -<span class="sourceLineNo">2367</span> RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2367"></a> -<span class="sourceLineNo">2368</span> if (rss == null) { // Try to connect one more time<a name="line.2368"></a> -<span class="sourceLineNo">2369</span> createRegionServerStatusStub();<a name="line.2369"></a> -<span class="sourceLineNo">2370</span> rss = rssStub;<a name="line.2370"></a> -<span class="sourceLineNo">2371</span> if (rss == null) {<a name="line.2371"></a> -<span class="sourceLineNo">2372</span> // Still no luck, we tried<a name="line.2372"></a> -<span class="sourceLineNo">2373</span> LOG.warn("Unable to connect to the master to check " + "the last flushed sequence id");<a name="line.2373"></a> -<span class="sourceLineNo">2374</span> return RegionStoreSequenceIds.newBuilder().setLastFlushedSequenceId(HConstants.NO_SEQNUM)<a name="line.2374"></a> -<span class="sourceLineNo">2375</span> .build();<a name="line.2375"></a> -<span class="sourceLineNo">2376</span> }<a name="line.2376"></a> -<span class="sourceLineNo">2377</span> }<a name="line.2377"></a> -<span class="sourceLineNo">2378</span> GetLastFlushedSequenceIdResponse resp = rss.getLastFlushedSequenceId(null, req);<a name="line.2378"></a> -<span class="sourceLineNo">2379</span> return RegionStoreSequenceIds.newBuilder()<a name="line.2379"></a> -<span class="sourceLineNo">2380</span> .setLastFlushedSequenceId(resp.getLastFlushedSequenceId())<a name="line.2380"></a> -<span class="sourceLineNo">2381</span> .addAllStoreSequenceId(resp.getStoreLastFlushedSequenceIdList()).build();<a name="line.2381"></a> -<span class="sourceLineNo">2382</span> } catch (ServiceException e) {<a name="line.2382"></a> -<span class="sourceLineNo">2383</span> LOG.warn("Unable to connect to the master to check the last flushed sequence id", e);<a name="line.2383"></a> -<span class="sourceLineNo">2384</span> return RegionStoreSequenceIds.newBuilder().setLastFlushedSequenceId(HConstants.NO_SEQNUM)<a name="line.2384"></a> -<span class="sourceLineNo">2385</span> .build();<a name="line.2385"></a> -<span class="sourceLineNo">2386</span> }<a name="line.2386"></a> -<span class="sourceLineNo">2387</span> }<a name="line.2387"></a> -<span class="sourceLineNo">2388</span><a name="line.2388"></a> -<span class="sourceLineNo">2389</span> /**<a name="line.2389"></a> -<span class="sourceLineNo">2390</span> * Closes all regions. Called on our way out.<a name="line.2390"></a> -<span class="sourceLineNo">2391</span> * Assumes that its not possible for new regions to be added to onlineRegions<a name="line.2391"></a> -<span class="sourceLineNo">2392</span> * while this method runs.<a name="line.2392"></a> -<span class="sourceLineNo">2393</span> */<a name="line.2393"></a> -<span class="sourceLineNo">2394</span> protected void closeAllRegions(final boolean abort) {<a name="line.2394"></a> -<span class="sourceLineNo">2395</span> closeUserRegions(abort);<a name="line.2395"></a> -<span class="sourceLineNo">2396</span> closeMetaTableRegions(abort);<a name="line.2396"></a> -<span class="sourceLineNo">2397</span> }<a name="line.2397"></a> -<span class="sourceLineNo">2398</span><a name="line.2398"></a> -<span class="sourceLineNo">2399</span> /**<a name="line.2399"></a> -<span class="sourceLineNo">2400</span> * Close meta region if we carry it<a name="line.2400"></a> -<span class="sourceLineNo">2401</span> * @param abort Whether we're running an abort.<a name="line.2401"></a> -<span class="sourceLineNo">2402</span> */<a name="line.2402"></a> -<span class="sourceLineNo">2403</span> void closeMetaTableRegions(final boolean abort) {<a name="line.2403"></a> -<span class="sourceLineNo">2404</span> Region meta = null;<a name="line.2404"></a> -<span class="sourceLineNo">2405</span> this.lock.writeLock().lock();<a name="line.2405"></a> -<span class="sourceLineNo">2406</span> try {<a name="line.2406"></a> -<span class="sourceLineNo">2407</span> for (Map.Entry<String, Region> e: onlineRegions.entrySet()) {<a name="line.2407"></a> -<span class="sourceLineNo">2408</span> HRegionInfo hri = e.getValue().getRegionInfo();<a name="line.2408"></a> -<span class="sourceLineNo">2409</span> if (hri.isMetaRegion()) {<a name="line.2409"></a> -<span class="sourceLineNo">2410</span> meta = e.getValue();<a name="line.2410"></a> -<span class="sourceLineNo">2411</span> }<a name="line.2411"></a> -<span class="sourceLineNo">2412</span> if (meta != null) break;<a name="line.2412"></a> -<span class="sourceLineNo">2413</span> }<a name="line.2413"></a> -<span class="sourceLineNo">2414</span> } finally {<a name="line.2414"></a> -<span class="sourceLineNo">2415</span> this.lock.writeLock().unlock();<a name="line.2415"></a> -<span class="sourceLineNo">2416</span> }<a name="line.2416"></a> -<span class="sourceLineNo">2417</span> if (meta != null) closeRegionIgnoreErrors(meta.getRegionInfo(), abort);<a name="line.2417"></a> -<span class="sourceLineNo">2418</span> }<a name="line.2418"></a> -<span class="sourceLineNo">2419</span><a name="line.2419"></a> -<span class="sourceLineNo">2420</span> /**<a name="line.2420"></a> -<span class="sourceLineNo">2421</span> * Schedule closes on all user regions.<a name="line.2421"></a> -<span class="sourceLineNo">2422</span> * Should be safe calling multiple times because it wont' close regions<a name="line.2422"></a> -<span class="sourceLineNo">2423</span> * that are already closed or that are closing.<a name="line.2423"></a> -<span class="sourceLineNo">2424</span> * @param abort Whether we're running an abort.<a name="line.2424"></a> -<span class="sourceLineNo">2425</span> */<a name="line.2425"></a> -<span class="sourceLineNo">2426</span> void closeUserRegions(final boolean abort) {<a name="line.2426"></a> -<span class="sourceLineNo">2427</span> this.lock.writeLock().lock();<a name="line.2427"></a> -<span class="sourceLineNo">2428</span> try {<a name="line.2428"></a> -<span class="sourceLineNo">2429</span> for (Map.Entry<String, Region> e: this.onlineRegions.entrySet()) {<a name="line.2429"></a> -<span class="sourceLineNo">2430</span> Region r = e.getValue();<a name="line.2430"></a> -<span class="sourceLineNo">2431</span> if (!r.getRegionInfo().isMetaTable() && r.isAvailable()) {<a name="line.2431"></a> -<span class="sourceLineNo">2432</span> // Don't update zk with this close transition; pass false.<a name="line.2432"></a> -<span class="sourceLineNo">2433</span> closeRegionIgnoreErrors(r.getRegionInfo(), abort);<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> } finally {<a name="line.2436"></a> -<span class="sourceLineNo">2437</span> this.lock.writeLock().unlock();<a name="line.2437"></a> -<span class="sourceLineNo">2438</span> }<a name="line.2438"></a> -<span class="sourceLineNo">2439</span> }<a name="line.2439"></a> -<span class="sourceLineNo">2440</span><a name="line.2440"></a> -<span class="sourceLineNo">2441</span> /** @return the info server */<a name="line.2441"></a> -<span class="sourceLineNo">2442</span> public InfoServer getInfoServer() {<a name="line.2442"></a> -<span class="sourceLineNo">2443</span> return infoServer;<a name="line.2443"></a> -<span class="sourceLineNo">2444</span> }<a name="line.2444"></a> -<span class="sourceLineNo">2445</span><a name="line.2445"></a> -<span class="sourceLineNo">2446</span> /**<a name="line.2446"></a> -<span class="sourceLineNo">2447</span> * @return true if a stop has been requested.<a name="line.2447"></a> -<span class="sourceLineNo">2448</span> */<a name="line.2448"></a> -<span class="sourceLineNo">2449</span> @Override<a name="line.2449"></a> -<span class="sourceLineNo">2450</span> public boolean isStopped() {<a name="line.2450"></a> -<span class="sourceLineNo">2451</span> return this.stopped;<a name="line.2451"></a> -<span class="sourceLineNo">2452</span> }<a name="line.2452"></a> -<span class="sourceLineNo">2453</span><a name="line.2453"></a> -<span class="sourceLineNo">2454</span> @Override<a name="line.2454"></a> -<span class="sourceLineNo">2455</span> public boolean isStopping() {<a name="line.2455"></a> -<span class="sourceLineNo">2456</span> return this.stopping;<a name="line.2456"></a> -<span class="sourceLineNo">2457</span> }<a name="line.2457"></a> -<span class="sourceLineNo">2458</span><a name="line.2458"></a> -<span class="sourceLineNo">2459</span> @Override<a name="line.2459"></a> -<span class="sourceLineNo">2460</span> public Map<String, Region> getRecoveringRegions() {<a name="line.2460"></a> -<span class="sourceLineNo">2461</span> return this.recoveringRegions;<a name="line.2461"></a> -<span class="sourceLineNo">2462</span> }<a name="line.2462"></a> -<span class="sourceLineNo">2463</span><a name="line.2463"></a> -<span class="sourceLineNo">2464</span> /**<a name="line.2464"></a> -<span class="sourceLineNo">2465</span> *<a name="line.2465"></a> -<span class="sourceLineNo">2466</span> * @return the configuration<a name="line.2466"></a> -<span class="sourceLineNo">2467</span> */<a name="line.2467"></a> -<span class="sourceLineNo">2468</span> @Override<a name="line.2468"></a> -<span class="sourceLineNo">2469</span> public Configuration getConfiguration() {<a name="line.2469"></a> -<span class="sourceLineNo">2470</span> return conf;<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> /** @return the write lock for the server */<a name="line.2473"></a> -<span class="sourceLineNo">2474</span> ReentrantReadWriteLock.WriteLock getWriteLock() {<a name="line.2474"></a> -<span class="sourceLineNo">2475</span> return lock.writeLock();<a name="line.2475"></a> -<span class="sourceLineNo">2476</span> }<a name="line.2476"></a> -<span class="sourceLineNo">2477</span><a name="line.2477"></a> -<span class="sourceLineNo">2478</span> public int getNumberOfOnlineRegions() {<a name="line.2478"></a> -<span class="sourceLineNo">2479</span> return this.onlineRegions.size();<a name="line.2479"></a> +<span class="sourceLineNo">2334</span> rpcServices.rpcGetRequestCount.set(0);<a name="line.2334"></a> +<span class="sourceLineNo">2335</span> rpcServices.rpcScanRequestCount.set(0);<a name="line.2335"></a> +<span class="sourceLineNo">2336</span> rpcServices.rpcMultiRequestCount.set(0);<a name="line.2336"></a> +<span class="sourceLineNo">2337</span> rpcServices.rpcMutateRequestCount.set(0);<a name="line.2337"></a> +<span class="sourceLineNo">2338</span> LOG.info("reportForDuty to master=" + masterServerName + " with port="<a name="line.2338"></a> +<span class="sourceLineNo">2339</span> + rpcServices.isa.getPort() + ", startcode=" + this.startcode);<a name="line.2339"></a> +<span class="sourceLineNo">2340</span> long now = EnvironmentEdgeManager.currentTime();<a name="line.2340"></a> +<span class="sourceLineNo">2341</span> int port = rpcServices.isa.getPort();<a name="line.2341"></a> +<span class="sourceLineNo">2342</span> RegionServerStartupRequest.Builder request = RegionServerStartupRequest.newBuilder();<a name="line.2342"></a> +<span class="sourceLineNo">2343</span> if (shouldUseThisHostnameInstead()) {<a name="line.2343"></a> +<span class="sourceLineNo">2344</span> request.setUseThisHostnameInstead(useThisHostnameInstead);<a name="line.2344"></a> +<span class="sourceLineNo">2345</span> }<a name="line.2345"></a> +<span class="sourceLineNo">2346</span> request.setPort(port);<a name="line.2346"></a> +<span class="sourceLineNo">2347</span> request.setServerStartCode(this.startcode);<a name="line.2347"></a> +<span class="sourceLineNo">2348</span> request.setServerCurrentTime(now);<a name="line.2348"></a> +<span class="sourceLineNo">2349</span> result = this.rssStub.regionServerStartup(null, request.build());<a name="line.2349"></a> +<span class="sourceLineNo">2350</span> } catch (ServiceException se) {<a name="line.2350"></a> +<span class="sourceLineNo">2351</span> IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2351"></a> +<span class="sourceLineNo">2352</span> if (ioe instanceof ClockOutOfSyncException) {<a name="line.2352"></a> +<span class="sourceLineNo">2353</span> LOG.fatal("Master rejected startup because clock is out of sync", ioe);<a name="line.2353"></a> +<span class="sourceLineNo">2354</span> // Re-throw IOE will cause RS to abort<a name="line.2354"></a> +<span class="sourceLineNo">2355</span> throw ioe;<a name="line.2355"></a> +<span class="sourceLineNo">2356</span> } else if (ioe instanceof ServerNotRunningYetException) {<a name="line.2356"></a> +<span class="sourceLineNo">2357</span> LOG.debug("Master is not running yet");<a name="line.2357"></a> +<span class="sourceLineNo">2358</span> } else {<a name="line.2358"></a> +<span class="sourceLineNo">2359</span> LOG.warn("error telling master we are up", se);<a name="line.2359"></a> +<span class="sourceLineNo">2360</span> }<a name="line.2360"></a> +<span class="sourceLineNo">2361</span> rssStub = null;<a name="line.2361"></a> +<span class="sourceLineNo">2362</span> }<a name="line.2362"></a> +<span class="sourceLineNo">2363</span> return result;<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> @Override<a name="line.2366"></a> +<span class="sourceLineNo">2367</span> public RegionStoreSequenceIds getLastSequenceId(byte[] encodedRegionName) {<a name="line.2367"></a> +<span class="sourceLineNo">2368</span> try {<a name="line.2368"></a> +<span class="sourceLineNo">2369</span> GetLastFlushedSequenceIdRequest req =<a name="line.2369"></a> +<span class="sourceLineNo">2370</span> RequestConverter.buildGetLastFlushedSequenceIdRequest(encodedRegionName);<a name="line.2370"></a> +<span class="sourceLineNo">2371</span> RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2371"></a> +<span class="sourceLineNo">2372</span> if (rss == null) { // Try to connect one more time<a name="line.2372"></a> +<span class="sourceLineNo">2373</span> createRegionServerStatusStub();<a name="line.2373"></a> +<span class="sourceLineNo">2374</span> rss = rssStub;<a name="line.2374"></a> +<span class="sourceLineNo">2375</span> if (rss == null) {<a name="line.2375"></a> +<span class="sourceLineNo">2376</span> // Still no luck, we tried<a name="line.2376"></a> +<span class="sourceLineNo">2377</span> LOG.warn("Unable to connect to the master to check " + "the last flushed sequence id");<a name="line.2377"></a> +<span class="sourceLineNo">2378</span> return RegionStoreSequenceIds.newBuilder().setLastFlushedSequenceId(HConstants.NO_SEQNUM)<a name="line.2378"></a> +<span class="sourceLineNo">2379</span> .build();<a name="line.2379"></a> +<span class="sourceLineNo">2380</span> }<a name="line.2380"></a> +<span class="sourceLineNo">2381</span> }<a name="line.2381"></a> +<span class="sourceLineNo">2382</span> GetLastFlushedSequenceIdResponse resp = rss.getLastFlushedSequenceId(null, req);<a name="line.2382"></a> +<span class="sourceLineNo">2383</span> return RegionStoreSequenceIds.newBuilder()<a name="line.2383"></a> +<span class="sourceLineNo">2384</span> .setLastFlushedSequenceId(resp.getLastFlushedSequenceId())<a name="line.2384"></a> +<span class="sourceLineNo">2385</span> .addAllStoreSequenceId(resp.getStoreLastFlushedSequenceIdList()).build();<a name="line.2385"></a> +<span class="sourceLineNo">2386</span> } catch (ServiceException e) {<a name="line.2386"></a> +<span class="sourceLineNo">2387</span> LOG.warn("Unable to connect to the master to check the last flushed sequence id", e);<a name="line.2387"></a> +<span class="sourceLineNo">2388</span> return RegionStoreSequenceIds.newBuilder().setLastFlushedSequenceId(HConstants.NO_SEQNUM)<a name="line.2388"></a> +<span class="sourceLineNo">2389</span> .build();<a name="line.2389"></a> +<span class="sourceLineNo">2390</span> }<a name="line.2390"></a> +<span class="sourceLineNo">2391</span> }<a name="line.2391"></a> +<span class="sourceLineNo">2392</span><a name="line.2392"></a> +<span class="sourceLineNo">2393</span> /**<a name="line.2393"></a> +<span class="sourceLineNo">2394</span> * Closes all regions. Called on our way out.<a name="line.2394"></a> +<span class="sourceLineNo">2395</span> * Assumes that its not possible for new regions to be added to onlineRegions<a name="line.2395"></a> +<span class="sourceLineNo">2396</span> * while this method runs.<a name="line.2396"></a> +<span class="sourceLineNo">2397</span> */<a name="line.2397"></a> +<span class="sourceLineNo">2398</span> protected void closeAllRegions(final boolean abort) {<a name="line.2398"></a> +<span class="sourceLineNo">2399</span> closeUserRegions(abort);<a name="line.2399"></a> +<span class="sourceLineNo">2400</span> closeMetaTableRegions(abort);<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> * Close meta region if we carry it<a name="line.2404"></a> +<span class="sourceLineNo">2405</span> * @param abort Whether we're running an abort.<a name="line.2405"></a> +<span class="sourceLineNo">2406</span> */<a name="line.2406"></a> +<span class="sourceLineNo">2407</span> void closeMetaTableRegions(final boolean abort) {<a name="line.2407"></a> +<span class="sourceLineNo">2408</span> Region meta = null;<a name="line.2408"></a> +<span class="sourceLineNo">2409</span> this.lock.writeLock().lock();<a name="line.2409"></a> +<span class="sourceLineNo">2410</span> try {<a name="line.2410"></a> +<span class="sourceLineNo">2411</span> for (Map.Entry<String, Region> e: onlineRegions.entrySet()) {<a name="line.2411"></a> +<span class="sourceLineNo">2412</span> HRegionInfo hri = e.getValue().getRegionInfo();<a name="line.2412"></a> +<span class="sourceLineNo">2413</span> if (hri.isMetaRegion()) {<a name="line.2413"></a> +<span class="sourceLineNo">2414</span> meta = e.getValue();<a name="line.2414"></a> +<span class="sourceLineNo">2415</span> }<a name="line.2415"></a> +<span class="sourceLineNo">2416</span> if (meta != null) break;<a name="line.2416"></a> +<span class="sourceLineNo">2417</span> }<a name="line.2417"></a> +<span class="sourceLineNo">2418</span> } finally {<a name="line.2418"></a> +<span class="sourceLineNo">2419</span> this.lock.writeLock().unlock();<a name="line.2419"></a> +<span class="sourceLineNo">2420</span> }<a name="line.2420"></a> +<span class="sourceLineNo">2421</span> if (meta != null) closeRegionIgnoreErrors(meta.getRegionInfo(), abort);<a name="line.2421"></a> +<span class="sourceLineNo">2422</span> }<a name="line.2422"></a> +<span class="sourceLineNo">2423</span><a name="line.2423"></a> +<span class="sourceLineNo">2424</span> /**<a name="line.2424"></a> +<span class="sourceLineNo">2425</span> * Schedule closes on all user regions.<a name="line.2425"></a> +<span class="sourceLineNo">2426</span> * Should be safe calling multiple times because it wont' close regions<a name="line.2426"></a> +<span class="sourceLineNo">2427</span> * that are already closed or that are closing.<a name="line.2427"></a> +<span class="sourceLineNo">2428</span> * @param abort Whether we're running an abort.<a name="line.2428"></a> +<span class="sourceLineNo">2429</span> */<a name="line.2429"></a> +<span class="sourceLineNo">2430</span> void closeUserRegions(final boolean abort) {<a name="line.2430"></a> +<span class="sourceLineNo">2431</span> this.lock.writeLock().lock();<a name="line.2431"></a> +<span class="sourceLineNo">2432</span> try {<a name="line.2432"></a> +<span class="sourceLineNo">2433</span> for (Map.Entry<String, Region> e: this.onlineRegions.entrySet()) {<a name="line.2433"></a> +<span class="sourceLineNo">2434</span> Region r = e.getValue();<a name="line.2434"></a> +<span class="sourceLineNo">2435</span> if (!r.getRegionInfo().isMetaTable() && r.isAvailable()) {<a name="line.2435"></a> +<span class="sourceLineNo">2436</span> // Don't update zk with this close transition; pass false.<a name="line.2436"></a> +<span class="sourceLineNo">2437</span> closeRegionIgnoreErrors(r.getRegionInfo(), abort);<a name="line.2437"></a> +<span class="sourceLineNo">2438</span> }<a name="line.2438"></a> +<span class="sourceLineNo">2439</span> }<a name="line.2439"></a> +<span class="sourceLineNo">2440</span> } finally {<a name="line.2440"></a> +<span class="sourceLineNo">2441</span> this.lock.writeLock().unlock();<a name="line.2441"></a> +<span class="sourceLineNo">2442</span> }<a name="line.2442"></a> +<span class="sourceLineNo">2443</span> }<a name="line.2443"></a> +<span class="sourceLineNo">2444</span><a name="line.2444"></a> +<span class="sourceLineNo">2445</span> /** @return the info server */<a name="line.2445"></a> +<span class="sourceLineNo">2446</span> public InfoServer getInfoServer() {<a name="line.2446"></a> +<span class="sourceLineNo">2447</span> return infoServer;<a name="line.2447"></a> +<span class="sourceLineNo">2448</span> }<a name="line.2448"></a> +<span class="sourceLineNo">2449</span><a name="line.2449"></a> +<span class="sourceLineNo">2450</span> /**<a name="line.2450"></a> +<span class="sourceLineNo">2451</span> * @return true if a stop has been requested.<a name="line.2451"></a> +<span class="sourceLineNo">2452</span> */<a name="line.2452"></a> +<span class="sourceLineNo">2453</span> @Override<a name="line.2453"></a> +<span class="sourceLineNo">2454</span> public boolean isStopped() {<a name="line.2454"></a> +<span class="sourceLineNo">2455</span> return this.stopped;<a name="line.2455"></a> +<span class="sourceLineNo">2456</span> }<a name="line.2456"></a> +<span class="sourceLineNo">2457</span><a name="line.2457"></a> +<span class="sourceLineNo">2458</span> @Override<a name="line.2458"></a> +<span class="sourceLineNo">2459</span> public boolean isStopping() {<a name="line.2459"></a> +<span class="sourceLineNo">2460</span> return this.stopping;<a name="line.2460"></a> +<span class="sourceLineNo">2461</span> }<a name="line.2461"></a> +<span class="sourceLineNo">2462</span><a name="line.2462"></a> +<span class="sourceLineNo">2463</span> @Override<a name="line.2463"></a> +<span class="sourceLineNo">2464</span> public Map<String, Region> getRecoveringRegions() {<a name="line.2464"></a> +<span class="sourceLineNo">2465</span> return this.recoveringRegions;<a name="line.2465"></a> +<span class="sourceLineNo">2466</span> }<a name="line.2466"></a> +<span class="sourceLineNo">2467</span><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> * @return the configuration<a name="line.2470"></a> +<span class="sourceLineNo">2471</span> */<a name="line.2471"></a> +<span class="sourceLineNo">2472</span> @Override<a name="line.2472"></a> +<span class="sourceLineNo">2473</span> public Configuration getConfiguration() {<a name="line.2473"></a> +<span class="sourceLineNo">2474</span> return conf;<a name="line.2474"></a> +<span class="sourceLineNo">2475</span> }<a name="line.2475"></a> +<span class="sourceLineNo">2476</span><a name="line.2476"></a> +<span class="sourceLineNo">2477</span> /** @return the write lock for the server */<a name="line.2477"></a> +<span class="sourceLineNo">2478</span> ReentrantReadWriteLock.WriteLock getWriteLock() {<a name="line.2478"></a> +<span class="sourceLineNo">2479</span> return lock.writeLock();<a name="line.2479"></a> <span class="sourceLineNo">2480</span> }<a name="line.2480"></a> <span class="sourceLineNo">2481</span><a name="line.2481"></a> -<span class="sourceLineNo">2482</span> boolean isOnlineRegionsEmpty() {<a name="line.2482"></a> -<span class="sourceLineNo">2483</span> return this.onlineRegions.isEmpty();<a name="line.2483"></a> +<span class="sourceLineNo">2482</span> public int getNumberOfOnlineRegions() {<a name="line.2482"></a> +<span class="sourceLineNo">2483</span> return this.onlineRegions.size();<a name="line.2483"></a> <span class="sourceLineNo">2484</span> }<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> * For tests, web ui and metrics.<a name="line.2487"></a> -<span class="sourceLineNo">2488</span> * This method will only work if HRegionServer is in the same JVM as client;<a name="line.2488"></a> -<span class="sourceLineNo">2489</span> * HRegion cannot be serialized to cross an rpc.<a name="line.2489"></a> -<span class="sourceLineNo">2490</span> */<a name="line.2490"></a> -<span class="sourceLineNo">2491</span> public Collection<Region> getOnlineRegionsLocalContext() {<a name="line.2491"></a> -<span class="sourceLineNo">2492</span> Collection<Region> regions = this.onlineRegions.values();<a name="line.2492"></a> -<span class="sourceLineNo">2493</span> return Collections.unmodifiableCollection(regions);<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> @Override<a name="line.2496"></a> -<span class="sourceLineNo">2497</span> public void addToOnlineRegions(Region region) {<a name="line.2497"></a> -<span class="sourceLineNo">2498</span> this.onlineRegions.put(region.getRegionInfo().getEncodedName(), region);<a name="line.2498"></a> -<span class="sourceLineNo">2499</span> configurationManager.registerObserver(region);<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> * @return A new Map of online regions sorted by region size with the first entry being the<a name="line.2503"></a> -<span class="sourceLineNo">2504</span> * biggest. If two regions are the same size, then the last one found wins; i.e. this method<a name="line.2504"></a> -<span class="sourceLineNo">2505</span> * may NOT return all regions.<a name="line.2505"></a> -<span class="sourceLineNo">2506</span> */<a name="line.2506"></a> -<span class="sourceLineNo">2507</span> SortedMap<Long, Region> getCopyOfOnlineRegionsSortedBySize() {<a name="line.2507"></a> -<span class="sourceLineNo">2508</span> // we'll sort the regions in reverse<a name="line.2508"></a> -<span class="sourceLineNo">2509</span> SortedMap<Long, Region> sortedRegions = new TreeMap<Long, Region>(<a name="line.2509"></a> -<span class="sourceLineNo">2510</span> new Comparator<Long>() {<a name="line.2510"></a> -<span class="sourceLineNo">2511</span> @Override<a name="line.2511"></a> -<span class="sourceLineNo">2512</span> public int compare(Long a, Long b) {<a name="line.2512"></a> -<span class="sourceLineNo">2513</span> return -1 * a.compareTo(b);<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> // Copy over all regions. Regions are sorted by size with biggest first.<a name="line.2516"></a> -<span class="sourceLineNo">2517</span> for (Region region : this.onlineRegions.values()) {<a name="line.2517"></a> -<span class="sourceLineNo">2518</span> sortedRegions.put(region.getMemstoreSize(), region);<a name="line.2518"></a> -<span class="sourceLineNo">2519</span> }<a name="line.2519"></a> -<span class="sourceLineNo">2520</span> return sortedRegions;<a name="line.2520"></a> -<span class="sourceLineNo">2521</span> }<a name="line.2521"></a> -<span class="sourceLineNo">2522</span><a name="line.2522"></a> -<span class="sourceLineNo">2523</span> /**<a name="line.2523"></a> -<span class="sourceLineNo">2524</span> * @return time stamp in millis of when this region server was started<a name="line.2524"></a> -<span class="sourceLineNo">2525</span> */<a name="line.2525"></a> -<span class="sourceLineNo">2526</span> public long getStartcode() {<a name="line.2526"></a> -<span class="sourceLineNo">2527</span> return this.startcode;<a name="line.2527"></a> -<span class="sourceLineNo">2528</span> }<a name="line.2528"></a> -<span class="sourceLineNo">2529</span><a name="line.2529"></a> -<span class="sourceLineNo">2530</span> /** @return reference to FlushRequester */<a name="line.2530"></a> -<span class="sourceLineNo">2531</span> @Override<a name="line.2531"></a> -<span class="sourceLineNo">2532</span> public FlushRequester getFlushRequester() {<a name="line.2532"></a> -<span class="sourceLineNo">2533</span> return this.cacheFlusher;<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> /**<a name="line.2536"></a> -<span class="sourceLineNo">2537</span> * Get the top N most loaded regions this server is serving so we can tell the<a name="line.2537"></a> -<span class="sourceLineNo">2538</span> * master which regions it can reallocate if we're overloaded. TODO: actually<a name="line.2538"></a> -<span class="sourceLineNo">2539</span> * calculate which regions are most loaded. (Right now, we're just grabbing<a name="line.2539"></a> -<span class="sourceLineNo">2540</span> * the first N regions being served regardless of load.)<a name="line.2540"></a> -<span class="sourceLineNo">2541</span> */<a name="line.2541"></a> -<span class="sourceLineNo">2542</span> protected HRegionInfo[] getMostLoadedRegions() {<a name="line.2542"></a> -<span class="sourceLineNo">2543</span> ArrayList<HRegionInfo> regions = new ArrayList<HRegionInfo>();<a name="line.2543"></a> -<span class="sourceLineNo">2544</span> for (Region r : onlineRegions.values()) {<a name="line.2544"></a> -<span class="sourceLineNo">2545</span> if (!r.isAvailable()) {<a name="line.2545"></a> -<span class="sourceLineNo">2546</span> continue;<a name="line.2546"></a> -<span class="sourceLineNo">2547</span> }<a name="line.2547"></a> -<span class="sourceLineNo">2548</span> if (regions.size() < numRegionsToReport) {<a name="line.2548"></a> -<span class="sourceLineNo">2549</span> regions.add(r.getRegionInfo());<a name="line.2549"></a> -<span class="sourceLineNo">2550</span> } else {<a name="line.2550"></a> -<span class="sourceLineNo">2551</span> break;<a name="line.2551"></a> -<span class="sourceLineNo">2552</span> }<a name="line.2552"></a> -<span class="sourceLineNo">2553</span> }<a name="line.2553"></a> -<span class="sourceLineNo">2554</span> return regions.toArray(new HRegionInfo[regions.size()]);<a name="line.2554"></a> -<span class="sourceLineNo">2555</span> }<a name="line.2555"></a> -<span class="sourceLineNo">2556</span><a name="line.2556"></a> -<span class="sourceLineNo">2557</span> @Override<a name="line.2557"></a> -<span class="sourceLineNo">2558</span> public Leases getLeases() {<a name="line.2558"></a> -<span class="sourceLineNo">2559</span> return leases;<a name="line.2559"></a> -<span class="sourceLineNo">2560</span> }<a name="line.2560"></a> -<span class="sourceLineNo">2561</span><a name="line.2561"></a> -<span class="sourceLineNo">2562</span> /**<a name="line.2562"></a> -<span class="sourceLineNo">2563</span> * @return Return the rootDir.<a name="line.2563"></a> -<span class="sourceLineNo">2564</span> */<a name="line.2564"></a> -<span class="sourceLineNo">2565</span> protected Path getRootDir() {<a name="line.2565"></a> -<span class="sourceLineNo">2566</span> return rootDir;<a name="line.2566"></a> -<span class="sourceLineNo">2567</span> }<a name="line.2567"></a> -<span class="sourceLineNo">2568</span><a name="line.2568"></a> -<span class="sourceLineNo">2569</span> /**<a name="line.2569"></a> -<span class="sourceLineNo">2570</span> * @return Return the fs.<a name="line.2570"></a> -<span class="sourceLineNo">2571</span> */<a name="line.2571"></a> -<span class="sourceLineNo">2572</span> @Override<a name="line.2572"></a> -<span class="sourceLineNo">2573</span> public FileSystem getFileSystem() {<a name="line.2573"></a> -<span class="sourceLineNo">2574</span> return fs;<a name="line.2574"></a> -<span class="sourceLineNo">2575</span> }<a name="line.2575"></a> -<span class="sourceLineNo">2576</span><a name="line.2576"></a> -<span class="sourceLineNo">2577</span> @Override<a name="line.2577"></a> -<span class="sourceLineNo">2578</span> public String toString() {<a name="line.2578"></a> -<span class="sourceLineNo">2579</span> return getServerName().toString();<a name="line.2579"></a> -<span class="sourceLineNo">2580</span> }<a name="line.2580"></a> -<span class="sourceLineNo">2581</span><a name="line.2581"></a> -<span class="sourceLineNo">2582</span> /**<a name="line.2582"></a> -<span class="sourceLineNo">2583</span> * Interval at which threads should run<a name="line.2583"></a> -<span class="sourceLineNo">2584</span> *<a name="line.2584"></a> -<span class="sourceLineNo">2585</span> * @return the interval<a name="line.2585"></a> -<span class="sourceLineNo">2586</span> */<a name="line.2586"></a> -<span class="sourceLineNo">2587</span> public int getThreadWakeFrequency() {<a name="line.2587"></a> -<span class="sourceLineNo">2588</span> return threadWakeFrequency;<a name="line.2588"></a> -<span class="sourceLineNo">2589</span> }<a name="line.2589"></a> -<span class="sourceLineNo">2590</span><a name="line.2590"></a> -<span class="sourceLineNo">2591</span> @Override<a name="line.2591"></a> -<span class="sourceLineNo">2592</span> public ZooKeeperWatcher getZooKeeper() {<a name="line.2592"></a> -<span class="sourceLineNo">2593</span> return zooKeeper;<a name="line.2593"></a> -<span class="sourceLineNo">2594</span> }<a name="line.2594"></a> -<span class="sourceLineNo">2595</span><a name="line.2595"></a> -<span class="sourceLineNo">2596</span> @Override<a name="line.2596"></a> -<span class="sourceLineNo">2597</span> public BaseCoordinatedStateManager getCoordinatedStateManager() {<a name="line.2597"></a> -<span class="sourceLineNo">2598</span> return csm;<a name="line.2598"></a> -<span class="sourceLineNo">2599</span> }<a name="line.2599"></a> -<span class="sourceLineNo">2600</span><a name="line.2600"></a> -<span class="sourceLineNo">2601</span> @Override<a name="line.2601"></a> -<span class="sourceLineNo">2602</span> public ServerName getServerName() {<a name="line.2602"></a> -<span class="sourceLineNo">2603</span> return serverName;<a name="line.2603"></a> -<span class="sourceLineNo">2604</span> }<a name="line.2604"></a> -<span class="sourceLineNo">2605</span><a name="line.2605"></a> -<span class="sourceLineNo">2606</span> @Override<a name="line.2606"></a> -<span class="sourceLineNo">2607</span> public CompactionRequestor getCompactionRequester() {<a name="line.2607"></a> -<span class="sourceLineNo">2608</span> return this.compactSplitThread;<a name="line.2608"></a> -<span class="sourceLineNo">2609</span> }<a name="line.2609"></a> -<span class="sourceLineNo">2610</span><a name="line.2610"></a> -<span class="sourceLineNo">2611</span> public RegionServerCoprocessorHost getRegionServerCoprocessorHost(){<a name="line.2611"></a> -<span class="sourceLineNo">2612</span> return this.rsHost;<a name="line.2612"></a> +<span class="sourceLineNo">2486</span> boolean isOnlineRegionsEmpty() {<a name="line.2486"></a> +<span class="sourceLineNo">2487</span> return this.onlineRegions.isEmpty();<a name="line.2487"></a> +<span class="sourceLineNo">2488</span> }<a name="line.2488"></a> +<span class="sourceLineNo">2489</span><a name="line.2489"></a> +<span class="sourceLineNo">2490</span> /**<a name="line.2490"></a> +<span class="sourceLineNo">2491</span> * For tests, web ui and metrics.<a name="line.2491"></a> +<span class="sourceLineNo">2492</span> * This method will only work if HRegionServer is in the same JVM as client;<a name="line.2492"></a> +<span class="sourceLineNo">2493</span> * HRegion cannot be serialized to cross an rpc.<a name="line.2493"></a> +<span class="sourceLineNo">2494</span> */<a name="line.2494"></a> +<span class="sourceLineNo">2495</span> public Collection<Region> getOnlineRegionsLocalContext() {<a name="line.2495"></a> +<span class="sourceLineNo">2496</span> Collection<Region> regions = this.onlineRegions.values();<a name="line.2496"></a> +<span class="sourceLineNo">2497</span> return Collections.unmodifiableCollection(regions);<a name="line.2497"></a> +<span class="sourceLineNo">2498</span> }<a name="line.2498"></a> +<span class="sourceLineNo">2499</span><a name="line.2499"></a> +<span class="sourceLineNo">2500</span> @Override<a name="line.2500"></a> +<span class="sourceLineNo">2501</span> public void addToOnlineRegions(Region region) {<a name="line.2501"></a> +<span class="sourceLineNo">2502</span> this.onlineRegions.put(region.getRegionInfo().getEncodedName(), region);<a name="line.2502"></a> +<span class="sourceLineNo">2503</span> configurationManager.registerObserver(region);<a name="line.2503"></a> +<span class="sourceLineNo">2504</span> }<a name="line.2504"></a> +<span class="sourceLineNo">2505</span><a name="line.2505"></a> +<span class="sourceLineNo">2506</span> /**<a name="line.2506"></a> +<span class="sourceLineNo">2507</span> * @return A new Map of online regions sorted by region size with the first entry being the<a name="line.2507"></a> +<span class="sourceLineNo">2508</span> * biggest. If two regions are the same size, then the last one found wins; i.e. this method<a name="line.2508"></a> +<span class="sourceLineNo">2509</span> * may NOT return all regions.<a name="line.2509"></a> +<span class="sourceLineNo">2510</span> */<a name="line.2510"></a> +<span class="sourceLineNo">2511</span> SortedMap<Long, Region> getCopyOfOnlineRegionsSortedBySize() {<a name="line.2511"></a> +<span class="sourceLineNo">2512</span> // we'll sort the regions in reverse<a name="line.2512"></a> +<span class="sourceLineNo">2513</span> SortedMap<Long, Region> sortedRegions = new TreeMap<Long, Region>(<a name="line.2513"></a> +<span class="sourceLineNo">2514</span> new Comparator<Long>() {<a name="line.2514"></a> +<span class="sourceLineNo">2515</span> @Override<a name="line.2515"></a> +<span class="sourceLineNo">2516</span> public int compare(Long a, Long b) {<a name="line.2516"></a> +<span class="sourceLineNo">2517</span> return -1 * a.compareTo(b);<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> // Copy over all regions. Regions are sorted by size with biggest first.<a name="line.2520"></a> +<span class="sourceLineNo">2521</span> for (Region region : this.onlineRegions.values()) {<a name="line.2521"></a> +<span class="sourceLineNo">2522</span> sortedRegions.put(region.getMemstoreSize(), region);<a name="line.2522"></a> +<span class="sourceLineNo">2523</span> }<a name="line.2523"></a> +<span class="sourceLineNo">2524</span> return sortedRegions;<a name="line.2524"></a> +<span class="sourceLineNo">2525</span> }<a name="line.2525"></a> +<span class="sourceLineNo">2526</span><a name="line.2526"></a> +<span class="sourceLineNo">2527</span> /**<a name="line.2527"></a> +<span class="sourceLineNo">2528</span> * @return time stamp in millis of when this region server was started<a name="line.2528"></a> +<span class="sourceLineNo">2529</span> */<a name="line.2529"></a> +<span class="sourceLineNo">2530</span> public long getStartcode() {<a name="line.2530"></a> +<span class="sourceLineNo">2531</span> return this.startcode;<a name="line.2531"></a> +<span class="sourceLineNo">2532</span> }<a name="line.2532"></a> +<span class="sourceLineNo">2533</span><a name="line.2533"></a> +<span class="sourceLineNo">2534</span> /** @return reference to FlushRequester */<a name="line.2534"></a> +<span class="sourceLineNo">2535</span> @Override<a name="line.2535"></a> +<span class="sourceLineNo">2536</span> public FlushRequester getFlushRequester() {<a name="line.2536"></a> +<span class="sourceLineNo">2537</span> return this.cacheFlusher;<a name="line.2537"></a> +<span class="sourceLineNo">2538</span> }<a name="line.2538"></a> +<span class="sourceLineNo">2539</span><a name="line.2539"></a> +<span class="sourceLineNo">2540</span> /**<a name="line.2540"></a> +<span class="sourceLineNo">2541</span> * Get the top N most loaded regions this server is serving so we can tell the<a name="line.2541"></a> +<span class="sourceLineNo">2542</span> * master which regions it can reallocate if we're overloaded. TODO: actually<a name="line.2542"></a> +<span class="sourceLineNo">2543</span> * calculate which regions are most loaded. (Right now, we're just grabbing<a name="line.2543"></a> +<span class="sourceLineNo">2544</span> * the first N regions being served regardless of load.)<a name="line.2544"></a> +<span class="sourceLineNo">2545</span> */<a name="line.2545"></a> +<span class="sourceLineNo">2546</span> protected HRegionInfo[] getMostLoadedRegions() {<a name="line.2546"></a> +<span class="sourceLineNo">2547</span> ArrayList<HRegionInfo> regions = new ArrayList<HRegionInfo>();<a name="line.2547"></a> +<span class="sourceLineNo">2548</span> for (Region r : onlineRegions.values()) {<a name="line.2548"></a> +<span class="sourceLineNo">2549</span> if (!r.isAvailable()) {<a name="line.2549"></a> +<span class="sourceLineNo">2550</span> continue;<a name="line.2550"></a> +<span class="sourceLineNo">2551</span> }<a name="line.2551"></a> +<span class="sourceLineNo">2552</span> if (regions.size() < numRegionsToReport) {<a name="line.2552"></a> +<span class="sourceLineNo">2553</span> regions.add(r.getRegionInfo());<a name="line.2553"></a> +<span class="sourceLineNo">2554</span> } else {<a name="line.2554"></a> +<span class="sourceLineNo">2555</span> break;<a name="line.2555"></a> +<span class="sourceLineNo">2556</span> }<a name="line.2556"></a> +<span class="sourceLineNo">2557</span> }<a name="line.2557"></a> +<span class="sourceLineNo">2558</span> return regions.toArray(new HRegionInfo[regions.size()]);<a name="line.2558"></a> +<span class="sourceLineNo">2559</span> }<a name="line.2559"></a> +<span class="sourceLineNo">2560</span><a name="line.2560"></a> +<span class="sourceLineNo">2561</span> @Override<a name="line.2561"></a> +<span class="sourceLineNo">2562</span> public Leases getLeases() {<a name="line.2562"></a> +<span class="sourceLineNo">2563</span> return leases;<a name="line.2563"></a> +<span class="sourceLineNo">2564</span> }<a name="line.2564"></a> +<span class="sourceLineNo">2565</span><a name="line.2565"></a> +<span class="sourceLineNo">2566</span> /**<a name="line.2566"></a> +<span class="sourceLineNo">2567</span> * @return Return the rootDir.<a name="line.2567"></a> +<span class="sourceLineNo">2568</span> */<a name="line.2568"></a> +<span class="sourceLineNo">2569</span> protected Path getRootDir() {<a name="line.2569"></a> +<span class="sourceLineNo">2570</span> return rootDir;<a name="line.2570"></a> +<span class="sourceLineNo">2571</span> }<a name="line.2571"></a> +<span class="sourceLineNo">2572</span><a name="line.2572"></a> +<span class="sourceLineNo">2573</span> /**<a name="line.2573"></a> +<span class="sourceLineNo">2574</span> * @return Return the fs.<a name="line.2574"></a> +<span class="sourceLineNo">2575</span> */<a name="line.2575"></a> +<span class="sourceLineNo">2576</span> @Override<a name="line.2576"></a> +<span class="sourceLineNo">2577</span> public FileSystem getFileSystem() {<a name="line.2577"></a> +<span class="sourceLineNo">2578</span> return fs;<a name="line.2578"></a> +<span class="sourceLineNo">2579</span> }<a name="line.2579"></a> +<span class="sourceLineNo">2580</span><a name="line.2580"></a> +<span class="sourceLineNo">2581</span> @Override<a name="line.2581"></a> +<span class="sourceLineNo">2582</span> public String toString() {<a name="line.2582"></a> +<span class="sourceLineNo">2583</span> return getServerName().toString();<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> /**<a name="line.2586"></a> +<span class="sourceLineNo">2587</span> * Interval at which threads should run<a name="line.2587"></a> +<span class="sourceLineNo">2588</span> *<a name="line.2588"></a> +<span class="sourceLineNo">2589</span> * @return the interval<a name="line.2589"></a> +<span class="sourceLineNo">2590</span> */<a name="line.2590"></a> +<span class="sourceLineNo">2591</span> public int getThreadWakeFrequency() {<a name="line.2591"></a> +<span class="sourceLineNo">2592</span> return threadWakeFrequency;<a name="line.2592"></a> +<span class="sourceLineNo">2593</span> }<a name="line.2593"></a> +<span class="sourceLineNo">2594</span><a name="line.2594"></a> +<span class="sourceLineNo">2595</span> @Override<a name="line.2595"></a> +<span class="sourceLineNo">2596</span> public ZooKeeperWatcher getZooKeeper() {<a name="line.2596"></a> +<span class="sourceLineNo">2597</span> return zooKeeper;<a name="line.2597"></a> +<span class="sourceLineNo">2598</span> }<a name="line.2598"></a> +<span class="sourceLineNo">2599</span><a name="line.2599"></a> +<span class="sourceLineNo">2600</span> @Override<a name="line.2600"></a> +<span class="sourceLineNo">2601</span> public BaseCoordinatedStateManager getCoordinatedStateManager() {<a name="line.2601"></a> +<span class="sourceLineNo">2602</span> return csm;<a name="line.2602"></a> +<span class="sourceLineNo">2603</span> }<a name="line.2603"></a> +<span class="sourceLineNo">2604</span><a name="line.2604"></a> +<span class="sourceLineNo">2605</span> @Override<a name="line.2605"></a> +<span class="sourceLineNo">2606</span> public ServerName getServerName() {<a name="line.2606"></a> +<span class="sourceLineNo">2607</span> return serverName;<a name="line.2607"></a> +<span class="sourceLineNo">2608</span> }<a name="line.2608"></a> +<span class="sourceLineNo">2609</span><a name="line.2609"></a> +<span class="sourceLineNo">2610</span> @Override<a name="line.2610"></a> +<span class="sourceLineNo">2611</span> public CompactionRequestor getCompactionRequester() {<a name="line.2611"></a> +<span class="sourceLineNo">2612</span> return this.compactSplitThread;<a name="line.2612"></a> <span class="sourceLineNo">2613</span> }<a name="line.2613"></a> <span class="sourceLineNo">2614</span><a name="line.2614"></a> -<span class="sourceLineNo">2615</span> @Override<a name="line.2615"></a> -<span class="sourceLineNo">2616</span> public ConcurrentMap<byte[], Boolean> getRegionsInTransitionInRS() {<a name="line.2616"></a> -<span class="sourceLineNo">2617</span> return this.regionsInTransitionInRS;<a name="line.2617"></a> -<span class="sourceLineNo">2618</span> }<a name="line.2618"></a> -<span class="sourceLineNo">2619</span><a name="line.2619"></a> -<span class="sourceLineNo">2620</span> @Override<a name="line.2620"></a> -<span class="sourceLineNo">2621</span> public ExecutorService getExecutorService() {<a name="line.2621"></a> -<span class="sourceLineNo">2622</span> return service;<a name="line.2622"></a> -<span class="sourceLineNo">2623</span> }<a name="line.2623"></a> -<span class="sourceLineNo">2624</span><a name="line.2624"></a> -<span class="sourceLineNo">2625</span> @Override<a name="line.2625"></a> -<span class="sourceLineNo">2626</span> public ChoreService getChoreService() {<a name="line.2626"></a> -<span class="sourceLineNo">2627</span> return choreService;<a name="line.2627"></a> -<span class="sourceLineNo">2628</span> }<a name="line.2628"></a> -<span class="sourceLineNo">2629</span><a name="line.2629"></a> -<span class="sourceLineNo">2630</span> @Override<a name="line.2630"></a> -<span class="sourceLineNo">2631</span> public RegionServerQuotaManager getRegionServerQuotaManager() {<a name="line.2631"></a> -<span class="sourceLineNo">2632</span> return rsQuotaManager;<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> //<a name="line.2635"></a> -<span class="sourceLineNo">2636</span> // Main program and support routines<a name="line.2636"></a> -<span class="sourceLineNo">2637</span> //<a name="line.2637"></a> +<span class="sourceLineNo">2615</span> public RegionServerCoprocessorHost getRegionServerCoprocessorHost(){<a name="line.2615"></a> +<span class="sourceLineNo">2616</span> return this.rsHost;<a name="line.2616"></a> +<span class="sourceLineNo">2617</span> }<a name="line.2617"></a> +<span class="sourceLineNo">2618</span><a name="line.2618"></a> +<span class="sourceLineNo">2619</span> @Override<a name="line.2619"></a> +<span class="sourceLineNo">2620</span> public ConcurrentMap<byte[], Boolean> getRegionsInTransitionInRS() {<a name="line.2620"></a> +<span class="sourceLineNo">2621</span> return this.regionsInTransitionInRS;<a name="line.2621"></a> +<span class="sourceLineNo">2622</span> }<a name="line.2622"></a> +<span class="sourceLineNo">2623</span><a name="line.2623"></a> +<span class="sourceLineNo">2624</span> @Override<a name="line.2624"></a> +<span class="sourceLineNo">2625</span> public ExecutorService getExecutorService() {<a name="line.2625"></a> +<span class="sourceLineNo">2626</span> return service;<a name="line.2626"></a> +<span class="sourceLineNo">2627</span> }<a name="line.2627"></a> +<span class="sourceLineNo">2628</span><a name="line.2628"></a> +<span class="sourceLineNo">2629</span> @Override<a name="line.2629"></a> +<span class="sourceLineNo">2630</span> public ChoreService getChoreService() {<a name="line.2630"></a> +<span class="sourceLineNo">2631</span> return choreService;<a name="line.2631"></a> +<span class="sourceLineNo">2632</span> }<a name="line.2632"></a> +<span class="sourceLineNo">2633</span><a name="line.2633"></a> +<span class="sourceLineNo">2634</span> @Override<a name="line.2634"></a> +<span class="sourceLineNo">2635</span> public RegionServerQuotaManager getRegionServerQuotaManager() {<a name="line.2635"></a> +<span class="sourceLineNo">2636</span> return rsQuotaManager;<a name="line.2636"></a> +<span class="sourceLineNo">2637</span> }<a name="line.2637"></a> <span class="sourceLineNo">2638</span><a name="line.2638"></a> -<span class="sourceLineNo">2639</span> /**<a name="line.2639"></a> -<span class="sourceLineNo">2640</span> * Load the replication service objects, if any<a name="line.2640"></a> -<span class="sourceLineNo">2641</span> */<a name="line.2641"></a> -<span class="sourceLineNo">2642</span> static private void createNewReplicationInstance(Configuration conf,<a name="line.2642"></a> -<span class="sourceLineNo">2643</span> HRegionServer server, FileSystem fs, Path logDir, Path oldLogDir) throws IOException{<a name="line.2643"></a> -<span class="sourceLineNo">2644</span><a name="line.2644"></a> -<span class="sourceLineNo">2645</span> // If replication is not enabled, then return immediately.<a name="line.2645"></a> -<span class="sourceLineNo">2646</span> if (!conf.getBoolean(HConstants.REPLICATION_ENABLE_KEY,<a name="line.2646"></a> -<span class="sourceLineNo">2647</span> HConstants.REPLICATION_ENABLE_DEFAULT)) {<a name="line.2647"></a> -<span class="sourceLineNo">2648</span> return;<a name="line.2648"></a> -<span class="sourceLineNo">2649</span> }<a name="line.2649"></a> -<span class="sourceLineNo">2650</span><a name="line.2650"></a> -<span class="sourceLineNo">2651</span> // read in the name of the source replication class from the config file.<a name="line.2651"></a> -<span class="sourceLineNo">2652</span> String sourceClassname = conf.get(HConstants.REPLICATION_SOURCE_SERVICE_CLASSNAME,<a name="line.2652"></a> -<span class="sourceLineNo">2653</span> HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT);<a name="line.2653"></a> +<span class="sourceLineNo">2639</span> //<a name="line.2639"></a> +<span class="sourceLineNo">2640</span> // Main program and support routines<a name="line.2640"></a> +<span class="sourceLineNo">2641</span> //<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> * Load the replication service objects, if any<a name="line.2644"></a> +<span class="sourceLineNo">2645</span> */<a name="line.2645"></a> +<span class="sourceLineNo">2646</span> static private void createNewReplicationInstance(Configuration conf,<a name="line.2646"></a> +<span class="sourceLineNo">2647</span> HRegionServer server, FileSystem fs, Path logDir, Path oldLogDir) throws IOException{<a name="line.2647"></a> +<span class="sourceLineNo">2648</span><a name="line.2648"></a> +<span class="sourceLineNo">2649</span> // If replication is not enabled, then return immediately.<a name="line.2649"></a> +<span class="sourceLineNo">2650</span> if (!conf.getBoolean(HConstants.REPLICATION_ENABLE_KEY,<a name="line.2650"></a> +<span class="sourceLineNo">2651</span> HConstants.REPLICATION_ENABLE_DEFAULT)) {<a name="line.2651"></a> +<span class="sourceLineNo">2652</span> return;<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> // read in the name of the sink replication class from the config file.<a name="line.2655"></a> -<span class="sourceLineNo">2656</span> String sinkClassname = conf.get(HConstants.REPLICATION_SINK_SERVICE_CLASSNAME,<a name="line.2656"></a> -<span class="sourceLineNo">2657</span> HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT);<a name="line.2657"></a> +<span class="sourceLineNo">2655</span> // read in the name of the source replication class from the config file.<a name="line.2655"></a> +<span class="sourceLineNo">2656</span> String sourceClassname = conf.get(HConstants.REPLICATION_SOURCE_SERVICE_CLASSNAME,<a name="line.2656"></a> +<span class="sourceLineNo">2657</span> HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT);<a name="line.2657"></a> <span class="sourceLineNo">2658</span><a name="line.2658"></a> -<span class="sourceLineNo">2659</span> // If both the sink and the source class names are the same, then instantiate<a name="line.2659"></a> -<span class="sourceLineNo">2660</span> // only one object.<a name="line.2660"></a> -<span class="sourceLineNo">2661</span> if (sourceClassname.equals(sinkClassname)) {<a name="line.2661"></a> -<span class="sourceLineNo">2662</span> server.replicationSourceHandler = (ReplicationSourceService)<a name="line.2662"></a> -<span class="sourceLineNo">2663</span> newReplicationInstance(sourceClassname,<a name="line.2663"></a> -<span class="sourceLineNo">2664</span> conf, server, fs, logDir, oldLogDir);<a name="line.2664"></a> -<span class="sourceLineNo">2665</span> server.replicationSinkHandler = (ReplicationSinkService)<a name="line.2665"></a> -<span class="sourceLineNo">2666</span> server.replicationSourceHandler;<a name="line.2666"></a> -<span class="sourceLineNo">2667</span> } else {<a name="line.2667"></a> -<span class="sourceLineNo">2668</span> server.replicationSourceHandler = (ReplicationSourceService)<a name="line.2668"></a> -<span class="sourceLineNo">2669</span> newReplicationInstance(sourceClassname,<a name="line.2669"></a> -<span class="sourceLineNo">2670</span> conf, server, fs, logDir, oldLogDir);<a name="line.2670"></a> -<span class="sourceLineNo">2671</span> server.replicationSinkHandler = (ReplicationSinkService)<a name="line.2671"></a> -<span class="sourceLineNo">2672</span> newReplicationInstance(sinkClassname,<a name="line.2672"></a> -<span class="sourceLineNo">2673</span> conf, server, fs, logDir, oldLogDir);<a name="line.2673"></a> -<span class="sourceLineNo">2674</span> }<a name="line.2674"></a> -<span class="sourceLineNo">2675</span> }<a name="line.2675"></a> -<span class="sourceLineNo">2676</span><a name="line.2676"></a> -<span class="sourceLineNo">2677</span> static private ReplicationService newReplicationInstance(String classname,<a name="line.2677"></a> -<span class="sourceLineNo">2678</span> Configuration conf, HRegionServer server, FileSystem fs, Path logDir,<a name="line.2678"></a> -<span class="sourceLineNo">2679</span> Path oldLogDir) throws IOException{<a name="line.2679"></a> +<span class="sourceLineNo">2659</span> // read in the name of the sink replication class from the config file.<a name="line.2659"></a> +<span class="sourceLineNo">2660</span> String sinkClassname = conf.get(HConstants.REPLICATION_SINK_SERVICE_CLASSNAME,<a name="line.2660"></a> +<span class="sourceLineNo">2661</span> HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT);<a name="line.2661"></a> +<span class="sourceLineNo">2662</span><a name="line.2662"></a> +<span class="sourceLineNo">2663</span> // If both the sink and the source class names are the same, then instantiate<a name="line.2663"></a> +<span class="sourceLineNo">2664</span> // only one object.<a name="line.2664"></a> +<span class="sourceLineNo">2665</span> if (sourceClassname.equals(sinkClassname)) {<a name="line.2665"></a> +<span class="sourceLineNo">2666</span> server.replicationSourceHandler = (ReplicationSourceService)<a name="line.2666"></a> +<span class="sourceLineNo">2667</span> newReplicationInstance(sourceClassname,<a name="line.2667"></a> +<span class="sourceLineNo">2668</span> conf, server, fs, logDir, oldLogDir);<a name="line.2668"></a> +<span class="sourceLineNo">2669</span> server.replicationSinkHandler = (ReplicationSinkService)<a name="line.2669"></a> +<span class="sourceLineNo">2670</span> server.replicationSourceHandler;<a name="line.2670"></a> +<span class="sourceLineNo">2671</span> } else {<a name="line.2671"></a> +<span class="sourceLineNo">2672</span> server.replicationSourceHandler = (ReplicationSourceService)<a name="line.2672"></a> +<span class="sourceLineNo">2673</span> newReplicationInstance(sourceClassname,<a name="line.2673"></a> +<span class="sourceLineNo">2674</span> conf, server, fs, logDir, oldLogDir);<a name="line.2674"></a> +<span class="sourceLineNo">2675</span> server.replicationSinkHandler = (ReplicationSinkService)<a name="line.2675"></a> +<span class="sourceLineNo">2676</span> newReplicationInstance(sinkClassname,<a name="line.2676"></a> +<span class="sourceLineNo">2677</span> conf, server, fs, logDir, oldLogDir);<a name="line.2677"></a> +<span class="sourceLineNo">2678</span> }<a name="line.2678"></a> +<span class="sourceLineNo">2679</span> }<a name="line.2679"></a> <span class="sourceLineNo">2680</span><a name="line.2680"></a> -<span class="sourceLineNo">2681</span> Class<?> clazz = null;<a name="line.2681"></a> -<span class="sourceLineNo">2682</span> try {<a name="line.2682"></a> -<span class="sourceLineNo">2683</span> ClassLoader classLoader = Thread.currentThread().getContextClassLoader();<a name="line.2683"></a> -<span class="sourceLineNo">2684</span> clazz = Class.forName(classname, true, classLoader);<a name="line.2684"></a> -<span class="sourceLineNo">2685</span> } catch (java.lang.ClassNotFoundException nfe) {<a name="line.2685"></a> -<span class="sourceLineNo">2686</span> throw new IOException("Could not find class for " + classname);<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> // create an instance of the replication object.<a name="line.2689"></a> -<span class="sourceLineNo">2690</span> ReplicationService service = (ReplicationService)<a name="line.2690"></a> -<span class="sourceLineNo">2691</span> ReflectionUtils.newInstance(clazz, conf);<a name="line.2691"></a> -<span class="sourceLineNo">2692</span> service.initialize(server, fs, logDir, oldLogDir);<a name="line.2692"></a> -<span class="sourceLineNo">2693</span> return service;<a name="line.2693"></a> -<span class="sourceLineNo">2694</span> }<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> * Utility for constructing an instance of the passed HRegionServer class.<a name="line.2697"></a> -<span class="sourceLineNo">2698</span> *<a name="line.2698"></a> -<span class="sourceLineNo">2699</span> * @param regionServerClass<a name="line.2699"></a> -<span class="sourceLineNo">2700</span> * @param conf2<a name="line.2700"></a> -<span class="sourceLineNo">2701</span> * @return HRegionServer instance.<a name="line.2701"></a> -<span class="sourceLineNo">2702</span> */<a name="line.2702"></a> -<span class="sourceLineNo">2703</span> public static HRegionServer constructRegionServer(<a name="line.2703"></a> -<span class="sourceLineNo">2704</span> Class<? extends HRegionServer> regionServerClass,<a name="line.2704"></a> -<span class="sourceLineNo">2705</span> final Configuration conf2, CoordinatedStateManager cp) {<a name="line.2705"></a> -<span class="sourceLineNo">2706</span> try {<a name="line.2706"></a> -<span class="sourceLineNo">2707</span> Constructor<? extends HRegionServer> c = regionServerClass<a name="line.2707"></a> -<span class="sourceLineNo">2708</span> .getConstructor(Configuration.class, CoordinatedStateManager.class);<a name="line.2708"></a> -<span class="sourceLineNo">2709</span> return c.newInstance(conf2, cp);<a name="line.2709"></a> -<span class="sourceLineNo">2710</span> } catch (Exception e) {<a name="line.2710"></a> -<span class="sourceLineNo">2711</span> throw new RuntimeException("Failed construction of " + "Regionserver: "<a name="line.2711"></a> -<span class="sourceLineNo">2712</span> + regionServerClass.toString(), e);<a name="line.2712"></a> -<span class="sourceLineNo">2713</span> }<a name="line.2713"></a> -<span class="sourceLineNo">2714</span> }<a name="line.2714"></a> -<span class="sourceLineNo">2715</span><a name="line.2715"></a> -<span class="sourceLineNo">2716</span> /**<a name="line.2716"></a> -<span class="sourceLineNo">2717</span> * @see org.apache.hadoop.hbase.regionserver.HRegionServerCommandLine<a name="line.2717"></a> -<span class="sourceLineNo">2718</span> */<a name="line.2718"></a> -<span class="sourceLineNo">2719</span> public static void main(String[] args) throws Exception {<a name="line.2719"></a> -<span class="sourceLineNo">2720</span> VersionInfo.logVersion();<a name="line.2720"></a> -<span class="sourceLineNo">2721</span> Configuration conf = HBaseConfiguration.create();<a name="line.2721"></a> -<span class="sourceLineNo">2722</span> @SuppressWarnings("unchecked")<a name="line.2722"></a> -<span class="sourceLineNo">2723</span> Class<? extends HRegionServer> regionServerClass = (Class<? extends HRegionServer>) conf<a name="line.2723"></a> -<span class="sourceLineNo">2724</span> .getClass(HConstants.REGION_SERVER_IMPL, HRegionServer.class);<a name="line.2724"></a> -<span class="sourceLineNo">2725</span><a name="line.2725"></a> -<span class="sourceLineNo">2726</span> new HRegionServerCommandLine(regionServerClass).doMain(args);<a name="line.2726"></a> -<span class="sourceLineNo">2727</span> }<a name="line.2727"></a> -<span class="sourceLineNo">2728</span><a name="line.2728"></a> -<span class="sourceLineNo">2729</span> /**<a name="line.2729"></a> -<span class="sourceLineNo">2730</span> * Gets the online regions of the specified table.<a name="line.2730"></a> -<span class="sourceLineNo">2731</span> * This method looks at the in-memory onlineRegions. It does not go to <code>hbase:meta</code>.<a name="line.2731"></a> -<span class="sourceLineNo">2732</span> * Only returns <em>online</em> regions. If a region on this table has been<a name="line.2732"></a> -<span class="sourceLineNo">2733</span> * closed during a disable, etc., it will not be included in the returned list.<a name="line.2733"></a> -<span class="sourceLineNo">2734</span> * So, the returned list may not necessarily be ALL regions in this table, its<a name="line.2734"></a> -<span class="sourceLineNo">2735</span> * all the ONLINE regions in the table.<a name="line.2735"></a> -<span class="sourceLineNo">2736</span> * @param tableName<a name="line.2736"></a> -<span class="sourceLineNo">2737</span> * @return Online regions from <code>tableName</code><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 List<Region> getOnlineRegions(TableName tableName) {<a name="line.2740"></a> -<span class="sourceLineNo">2741</span> List<Region> tableRegions = new ArrayList<Region>();<a name="line.2741"></a> -<span class="sourceLineNo">2742</span> synchronized (this.onlineRegions) {<a name="line.2742"></a> -<span class="sourceLineNo">2743</span> for (Region region: this.onlineRegions.values()) {<a name="line.2743"></a> -<span class="sourceLineNo">2744</span> HRegionInfo regionInfo = region.getRegionInfo();<a name="line.2744"></a> -<span class="sourceLineNo">2745</span> if(regionInfo.getTable().equals(tableName)) {<a name="line.2745"></a> -<span class="sourceLineNo">2746</span> tableRegions.add(region);<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> }<a name="line.2749"></a> -<span class="sourceLineNo">2750</span> return tableRegions;<a name="line.2750"></a> -<span class="sourceLineNo">2751</span> }<a name="line.2751"></a> -<span class="sourceLineNo">2752</span><a name="line.2752"></a> -<span class="sourceLineNo">2753</span> @Override<a name="line.2753"></a> -<span class="sourceLineNo">2754</span> public List<Region> getOnlineRegions() {<a name="line.2754"></a> -<span class="sourceLineNo">2755</span> List<Region> allRegions = new ArrayList<Region>();<a name="line.2755"></a> -<span class="sourceLineNo">2756</span> synchronized (this.onlineRegions) {<a name="line.2756"></a> -<span class="sourceLineNo">2757</span> // Return a clone copy of the onlineRegions<a name="line.2757"></a> -<span class="sourceLineNo">2758</span> allRegions.addAll(onlineRegions.values());<a name="line.2758"></a> -<span class="sourceLineNo">2759</span> }<a name="line.2759"></a> -<span class="sourceLineNo">2760</span> return allRegions;<a name="line.2760"></a> -<span class="sourceLineNo">2761</span> }<a name="line.2761"></a> -<span class="sourceLineNo">2762</span> /**<a name="line.2762"></a> -<span class="sourceLineNo">2763</span> * Gets the online tables in this RS.<a name="line.2763"></a> -<span class="sourceLineNo">2764</span> * This method looks at the in-memory onlineRegions.<a name="line.2764"></a> -<span class="sourceLineNo">2765</span> * @return all the online tables in this RS<a name="line.2765"></a> -<span class="sourceLineNo">2766</span> */<a name="line.2766"></a> -<span class="sourceLineNo">2767</span> @Override<a name="line.2767"></a> -<span class="sourceLineNo">2768</span> public Set<TableName> getOnlineTables() {<a name="line.2768"></a> -<span class="sourceLineNo">2769</span> Set<TableName> tables = new HashSet<TableName>();<a name="line.2769"></a> -<span class="sourceLineNo">2770</span> synchronized (this.onlineRegions) {<a name="line.2770"></a> -<span class="sourceLineNo">2771</span> for (Region region: this.onlineRegions.values()) {<a name="line.2771"></a> -<span class="sourceLineNo">2772</span> tables.add(region.getTableDesc().getTableName());<a name="line.2772"></a> -<span class="sourceLineNo">2773</span> }<a name="line.2773"></a> -<span class="sourceLineNo">2774</span> }<a name="line.2774"></a> -<span class="sourceLineNo">2775</span> return tables;<a name="line.2775"></a> -<span class="sourceLineNo">2776</span> }<a name="line.2776"></a> -<span class="sourceLineNo">2777</span><a name="line.2777"></a> -<span class="sourceLineNo">2778</span> // used by org/apache/hbase/tmpl/regionserver/RSStatusTmpl.jamon (HBASE-4070).<a name="line.2778"></a> -<span class="sourceLineNo">2779</span> public String[] getRegionServerCoprocessors() {<a name="line.2779"></a> -<span class="sourceLineNo">2780</span> TreeSet<String> coprocessors = new TreeSet<String>();<a name="line.2780"></a> -<span class="sourceLineNo">2781</span> try {<a name="line.2781"></a> -<span class="sourceLineNo">2782</span> coprocessors.addAll(getWAL(null).getCoprocessorHost().getCoprocessors());<a name="line.2782"></a> -<span class="sourceLineNo">2783</span> } catch (IOException exception) {<a name="line.2783"></a> -<span class="sourceLineNo">2784</span> LOG.warn("Exception attempting to fetch wal coprocessor information for the common wal; " +<a name="line.2784"></a> -<span class="sourceLineNo">2785</span> "skipping.");<a name="line.2785"></a> -<span class="sourceLineNo">2786</span> LOG.debug("Exception details for failure to fetch wal coprocessor information.", exception);<a name="line.2786"></a> -<span class="sourceLineNo">2787</span> }<a name="line.2787"></a> -<span class="sourceLineNo">2788</span> Collection<Region> regions = getOnlineRegionsLocalContext();<a name="line.2788"></a> -<span class="sourceLineNo">2789</span> for (Region region: regions) {<a name="line.2789"></a> -<span class="sourceLineNo">2790</span> coprocessors.addAll(region.getCoprocessorHost().getCoprocessors());<a name="line.2790"></a> -<span class="sourceLineNo">2791</span> try {<a name="line.2791"></a> -<span class="sourceLineNo">2792</span> coprocessors.addAll(getWAL(region.getRegionInfo()).getCoprocessorHost().getCoprocessors());<a name="line.2792"></a> -<span class="sourceLineNo">2793</span> } catch (IOException exception) {<a name="line.2793"></a> -<span class="sourceLineNo">2794</span> LOG.warn("Exception attempting to fetch wal coprocessor information for region " + region +<a name="line.2794"></a> -<span class="sourceLineNo">2795</span> "; skipping.");<a name="line.2795"></a> -<span class="sourceLineNo">2796</span> LOG.debug("Exception details for failure to fetch wal coprocessor information.", exception);<a name="line.2796"></a> -<span class="sourceLineNo">2797</span> }<a name="line.2797"></a> -<span class="sourceLineNo">2798</span> }<a name="line.2798"></a> -<span class="sourceLineNo">2799</span> return coprocessors.toArray(new String[coprocessors.size()]);<a name="line.2799"></a> -<span class="sourceLineNo">2800</span> }<a name="line.2800"></a> -<span class="sourceLineNo">2801</span><a name="line.2801"></a> -<span class="sourceLineNo">2802</span> /**<a name="line.2802"></a> -<span class="sourceLineNo">2803</span> * Try to close the region, logs a warning on failure but continues.<a name="line.2803"></a> -<span class="sourceLineNo">2804</span> * @param region Region to close<a name="line.2804"></a> -<span class="sourceLineNo">2805</span> */<a name="line.2805"></a> -<span class="sourceLineNo">2806</span> private void closeRegionIgnoreErrors(HRegionInfo region, final boolean abort) {<a name="line.2806"></a> -<span class="sourceLineNo">2807</span> try {<a name="line.2807"></a> -<span class="sourceLineNo">2808</span> if (!closeRegion(region.getEncodedName(), abort, null)) {<a name="line.2808"></a> -<span class="sourceLineNo">2809</span> LOG.warn("Failed to close " + region.getRegionNameAsString() +<a name="line.2809"></a> -<span class="sourceLineNo">2810</span> " - ignoring and continuing");<a name="line.2810"></a> -<span class="sourceLineNo">2811</span> }<a name="line.2811"></a> -<span class="sourceLineNo">2812</span> } catch (IOException e) {<a name="line.2812"></a> -<span class="sourceLineNo">2813</span> LOG.warn("Failed to close " + region.getRegionNameAsString() +<a name="line.2813"></a> -<span class="sourceLineNo">2814</span> " - ignoring and continuing", e);<a name="line.2814"></a> -<span class="sourceLineNo">2815</span> }<a name="line.2815"></a> -<span class="sourceLineNo">2816</span> }<a name="line.2816"></a> -<span class="sourceLineNo">2817</span><a name="line.2817"></a> -<span class="sourceLineNo">2818</span> /**<a name="line.2818"></a> -<span class="sourceLineNo">2819</span> * Close asynchronously a region, can be called from the master or internally by the regionserver<a name="line.2819"></a> -<span class="sourceLineNo">2820</span> * when stopping. If called from the master, the region will update the znode status.<a name="line.2820"></a> -<span class="sourceLineNo">2821</span> *<a name="line.2821"></a> -<span class="sourceLineNo">2822</span> * <p><a name="line.2822"></a> -<span class="sourceLineNo">2823</span> * If an opening was in progress, this method will cancel it, but will not start a new close. The<a name="line.2823"></a> -<span class="sourceLineNo">2824</span> * coprocessors are not called in this case. A NotServingRegionException exception is thrown.<a name="line.2824"></a> -<span class="sourceLineNo">2825</span> * </p><a name="line.2825"></a> -<span class="sourceLineNo">2826</span><a name="line.2826"></a> -<span class="sourceLineNo">2827</span> * <p><a name="line.2827"></a> -<span class="sourceLineNo">2828</span> * If a close was in progress, this new request will be ignored, and an exception thrown.<a name="line.2828"></a> +<span class="sourceLineNo">2681</span> static private ReplicationService newReplicationInstance(String classname,<a name="line.2681"></a> +<span class="sourceLineNo">2682</span> Configuration conf, HRegionServer server, FileSystem fs, Path logDir,<a name="line.2682"></a> +<span class="sourceLineNo">2683</span> Path oldLogDir) throws IOException{<a name="line.2683"></a> +<span class="sourceLineNo">2684</span><a name="line.2684"></a> +<span class="sourceLineNo">2685</span> Class<?> clazz = null;<a name="line.2685"></a> +<span class="sourceLineNo">2686</span> try {<a name="line.2686"></a> +<span class="sourceLineNo">2687</span> ClassLoader classLoader = Thread.currentThread().getContextClassLoader();<a name="line.2687"></a> +<span class="sourceLineNo">2688</span> clazz = Class.forName(classname, true, classLoader);<a name="line.2688"></a> +<span class="sourceLineNo">2689</span> } catch (java.lang.ClassNotFoundException nfe) {<a name="line.2689"></a> +<span class="sourceLineNo">2690</span> throw new IOException("Could not find class for " + classname);<a name="line.2690"></a> +<span class="sourceLineNo">2691</span> }<a name="line.2691"></a> +<span class="sourceLineNo">2692</span><a name="line.2692"></a> +<span class="sourceLineNo">2693</span> // create an instance of the replication object.<a name="line.2693"></a> +<span class="sourceLineNo">2694</span> ReplicationService service = (ReplicationService)<a name="line.2694"></a> +<span class="sourceLineNo">2695</span> ReflectionUtils.newInstance(clazz, conf);<a name="line.2695"></a> +<span class="sourceLineNo">2696</span> service.initialize(server, fs, logDir, oldLogDir);<a name="line.2696"></a> +<span class="sourceLineNo">2697</span> return service;<a name="line.2697"></a> +<span class="sourceLineNo">2698</span> }<a name="line.2698"></a> +<span class="sourceLineNo">2699</span><a name="line.2699"></a> +<span class="sourceLineNo">2700</span> /**<a name="line.2700"></a> +<span class="sourceLineNo">2701</span> * Utility for constructing an instance of the passed HRegionServer class.<a name="line.2701"></a> +<span class="sourceLineNo">2702</span> *<a name="line.2702"></a> +<span class="sourceLineNo">2703</span> * @param regionServerClass<a name="line.2703"></a> +<span class="sourceLineNo">2704</span> * @param conf2<a name="line.2704"></a> +<span class="sourceLineNo">2705</span> * @return HRegionServer instance.<a name="line.2705"></a> +<span class="sourceLineNo">2706</span> */<a name="line.2706"></a> +<span class="sourceLineNo">2707</span> public static HRegionServer constructRegionServer(<a name="line.2707"></a> +<span class="sourceLineNo">2708</span> Class<? extends HRegionServer> regionServerClass,<a name="line.2708"></a> +<span class="sourceLineNo">2709</span> final Configuration conf2, CoordinatedStateManager cp) {<a name="line.2709"></a> +<span class="sourceLineNo">2710</span> try {<a name="line.2710"></a> +<span class="sourceLineNo">2711</span> Constructor<? extends HRegionServer> c = regionServerClass<a name="line.2711"></a> +<span class="sourceLineNo">2712</span> .getConstructor(Configuration.class, CoordinatedStateManager.class);<a name="line.2712"></a> +<span class="sourceLineNo">2713</span> return c.newInstance(conf2, cp);<a name="line.2713"></a> +<span class="sourceLineNo">2714</span> } catch (Exception e) {<a name="line.2714"></a> +<span class="sourceLineNo">2715</span> throw new RuntimeException("Failed construction of " + "Regionserver: "<a name="line.2715"></a> +<span class="sourceLineNo">2716</span> + regionServerClass.toString(), e);<a name="line.2716"></a> +<span class="sourceLineNo">2717</span> }<a name="line.2717"></a> +<span class="sourceLineNo">2718</span> }<a name="line.2718"></a> +<span class="sourceLineNo">2719</span><a name="line.2719"></a> +<span class="sourceLineNo">2720</span> /**<a name="line.2720"></a> +<span class="sourceLineNo">2721</span> * @see org.apache.hadoop.hbase.regionserver.HRegionServerCommandLine<a name="line.2721"></a> +<span class="sourceLineNo">2722</span> */<a name="line.2722"></a> +<span class="sourceLineNo">2723</span> public static void main(String[] args) throws Exception {<a name="line.2723"></a> +<span class="sourceLineNo">2724</span> VersionInfo.logVersion();<a name="line.2724"></a> +<span class="sourceLineNo">2725</span> Configuration conf = HBaseConfiguration.create();<a name="line.2725"></a> +<span class="sourceLineNo">2726</span> @SuppressWarnings("unchecked")<a name="line.2726"></a> +<span class="sourceLineNo">2727</span> Class<? extends HRegionServer> regionServerClass = (Class<? extends HRegionServer>) conf<a name="line.2727"></a> +<span class="sourceLineNo">2728</span> .getClass(HConstants.REGION_SERVER_IMPL, HRegionServer.class);<a name="line.2728"></a> +<span class="sourceLineNo">2729</span><a name="line.2729"></a> +<span class="sourceLineNo">2730</span> new HRegionServerCommandLine(regionServerClass).doMain(args);<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> * Gets the online regions of the specified table.<a name="line.2734"></a> +<span class="sourceLineNo">2735</span> * This method looks at the in-memory onlineRegions. It does not go to <code>hbase:meta</code>.<a name="line.2735"></a> +<span class="sourceLineNo">2736</span> * Only returns <em>online</em> regions. If a region on this table has been<a name="line.2736"></a> +<span class="sourceLineNo">2737</span> * closed during a disable, etc., it will not be included in the returned list.<a name="line.2737"></a> +<span class="sourceLineNo">2738</span> * So, the returned list may not necessarily be ALL regions in this table, its<a name="line.2738"></a> +<span class="sourceLineNo">2739</span> * all the ONLINE regions in the table.<a name="line.2739"></a> +<span class="sourceLineNo">2740</span> * @param tableName<a name="line.2740"></a> +<span class="sourceLineNo">2741</span> * @return Online regions from <code>tableName</code><a name="line.2741"></a> +<span class="sourceLineNo">2742</span> */<a name="line.2742"></a> +<span class="sourceLineNo">2743</span> @Override<a name="line.2743"></a> +<span class="sourceLineNo">2744</span> public List<Region> getOnlineRegions(TableName tableName) {<a name="line.2744"></a> +<span class="sourceLineNo">2745</span> List<Region> tableRegions = new ArrayList<Region>();<a name="line.2745"></a> +<span class="sourceLineNo">2746</span> synchronized (this.onlineRegions) {<a name="line.2746"></a> +<span class="sourceLineNo">2747</span> for (Region region: this.onlineRegions.values()) {<a name="line.2747"></a> +<span class="sourceLineNo">2748</span> HRegionInfo regionInfo = region.getRegionInfo();<a name="line.2748"></a> +<span class="sourceLineNo">2749</span> if(regionInfo.getTable().equals(tableName)) {<a name="line.2749"></a> +<span class="sourceLineNo">2750</span> tableRegions.add(region);<a name="line.2750"></a> +<span class="sourceLineNo">2751</span> }<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> return tableRegions;<a name="line.2754"></a> +<span class="sourceLineNo">2755</span> }<a name="line.2755"></a> +<span class="sourceLineNo">2756</span><a name="line.2756"></a> +<span class="sourceLineNo">2757</span> @Override<a name="line.2757"></a> +<span class="sourceLineNo">2758</span> public List<Region> getOnlineRegions() {<a name="line.2758"></a> +<span class="sourceLineNo">2759</span> List<Region> allRegions = new ArrayList<Region>();<a name="line.2759"></a> +<span class="sourceLineNo">2760</span> synchronized (this.onlineRegions) {<a name="line.2760"></a> +<span class="sourceLineNo">2761</span> // Return a clone copy of the onlineRegions<a name="line.2761"></a> +<span class="sourceLineNo">2762</span> allRegions.addAll(onlineRegions.values());<a name="l
<TRUNCATED>