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

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

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

Lifecycle.start介绍

[英]This lock is used to linearize all calls to Handler.start() and Handler.stop() on the managed handlers.
[中]此锁用于线性化对处理程序的所有调用。start()和处理程序。托管处理程序上的stop()。

代码示例

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

@Override
public void start() throws Exception
{
 metamxLifecycle.start();
}

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

@Override
 public void start() throws Exception
 {
  for (KeyHolder<?> holder : eagerClasses) {
   injector.getInstance(holder.getKey()); // Pull the key so as to "eagerly" load up the class.
  }
  super.start();
 }
};

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

@Override
@LifecycleStart
public void start()
{
 // Use full synchronized instead of atomic flag, because otherwise some thread may think that the emitter is already
 // started while it's in the process of starting by another thread.
 synchronized (startCloseLock) {
  if (started) {
   return;
  }
  started = true;
  try {
   innerLifecycle.start();
  }
  catch (RuntimeException e) {
   throw e;
  }
  catch (Exception e) {
   throw new RuntimeException(e);
  }
 }
}

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

private Emitter parametrizedEmmiter(String uriPattern) throws Exception
{
 final Properties props = new Properties();
 props.setProperty("org.apache.druid.java.util.emitter.type", "parametrized");
 props.setProperty("org.apache.druid.java.util.emitter.recipientBaseUrlPattern", uriPattern);
 lifecycle = new Lifecycle();
 Emitter emitter = Emitters.create(props, httpClient, lifecycle);
 assertEquals(ParametrizedUriEmitter.class, emitter.getClass());
 lifecycle.start();
 return emitter;
}

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

lifecycle.start();

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

@Before
public void setup() throws Exception
{
 setProperties();
 Injector injector = setupInjector();
 final DruidNode node = injector.getInstance(Key.get(DruidNode.class, Self.class));
 port = node.getPlaintextPort();
 lifecycle = injector.getInstance(Lifecycle.class);
 lifecycle.start();
 ClientHolder holder = injector.getInstance(ClientHolder.class);
 server = injector.getInstance(Server.class);
 client = holder.getClient();
}

代码示例来源: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.start();

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

@Override
@Before
public void setup() throws Exception
{
 setProperties();
 Injector injector = setupInjector();
 final DruidNode node = injector.getInstance(Key.get(DruidNode.class, Self.class));
 port = node.getPlaintextPort();
 port1 = SocketUtil.findOpenPortFrom(port + 1);
 port2 = SocketUtil.findOpenPortFrom(port1 + 1);
 lifecycle = injector.getInstance(Lifecycle.class);
 lifecycle.start();
 ClientHolder holder = injector.getInstance(ClientHolder.class);
 client = holder.getClient();
}

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

leaderLifecycle.start();

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

lifecycle.start();
try {
 Cache cache = injector.getInstance(Cache.class);

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

Lifecycle lifecycle = new Lifecycle();
lifecycle.addHandler(stoppingHandler);
lifecycle.start();
new Thread(lifecycle::stop).start(); // will stop at stoppingHandler.stop()
reachedStop.await();

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

lifecycle.start();
lifecycle.stop();
lifecycle.stop();

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

final List<Integer> expectedStopOrder = Arrays.asList(6, 3, 7, 5, 4, 1, 0, 2);
lifecycle.start();

代码示例来源: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

Assert.assertEquals(1, instance.getRan());
lifecycle.start();
Assert.assertEquals(2, instance.getStarted());
Assert.assertEquals(0, instance.getStopped());

代码示例来源: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());
}

代码示例来源:origin: org.apache.druid/druid-server

@Override
public void start() throws Exception
{
 metamxLifecycle.start();
}

代码示例来源:origin: org.apache.druid/druid-api

@Override
 public void start() throws Exception
 {
  for (KeyHolder<?> holder : eagerClasses) {
   injector.getInstance(holder.getKey()); // Pull the key so as to "eagerly" load up the class.
  }
  super.start();
 }
};

相关文章