@Override public StreamExecutionEnvironment createExecutionEnvironment() { return new TestStreamEnvironment( jobExecutor, parallelism, jarFiles, classpaths); } };
/** * Resets the streaming context environment to null. */ public static void unsetAsContext() { resetContextEnvironment(); } }
@Override protected void reportOrForwardLatencyMarker(LatencyMarker marker) { // all operators are tracking latencies this.latencyStats.reportLatency(marker); // sinks don't forward latency markers }
@Override public void go() throws Exception { testHarness.snapshot(1L, 1000L); } };
private static void closeSilently(OneInputStreamOperatorTestHarness<?, ?> harness) { if (harness != null) { try { harness.close(); } catch (Throwable ignored) { } } }
public static void move(String name, ContentDump source, ContentDump target) { Collection<String> content = source.read(name); try (ContentWriter contentWriter = target.createWriter(name)) { contentWriter.write(content).flush(); } source.delete(name); }
public void initializeState(String operatorStateSnapshotPath) throws Exception { initializeState(OperatorSnapshotUtil.readStateHandle(operatorStateSnapshotPath)); }
/** * Calls {@link org.apache.flink.streaming.api.operators.StreamOperator#initializeState()}. * Calls {@link org.apache.flink.streaming.api.operators.StreamOperator#setup(StreamTask, StreamConfig, Output)} * if it was not called before. * * <p>This will reshape the state handles to include only those key-group states * in the local key-group range and the operator states that would be assigned to the local * subtask. */ public void initializeState(OperatorSubtaskState operatorStateHandles) throws Exception { initializeState(operatorStateHandles, null); }
/** * Calls {@link StreamOperator#setup(StreamTask, StreamConfig, Output)} ()}. */ public void setup() { setup(null); }
public static <T extends Serializable> List<T> runSourceFunction(SourceFunction<T> sourceFunction) throws Exception { if (sourceFunction instanceof RichFunction) { return runRichSourceFunction(sourceFunction); } else { return runNonRichSourceFunction(sourceFunction); } }
@Override public void run(SourceContext<T> ctx) throws Exception { // first round of sending the elements and waiting for the checkpoints emitElementsAndWaitForCheckpoints(ctx, 2); // second round of the same emitElementsAndWaitForCheckpoints(ctx, 2); }
@Override public int numTimers(AbstractStreamOperatorTestHarness testHarness) { return testHarness.numEventTimeTimers(); }
@Override public int numTimers(AbstractStreamOperatorTestHarness testHarness) { return testHarness.numProcessingTimeTimers(); }
@Override protected void invoke(ContentTransaction transaction, String value, Context context) throws Exception { transaction.tmpContentWriter.write(value); }
@Override public void go() throws Exception { // this should block at first, since there are still two pending records that needs to be flushed testHarness.snapshot(123L, 123L); } };
@Override public void go() throws Exception { // this should block until all records are flushed; // if the snapshot implementation returns before pending records are flushed, testHarness.snapshot(123L, 123L); } };
@Override public void go() throws Exception { testHarness.snapshot(1L, 1000L); } };
@Override public void go() throws Exception { testHarness.snapshot(1L, 1000L); } };