本文整理汇总了Java中org.apache.samza.container.RunLoop类的典型用法代码示例。如果您正苦于以下问题:Java RunLoop类的具体用法?Java RunLoop怎么用?Java RunLoop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RunLoop类属于org.apache.samza.container包,在下文中一共展示了RunLoop类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSamzaContainer
import org.apache.samza.container.RunLoop; //导入依赖的package包/类
@Override
SamzaContainer createSamzaContainer(String processorId, JobModel jobModel) {
if (container == null) {
RunLoop mockRunLoop = mock(RunLoop.class);
doAnswer(invocation ->
{
try {
runLoopStartForMain.countDown();
containerStop.await();
} catch (InterruptedException e) {
System.out.println("In exception" + e);
e.printStackTrace();
}
return null;
}).when(mockRunLoop).run();
doAnswer(invocation ->
{
containerStop.countDown();
return null;
}).when(mockRunLoop).shutdown();
container = StreamProcessorTestUtils.getDummyContainer(mockRunLoop, mock(StreamTask.class));
}
return container;
}
示例2: invokeShutdownNow
import org.apache.samza.container.RunLoop; //导入依赖的package包/类
private void invokeShutdownNow() {
try {
Field field = ReflectionUtils.findField(SamzaContainer.class, "runLoop");
ReflectionUtils.makeAccessible(field);
final Object runLoopObject = field.get(samzaContainer);
ReflectionUtils.doWithFields(RunLoop.class, aField -> {
ReflectionUtils.makeAccessible(aField);
aField.setBoolean(runLoopObject, true);
}, aField -> aField.getName().endsWith("shutdownNow"));
} catch (Exception e) {
throw new IllegalStateException("Cannot set samzaContainer.runLoop.shutdownNow field", e);
}
}