use of org.apache.kafka.streams.state.StreamsMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldGetInstanceWithKey.
@Test
public void shouldGetInstanceWithKey() throws Exception {
final TopicPartition tp4 = new TopicPartition("topic-three", 1);
hostToPartitions.put(hostTwo, Utils.mkSet(topic2P0, tp4));
discovery.onChange(hostToPartitions, cluster.withPartitions(Collections.singletonMap(tp4, new PartitionInfo("topic-three", 1, null, null, null))));
final StreamsMetadata expected = new StreamsMetadata(hostThree, Utils.mkSet(globalTable, "table-three"), Collections.singleton(topic3P0));
final StreamsMetadata actual = discovery.getMetadataWithKey("table-three", "the-key", Serdes.String().serializer());
assertEquals(expected, actual);
}
use of org.apache.kafka.streams.state.StreamsMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldGetMyMetadataForGlobalStoreWithKey.
@Test
public void shouldGetMyMetadataForGlobalStoreWithKey() throws Exception {
final StreamsMetadata metadata = discovery.getMetadataWithKey(globalTable, "key", Serdes.String().serializer());
assertEquals(hostOne, metadata.hostInfo());
}
use of org.apache.kafka.streams.state.StreamsMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldGetInstanceWithKeyWithMergedStreams.
@Test
public void shouldGetInstanceWithKeyWithMergedStreams() throws Exception {
final TopicPartition topic2P2 = new TopicPartition("topic-two", 2);
hostToPartitions.put(hostTwo, Utils.mkSet(topic2P0, topic1P1, topic2P2));
discovery.onChange(hostToPartitions, cluster.withPartitions(Collections.singletonMap(topic2P2, new PartitionInfo("topic-two", 2, null, null, null))));
final StreamsMetadata expected = new StreamsMetadata(hostTwo, Utils.mkSet("global-table", "table-two", "table-one", "merged-table"), Utils.mkSet(topic2P0, topic1P1, topic2P2));
final StreamsMetadata actual = discovery.getMetadataWithKey("merged-table", "123", new StreamPartitioner<String, Object>() {
@Override
public Integer partition(final String key, final Object value, final int numPartitions) {
return 2;
}
});
assertEquals(expected, actual);
}
use of org.apache.kafka.streams.state.StreamsMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldHaveGlobalStoreInAllMetadata.
@Test
public void shouldHaveGlobalStoreInAllMetadata() throws Exception {
final Collection<StreamsMetadata> metadata = discovery.getAllMetadataForStore(globalTable);
assertEquals(3, metadata.size());
for (StreamsMetadata streamsMetadata : metadata) {
assertTrue(streamsMetadata.stateStoreNames().contains(globalTable));
}
}
Aggregations