Java Code Examples for org.apache.hadoop.hbase.util.Threads#shutdown()
The following examples show how to use
org.apache.hadoop.hbase.util.Threads#shutdown() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MiniHBaseCluster.java From hbase with Apache License 2.0 | 6 votes |
@Override public void run() { try { this.user.runAs(new PrivilegedAction<Object>() { @Override public Object run() { runRegionServer(); return null; } }); } catch (Throwable t) { LOG.error("Exception in run", t); } finally { // Run this on the way out. if (this.shutdownThread != null) { this.shutdownThread.start(); Threads.shutdown(this.shutdownThread, 30000); } } }
Example 2
Source File: RecoveredReplicationSourceShipper.java From hbase with Apache License 2.0 | 5 votes |
private void terminate(String reason, Exception cause) { if (cause == null) { LOG.info("Closing worker for wal group {} because: {}", this.walGroupId, reason); } else { LOG.error( "Closing worker for wal group " + this.walGroupId + " because an error occurred: " + reason, cause); } entryReader.interrupt(); Threads.shutdown(entryReader, sleepForRetries); this.interrupt(); Threads.shutdown(this, sleepForRetries); LOG.info("ReplicationSourceWorker {} terminated", this.getName()); }
Example 3
Source File: EntityLock.java From hbase with Apache License 2.0 | 5 votes |
public void unlock() throws IOException { Threads.shutdown(worker.shutdown()); try { stub.lockHeartbeat(null, LockHeartbeatRequest.newBuilder().setProcId(procId).setKeepAlive(false).build()); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
Example 4
Source File: ShutdownHook.java From hbase with Apache License 2.0 | 5 votes |
@Override public void run() { boolean b = this.conf.getBoolean(RUN_SHUTDOWN_HOOK, true); LOG.info("Shutdown hook starting; " + RUN_SHUTDOWN_HOOK + "=" + b + "; fsShutdownHook=" + this.fsShutdownHook); if (b) { this.stop.stop("Shutdown hook"); Threads.shutdown(this.threadToJoin); if (this.fsShutdownHook != null) { synchronized (fsShutdownHooks) { int refs = fsShutdownHooks.get(fsShutdownHook); if (refs == 1) { LOG.info("Starting fs shutdown hook thread."); Thread fsShutdownHookThread = (fsShutdownHook instanceof Thread) ? (Thread)fsShutdownHook : new Thread(fsShutdownHook, fsShutdownHook.getClass().getSimpleName() + "-shutdown-hook"); fsShutdownHookThread.start(); Threads.shutdown(fsShutdownHookThread, this.conf.getLong(FS_SHUTDOWN_HOOK_WAIT, 30000)); } if (refs > 0) { fsShutdownHooks.put(fsShutdownHook, refs - 1); } } } } LOG.info("Shutdown hook finished."); }
Example 5
Source File: MemStoreFlusher.java From hbase with Apache License 2.0 | 5 votes |
void join() { for (FlushHandler flushHander : flushHandlers) { if (flushHander != null) { Threads.shutdown(flushHander); } } }
Example 6
Source File: TestTokenAuthentication.java From hbase with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { server.stop("Test complete"); Threads.shutdown(serverThread); TEST_UTIL.shutdownMiniZKCluster(); }
Example 7
Source File: TestSecureBulkLoadManager.java From hbase with Apache License 2.0 | 4 votes |
/** * After a secure bulkload finished , there is a clean-up for FileSystems used in the bulkload. * Sometimes, FileSystems used in the finished bulkload might also be used in other bulkload * calls, or there are other FileSystems created by the same user, they could be closed by a * FileSystem.closeAllForUGI call. So during the clean-up, those FileSystems need to be used * later can not get closed ,or else a race condition occurs. * * testForRaceCondition tests the case that two secure bulkload calls from the same UGI go * into two different regions and one bulkload finishes earlier when the other bulkload still * needs its FileSystems, checks that both bulkloads succeed. */ @Test public void testForRaceCondition() throws Exception { Consumer<HRegion> fsCreatedListener = new Consumer<HRegion>() { @Override public void accept(HRegion hRegion) { if (hRegion.getRegionInfo().containsRow(key3)) { Threads.shutdown(ealierBulkload);/// wait util the other bulkload finished } } } ; testUtil.getMiniHBaseCluster().getRegionServerThreads().get(0).getRegionServer() .getSecureBulkLoadManager().setFsCreatedListener(fsCreatedListener); /// create table testUtil.createTable(TABLE,FAMILY,Bytes.toByteArrays(SPLIT_ROWKEY)); /// prepare files Path rootdir = testUtil.getMiniHBaseCluster().getRegionServerThreads().get(0) .getRegionServer().getDataRootDir(); Path dir1 = new Path(rootdir, "dir1"); prepareHFile(dir1, key1, value1); Path dir2 = new Path(rootdir, "dir2"); prepareHFile(dir2, key3, value3); /// do bulkload final AtomicReference<Throwable> t1Exception = new AtomicReference<>(); final AtomicReference<Throwable> t2Exception = new AtomicReference<>(); ealierBulkload = new Thread(new Runnable() { @Override public void run() { try { doBulkloadWithoutRetry(dir1); } catch (Exception e) { LOG.error("bulk load failed .",e); t1Exception.set(e); } } }); laterBulkload = new Thread(new Runnable() { @Override public void run() { try { doBulkloadWithoutRetry(dir2); } catch (Exception e) { LOG.error("bulk load failed .",e); t2Exception.set(e); } } }); ealierBulkload.start(); laterBulkload.start(); Threads.shutdown(ealierBulkload); Threads.shutdown(laterBulkload); Assert.assertNull(t1Exception.get()); Assert.assertNull(t2Exception.get()); /// check bulkload ok Get get1 = new Get(key1); Get get3 = new Get(key3); Table t = testUtil.getConnection().getTable(TABLE); Result r = t.get(get1); Assert.assertArrayEquals(r.getValue(FAMILY, COLUMN), value1); r = t.get(get3); Assert.assertArrayEquals(r.getValue(FAMILY, COLUMN), value3); }
Example 8
Source File: TestProcedureNonce.java From hbase with Apache License 2.0 | 4 votes |
private void testConcurrentNonceRegistration(final boolean submitProcedure, final long nonceGroup, final long nonce) throws IOException { // register the nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); final AtomicReference<Throwable> t1Exception = new AtomicReference(); final AtomicReference<Throwable> t2Exception = new AtomicReference(); final CountDownLatch t1NonceRegisteredLatch = new CountDownLatch(1); final CountDownLatch t2BeforeNonceRegisteredLatch = new CountDownLatch(1); final Thread[] threads = new Thread[2]; threads[0] = new Thread() { @Override public void run() { try { // release the nonce and wake t2 assertFalse("unexpected already registered nonce", procExecutor.registerNonce(nonceKey) >= 0); t1NonceRegisteredLatch.countDown(); // hold the submission until t2 is registering the nonce t2BeforeNonceRegisteredLatch.await(); Threads.sleep(1000); if (submitProcedure) { CountDownLatch latch = new CountDownLatch(1); TestSingleStepProcedure proc = new TestSingleStepProcedure(); procEnv.setWaitLatch(latch); procExecutor.submitProcedure(proc, nonceKey); Threads.sleep(100); // complete the procedure latch.countDown(); } else { procExecutor.unregisterNonceIfProcedureWasNotSubmitted(nonceKey); } } catch (Throwable e) { t1Exception.set(e); } finally { t1NonceRegisteredLatch.countDown(); t2BeforeNonceRegisteredLatch.countDown(); } } }; threads[1] = new Thread() { @Override public void run() { try { // wait until t1 has registered the nonce t1NonceRegisteredLatch.await(); // register the nonce t2BeforeNonceRegisteredLatch.countDown(); assertFalse("unexpected non registered nonce", procExecutor.registerNonce(nonceKey) < 0); } catch (Throwable e) { t2Exception.set(e); } finally { t1NonceRegisteredLatch.countDown(); t2BeforeNonceRegisteredLatch.countDown(); } } }; for (int i = 0; i < threads.length; ++i) { threads[i].start(); } for (int i = 0; i < threads.length; ++i) { Threads.shutdown(threads[i]); } ProcedureTestingUtility.waitNoProcedureRunning(procExecutor); assertEquals(null, t1Exception.get()); assertEquals(null, t2Exception.get()); }