Search in sources :

Example 1 with Duration.ofSeconds

use of java.time.Duration.ofSeconds in project kafka by apache.

the class InternalTopicIntegrationTest method shouldGetToRunningWithWindowedTableInFKJ.

/*
     * This test just ensures that that the assignor does not get stuck during partition number resolution
     * for internal repartition topics. See KAFKA-10689
     */
@Test
public void shouldGetToRunningWithWindowedTableInFKJ() throws Exception {
    final String appID = APP_ID + "-windowed-FKJ";
    streamsProp.put(StreamsConfig.APPLICATION_ID_CONFIG, appID);
    final StreamsBuilder streamsBuilder = new StreamsBuilder();
    final KStream<String, String> inputTopic = streamsBuilder.stream(DEFAULT_INPUT_TOPIC);
    final KTable<String, String> inputTable = streamsBuilder.table(DEFAULT_INPUT_TABLE_TOPIC);
    inputTopic.groupBy((k, v) -> k, Grouped.with("GroupName", Serdes.String(), Serdes.String())).windowedBy(TimeWindows.of(Duration.ofMinutes(10))).aggregate(() -> "", (k, v, a) -> a + k).leftJoin(inputTable, v -> v, (x, y) -> x + y);
    final KafkaStreams streams = new KafkaStreams(streamsBuilder.build(), streamsProp);
    startApplicationAndWaitUntilRunning(singletonList(streams), Duration.ofSeconds(60));
}
Also used : StreamsBuilder(org.apache.kafka.streams.StreamsBuilder) Arrays(java.util.Arrays) ConfigEntry(org.apache.kafka.clients.admin.ConfigEntry) Collections.singletonList(java.util.Collections.singletonList) MockTime(kafka.utils.MockTime) Locale(java.util.Locale) Duration(java.time.Duration) ProcessorStateManager(org.apache.kafka.streams.processor.internals.ProcessorStateManager) After(org.junit.After) Serdes(org.apache.kafka.common.serialization.Serdes) StringSerializer(org.apache.kafka.common.serialization.StringSerializer) MockMapper(org.apache.kafka.test.MockMapper) AfterClass(org.junit.AfterClass) IntegrationTestUtils.waitForCompletion(org.apache.kafka.streams.integration.utils.IntegrationTestUtils.waitForCompletion) TestUtils(org.apache.kafka.test.TestUtils) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) Category(org.junit.experimental.categories.Category) Bytes(org.apache.kafka.common.utils.Bytes) IntegrationTestUtils(org.apache.kafka.streams.integration.utils.IntegrationTestUtils) List(java.util.List) Materialized(org.apache.kafka.streams.kstream.Materialized) Duration.ofMillis(java.time.Duration.ofMillis) Config(org.apache.kafka.clients.admin.Config) StreamsConfig(org.apache.kafka.streams.StreamsConfig) IntegrationTestUtils.startApplicationAndWaitUntilRunning(org.apache.kafka.streams.integration.utils.IntegrationTestUtils.startApplicationAndWaitUntilRunning) BeforeClass(org.junit.BeforeClass) IntegrationTest(org.apache.kafka.test.IntegrationTest) LogConfig(kafka.log.LogConfig) KStream(org.apache.kafka.streams.kstream.KStream) Duration.ofSeconds(java.time.Duration.ofSeconds) WindowStore(org.apache.kafka.streams.state.WindowStore) ConfigResource(org.apache.kafka.common.config.ConfigResource) EmbeddedKafkaCluster(org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster) Admin(org.apache.kafka.clients.admin.Admin) ProducerConfig(org.apache.kafka.clients.producer.ProducerConfig) Before(org.junit.Before) StreamsBuilder(org.apache.kafka.streams.StreamsBuilder) KTable(org.apache.kafka.streams.kstream.KTable) Properties(java.util.Properties) AdminClientConfig(org.apache.kafka.clients.admin.AdminClientConfig) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) Grouped(org.apache.kafka.streams.kstream.Grouped) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) TimeWindows(org.apache.kafka.streams.kstream.TimeWindows) KafkaStreams(org.apache.kafka.streams.KafkaStreams) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) KafkaStreams(org.apache.kafka.streams.KafkaStreams) IntegrationTest(org.apache.kafka.test.IntegrationTest) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 Duration (java.time.Duration)1 Duration.ofMillis (java.time.Duration.ofMillis)1 Duration.ofSeconds (java.time.Duration.ofSeconds)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Locale (java.util.Locale)1 Properties (java.util.Properties)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 LogConfig (kafka.log.LogConfig)1 MockTime (kafka.utils.MockTime)1 Admin (org.apache.kafka.clients.admin.Admin)1 AdminClientConfig (org.apache.kafka.clients.admin.AdminClientConfig)1 Config (org.apache.kafka.clients.admin.Config)1 ConfigEntry (org.apache.kafka.clients.admin.ConfigEntry)1 ConsumerConfig (org.apache.kafka.clients.consumer.ConsumerConfig)1 ProducerConfig (org.apache.kafka.clients.producer.ProducerConfig)1