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


Java Tailer.stop方法代码示例

本文整理汇总了Java中org.apache.commons.io.input.Tailer.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Tailer.stop方法的具体用法?Java Tailer.stop怎么用?Java Tailer.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.input.Tailer的用法示例。


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

示例1: preDestroy

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
@PreDestroy
public void preDestroy() {
	if (this.tailers != null) {
		for (Tailer tailer : this.tailers) {
			tailer.stop();
		}
	}

	if (this.executor != null) {
		this.executor.shutdown();
	}
}
 
开发者ID:ralscha,项目名称:wampspring-demos,代码行数:13,代码来源:TailService.java

示例2: createSubscription

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
private Subscription createSubscription(final Tailer tailer) {
	return new Subscription() {
		@Override
		public void unsubscribe() {
			tailer.stop();
		}
	};
}
 
开发者ID:davidmoten,项目名称:websockets-log-tail,代码行数:9,代码来源:FileTailer.java

示例3: test

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public static void test(final TestParams testParams) throws IOException, ClassNotFoundException,
    NoSuchMethodException, InvocationTargetException, IllegalAccessException, InterruptedException {

  final File tempFile = File.createTempFile("test", "test");
  final File labelFile = File.createTempFile("result", "result");
  LOG.info("Starting test, output file is {}, test config is \n{}", tempFile.getAbsolutePath(), testParams.toString());  
  Executors.newSingleThreadExecutor().submit(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      try {          
        Class.forName(testParams.getTaskClassName())
              .getMethod("main", String[].class)
              .invoke(null, (Object) String.format(
                  testParams.getCliStringTemplate(),
                  tempFile.getAbsolutePath(),
                  testParams.getInputInstances(),
                  testParams.getSamplingSize(),
                  testParams.getInputDelayMicroSec(),
                  labelFile.getAbsolutePath(),
                  testParams.getLabelSamplingSize()
                  ).split("[ ]"));
        } catch (Exception e) {
          LOG.error("Cannot execute test {} {}", e.getMessage(), e.getCause().getMessage());
        }
        return null;
      }
    });

  Thread.sleep(TimeUnit.SECONDS.toMillis(testParams.getPrePollWaitSeconds()));

  CountDownLatch signalComplete = new CountDownLatch(1);

  final Tailer tailer = Tailer.create(tempFile, new TestResultsTailerAdapter(signalComplete), 1000);
  new Thread(new Runnable() {
    @Override
    public void run() {
      tailer.run();
    }
  }).start();

  signalComplete.await();
  tailer.stop();

  assertResults(tempFile, testParams);
  if (testParams.getLabelFileCreated())
    assertLabels(labelFile, testParams);
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:48,代码来源:TestUtils.java

示例4: test

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public static void test(final TestParams testParams) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InterruptedException {

        final File tempFile = File.createTempFile("test", "test");

        LOG.info("Starting test, output file is {}, test config is \n{}", tempFile.getAbsolutePath(), testParams.toString());

        Executors.newSingleThreadExecutor().submit(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                try {
                    Class.forName(testParams.getTaskClassName())
                            .getMethod("main", String[].class)
                            .invoke(null, (Object) String.format(
                                    testParams.getCliStringTemplate(),
                                    tempFile.getAbsolutePath(),
                                    testParams.getInputInstances(),
                                    testParams.getSamplingSize(),
                                    testParams.getInputDelayMicroSec()
                                    ).split("[ ]"));
                } catch (Exception e) {
                    LOG.error("Cannot execute test {} {}", e.getMessage(), e.getCause().getMessage());
                }
                return null;
            }
        });

        Thread.sleep(TimeUnit.SECONDS.toMillis(testParams.getPrePollWaitSeconds()));

        CountDownLatch signalComplete = new CountDownLatch(1);

        final Tailer tailer = Tailer.create(tempFile, new TestResultsTailerAdapter(signalComplete), 1000);
        new Thread(new Runnable() {
            @Override
            public void run() {
                tailer.run();
            }
        }).start();

        signalComplete.await();
        tailer.stop();

        assertResults(tempFile, testParams);
    }
 
开发者ID:YahooArchive,项目名称:samoa,代码行数:45,代码来源:TestUtils.java


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