use of org.apache.kafka.streams.state.StreamsMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldGetAllStreamsInstancesWithNoStores.
@Test
public void shouldGetAllStreamsInstancesWithNoStores() throws Exception {
builder.stream("topic-five").filter(new Predicate<Object, Object>() {
@Override
public boolean test(final Object key, final Object value) {
return true;
}
}).to("some-other-topic");
final TopicPartition tp5 = new TopicPartition("topic-five", 1);
final HostInfo hostFour = new HostInfo("host-four", 8080);
hostToPartitions.put(hostFour, Utils.mkSet(tp5));
discovery.onChange(hostToPartitions, cluster.withPartitions(Collections.singletonMap(tp5, new PartitionInfo("topic-five", 1, null, null, null))));
final StreamsMetadata expected = new StreamsMetadata(hostFour, Collections.singleton(globalTable), Collections.singleton(tp5));
final Collection<StreamsMetadata> actual = discovery.getAllMetadata();
assertTrue("expected " + actual + " to contain " + expected, actual.contains(expected));
}
use of org.apache.kafka.streams.state.StreamsMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldReturnNotAvailableWhenClusterIsEmpty.
@Test
public void shouldReturnNotAvailableWhenClusterIsEmpty() throws Exception {
discovery.onChange(Collections.<HostInfo, Set<TopicPartition>>emptyMap(), Cluster.empty());
final StreamsMetadata result = discovery.getMetadataWithKey("table-one", "a", Serdes.String().serializer());
assertEquals(StreamsMetadata.NOT_AVAILABLE, result);
}
use of org.apache.kafka.streams.state.StreamsMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldGetInstanceWithKeyAndCustomPartitioner.
@Test
public void shouldGetInstanceWithKeyAndCustomPartitioner() 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(hostTwo, Utils.mkSet(globalTable, "table-two", "table-three", "merged-table"), Utils.mkSet(topic2P0, tp4));
StreamsMetadata actual = discovery.getMetadataWithKey("table-three", "the-key", partitioner);
assertEquals(expected, actual);
}
use of org.apache.kafka.streams.state.StreamsMetadata in project kafka by apache.
the class StreamsMetadataStateTest method shouldReturnNullOnGetWithKeyWhenStoreDoesntExist.
@Test
public void shouldReturnNullOnGetWithKeyWhenStoreDoesntExist() throws Exception {
final StreamsMetadata actual = discovery.getMetadataWithKey("not-a-store", "key", Serdes.String().serializer());
assertNull(actual);
}
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);
}
Aggregations