ProducerThreadPartitioner implements IDataPartitioner<T> { @Override public int partition(int total, T data) { return (int) Thread.currentThread().getId() % total; } ProducerThreadPartitioner(); @Override int partition(int total, T data); @Override int maxRetryCount();  }
@Test public void testPartition() { int partitionNum = (int) Thread.currentThread().getId() % 10; ProducerThreadPartitioner<SampleData> partitioner = new ProducerThreadPartitioner<SampleData>(); Assert.assertEquals(partitioner.partition(10, new SampleData()), partitionNum); Assert.assertEquals(partitioner.partition(10, new SampleData()), partitionNum); Assert.assertEquals(partitioner.partition(10, new SampleData()), partitionNum); }