Search in sources :

Example 11 with ThreadMetadata

use of org.apache.kafka.streams.ThreadMetadata in project kafka by apache.

the class StreamThreadTest method shouldAlwaysUpdateTasksMetadataAfterChangingState.

@Test
public void shouldAlwaysUpdateTasksMetadataAfterChangingState() {
    final StreamThread thread = createStreamThread(CLIENT_ID, config, false);
    ThreadMetadata metadata = thread.threadMetadata();
    assertEquals(StreamThread.State.CREATED.name(), metadata.threadState());
    thread.setState(StreamThread.State.STARTING);
    thread.setState(StreamThread.State.PARTITIONS_REVOKED);
    thread.setState(StreamThread.State.PARTITIONS_ASSIGNED);
    thread.setState(StreamThread.State.RUNNING);
    metadata = thread.threadMetadata();
    assertEquals(StreamThread.State.RUNNING.name(), metadata.threadState());
}
Also used : ThreadMetadata(org.apache.kafka.streams.ThreadMetadata) Test(org.junit.Test)

Example 12 with ThreadMetadata

use of org.apache.kafka.streams.ThreadMetadata in project kafka by apache.

the class ThreadMetadataImplTest method shouldNotBeEqualIfDifferInActiveTasks.

@Test
public void shouldNotBeEqualIfDifferInActiveTasks() {
    final ThreadMetadata differActiveTasks = new ThreadMetadataImpl(THREAD_NAME, THREAD_STATE, MAIN_CONSUMER_CLIENT_ID, RESTORE_CONSUMER_CLIENT_ID, PRODUCER_CLIENT_IDS, ADMIN_CLIENT_ID, mkSet(TM_0), STANDBY_TASKS);
    assertThat(threadMetadata, not(equalTo(differActiveTasks)));
    assertThat(threadMetadata.hashCode(), not(equalTo(differActiveTasks.hashCode())));
}
Also used : ThreadMetadata(org.apache.kafka.streams.ThreadMetadata) Test(org.junit.Test)

Example 13 with ThreadMetadata

use of org.apache.kafka.streams.ThreadMetadata in project kafka by apache.

the class ThreadMetadataImplTest method shouldNotBeEqualIfDifferInClientId.

@Test
public void shouldNotBeEqualIfDifferInClientId() {
    final ThreadMetadata differMainConsumerClientId = new ThreadMetadataImpl(THREAD_NAME, THREAD_STATE, "different", RESTORE_CONSUMER_CLIENT_ID, PRODUCER_CLIENT_IDS, ADMIN_CLIENT_ID, ACTIVE_TASKS, STANDBY_TASKS);
    assertThat(threadMetadata, not(equalTo(differMainConsumerClientId)));
    assertThat(threadMetadata.hashCode(), not(equalTo(differMainConsumerClientId.hashCode())));
}
Also used : ThreadMetadata(org.apache.kafka.streams.ThreadMetadata) Test(org.junit.Test)

Example 14 with ThreadMetadata

use of org.apache.kafka.streams.ThreadMetadata in project kafka by apache.

the class ThreadMetadataImplTest method shouldNotBeEqualIfDifferInAdminClientId.

@Test
public void shouldNotBeEqualIfDifferInAdminClientId() {
    final ThreadMetadata differAdminClientId = new ThreadMetadataImpl(THREAD_NAME, THREAD_STATE, MAIN_CONSUMER_CLIENT_ID, RESTORE_CONSUMER_CLIENT_ID, PRODUCER_CLIENT_IDS, "different", ACTIVE_TASKS, STANDBY_TASKS);
    assertThat(threadMetadata, not(equalTo(differAdminClientId)));
    assertThat(threadMetadata.hashCode(), not(equalTo(differAdminClientId.hashCode())));
}
Also used : ThreadMetadata(org.apache.kafka.streams.ThreadMetadata) Test(org.junit.Test)

Example 15 with ThreadMetadata

use of org.apache.kafka.streams.ThreadMetadata in project kafka by apache.

the class ThreadMetadataImplTest method shouldNotBeEqualIfDifferInThreadState.

@Test
public void shouldNotBeEqualIfDifferInThreadState() {
    final ThreadMetadata differThreadState = new ThreadMetadataImpl(THREAD_NAME, "different", MAIN_CONSUMER_CLIENT_ID, RESTORE_CONSUMER_CLIENT_ID, PRODUCER_CLIENT_IDS, ADMIN_CLIENT_ID, ACTIVE_TASKS, STANDBY_TASKS);
    assertThat(threadMetadata, not(equalTo(differThreadState)));
    assertThat(threadMetadata.hashCode(), not(equalTo(differThreadState.hashCode())));
}
Also used : ThreadMetadata(org.apache.kafka.streams.ThreadMetadata) Test(org.junit.Test)

Aggregations

ThreadMetadata (org.apache.kafka.streams.ThreadMetadata)15 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 KafkaStreams (org.apache.kafka.streams.KafkaStreams)3 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)3 IOException (java.io.IOException)2 Duration (java.time.Duration)2 Collections.emptySet (java.util.Collections.emptySet)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutorService (java.util.concurrent.ExecutorService)2 Executors (java.util.concurrent.Executors)2 TimeUnit (java.util.concurrent.TimeUnit)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2