use of org.apache.kafka.streams.KeyQueryMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldGetInstanceWithKey.
@Test
public void shouldGetInstanceWithKey() {
final TopicPartition tp4 = new TopicPartition("topic-three", 1);
hostToActivePartitions.put(hostTwo, mkSet(topic2P0, tp4));
metadataState.onChange(hostToActivePartitions, hostToStandbyPartitions, cluster.withPartitions(Collections.singletonMap(tp4, new PartitionInfo("topic-three", 1, null, null, null))));
final KeyQueryMetadata expected = new KeyQueryMetadata(hostThree, mkSet(hostTwo), 0);
final KeyQueryMetadata actual = metadataState.getKeyQueryMetadataForKey("table-three", "the-key", Serdes.String().serializer());
assertEquals(expected, actual);
}
use of org.apache.kafka.streams.KeyQueryMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldGetInstanceWithKeyWithMergedStreams.
@Test
public void shouldGetInstanceWithKeyWithMergedStreams() {
final TopicPartition topic2P2 = new TopicPartition("topic-two", 2);
hostToActivePartitions.put(hostTwo, mkSet(topic2P0, topic1P1, topic2P2));
hostToStandbyPartitions.put(hostOne, mkSet(topic2P0, topic1P1, topic2P2));
metadataState.onChange(hostToActivePartitions, hostToStandbyPartitions, cluster.withPartitions(Collections.singletonMap(topic2P2, new PartitionInfo("topic-two", 2, null, null, null))));
final KeyQueryMetadata expected = new KeyQueryMetadata(hostTwo, mkSet(hostOne), 2);
final KeyQueryMetadata actual = metadataState.getKeyQueryMetadataForKey("merged-table", "the-key", (topic, key, value, numPartitions) -> 2);
assertEquals(expected, actual);
}
Aggregations