org.apache.druid.java.util.common.lifecycle.Lifecycle.stop()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中org.apache.druid.java.util.common.lifecycle.Lifecycle.stop()方法的一些代码示例,展示了Lifecycle.stop()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lifecycle.stop()方法的具体详情如下:
包路径:org.apache.druid.java.util.common.lifecycle.Lifecycle
类名称:Lifecycle
方法名:stop

Lifecycle.stop介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-druid

@Override
 public void stop()
 {
  metamxLifecycle.stop();
 }
});

代码示例来源:origin: apache/incubator-druid

@Override
 public void stopBeingLeader()
 {
  giant.lock();
  try {
   initialized = false;
   final Lifecycle leaderLifecycle = leaderLifecycleRef.getAndSet(null);
   if (leaderLifecycle != null) {
    leaderLifecycle.stop();
   }
  }
  finally {
   giant.unlock();
  }
 }
};

代码示例来源:origin: apache/incubator-druid

@Override
 public void run()
 {
  log.info("Lifecycle [%s] running shutdown hook", name);
  stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@Override
@LifecycleStop
public void close()
{
 // Use full synchronized instead of atomic flag, because otherwise some thread may think that the emitter is already
 // closed while it's in the process of closing by another thread.
 synchronized (startCloseLock) {
  if (closed) {
   return;
  }
  closed = true;
  innerLifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@After
public void teardown()
{
 lifecycle.stop();
}

代码示例来源:origin: apache/incubator-druid

@After
public void tearDown()
{
 if (lifecycle != null) {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@Override
public void run()
{
 Injector injector = DruidTestModuleFactory.getInjector();
 IntegrationTestingConfig config = injector.getInstance(IntegrationTestingConfig.class);
 HttpClient client = injector.getInstance(Key.get(HttpClient.class, TestClient.class));
 waitUntilInstanceReady(client, config.getCoordinatorUrl());
 waitUntilInstanceReady(client, config.getIndexerUrl());
 waitUntilInstanceReady(client, config.getBrokerUrl());
 String routerHost = config.getRouterUrl();
 if (null != routerHost) {
  waitUntilInstanceReady(client, config.getRouterUrl());
 }
 Lifecycle lifecycle = injector.getInstance(Lifecycle.class);
 try {
  lifecycle.start();
  runTests();
 }
 catch (Exception e) {
  LOG.error(e, "");
  throw Throwables.propagate(e);
 }
 finally {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testBasicInjection() throws Exception
{
 final CaffeineCacheConfig config = new CaffeineCacheConfig();
 Injector injector = Initialization.makeInjectorWithModules(
   GuiceInjectors.makeStartupInjector(), ImmutableList.of(
     binder -> {
      binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/test/redis");
      binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
      binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
      binder.bind(CaffeineCacheConfig.class).toInstance(config);
      binder.bind(Cache.class).toProvider(CaffeineCacheProviderWithConfig.class).in(ManageLifecycle.class);
     }
   )
 );
 final Lifecycle lifecycle = injector.getInstance(Lifecycle.class);
 lifecycle.start();
 try {
  Cache cache = injector.getInstance(Cache.class);
  Assert.assertEquals(CaffeineCache.class, cache.getClass());
 }
 finally {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

lifecycle.addHandler(exceptionalHandler);
lifecycle.start();
lifecycle.stop();
lifecycle.stop();
lifecycle.stop();
Assert.assertEquals(0, failedCount.get());
Exception ex = null;

代码示例来源:origin: apache/incubator-druid

lifecycle.stop();

代码示例来源:origin: apache/incubator-druid

@Test
public void testHttpSilentServerWithRequestTimeout() throws Throwable
{
 final Lifecycle lifecycle = new Lifecycle();
 try {
  final HttpClientConfig config = HttpClientConfig.builder().withReadTimeout(new Duration(86400L * 365)).build();
  final HttpClient client = HttpClientInit.createClient(config, lifecycle);
  final ListenableFuture<StatusResponseHolder> future = client
    .go(
      new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", silentServerSocket.getLocalPort()))),
      new StatusResponseHandler(StandardCharsets.UTF_8),
      new Duration(100L)
    );
  Throwable e = null;
  try {
   future.get();
  }
  catch (ExecutionException e1) {
   e = e1.getCause();
  }
  Assert.assertTrue("ReadTimeoutException thrown by 'get'", e instanceof ReadTimeoutException);
 }
 finally {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testHttpsSilentServer() throws Throwable
{
 final Lifecycle lifecycle = new Lifecycle();
 try {
  final HttpClientConfig config = HttpClientConfig.builder()
                          .withSslContext(SSLContext.getDefault())
                          .withSslHandshakeTimeout(new Duration(100))
                          .build();
  final HttpClient client = HttpClientInit.createClient(config, lifecycle);
  final ListenableFuture<StatusResponseHolder> response = client
    .go(
      new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", silentServerSocket.getLocalPort()))),
      new StatusResponseHandler(StandardCharsets.UTF_8)
    );
  Throwable e = null;
  try {
   response.get();
  }
  catch (ExecutionException e1) {
   e = e1.getCause();
  }
  Assert.assertTrue("ChannelException thrown by 'get'", e instanceof ChannelException);
 }
 finally {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testHttpsConnectionClosingServer() throws Throwable
{
 final Lifecycle lifecycle = new Lifecycle();
 try {
  final HttpClientConfig config = HttpClientConfig.builder().withSslContext(SSLContext.getDefault()).build();
  final HttpClient client = HttpClientInit.createClient(config, lifecycle);
  final ListenableFuture<StatusResponseHolder> response = client
    .go(
      new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", closingServerSocket.getLocalPort()))),
      new StatusResponseHandler(StandardCharsets.UTF_8)
    );
  Throwable e = null;
  try {
   response.get();
  }
  catch (ExecutionException e1) {
   e = e1.getCause();
   e1.printStackTrace();
  }
  Assert.assertTrue("ChannelException thrown by 'get'", isChannelClosedException(e));
 }
 finally {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testHttpConnectionClosingServer() throws Throwable
{
 final Lifecycle lifecycle = new Lifecycle();
 try {
  final HttpClientConfig config = HttpClientConfig.builder().build();
  final HttpClient client = HttpClientInit.createClient(config, lifecycle);
  final ListenableFuture<StatusResponseHolder> response = client
    .go(
      new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", closingServerSocket.getLocalPort()))),
      new StatusResponseHandler(StandardCharsets.UTF_8)
    );
  Throwable e = null;
  try {
   response.get();
  }
  catch (ExecutionException e1) {
   e = e1.getCause();
   e1.printStackTrace();
  }
  Assert.assertTrue("ChannelException thrown by 'get'", isChannelClosedException(e));
 }
 finally {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testHttpSilentServerWithGlobalTimeout() throws Throwable
{
 final Lifecycle lifecycle = new Lifecycle();
 try {
  final HttpClientConfig config = HttpClientConfig.builder().withReadTimeout(new Duration(100)).build();
  final HttpClient client = HttpClientInit.createClient(config, lifecycle);
  final ListenableFuture<StatusResponseHolder> future = client
    .go(
      new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", silentServerSocket.getLocalPort()))),
      new StatusResponseHandler(StandardCharsets.UTF_8)
    );
  Throwable e = null;
  try {
   future.get();
  }
  catch (ExecutionException e1) {
   e = e1.getCause();
  }
  Assert.assertTrue("ReadTimeoutException thrown by 'get'", e instanceof ReadTimeoutException);
 }
 finally {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

@Test
 public void testHttpsEchoServer() throws Throwable
 {
  final Lifecycle lifecycle = new Lifecycle();
  try {
   final HttpClientConfig config = HttpClientConfig.builder().withSslContext(SSLContext.getDefault()).build();
   final HttpClient client = HttpClientInit.createClient(config, lifecycle);

   final ListenableFuture<StatusResponseHolder> response = client
     .go(
       new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", echoServerSocket.getLocalPort()))),
       new StatusResponseHandler(StandardCharsets.UTF_8)
     );

   expectedException.expect(ExecutionException.class);
   expectedException.expectMessage("org.jboss.netty.channel.ChannelException: Faulty channel in resource pool");

   response.get();
  }
  finally {
   lifecycle.stop();
  }
 }
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testHttpEchoServer() throws Throwable
{
 final Lifecycle lifecycle = new Lifecycle();
 try {
  final HttpClientConfig config = HttpClientConfig.builder().build();
  final HttpClient client = HttpClientInit.createClient(config, lifecycle);
  final ListenableFuture<StatusResponseHolder> response = client
    .go(
      new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", echoServerSocket.getLocalPort()))),
      new StatusResponseHandler(StandardCharsets.UTF_8)
    );
  expectedException.expect(ExecutionException.class);
  expectedException.expectMessage("java.lang.IllegalArgumentException: invalid version format: GET");
  response.get();
 }
 finally {
  lifecycle.stop();
 }
}

代码示例来源:origin: apache/incubator-druid

lifecycle.stop();

代码示例来源:origin: apache/incubator-druid

@Test
public void testSanity() throws Exception
{
 Lifecycle lifecycle = new Lifecycle();
 List<Integer> startOrder = new ArrayList<>();
 List<Integer> stopOrder = new ArrayList<>();
 lifecycle.addManagedInstance(new ObjectToBeLifecycled(0, startOrder, stopOrder));
 lifecycle.addManagedInstance(new ObjectToBeLifecycled(1, startOrder, stopOrder), Lifecycle.Stage.NORMAL);
 lifecycle.addManagedInstance(new ObjectToBeLifecycled(2, startOrder, stopOrder), Lifecycle.Stage.NORMAL);
 lifecycle.addManagedInstance(new ObjectToBeLifecycled(3, startOrder, stopOrder), Lifecycle.Stage.LAST);
 lifecycle.addStartCloseInstance(new ObjectToBeLifecycled(4, startOrder, stopOrder));
 lifecycle.addManagedInstance(new ObjectToBeLifecycled(5, startOrder, stopOrder));
 lifecycle.addStartCloseInstance(new ObjectToBeLifecycled(6, startOrder, stopOrder), Lifecycle.Stage.LAST);
 lifecycle.addManagedInstance(new ObjectToBeLifecycled(7, startOrder, stopOrder));
 lifecycle.addStartCloseInstance(new ObjectToBeLifecycled(8, startOrder, stopOrder), Lifecycle.Stage.INIT);
 final List<Integer> expectedOrder = Arrays.asList(8, 0, 1, 2, 4, 5, 7, 3, 6);
 lifecycle.start();
 Assert.assertEquals(9, startOrder.size());
 Assert.assertEquals(0, stopOrder.size());
 Assert.assertEquals(expectedOrder, startOrder);
 lifecycle.stop();
 Assert.assertEquals(9, startOrder.size());
 Assert.assertEquals(9, stopOrder.size());
 Assert.assertEquals(Lists.reverse(expectedOrder), stopOrder);
}

代码示例来源:origin: apache/incubator-druid

private void testIt(Injector injector, Lifecycle lifecycle, TestInterface instance)
  throws Exception
{
 Assert.assertEquals(0, instance.getStarted());
 Assert.assertEquals(0, instance.getStopped());
 Assert.assertEquals(0, instance.getRan());
 instance.run();
 Assert.assertEquals(0, instance.getStarted());
 Assert.assertEquals(0, instance.getStopped());
 Assert.assertEquals(1, instance.getRan());
 lifecycle.start();
 Assert.assertEquals(1, instance.getStarted());
 Assert.assertEquals(0, instance.getStopped());
 Assert.assertEquals(1, instance.getRan());
 injector.getInstance(TestInterface.class).run();  // It's a singleton
 Assert.assertEquals(1, instance.getStarted());
 Assert.assertEquals(0, instance.getStopped());
 Assert.assertEquals(2, instance.getRan());
 lifecycle.stop();
 Assert.assertEquals(1, instance.getStarted());
 Assert.assertEquals(1, instance.getStopped());
 Assert.assertEquals(2, instance.getRan());
}

相关文章