flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chesnay Schepler <ches...@apache.org>
Subject Re: Use a round-robin kafka partitioner
Date Wed, 25 Oct 2017 08:29:20 GMT
So you want to use the kafka partitioner directly?

How about an adapter?

public class KafkaPartitionerWrapper<T> extends KafkaPartitioner<T> implements
Serializable {
    private final kafka.producer.Partitionerpartitioner; public KafkaPartitionerWrapper(kafka.producer.Partitioner
partitioner) {
       this.partitioner = partitioner; }

    @Override public int partition(T record, byte[] key, byte[] value, String targetTopic,
int[] partitions) {
       // maybe pass Arrays.hashCode(key) instead
       return partitioner.partition(key, partitions.length); }
}

On 25.10.2017 09:58, kla wrote:
> Exactly, I did like this, the only thing is that I am using 1.2.0 version of
> Flink and in this version the class name is KafkaPartitioner.
>
> But the problem is that I would not like to "fork" the Kafka's source code.
> (Please check my first comment)
>
> Thanks,
> Konstantin
>
>
>
> --
> Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
>


Mime
View raw message