use of org.apache.kafka.common.Cluster in project kafka by apache.
the class StreamPartitionAssignorTest method shouldReturnEmptyClusterMetadataIfItHasntBeenBuilt.
@Test
public void shouldReturnEmptyClusterMetadataIfItHasntBeenBuilt() throws Exception {
final Cluster cluster = partitionAssignor.clusterMetadata();
assertNotNull(cluster);
}
use of org.apache.kafka.common.Cluster in project kafka by apache.
the class StreamsMetadataStateTest method before.
@Before
public void before() {
builder = new KStreamBuilder();
final KStream<Object, Object> one = builder.stream("topic-one");
one.groupByKey().count("table-one");
final KStream<Object, Object> two = builder.stream("topic-two");
two.groupByKey().count("table-two");
builder.stream("topic-three").groupByKey().count("table-three");
builder.merge(one, two).groupByKey().count("merged-table");
builder.stream("topic-four").mapValues(new ValueMapper<Object, Object>() {
@Override
public Object apply(final Object value) {
return value;
}
});
builder.globalTable("global-topic", "global-table");
builder.setApplicationId("appId");
topic1P0 = new TopicPartition("topic-one", 0);
topic1P1 = new TopicPartition("topic-one", 1);
topic2P0 = new TopicPartition("topic-two", 0);
topic2P1 = new TopicPartition("topic-two", 1);
topic3P0 = new TopicPartition("topic-three", 0);
topic4P0 = new TopicPartition("topic-four", 0);
hostOne = new HostInfo("host-one", 8080);
hostTwo = new HostInfo("host-two", 9090);
hostThree = new HostInfo("host-three", 7070);
hostToPartitions = new HashMap<>();
hostToPartitions.put(hostOne, Utils.mkSet(topic1P0, topic2P1, topic4P0));
hostToPartitions.put(hostTwo, Utils.mkSet(topic2P0, topic1P1));
hostToPartitions.put(hostThree, Collections.singleton(topic3P0));
partitionInfos = Arrays.asList(new PartitionInfo("topic-one", 0, null, null, null), new PartitionInfo("topic-one", 1, null, null, null), new PartitionInfo("topic-two", 0, null, null, null), new PartitionInfo("topic-two", 1, null, null, null), new PartitionInfo("topic-three", 0, null, null, null), new PartitionInfo("topic-four", 0, null, null, null));
cluster = new Cluster(null, Collections.<Node>emptyList(), partitionInfos, Collections.<String>emptySet(), Collections.<String>emptySet());
discovery = new StreamsMetadataState(builder, hostOne);
discovery.onChange(hostToPartitions, cluster);
partitioner = new StreamPartitioner<String, Object>() {
@Override
public Integer partition(final String key, final Object value, final int numPartitions) {
return 1;
}
};
}
Aggregations