use of org.apache.flink.runtime.operators.coordination.OperatorCoordinator in project flink by apache.
the class DefaultOperatorCoordinatorHandler method deliverCoordinationRequestToCoordinator.
@Override
public CompletableFuture<CoordinationResponse> deliverCoordinationRequestToCoordinator(OperatorID operator, CoordinationRequest request) throws FlinkException {
final OperatorCoordinatorHolder coordinatorHolder = coordinatorMap.get(operator);
if (coordinatorHolder == null) {
throw new FlinkException("Coordinator of operator " + operator + " does not exist or the job vertex this operator belongs to is not initialized.");
}
final OperatorCoordinator coordinator = coordinatorHolder.coordinator();
if (coordinator instanceof CoordinationRequestHandler) {
return ((CoordinationRequestHandler) coordinator).handleCoordinationRequest(request);
} else {
throw new FlinkException("Coordinator of operator " + operator + " cannot handle client event");
}
}
use of org.apache.flink.runtime.operators.coordination.OperatorCoordinator in project flink by apache.
the class SourceCoordinatorTest method testUserClassLoaderWhenCreatingNewEnumerator.
@Test
public void testUserClassLoaderWhenCreatingNewEnumerator() throws Exception {
final ClassLoader testClassLoader = new URLClassLoader(new URL[0]);
final OperatorCoordinator.Context context = new MockOperatorCoordinatorContext(new OperatorID(), testClassLoader);
final EnumeratorCreatingSource<?, ClassLoaderTestEnumerator> source = new EnumeratorCreatingSource<>(ClassLoaderTestEnumerator::new);
final SourceCoordinatorProvider<?> provider = new SourceCoordinatorProvider<>("testOperator", context.getOperatorId(), source, 1, WatermarkAlignmentParams.WATERMARK_ALIGNMENT_DISABLED);
final OperatorCoordinator coordinator = provider.getCoordinator(context);
coordinator.start();
final ClassLoaderTestEnumerator enumerator = source.createEnumeratorFuture.get();
assertSame(testClassLoader, enumerator.constructorClassLoader);
assertSame(testClassLoader, enumerator.threadClassLoader.get());
// cleanup
coordinator.close();
}
use of org.apache.flink.runtime.operators.coordination.OperatorCoordinator in project flink by apache.
the class SourceCoordinatorTest method testUserClassLoaderWhenRestoringEnumerator.
@Test
public void testUserClassLoaderWhenRestoringEnumerator() throws Exception {
final ClassLoader testClassLoader = new URLClassLoader(new URL[0]);
final OperatorCoordinator.Context context = new MockOperatorCoordinatorContext(new OperatorID(), testClassLoader);
final EnumeratorCreatingSource<?, ClassLoaderTestEnumerator> source = new EnumeratorCreatingSource<>(ClassLoaderTestEnumerator::new);
final SourceCoordinatorProvider<?> provider = new SourceCoordinatorProvider<>("testOperator", context.getOperatorId(), source, 1, WatermarkAlignmentParams.WATERMARK_ALIGNMENT_DISABLED);
final OperatorCoordinator coordinator = provider.getCoordinator(context);
coordinator.resetToCheckpoint(1L, createEmptyCheckpoint());
coordinator.start();
final ClassLoaderTestEnumerator enumerator = source.restoreEnumeratorFuture.get();
assertSame(testClassLoader, enumerator.constructorClassLoader);
assertSame(testClassLoader, enumerator.threadClassLoader.get());
// cleanup
coordinator.close();
}
use of org.apache.flink.runtime.operators.coordination.OperatorCoordinator in project flink by apache.
the class SourceCoordinatorProviderTest method testCreate.
@Test
public void testCreate() throws Exception {
OperatorCoordinator coordinator = provider.create(new MockOperatorCoordinatorContext(OPERATOR_ID, NUM_SPLITS));
assertTrue(coordinator instanceof RecreateOnResetOperatorCoordinator);
}
Aggregations