Search in sources :

Example 16 with StreamsMetadata

use of org.apache.kafka.streams.state.StreamsMetadata in project apache-kafka-on-k8s by banzaicloud.

the class StreamsMetadataStateTest method shouldGetInstanceWithKey.

@Test
public void shouldGetInstanceWithKey() {
    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);
}
Also used : TopicPartition(org.apache.kafka.common.TopicPartition) StreamsMetadata(org.apache.kafka.streams.state.StreamsMetadata) PartitionInfo(org.apache.kafka.common.PartitionInfo) StreamsBuilderTest(org.apache.kafka.streams.StreamsBuilderTest) Test(org.junit.Test)

Example 17 with StreamsMetadata

use of org.apache.kafka.streams.state.StreamsMetadata in project apache-kafka-on-k8s by banzaicloud.

the class StreamsMetadataStateTest method shouldGetInstanceWithKeyWithMergedStreams.

@Test
public void shouldGetInstanceWithKeyWithMergedStreams() {
    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);
}
Also used : TopicPartition(org.apache.kafka.common.TopicPartition) StreamsMetadata(org.apache.kafka.streams.state.StreamsMetadata) PartitionInfo(org.apache.kafka.common.PartitionInfo) StreamsBuilderTest(org.apache.kafka.streams.StreamsBuilderTest) Test(org.junit.Test)

Example 18 with StreamsMetadata

use of org.apache.kafka.streams.state.StreamsMetadata in project apache-kafka-on-k8s by banzaicloud.

the class StreamsMetadataStateTest method shouldHaveGlobalStoreInAllMetadata.

@Test
public void shouldHaveGlobalStoreInAllMetadata() {
    final Collection<StreamsMetadata> metadata = discovery.getAllMetadataForStore(globalTable);
    assertEquals(3, metadata.size());
    for (StreamsMetadata streamsMetadata : metadata) {
        assertTrue(streamsMetadata.stateStoreNames().contains(globalTable));
    }
}
Also used : StreamsMetadata(org.apache.kafka.streams.state.StreamsMetadata) StreamsBuilderTest(org.apache.kafka.streams.StreamsBuilderTest) Test(org.junit.Test)

Aggregations

StreamsMetadata (org.apache.kafka.streams.state.StreamsMetadata)18 Test (org.junit.Test)14 StreamsBuilderTest (org.apache.kafka.streams.StreamsBuilderTest)11 TopicPartition (org.apache.kafka.common.TopicPartition)8 PartitionInfo (org.apache.kafka.common.PartitionInfo)4 HashSet (java.util.HashSet)3 HostInfo (org.apache.kafka.streams.state.HostInfo)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 PlayEvent (io.confluent.examples.streams.avro.PlayEvent)1 Song (io.confluent.examples.streams.avro.Song)1 WordCountInteractiveQueriesExampleTest.randomFreeLocalPort (io.confluent.examples.streams.interactivequeries.WordCountInteractiveQueriesExampleTest.randomFreeLocalPort)1 EmbeddedSingleNodeKafkaCluster (io.confluent.examples.streams.kafka.EmbeddedSingleNodeKafkaCluster)1 AbstractKafkaAvroSerDeConfig (io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig)1 SpecificAvroSerializer (io.confluent.kafka.streams.serdes.avro.SpecificAvroSerializer)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Properties (java.util.Properties)1 Set (java.util.Set)1