Search in sources :

Example 21 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class TestRegionNormalizerWorker method before.

@Before
public void before() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(masterServices.skipRegionManagementAction(any())).thenReturn(false);
    testingUtility = new HBaseCommonTestingUtil();
    queue = new RegionNormalizerWorkQueue<>();
    workerThreadThrowable.set(null);
    final String threadNameFmt = TestRegionNormalizerWorker.class.getSimpleName() + "-" + testName.getMethodName() + "-%d";
    final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(threadNameFmt).setDaemon(true).setUncaughtExceptionHandler((t, e) -> workerThreadThrowable.set(e)).build();
    workerPool = Executors.newSingleThreadExecutor(threadFactory);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Waiter(org.apache.hadoop.hbase.Waiter) StringDescription(org.hamcrest.StringDescription) Mock(org.mockito.Mock) ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) AtomicReference(java.util.concurrent.atomic.AtomicReference) Supplier(java.util.function.Supplier) Collections.singletonList(java.util.Collections.singletonList) MockitoAnnotations(org.mockito.MockitoAnnotations) HBaseCommonTestingUtil(org.apache.hadoop.hbase.HBaseCommonTestingUtil) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) Matchers.comparesEqualTo(org.hamcrest.Matchers.comparesEqualTo) TestName(org.junit.rules.TestName) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Duration(java.time.Duration) Configuration(org.apache.hadoop.conf.Configuration) After(org.junit.After) MasterServices(org.apache.hadoop.hbase.master.MasterServices) MockitoJUnit(org.mockito.junit.MockitoJUnit) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ThreadFactory(java.util.concurrent.ThreadFactory) ClassRule(org.junit.ClassRule) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) Description(org.hamcrest.Description) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) TableName(org.apache.hadoop.hbase.TableName) Answers(org.mockito.Answers) Assert.assertTrue(org.junit.Assert.assertTrue) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Category(org.junit.experimental.categories.Category) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) Rule(org.junit.Rule) TableNameTestRule(org.apache.hadoop.hbase.TableNameTestRule) MasterTests(org.apache.hadoop.hbase.testclassification.MasterTests) Matcher(org.hamcrest.Matcher) SmallTests(org.apache.hadoop.hbase.testclassification.SmallTests) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) MockitoRule(org.mockito.junit.MockitoRule) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) RegionInfoBuilder(org.apache.hadoop.hbase.client.RegionInfoBuilder) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) ThreadFactory(java.util.concurrent.ThreadFactory) HBaseCommonTestingUtil(org.apache.hadoop.hbase.HBaseCommonTestingUtil) ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) Before(org.junit.Before)

Example 22 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class TestAssignmentManagerBase method setUp.

