当前位置: 首页>>代码示例>>Java>>正文


Java LifecycleState类代码示例

本文整理汇总了Java中org.apache.flume.lifecycle.LifecycleState的典型用法代码示例。如果您正苦于以下问题:Java LifecycleState类的具体用法?Java LifecycleState怎么用?Java LifecycleState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LifecycleState类属于org.apache.flume.lifecycle包,在下文中一共展示了LifecycleState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Override
public synchronized void configure(Context context) {
  if (isStarted()) {
    throw new IllegalStateException("Configure called when started");
  } else {
    try {
      exception = null;
      setLifecycleState(LifecycleState.IDLE);
      doConfigure(context);
    } catch (Exception e) {
      exception = e;
      setLifecycleState(LifecycleState.ERROR);
      // causes source to be removed by configuration code
      Throwables.propagate(e);
    }
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:18,代码来源:BasicSourceSemantics.java

示例2: start

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Override
public synchronized void start() {
  if (exception != null) {
    logger.error(String.format("Cannot start due to error: name = %s",
        getName()), exception);
  } else {
    try {
      Preconditions.checkState(channelProcessor != null,
          "No channel processor configured");
      doStart();
      setLifecycleState(LifecycleState.START);
    } catch (Exception e) {
      logger.error(String.format(
          "Unexpected error performing start: name = %s", getName()), e);
      exception = e;
      setLifecycleState(LifecycleState.ERROR);
    }
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:BasicSourceSemantics.java

示例3: start

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Override
public void start() {
  PollableSource source = (PollableSource) getSource();
  ChannelProcessor cp = source.getChannelProcessor();
  cp.initialize();
  source.start();

  runner = new PollingRunner();

  runner.source = source;
  runner.counterGroup = counterGroup;
  runner.shouldStop = shouldStop;

  runnerThread = new Thread(runner);
  runnerThread.setName(getClass().getSimpleName() + "-" + 
      source.getClass().getSimpleName() + "-" + source.getName());
  runnerThread.start();

  lifecycleState = LifecycleState.START;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:PollableSourceRunner.java

示例4: stop

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Override
public void stop() {

  runner.shouldStop.set(true);

  try {
    runnerThread.interrupt();
    runnerThread.join();
  } catch (InterruptedException e) {
    logger.warn("Interrupted while waiting for polling runner to stop. Please report this.", e);
    Thread.currentThread().interrupt();
  }

  Source source = getSource();
  source.stop();
  ChannelProcessor cp = source.getChannelProcessor();
  cp.close();

  lifecycleState = LifecycleState.STOP;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:PollableSourceRunner.java

示例5: start

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Override
public void start() {
  SinkProcessor policy = getPolicy();

  policy.start();

  runner = new PollingRunner();

  runner.policy = policy;
  runner.counterGroup = counterGroup;
  runner.shouldStop = new AtomicBoolean();

  runnerThread = new Thread(runner);
  runnerThread.setName("SinkRunner-PollingRunner-" +
      policy.getClass().getSimpleName());
  runnerThread.start();

  lifecycleState = LifecycleState.START;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:SinkRunner.java

示例6: stop

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Override
public void stop() {

  if (runnerThread != null) {
    runner.shouldStop.set(true);
    runnerThread.interrupt();

    while (runnerThread.isAlive()) {
      try {
        logger.debug("Waiting for runner thread to exit");
        runnerThread.join(500);
      } catch (InterruptedException e) {
        logger.debug("Interrupted while waiting for runner thread to exit. Exception follows.",
                     e);
      }
    }
  }

  getPolicy().stop();
  lifecycleState = LifecycleState.STOP;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:SinkRunner.java

示例7: testLifecycle

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Test
public void testLifecycle() throws InterruptedException,
    InstantiationException, IllegalAccessException {
  setUp();
  Server server = createServer(new MockAvroServer());

  server.start();

  sink.start();
  Assert.assertTrue(LifecycleController.waitForOneOf(sink,
      LifecycleState.START_OR_ERROR, 5000));

  sink.stop();
  Assert.assertTrue(LifecycleController.waitForOneOf(sink,
      LifecycleState.STOP_OR_ERROR, 5000));

  server.close();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:19,代码来源:TestAvroSink.java

示例8: testDoConfigureThrowsException

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Test
public void testDoConfigureThrowsException() throws Exception {
  source = spy(new DoNothingSource() {
    @Override
    protected void doConfigure(Context context) throws FlumeException {
      throw new FlumeException("dummy");
    }
  });
  source.setChannelProcessor(channelProcessor);
  try {
    source.configure(context);
    Assert.fail();
  } catch (FlumeException expected) {

  }
  Assert.assertFalse(source.isStarted());
  Assert.assertEquals(LifecycleState.ERROR, source.getLifecycleState());
  Assert.assertNotNull(source.getStartException());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:TestBasicSourceSemantics.java

示例9: testLifecycle

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Test
public void testLifecycle() throws IOException, InterruptedException {
  File f1 = new File(tmpDir, "file1");
  Files.write("file1line1\nfile1line2\n", f1, Charsets.UTF_8);

  Context context = new Context();
  context.put(POSITION_FILE, posFilePath);
  context.put(FILE_GROUPS, "f1");
  context.put(FILE_GROUPS_PREFIX + "f1", tmpDir.getAbsolutePath() + "/file1$");
  Configurables.configure(source, context);

  for (int i = 0; i < 3; i++) {
    source.start();
    source.process();
    assertTrue("Reached start or error", LifecycleController.waitForOneOf(
        source, LifecycleState.START_OR_ERROR));
    assertEquals("Server is started", LifecycleState.START,
        source.getLifecycleState());

    source.stop();
    assertTrue("Reached stop or error",
        LifecycleController.waitForOneOf(source, LifecycleState.STOP_OR_ERROR));
    assertEquals("Server is stopped", LifecycleState.STOP,
        source.getLifecycleState());
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:27,代码来源:TestTaildirSource.java

示例10: start

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Override
public void start() {
  LOGGER.info("Configuration provider starting");

  Preconditions.checkState(file != null,
      "The parameter file must not be null");

  executorService = Executors.newSingleThreadScheduledExecutor(
          new ThreadFactoryBuilder().setNameFormat("conf-file-poller-%d")
              .build());

  FileWatcherRunnable fileWatcherRunnable =
      new FileWatcherRunnable(file, counterGroup);

  executorService.scheduleWithFixedDelay(fileWatcherRunnable, 0, interval,
      TimeUnit.SECONDS);

  lifecycleState = LifecycleState.START;

  LOGGER.debug("Configuration provider started");
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:PollingPropertiesFileConfigurationProvider.java

示例11: stop

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Override
public void stop() {
  LOGGER.info("Configuration provider stopping");

  executorService.shutdown();
  try {
    while (!executorService.awaitTermination(500, TimeUnit.MILLISECONDS)) {
      LOGGER.debug("Waiting for file watcher to terminate");
    }
  } catch (InterruptedException e) {
    LOGGER.debug("Interrupted while waiting for file watcher to terminate");
    Thread.currentThread().interrupt();
  }
  lifecycleState = LifecycleState.STOP;
  LOGGER.debug("Configuration provider stopped");
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:17,代码来源:PollingPropertiesFileConfigurationProvider.java

示例12: setUp

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

  baseDir = Files.createTempDir();

  configFile = new File(baseDir, TESTFILE.getName());
  Files.copy(TESTFILE, configFile);

  eventBus = new EventBus("test");
  provider =
      new PollingPropertiesFileConfigurationProvider("host1",
          configFile, eventBus, 1);
  provider.start();
  LifecycleController.waitForOneOf(provider, LifecycleState.START_OR_ERROR);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:16,代码来源:TestPollingPropertiesFileConfigurationProvider.java

示例13: bind

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
private void bind() throws InterruptedException {
  boolean bound = false;

  for (int i = 0; i < 100 && !bound; i++) {
    try {
      Context context = new Context();

      context.put("port", String.valueOf(selectedPort = 41414 + i));
      context.put("host", "0.0.0.0");

      Configurables.configure(source, context);

      source.start();
      bound = true;
    } catch (FlumeException e) {
      // Assume port in use, try another one
    }
  }

  Assert
      .assertTrue("Reached start or error", LifecycleController.waitForOneOf(
          source, LifecycleState.START_OR_ERROR));
  Assert.assertEquals("Server is started", LifecycleState.START,
          source.getLifecycleState());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:26,代码来源:TestThriftLegacySource.java

示例14: doStart

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
private void doStart() {
  boolean error = true;
  try {
    channel.start();
    sinkRunner.start();
    sourceRunner.start();

    supervisor.supervise(channel,
        new SupervisorPolicy.AlwaysRestartPolicy(), LifecycleState.START);
    supervisor.supervise(sinkRunner,
        new SupervisorPolicy.AlwaysRestartPolicy(), LifecycleState.START);
    supervisor.supervise(sourceRunner,
        new SupervisorPolicy.AlwaysRestartPolicy(), LifecycleState.START);
    error = false;
  } finally {
    if (error) {
      stopLogError(sourceRunner);
      stopLogError(channel);
      stopLogError(sinkRunner);
      supervisor.stop();
    }
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:24,代码来源:EmbeddedAgent.java

示例15: testStart

import org.apache.flume.lifecycle.LifecycleState; //导入依赖的package包/类
/**
 * [CygnusSink.start] -------- The sink starts properly.
 */
@Test
public void testStart() {
    System.out.println(getTestTraceHead("[NGSISink.start]") + "-------- The sink starts properly");
    NGSISinkImpl sink = new NGSISinkImpl();
    sink.configure(createContext(null, null, null, null, null, null, null, null, null, null, null));
    sink.setChannel(new MemoryChannel());
    sink.start();
    LifecycleState state = sink.getLifecycleState();
    
    try {
        assertEquals(LifecycleState.START, state);
        System.out.println(getTestTraceHead("[NGSISink.start]")
                + "-  OK  - The sink started properly, the lifecycle state is '" + state.toString() + "'");
    } catch (AssertionError e) {
        System.out.println(getTestTraceHead("[NGSISink.start]")
                + "- FAIL - The sink did not start properly, the lifecycle state is '" + state.toString() + "'");
    } // try catch
}
 
开发者ID:telefonicaid,项目名称:fiware-cygnus,代码行数:22,代码来源:NGSISinkTest.java


注:本文中的org.apache.flume.lifecycle.LifecycleState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。