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

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

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

Lifecycle.addMaybeStartHandler介绍

[英]Adds a handler to the Lifecycle at the Stage.NORMAL stage and starts it if the lifecycle has already been started.
[中]在阶段中将处理程序添加到生命周期。正常阶段,如果生命周期已经启动,则启动该阶段。

代码示例

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

/**
 * Adds a handler to the Lifecycle at the Stage.NORMAL stage and starts it if the lifecycle has already been started.
 *
 * @param handler The hander to add to the lifecycle
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public void addMaybeStartHandler(Handler handler) throws Exception
{
 addMaybeStartHandler(handler, Stage.NORMAL);
}

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

public static <T extends ExecutorService> T manageLifecycle(Lifecycle lifecycle, final T service)
 {
  try {
   lifecycle.addMaybeStartHandler(
     new Lifecycle.Handler()
     {
      @Override
      public void start()
      {
      }

      @Override
      public void stop()
      {
       service.shutdownNow();
      }
     }
   );
  }
  catch (Exception e) {
   Throwables.propagate(e);
  }
  return service;
 }
}

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

/**
 * Adds a "managed" instance (annotated with {@link LifecycleStart} and {@link LifecycleStop}) to the Lifecycle at
 * Stage.NORMAL and starts it if the lifecycle has already been started.
 *
 * @param o The object to add to the lifecycle
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public <T> T addMaybeStartManagedInstance(T o) throws Exception
{
 addMaybeStartHandler(new AnnotationBasedHandler(o));
 return o;
}

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

/**
 * Adds an instance with a start() and/or close() method to the Lifecycle at Stage.NORMAL and starts it if the
 * lifecycle has already been started.
 *
 * @param o The object to add to the lifecycle
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public <T> T addMaybeStartStartCloseInstance(T o) throws Exception
{
 addMaybeStartHandler(new StartCloseHandler(o));
 return o;
}

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

/**
 * Adds an instance with a start() and/or close() method to the Lifecycle and starts it if the lifecycle has
 * already been started.
 *
 * @param o     The object to add to the lifecycle
 * @param stage The stage to add the lifecycle at
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public <T> T addMaybeStartStartCloseInstance(T o, Stage stage) throws Exception
{
 addMaybeStartHandler(new StartCloseHandler(o), stage);
 return o;
}

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

/**
 * Adds a "managed" instance (annotated with {@link LifecycleStart} and {@link LifecycleStop}) to the Lifecycle
 * and starts it if the lifecycle has already been started.
 *
 * @param o     The object to add to the lifecycle
 * @param stage The stage to add the lifecycle at
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public <T> T addMaybeStartManagedInstance(T o, Stage stage) throws Exception
{
 addMaybeStartHandler(new AnnotationBasedHandler(o), stage);
 return o;
}

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

public static Lifecycle asMmxLifecycle(Lifecycle lifecycle)
 {
  final Lifecycle metamxLifecycle = new Lifecycle("http-client");
  try {
   lifecycle.addMaybeStartHandler(new Lifecycle.Handler()
   {
    @Override
    public void start() throws Exception
    {
     metamxLifecycle.start();
    }

    @Override
    public void stop()
    {
     metamxLifecycle.stop();
    }
   });
  }
  catch (Exception e) {
   throw Throwables.propagate(e);
  }

  return metamxLifecycle;
 }
}

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

@Override
 public AuditManager get()
 {
  try {
   lifecycle.addMaybeStartHandler(
     new Lifecycle.Handler()
     {
      @Override
      public void start()
      {
       connector.createAuditTable();
      }

      @Override
      public void stop()
      {

      }
     }
   );
  }
  catch (Exception e) {
   throw Throwables.propagate(e);
  }

  return new SQLAuditManager(connector, dbTables, emitter, mapper, config);
 }
}

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

lifecycle.addMaybeStartHandler(
  new Lifecycle.Handler()

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

) throws Exception
 lifecycle.addMaybeStartHandler(
   new Lifecycle.Handler()

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

lifecycle.addMaybeStartHandler(
  new Lifecycle.Handler()

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

.make();
try {
 lifecycle.addMaybeStartHandler(
   new Lifecycle.Handler()

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

lifecycle.addMaybeStartHandler(
  new Lifecycle.Handler()

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

.build();
lifecycle.addMaybeStartHandler(
  new Lifecycle.Handler()

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

512
);
lifecycle.addMaybeStartHandler(
  new Lifecycle.Handler()

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

lifecycle.addMaybeStartHandler(dummyHandler);
Assert.fail("Expected exception");

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

/**
 * Adds a handler to the Lifecycle at the Stage.NORMAL stage and starts it if the lifecycle has already been started.
 *
 * @param handler The hander to add to the lifecycle
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public void addMaybeStartHandler(Handler handler) throws Exception
{
 addMaybeStartHandler(handler, Stage.NORMAL);
}

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

/**
 * Adds an instance with a start() and/or close() method to the Lifecycle at Stage.NORMAL and starts it if the
 * lifecycle has already been started.
 *
 * @param o The object to add to the lifecycle
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public <T> T addMaybeStartStartCloseInstance(T o) throws Exception
{
 addMaybeStartHandler(new StartCloseHandler(o));
 return o;
}

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

/**
 * Adds a "managed" instance (annotated with {@link LifecycleStart} and {@link LifecycleStop}) to the Lifecycle at
 * Stage.NORMAL and starts it if the lifecycle has already been started.
 *
 * @param o The object to add to the lifecycle
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public <T> T addMaybeStartManagedInstance(T o) throws Exception
{
 addMaybeStartHandler(new AnnotationBasedHandler(o));
 return o;
}

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

/**
 * Adds an instance with a start() and/or close() method to the Lifecycle and starts it if the lifecycle has
 * already been started.
 *
 * @param o     The object to add to the lifecycle
 * @param stage The stage to add the lifecycle at
 *
 * @throws Exception {@link Lifecycle#addMaybeStartHandler(Handler, Stage)}
 */
public <T> T addMaybeStartStartCloseInstance(T o, Stage stage) throws Exception
{
 addMaybeStartHandler(new StartCloseHandler(o), stage);
 return o;
}

相关文章