@Test public void testNoMaxWatermarkOnImmediateStop() throws Exception { final List<StreamElement> output = new ArrayList<>(); // regular stream source operator final StoppableStreamSource<String, InfiniteSource<String>> operator = new StoppableStreamSource<>(new InfiniteSource<String>()); setupSourceOperator(operator, TimeCharacteristic.EventTime, 0); operator.stop(); // run and stop operator.run(new Object(), mock(StreamStatusMaintainer.class), new CollectorOutput<String>(output)); assertTrue(output.isEmpty()); }
/** * Marks the source a stopped and calls {@link StoppableFunction#stop()} on the user function. */ public void stop() { // important: marking the source as stopped has to happen before the function is stopped. // the flag that tracks this status is volatile, so the memory model also guarantees // the happens-before relationship markCanceledOrStopped(); userFunction.stop(); } }
StreamSource<OUT, ?> sourceOperator; if (function instanceof StoppableFunction) { sourceOperator = new StoppableStreamSource<>(cast2StoppableSourceFunction(function)); } else { sourceOperator = new StreamSource<>(function);
@Override public void stop() { stopped = true; if (this.headOperator != null) { this.headOperator.stop(); } } }
new StoppableStreamSource<>(new InfiniteSource<String>()); operator.getContainingTask().getProcessingTimeService(), operator.getContainingTask().getCheckpointLock(), operator.getContainingTask().getStreamStatusMaintainer(), new CollectorOutput<String>(output), operator.getExecutionConfig().getAutoWatermarkInterval(), -1);
@Test public void testNoMaxWatermarkOnAsyncStop() throws Exception { final List<StreamElement> output = new ArrayList<>(); // regular stream source operator final StoppableStreamSource<String, InfiniteSource<String>> operator = new StoppableStreamSource<>(new InfiniteSource<String>()); setupSourceOperator(operator, TimeCharacteristic.EventTime, 0); // trigger an async cancel in a bit new Thread("canceler") { @Override public void run() { try { Thread.sleep(200); } catch (InterruptedException ignored) {} operator.stop(); } }.start(); // run and wait to be stopped operator.run(new Object(), mock(StreamStatusMaintainer.class), new CollectorOutput<String>(output)); assertTrue(output.isEmpty()); }
@Test public void testStop() { final StoppableSourceStreamTask<Object, StoppableSource> sourceTask = new StoppableSourceStreamTask<>(new DummyEnvironment("test", 1, 0)); sourceTask.headOperator = new StoppableStreamSource<>(new StoppableSource()); sourceTask.stop(); assertTrue(stopped); }
@Override public void run() { try { Thread.sleep(200); } catch (InterruptedException ignored) {} operator.stop(); } }.start();
@Test public void testStopBeforeInitialization() throws Exception { final StoppableSourceStreamTask<Object, StoppableFailingSource> sourceTask = new StoppableSourceStreamTask<>(new DummyEnvironment("test", 1, 0)); sourceTask.stop(); sourceTask.headOperator = new StoppableStreamSource<>(new StoppableFailingSource()); sourceTask.run(); }
@Override public void stop() { stopped = true; if (this.headOperator != null) { this.headOperator.stop(); } } }
/** * Marks the source a stopped and calls {@link StoppableFunction#stop()} on the user function. */ public void stop() { // important: marking the source as stopped has to happen before the function is stopped. // the flag that tracks this status is volatile, so the memory model also guarantees // the happens-before relationship markCanceledOrStopped(); userFunction.stop(); } }
StreamSource<OUT, ?> sourceOperator; if (function instanceof StoppableFunction) { sourceOperator = new StoppableStreamSource<>(cast2StoppableSourceFunction(function)); } else { sourceOperator = new StreamSource<>(function);
@Override public void stop() { stopped = true; if (this.headOperator != null) { this.headOperator.stop(); } } }
/** * Marks the source a stopped and calls {@link StoppableFunction#stop()} on the user function. */ public void stop() { // important: marking the source as stopped has to happen before the function is stopped. // the flag that tracks this status is volatile, so the memory model also guarantees // the happens-before relationship markCanceledOrStopped(); userFunction.stop(); } }
StreamSource<OUT, ?> sourceOperator; if (function instanceof StoppableFunction) { sourceOperator = new StoppableStreamSource<>(cast2StoppableSourceFunction(function)); } else { sourceOperator = new StreamSource<>(function);
@Override public void stop() { stopped = true; if (this.headOperator != null) { this.headOperator.stop(); } } }
/** * Marks the source a stopped and calls {@link StoppableFunction#stop()} on the user function. */ public void stop() { // important: marking the source as stopped has to happen before the function is stopped. // the flag that tracks this status is volatile, so the memory model also guarantees // the happens-before relationship markCanceledOrStopped(); userFunction.stop(); } }
StreamSource<OUT, ?> sourceOperator; if (function instanceof StoppableFunction) { sourceOperator = new StoppableStreamSource<>(cast2StoppableSourceFunction(function)); } else { sourceOperator = new StreamSource<>(function);
StreamSource<OUT, ?> sourceOperator; if (function instanceof StoppableFunction) { sourceOperator = new StoppableStreamSource<>(cast2StoppableSourceFunction(function)); } else { sourceOperator = new StreamSource<>(function);