Search in sources :

Example 1 with OperatorCoordinator

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");
    }
}
Also used : CoordinationRequestHandler(org.apache.flink.runtime.operators.coordination.CoordinationRequestHandler) OperatorCoordinatorHolder(org.apache.flink.runtime.operators.coordination.OperatorCoordinatorHolder) OperatorCoordinator(org.apache.flink.runtime.operators.coordination.OperatorCoordinator) FlinkException(org.apache.flink.util.FlinkException)

Example 2 with OperatorCoordinator

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();
}
Also used : MockOperatorCoordinatorContext(org.apache.flink.runtime.operators.coordination.MockOperatorCoordinatorContext) URLClassLoader(java.net.URLClassLoader) OperatorCoordinator(org.apache.flink.runtime.operators.coordination.OperatorCoordinator) URLClassLoader(java.net.URLClassLoader) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) Test(org.junit.Test)

Example 3 with OperatorCoordinator

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();
}
Also used : MockOperatorCoordinatorContext(org.apache.flink.runtime.operators.coordination.MockOperatorCoordinatorContext) URLClassLoader(java.net.URLClassLoader) OperatorCoordinator(org.apache.flink.runtime.operators.coordination.OperatorCoordinator) URLClassLoader(java.net.URLClassLoader) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) Test(org.junit.Test)

Example 4 with OperatorCoordinator

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);
}
Also used : MockOperatorCoordinatorContext(org.apache.flink.runtime.operators.coordination.MockOperatorCoordinatorContext) RecreateOnResetOperatorCoordinator(org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator) OperatorCoordinator(org.apache.flink.runtime.operators.coordination.OperatorCoordinator) RecreateOnResetOperatorCoordinator(org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator) Test(org.junit.Test)

Aggregations

OperatorCoordinator (org.apache.flink.runtime.operators.coordination.OperatorCoordinator)4 MockOperatorCoordinatorContext (org.apache.flink.runtime.operators.coordination.MockOperatorCoordinatorContext)3 Test (org.junit.Test)3 URLClassLoader (java.net.URLClassLoader)2 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)2 CoordinationRequestHandler (org.apache.flink.runtime.operators.coordination.CoordinationRequestHandler)1 OperatorCoordinatorHolder (org.apache.flink.runtime.operators.coordination.OperatorCoordinatorHolder)1 RecreateOnResetOperatorCoordinator (org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator)1 FlinkException (org.apache.flink.util.FlinkException)1