@Before
public void setUp() throws Exception {
    util = new HBaseTestingUtil();
    this.executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setUncaughtExceptionHandler((t, e) -> LOG.warn("Uncaught: ", e)).build());
    setupConfiguration(util.getConfiguration());
    master = new MockMasterServices(util.getConfiguration(), this.regionsToRegionServers);
    rsDispatcher = new MockRSProcedureDispatcher(master);
    master.start(NSERVERS, rsDispatcher);
    newRsAdded = 0;
    am = master.getAssignmentManager();
    assignProcMetrics = am.getAssignmentManagerMetrics().getAssignProcMetrics();
    unassignProcMetrics = am.getAssignmentManagerMetrics().getUnassignProcMetrics();
    moveProcMetrics = am.getAssignmentManagerMetrics().getMoveProcMetrics();
    reopenProcMetrics = am.getAssignmentManagerMetrics().getReopenProcMetrics();
    openProcMetrics = am.getAssignmentManagerMetrics().getOpenProcMetrics();
    closeProcMetrics = am.getAssignmentManagerMetrics().getCloseProcMetrics();
    setUpMeta();
}
Also used : RegionOpenInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionRequest.RegionOpenInfo) Arrays(java.util.Arrays) SortedSet(java.util.SortedSet) ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) RegionStateTransition(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition) Future(java.util.concurrent.Future) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) Configuration(org.apache.hadoop.conf.Configuration) After(org.junit.After) MasterServices(org.apache.hadoop.hbase.master.MasterServices) MasterProcedureConstants(org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants) CommonFSUtils(org.apache.hadoop.hbase.util.CommonFSUtils) ProtobufUtil(org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) CloseRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest) Set(java.util.Set) NavigableMap(java.util.NavigableMap) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) WALProcedureStore(org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore) Executors(java.util.concurrent.Executors) UncheckedIOException(java.io.UncheckedIOException) Assert.assertFalse(org.junit.Assert.assertFalse) EnvironmentEdgeManager(org.apache.hadoop.hbase.util.EnvironmentEdgeManager) OpenRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionResponse) ServerMetricsBuilder(org.apache.hadoop.hbase.ServerMetricsBuilder) RegionInfoBuilder(org.apache.hadoop.hbase.client.RegionInfoBuilder) RegionOpeningState(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionResponse.RegionOpeningState) RegionServerAbortedException(org.apache.hadoop.hbase.regionserver.RegionServerAbortedException) InterruptedIOException(java.io.InterruptedIOException) TransitionCode(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode) CallQueueTooBigException(org.apache.hadoop.hbase.CallQueueTooBigException) TestName(org.junit.rules.TestName) SocketTimeoutException(java.net.SocketTimeoutException) ExecuteProceduresResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ExecuteProceduresResponse) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) YouAreDeadException(org.apache.hadoop.hbase.YouAreDeadException) ExpectedException(org.junit.rules.ExpectedException) ServerName(org.apache.hadoop.hbase.ServerName) Bytes(org.apache.hadoop.hbase.util.Bytes) Before(org.junit.Before) ExecuteProceduresRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ExecuteProceduresRequest) TableName(org.apache.hadoop.hbase.TableName) Logger(org.slf4j.Logger) OpenRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionRequest) IOException(java.io.IOException) ServerNotRunningYetException(org.apache.hadoop.hbase.ipc.ServerNotRunningYetException) ProcedureSyncWait(org.apache.hadoop.hbase.master.procedure.ProcedureSyncWait) CallTimeoutException(org.apache.hadoop.hbase.ipc.CallTimeoutException) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) RegionServerStoppedException(org.apache.hadoop.hbase.regionserver.RegionServerStoppedException) RemoteException(org.apache.hadoop.ipc.RemoteException) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) ProcedureUtil(org.apache.hadoop.hbase.procedure2.ProcedureUtil) ReportRegionStateTransitionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Rule(org.junit.Rule) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) ProcedureMetrics(org.apache.hadoop.hbase.procedure2.ProcedureMetrics) CloseRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse) RSProcedureDispatcher(org.apache.hadoop.hbase.master.procedure.RSProcedureDispatcher) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Assert.assertEquals(org.junit.Assert.assertEquals) ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Before(org.junit.Before)

Example 23 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class TestAsyncFSWAL method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    GROUP = new NioEventLoopGroup(1, new ThreadFactoryBuilder().setNameFormat("TestAsyncFSWAL-pool-%d").setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build());
    CHANNEL_CLASS = NioSocketChannel.class;
    AbstractTestFSWAL.setUpBeforeClass();
}
Also used : ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) NioEventLoopGroup(org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup) BeforeClass(org.junit.BeforeClass)

Example 24 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class TestAsyncWALReplay method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    GROUP = new NioEventLoopGroup(1, new ThreadFactoryBuilder().setNameFormat("TestAsyncWALReplay-pool-%d").setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build());
    CHANNEL_CLASS = NioSocketChannel.class;
    Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration();
    conf.set(WALFactory.WAL_PROVIDER, "asyncfs");
    AbstractTestWALReplay.setUpBeforeClass();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) NioEventLoopGroup(org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup) BeforeClass(org.junit.BeforeClass)

Example 25 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class ThriftServer method createExecutor.

protected ExecutorService createExecutor(BlockingQueue<Runnable> callQueue, int minWorkers, int maxWorkers) {
    ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();
    tfb.setDaemon(true);
    tfb.setNameFormat("thrift-worker-%d");
    ThreadPoolExecutor threadPool = new THBaseThreadPoolExecutor(minWorkers, maxWorkers, Long.MAX_VALUE, TimeUnit.SECONDS, callQueue, tfb.build(), metrics);
    threadPool.allowCoreThreadTimeOut(true);
    return threadPool;
}
Also used : ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Aggregations

ThreadFactoryBuilder (org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder)25 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)9 ExecutorService (java.util.concurrent.ExecutorService)7 IOException (java.io.IOException)6 Configuration (org.apache.hadoop.conf.Configuration)6 Future (java.util.concurrent.Future)5 TableName (org.apache.hadoop.hbase.TableName)5 BeforeClass (org.junit.BeforeClass)5 ExecutionException (java.util.concurrent.ExecutionException)4 Executors (java.util.concurrent.Executors)4 TimeUnit (java.util.concurrent.TimeUnit)4 InterruptedIOException (java.io.InterruptedIOException)3 Arrays (java.util.Arrays)3 Path (org.apache.hadoop.fs.Path)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 NavigableMap (java.util.NavigableMap)2 Random (java.util.Random)2 Set (java.util.Set)2 SortedSet (java.util.SortedSet)2