public class EvenlyDistributingPartitioner extends Object implements org.apache.kafka.clients.producer.Partitioner
Created by Ken Yu on 2017/3/8.
| Modifier and Type | Field and Description |
|---|---|
private ConcurrentMap<String,AtomicInteger>
|
topicCounterMap
|
| Constructor and Description |
|---|
EvenlyDistributingPartitioner()
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
|
void |
configure(Map<String,?> configs)
|
private int |
nextValue(String topic)
|
int |
partition(String topic,
Object key,
byte[] keyBytes,
Object value,
byte[] valueBytes,
org.apache.kafka.common.Cluster cluster)
Compute the partition for the given record.
|
private final ConcurrentMap<String,AtomicInteger> topicCounterMap
public void configure(Map<String,?> configs)
configure in interface org.apache.kafka.common.Configurable
public int partition(String topic, Object key, byte[] keyBytes, Object value, byte[] valueBytes, org.apache.kafka.common.Cluster cluster)
partition in interface org.apache.kafka.clients.producer.Partitioner
topic - The topic namekey - The key to partition on (or null if no key)keyBytes - serialized key to partition on (or null if no key)value - The value to partition on or nullvalueBytes - serialized value to partition on or nullcluster - The current cluster metadataprivate int nextValue(String topic)
public void close()
close in interface Closeableclose in interface AutoCloseableclose in interface org.apache.kafka.clients.producer.Partitioner