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);
}
}
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());
}
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());
}
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);
}
}
}
}
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());
}
Aggregations