本文整理了Java中org.apache.edgent.topology.Topology.generate()
方法的一些代码示例,展示了Topology.generate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Topology.generate()
方法的具体详情如下:
包路径:org.apache.edgent.topology.Topology
类名称:Topology
方法名:generate
[英]Declare an endless source stream. data.get() will be called repeatably. Each non-null returned value will be present on the stream.
If data implements AutoCloseable, its close()method will be called when the topology's execution is terminated.
[中]宣布源源不断。数据get()将被重复调用。每个非空返回值都将出现在流中。
如果数据实现了AutoCloseable,则在拓扑执行终止时将调用其close()方法。
代码示例来源:origin: apache/incubator-edgent
return topology.generate(endlessCommandReader(cmd));
代码示例来源:origin: apache/incubator-edgent
@Test
public void jobProcessSource() throws Exception {
Topology t = newTopology();
AtomicInteger n = new AtomicInteger(0);
@SuppressWarnings("unused")
TStream<Integer> ints = t.generate(() -> n.incrementAndGet());
Future<Job> fj = ((DirectProvider)getTopologyProvider()).submit(t);
Job job = fj.get();
assertEquals(Job.State.RUNNING, job.getCurrentState());
assertEquals(Job.Health.HEALTHY, job.getHealth());
assertEquals("", job.getLastError());
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
assertTrue(n.get() > 0); // At least one tuple was processed
job.stateChange(Job.Action.CLOSE);
assertEquals(Job.State.CLOSED, job.getCurrentState());
assertEquals(Job.Health.HEALTHY, job.getHealth());
assertEquals("", job.getLastError());
}
代码示例来源:origin: apache/incubator-edgent
@Test(expected = ExecutionException.class)
public void jobProcessSourceError() throws Exception {
Topology t = newTopology();
AtomicInteger n = new AtomicInteger(0);
TStream<Integer> ints = t.generate(() -> n.incrementAndGet());
ints.pipe(new FailedOplet<Integer>(12, 100));
Future<Job> fj = ((DirectProvider)getTopologyProvider()).submit(t);
Job job = fj.get();
assertEquals(Job.State.RUNNING, job.getCurrentState());
try {
job.complete(10, TimeUnit.SECONDS);
} finally {
// RUNNING even though execution error
assertEquals(Job.State.RUNNING, job.getCurrentState());
assertEquals(Job.Health.UNHEALTHY, job.getHealth());
assertEquals("java.lang.RuntimeException: Expected Test Exception", job.getLastError());
}
}
内容来源于网络,如有侵权,请联系作者删除!