本文整理汇总了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();
}
}
示例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();
}
};
}
示例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);
}
示例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);
}