Search in sources :

Example 1 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class KinesisPartitionKeyGeneratorFactory method initializePartitioner.

/**
 * Returns a class value with the given class name.
 */
private static <T> PartitionKeyGenerator<T> initializePartitioner(String name, ClassLoader classLoader) {
    try {
        Class<?> clazz = Class.forName(name, true, classLoader);
        if (!PartitionKeyGenerator.class.isAssignableFrom(clazz)) {
            throw new ValidationException(String.format("Partitioner class '%s' should have %s in its parents chain", name, PartitionKeyGenerator.class.getName()));
        }
        @SuppressWarnings("unchecked") final PartitionKeyGenerator<T> partitioner = InstantiationUtil.instantiate(name, PartitionKeyGenerator.class, classLoader);
        return partitioner;
    } catch (ClassNotFoundException | FlinkException e) {
        throw new ValidationException(String.format("Could not find and instantiate partitioner class '%s'", name), e);
    }
}
Also used : PartitionKeyGenerator(org.apache.flink.connector.kinesis.sink.PartitionKeyGenerator) ValidationException(org.apache.flink.table.api.ValidationException) FlinkException(org.apache.flink.util.FlinkException)

Example 2 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class FlinkKafkaConsumerBaseTest method testClosePartitionDiscovererWhenOpenThrowException.

@Test
public void testClosePartitionDiscovererWhenOpenThrowException() throws Exception {
    final RuntimeException failureCause = new RuntimeException(new FlinkException("Test partition discoverer exception"));
    final FailingPartitionDiscoverer failingPartitionDiscoverer = new FailingPartitionDiscoverer(failureCause);
    final DummyFlinkKafkaConsumer<String> consumer = new DummyFlinkKafkaConsumer<>(failingPartitionDiscoverer);
    testFailingConsumerLifecycle(consumer, failureCause);
    assertTrue("partitionDiscoverer should be closed when consumer is closed", failingPartitionDiscoverer.isClosed());
}
Also used : FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 3 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class FlinkKafkaConsumerBaseTest method testClosePartitionDiscovererWhenCreateKafkaFetcherFails.

@Test
public void testClosePartitionDiscovererWhenCreateKafkaFetcherFails() throws Exception {
    final FlinkException failureCause = new FlinkException("Create Kafka fetcher failure.");
    final DummyPartitionDiscoverer testPartitionDiscoverer = new DummyPartitionDiscoverer();
    final DummyFlinkKafkaConsumer<String> consumer = new DummyFlinkKafkaConsumer<>(() -> {
        throw failureCause;
    }, testPartitionDiscoverer, 100L);
    testFailingConsumerLifecycle(consumer, failureCause);
    assertTrue("partitionDiscoverer should be closed when consumer is closed", testPartitionDiscoverer.isClosed());
}
Also used : FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 4 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class DefaultJobGraphStore method stop.

@Override
public void stop() throws Exception {
    synchronized (lock) {
        if (running) {
            running = false;
            LOG.info("Stopping DefaultJobGraphStore.");
            Exception exception = null;
            try {
                jobGraphStateHandleStore.releaseAll();
            } catch (Exception e) {
                exception = e;
            }
            try {
                jobGraphStoreWatcher.stop();
            } catch (Exception e) {
                exception = ExceptionUtils.firstOrSuppressed(e, exception);
            }
            if (exception != null) {
                throw new FlinkException("Could not properly stop the DefaultJobGraphStore.", exception);
            }
        }
    }
}
Also used : FlinkException(org.apache.flink.util.FlinkException) IOException(java.io.IOException) CompletionException(java.util.concurrent.CompletionException) FlinkException(org.apache.flink.util.FlinkException)

Example 5 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class ResourceManager method registerTaskExecutor.

@Override
public CompletableFuture<RegistrationResponse> registerTaskExecutor(final TaskExecutorRegistration taskExecutorRegistration, final Time timeout) {
    CompletableFuture<TaskExecutorGateway> taskExecutorGatewayFuture = getRpcService().connect(taskExecutorRegistration.getTaskExecutorAddress(), TaskExecutorGateway.class);
    taskExecutorGatewayFutures.put(taskExecutorRegistration.getResourceId(), taskExecutorGatewayFuture);
    return taskExecutorGatewayFuture.handleAsync((TaskExecutorGateway taskExecutorGateway, Throwable throwable) -> {
        final ResourceID resourceId = taskExecutorRegistration.getResourceId();
        if (taskExecutorGatewayFuture == taskExecutorGatewayFutures.get(resourceId)) {
            taskExecutorGatewayFutures.remove(resourceId);
            if (throwable != null) {
                return new RegistrationResponse.Failure(throwable);
            } else {
                return registerTaskExecutorInternal(taskExecutorGateway, taskExecutorRegistration);
            }
        } else {
            log.debug("Ignoring outdated TaskExecutorGateway connection for {}.", resourceId.getStringWithMetadata());
            return new RegistrationResponse.Failure(new FlinkException("Decline outdated task executor registration."));
        }
    }, getMainThreadExecutor());
}
Also used : ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TaskExecutorGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorGateway) FlinkException(org.apache.flink.util.FlinkException)

Aggregations

FlinkException (org.apache.flink.util.FlinkException)197 Test (org.junit.Test)91 CompletableFuture (java.util.concurrent.CompletableFuture)59 IOException (java.io.IOException)38 ExecutionException (java.util.concurrent.ExecutionException)26 ArrayList (java.util.ArrayList)25 JobID (org.apache.flink.api.common.JobID)24 Collection (java.util.Collection)22 CompletionException (java.util.concurrent.CompletionException)22 Configuration (org.apache.flink.configuration.Configuration)21 TimeoutException (java.util.concurrent.TimeoutException)19 FutureUtils (org.apache.flink.util.concurrent.FutureUtils)19 Time (org.apache.flink.api.common.time.Time)16 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)16 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)16 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)15 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)14 Collections (java.util.Collections)13 List (java.util.List)13 ExecutorService (java.util.concurrent.ExecutorService)13