Java Code Examples for org.apache.flink.streaming.runtime.tasks.OneInputStreamTaskTestHarness#setTaskStateSnapshot()
The following examples show how to use
org.apache.flink.streaming.runtime.tasks.OneInputStreamTaskTestHarness#setTaskStateSnapshot() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatefulOperatorChainedTaskTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private JobManagerTaskRestore createRunAndCheckpointOperatorChain( OperatorID headId, OneInputStreamOperator<String, String> headOperator, OperatorID tailId, OneInputStreamOperator<String, String> tailOperator, Optional<JobManagerTaskRestore> restore) throws Exception { File localRootDir = temporaryFolder.newFolder(); final OneInputStreamTaskTestHarness<String, String> testHarness = new OneInputStreamTaskTestHarness<>( OneInputStreamTask::new, 1, 1, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO, localRootDir); testHarness.setupOperatorChain(headId, headOperator) .chain(tailId, tailOperator, StringSerializer.INSTANCE, true) .finish(); if (restore.isPresent()) { JobManagerTaskRestore taskRestore = restore.get(); testHarness.setTaskStateSnapshot( taskRestore.getRestoreCheckpointId(), taskRestore.getTaskStateSnapshot()); } StreamMockEnvironment environment = new StreamMockEnvironment( testHarness.jobConfig, testHarness.taskConfig, testHarness.getExecutionConfig(), testHarness.memorySize, new MockInputSplitProvider(), testHarness.bufferSize, testHarness.getTaskStateManager()); Configuration configuration = new Configuration(); configuration.setString(STATE_BACKEND.key(), "rocksdb"); File file = temporaryFolder.newFolder(); configuration.setString(CHECKPOINTS_DIRECTORY.key(), file.toURI().toString()); configuration.setString(INCREMENTAL_CHECKPOINTS.key(), "true"); environment.setTaskManagerInfo( new TestingTaskManagerRuntimeInfo( configuration, System.getProperty("java.io.tmpdir").split(",|" + File.pathSeparator))); testHarness.invoke(environment); testHarness.waitForTaskRunning(); OneInputStreamTask<String, String> streamTask = testHarness.getTask(); processRecords(testHarness); triggerCheckpoint(testHarness, streamTask); TestTaskStateManager taskStateManager = testHarness.getTaskStateManager(); JobManagerTaskRestore jobManagerTaskRestore = new JobManagerTaskRestore( taskStateManager.getReportedCheckpointId(), taskStateManager.getLastJobManagerTaskStateSnapshot()); testHarness.endInput(); testHarness.waitForTaskCompletion(); return jobManagerTaskRestore; }
Example 2
Source File: StatefulOperatorChainedTaskTest.java From flink with Apache License 2.0 | 4 votes |
private JobManagerTaskRestore createRunAndCheckpointOperatorChain( OperatorID headId, OneInputStreamOperator<String, String> headOperator, OperatorID tailId, OneInputStreamOperator<String, String> tailOperator, Optional<JobManagerTaskRestore> restore) throws Exception { File localRootDir = temporaryFolder.newFolder(); final OneInputStreamTaskTestHarness<String, String> testHarness = new OneInputStreamTaskTestHarness<>( OneInputStreamTask::new, 1, 1, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO, localRootDir); testHarness.setupOperatorChain(headId, headOperator) .chain(tailId, tailOperator, StringSerializer.INSTANCE, true) .finish(); if (restore.isPresent()) { JobManagerTaskRestore taskRestore = restore.get(); testHarness.setTaskStateSnapshot( taskRestore.getRestoreCheckpointId(), taskRestore.getTaskStateSnapshot()); } StreamMockEnvironment environment = new StreamMockEnvironment( testHarness.jobConfig, testHarness.taskConfig, testHarness.getExecutionConfig(), testHarness.memorySize, new MockInputSplitProvider(), testHarness.bufferSize, testHarness.getTaskStateManager()); Configuration configuration = new Configuration(); configuration.setString(STATE_BACKEND.key(), "rocksdb"); File file = temporaryFolder.newFolder(); configuration.setString(CHECKPOINTS_DIRECTORY.key(), file.toURI().toString()); configuration.setString(INCREMENTAL_CHECKPOINTS.key(), "true"); environment.setTaskManagerInfo( new TestingTaskManagerRuntimeInfo( configuration, System.getProperty("java.io.tmpdir").split(",|" + File.pathSeparator))); testHarness.invoke(environment); testHarness.waitForTaskRunning(); OneInputStreamTask<String, String> streamTask = testHarness.getTask(); processRecords(testHarness); triggerCheckpoint(testHarness, streamTask); TestTaskStateManager taskStateManager = testHarness.getTaskStateManager(); JobManagerTaskRestore jobManagerTaskRestore = new JobManagerTaskRestore( taskStateManager.getReportedCheckpointId(), taskStateManager.getLastJobManagerTaskStateSnapshot()); testHarness.endInput(); testHarness.waitForTaskCompletion(); return jobManagerTaskRestore; }
Example 3
Source File: StatefulOperatorChainedTaskTest.java From flink with Apache License 2.0 | 4 votes |
private JobManagerTaskRestore createRunAndCheckpointOperatorChain( OperatorID headId, OneInputStreamOperator<String, String> headOperator, OperatorID tailId, OneInputStreamOperator<String, String> tailOperator, Optional<JobManagerTaskRestore> restore) throws Exception { File localRootDir = temporaryFolder.newFolder(); final OneInputStreamTaskTestHarness<String, String> testHarness = new OneInputStreamTaskTestHarness<>( OneInputStreamTask::new, 1, 1, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO, localRootDir); testHarness.setupOperatorChain(headId, headOperator) .chain(tailId, tailOperator, StringSerializer.INSTANCE, true) .finish(); if (restore.isPresent()) { JobManagerTaskRestore taskRestore = restore.get(); testHarness.setTaskStateSnapshot( taskRestore.getRestoreCheckpointId(), taskRestore.getTaskStateSnapshot()); } StreamMockEnvironment environment = new StreamMockEnvironment( testHarness.jobConfig, testHarness.taskConfig, testHarness.getExecutionConfig(), testHarness.memorySize, new MockInputSplitProvider(), testHarness.bufferSize, testHarness.getTaskStateManager()); Configuration configuration = new Configuration(); configuration.setString(STATE_BACKEND.key(), "rocksdb"); File file = temporaryFolder.newFolder(); configuration.setString(CHECKPOINTS_DIRECTORY.key(), file.toURI().toString()); configuration.setString(INCREMENTAL_CHECKPOINTS.key(), "true"); environment.setTaskManagerInfo( new TestingTaskManagerRuntimeInfo( configuration, System.getProperty("java.io.tmpdir").split(",|" + File.pathSeparator))); testHarness.invoke(environment); testHarness.waitForTaskRunning(); OneInputStreamTask<String, String> streamTask = testHarness.getTask(); processRecords(testHarness); triggerCheckpoint(testHarness, streamTask); TestTaskStateManager taskStateManager = testHarness.getTaskStateManager(); JobManagerTaskRestore jobManagerTaskRestore = new JobManagerTaskRestore( taskStateManager.getReportedCheckpointId(), taskStateManager.getLastJobManagerTaskStateSnapshot()); testHarness.endInput(); testHarness.waitForTaskCompletion(); return jobManagerTaskRestore; }