Search in sources :

Example 1 with PartitionKeyGenerator

use of org.apache.flink.connector.kinesis.sink.PartitionKeyGenerator 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)

Aggregations

PartitionKeyGenerator (org.apache.flink.connector.kinesis.sink.PartitionKeyGenerator)1 ValidationException (org.apache.flink.table.api.ValidationException)1 FlinkException (org.apache.flink.util.FlinkException)1