Asume the following code snippet:
TStream<Integer> stream = top.generate(() -> {
try{
Thread.sleep(1500);
}catch(InterruptedException ex){
//DO NOTHING
}
return (int)(Math.random() * 100);
});
TWindow<Integer, Integer> window = stream.last(5, TimeUnit.SECONDS, zero());
TStream<Double> average = window.batch((values, key) -> {
int sum = values.stream().mapToInt(Integer::intValue).sum();
return (double)sum / values.size();
});
average.peek(average1 -> LOGGER.info("Calculated average : " + average1));
job = dp.submit(top);
After calling job = dp.submit(top)
, the threads executing the topology will continu to run in the background until the JVM is stopped.
How can I stop this background process programmatically? This is specifically usefull when an Edgent topology is running as a separate process with other tasks in the same JVM. I tried to call job.cancel(true)
, but this does not solve the problem. The task keeps on running...