org.apache.flink.runtime.state.TestTaskLocalStateStore Java Examples

The following examples show how to use org.apache.flink.runtime.state.TestTaskLocalStateStore. 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: StreamTaskStateInitializerImplTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private StreamTaskStateInitializer streamTaskStateManager(
	StateBackend stateBackend,
	JobManagerTaskRestore jobManagerTaskRestore,
	boolean createTimerServiceManager) {

	JobID jobID = new JobID(42L, 43L);
	ExecutionAttemptID executionAttemptID = new ExecutionAttemptID(23L, 24L);
	TestCheckpointResponder checkpointResponderMock = new TestCheckpointResponder();

	TaskLocalStateStore taskLocalStateStore = new TestTaskLocalStateStore();

	TaskStateManager taskStateManager = TaskStateManagerImplTest.taskStateManager(
		jobID,
		executionAttemptID,
		checkpointResponderMock,
		jobManagerTaskRestore,
		taskLocalStateStore);

	DummyEnvironment dummyEnvironment = new DummyEnvironment("test-task", 1, 0);
	dummyEnvironment.setTaskStateManager(taskStateManager);

	if (createTimerServiceManager) {
		return new StreamTaskStateInitializerImpl(
			dummyEnvironment,
			stateBackend);
	} else {
		return new StreamTaskStateInitializerImpl(
			dummyEnvironment,
			stateBackend) {
			@Override
			protected <K> InternalTimeServiceManager<K> internalTimeServiceManager(
				AbstractKeyedStateBackend<K> keyedStatedBackend,
				KeyContext keyContext,
				ProcessingTimeService processingTimeService,
				Iterable<KeyGroupStatePartitionStreamProvider> rawKeyedStates) throws Exception {
				return null;
			}
		};
	}
}
 
Example #2
Source File: StreamTaskStateInitializerImplTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private StreamTaskStateInitializer streamTaskStateManager(
	StateBackend stateBackend,
	JobManagerTaskRestore jobManagerTaskRestore,
	boolean createTimerServiceManager) {

	JobID jobID = new JobID(42L, 43L);
	ExecutionAttemptID executionAttemptID = new ExecutionAttemptID(23L, 24L);
	TestCheckpointResponder checkpointResponderMock = new TestCheckpointResponder();

	TaskLocalStateStore taskLocalStateStore = new TestTaskLocalStateStore();

	TaskStateManager taskStateManager = TaskStateManagerImplTest.taskStateManager(
		jobID,
		executionAttemptID,
		checkpointResponderMock,
		jobManagerTaskRestore,
		taskLocalStateStore);

	DummyEnvironment dummyEnvironment = new DummyEnvironment("test-task", 1, 0);
	dummyEnvironment.setTaskStateManager(taskStateManager);

	ProcessingTimeService processingTimeService = new TestProcessingTimeService();

	if (createTimerServiceManager) {
		return new StreamTaskStateInitializerImpl(
			dummyEnvironment,
			stateBackend,
			processingTimeService);
	} else {
		return new StreamTaskStateInitializerImpl(
			dummyEnvironment,
			stateBackend,
			processingTimeService) {
			@Override
			protected <K> InternalTimeServiceManager<K> internalTimeServiceManager(
				AbstractKeyedStateBackend<K> keyedStatedBackend,
				KeyContext keyContext,
				Iterable<KeyGroupStatePartitionStreamProvider> rawKeyedStates) throws Exception {
				return null;
			}
		};
	}
}
 
Example #3
Source File: StreamTaskStateInitializerImplTest.java    From flink with Apache License 2.0 4 votes vote down vote up
private StreamTaskStateInitializer streamTaskStateManager(
	StateBackend stateBackend,
	JobManagerTaskRestore jobManagerTaskRestore,
	boolean createTimerServiceManager) {

	JobID jobID = new JobID(42L, 43L);
	ExecutionAttemptID executionAttemptID = new ExecutionAttemptID(23L, 24L);
	TestCheckpointResponder checkpointResponderMock = new TestCheckpointResponder();

	TaskLocalStateStore taskLocalStateStore = new TestTaskLocalStateStore();

	TaskStateManager taskStateManager = TaskStateManagerImplTest.taskStateManager(
		jobID,
		executionAttemptID,
		checkpointResponderMock,
		jobManagerTaskRestore,
		taskLocalStateStore);

	DummyEnvironment dummyEnvironment = new DummyEnvironment("test-task", 1, 0);
	dummyEnvironment.setTaskStateManager(taskStateManager);

	ProcessingTimeService processingTimeService = new TestProcessingTimeService();

	if (createTimerServiceManager) {
		return new StreamTaskStateInitializerImpl(
			dummyEnvironment,
			stateBackend,
			processingTimeService);
	} else {
		return new StreamTaskStateInitializerImpl(
			dummyEnvironment,
			stateBackend,
			processingTimeService) {
			@Override
			protected <K> InternalTimeServiceManager<K> internalTimeServiceManager(
				AbstractKeyedStateBackend<K> keyedStatedBackend,
				KeyContext keyContext,
				Iterable<KeyGroupStatePartitionStreamProvider> rawKeyedStates) throws Exception {
				return null;
			}
		};
	}
}
 
Example #4
Source File: StreamTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testBeforeInvokeWithChannelStates() throws Exception {
	int numWriters = 2;
	int numGates = 2;
	RecoveryResultPartition[] partitions = new RecoveryResultPartition[numWriters];
	for (int i = 0; i < numWriters; i++) {
		partitions[i] = new RecoveryResultPartition();
	}
	RecoveryInputGate[] gates = new RecoveryInputGate[numGates];
	for (int i = 0; i < numGates; i++) {
		gates[i] = new RecoveryInputGate(partitions);
	}

	ChannelStateReader reader = new ResultPartitionTest.FiniteChannelStateReader(1, new int[] {0});
	TaskStateManager taskStateManager = new TaskStateManagerImpl(
		new JobID(),
		new ExecutionAttemptID(),
		new TestTaskLocalStateStore(),
		null,
		NoOpCheckpointResponder.INSTANCE,
		reader);
	MockEnvironment mockEnvironment = new MockEnvironmentBuilder().setTaskStateManager(taskStateManager).build();
	mockEnvironment.addOutputs(asList(partitions));
	mockEnvironment.addInputs(asList(gates));
	StreamTask task = new MockStreamTaskBuilder(mockEnvironment).build();
	try {
		verifyResults(gates, partitions, false, false);

		task.beforeInvoke();

		verifyResults(gates, partitions, true, false);

		// execute the partition request mail inserted after input recovery completes
		task.mailboxProcessor.drain();

		for (RecoveryInputGate inputGate : gates) {
			assertTrue(inputGate.isPartitionRequested());
		}
	} finally {
		task.cleanUpInvoke();
	}
}