美文网首页
KAFKA 分区

KAFKA 分区

作者: felix_feng | 来源:发表于2016-08-17 09:51 被阅读46次

    import kafka.producer.Partitioner;

    import kafka.utils.VerifiableProperties;

    public class MyPartitioner implements Partitioner {

    public MyPartitioner(VerifiableProperties props) {}

    public int partition(Object key, int partitionCount) {

               return Integer.valueOf((String) key) % partitionCount;

    }

    }

    Properties props =newProperties();

    props.put("partitioner.class","com.kafka.MyPartitioner");

    相关文章

      网友评论

          本文标题:KAFKA 分区

          本文链接:https://www.haomeiwen.com/subject/cirmsttx.html