Search in sources :

Example 1 with TestTaskStateManagerBuilder

use of org.apache.flink.runtime.state.TestTaskStateManagerBuilder in project flink by apache.

the class StreamTaskMailboxTestHarnessBuilder method buildUnrestored.

public StreamTaskMailboxTestHarness<OUT> buildUnrestored() throws Exception {
    TestTaskStateManagerBuilder taskStateManagerBuilder = TestTaskStateManager.builder().setLocalRecoveryConfig(localRecoveryConfig).setCheckpointResponder(checkpointResponder);
    if (taskStateSnapshots != null) {
        taskStateManagerBuilder.setReportedCheckpointId(taskStateSnapshots.keySet().iterator().next()).setJobManagerTaskStateSnapshotsByCheckpointId(taskStateSnapshots);
    }
    TestTaskStateManager taskStateManager = taskStateManagerBuilder.build();
    StreamMockEnvironment streamMockEnvironment = new StreamMockEnvironment(new JobID(), new ExecutionAttemptID(), jobConfig, streamConfig.getConfiguration(), executionConfig, memorySize, new MockInputSplitProvider(), bufferSize, taskStateManager, collectNetworkEvents);
    streamMockEnvironment.setCheckpointResponder(taskStateManager.getCheckpointResponder());
    streamMockEnvironment.setTaskManagerInfo(taskManagerRuntimeInfo);
    initializeInputs(streamMockEnvironment);
    checkState(inputGates != null, "InputGates hasn't been initialised");
    StreamElementSerializer<OUT> outputStreamRecordSerializer = new StreamElementSerializer<>(outputSerializer);
    Queue<Object> outputList = new ArrayDeque<>();
    streamMockEnvironment.addOutput(outputList, outputStreamRecordSerializer);
    streamMockEnvironment.setTaskMetricGroup(taskMetricGroup);
    for (ResultPartitionWriter writer : additionalOutputs) {
        streamMockEnvironment.addOutput(writer);
    }
    StreamTask<OUT, ?> task = taskFactory.apply(streamMockEnvironment);
    return new StreamTaskMailboxTestHarness<>(task, outputList, inputGates, streamMockEnvironment);
}
Also used : ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) ResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter) ArrayDeque(java.util.ArrayDeque) TestTaskStateManager(org.apache.flink.runtime.state.TestTaskStateManager) TestTaskStateManagerBuilder(org.apache.flink.runtime.state.TestTaskStateManagerBuilder) StreamElementSerializer(org.apache.flink.streaming.runtime.streamrecord.StreamElementSerializer) MockInputSplitProvider(org.apache.flink.runtime.operators.testutils.MockInputSplitProvider) JobID(org.apache.flink.api.common.JobID)

Aggregations

ArrayDeque (java.util.ArrayDeque)1 JobID (org.apache.flink.api.common.JobID)1 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)1 ResultPartitionWriter (org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter)1 MockInputSplitProvider (org.apache.flink.runtime.operators.testutils.MockInputSplitProvider)1 TestTaskStateManager (org.apache.flink.runtime.state.TestTaskStateManager)1 TestTaskStateManagerBuilder (org.apache.flink.runtime.state.TestTaskStateManagerBuilder)1 StreamElementSerializer (org.apache.flink.streaming.runtime.streamrecord.StreamElementSerializer)1