use of org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl in project kafka by apache.
the class StreamThreadTest method shouldEnforceRebalanceAfterNextScheduledProbingRebalanceTime.
@Test
public void shouldEnforceRebalanceAfterNextScheduledProbingRebalanceTime() throws InterruptedException {
final StreamsConfig config = new StreamsConfig(configProps(false));
internalTopologyBuilder.buildTopology();
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, APPLICATION_ID, config.getString(StreamsConfig.BUILT_IN_METRICS_VERSION_CONFIG), mockTime);
final Consumer<byte[], byte[]> mockConsumer = EasyMock.createNiceMock(Consumer.class);
expect(mockConsumer.poll(anyObject())).andStubReturn(ConsumerRecords.empty());
final ConsumerGroupMetadata consumerGroupMetadata = mock(ConsumerGroupMetadata.class);
expect(mockConsumer.groupMetadata()).andStubReturn(consumerGroupMetadata);
expect(consumerGroupMetadata.groupInstanceId()).andReturn(Optional.empty());
EasyMock.replay(consumerGroupMetadata);
final EasyMockConsumerClientSupplier mockClientSupplier = new EasyMockConsumerClientSupplier(mockConsumer);
mockClientSupplier.setCluster(createCluster());
EasyMock.replay(mockConsumer);
final TopologyMetadata topologyMetadata = new TopologyMetadata(internalTopologyBuilder, config);
topologyMetadata.buildAndRewriteTopology();
final StreamThread thread = StreamThread.create(topologyMetadata, config, mockClientSupplier, mockClientSupplier.getAdmin(config.getAdminConfigs(CLIENT_ID)), PROCESS_ID, CLIENT_ID, streamsMetrics, mockTime, streamsMetadataState, 0, stateDirectory, new MockStateRestoreListener(), threadIdx, null, null);
mockConsumer.enforceRebalance();
mockClientSupplier.nextRebalanceMs().set(mockTime.milliseconds() - 1L);
thread.start();
TestUtils.waitForCondition(() -> thread.state() == StreamThread.State.STARTING, 10 * 1000, "Thread never started.");
TestUtils.retryOnExceptionWithTimeout(() -> verify(mockConsumer));
thread.shutdown();
TestUtils.waitForCondition(() -> thread.state() == StreamThread.State.DEAD, 10 * 1000, "Thread never shut down.");
}
use of org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl in project kafka by apache.
the class NamedCacheTest method setUp.
@Before
public void setUp() {
final Metrics innerMetrics = new Metrics();
final StreamsMetricsImpl metrics = new MockStreamsMetrics(innerMetrics);
cache = new NamedCache("dummy-name", metrics);
}
use of org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl in project kafka by apache.
the class MeteredWindowStoreTest method setUp.
@Before
public void setUp() {
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, "test", StreamsConfig.METRICS_LATEST, new MockTime());
context = new InternalMockProcessorContext<>(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), streamsMetrics, new StreamsConfig(StreamsTestUtils.getStreamsConfig()), MockRecordCollector::new, new ThreadCache(new LogContext("testCache "), 0, streamsMetrics), Time.SYSTEM);
tags = mkMap(mkEntry(THREAD_ID_TAG_KEY, threadId), mkEntry("task-id", context.taskId().toString()), mkEntry(STORE_TYPE + "-state-id", STORE_NAME));
}
use of org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl in project kafka by apache.
the class MeteredSessionStoreTest method before.
@Before
public void before() {
final Time mockTime = new MockTime();
store = new MeteredSessionStore<>(innerStore, STORE_TYPE, Serdes.String(), Serdes.String(), mockTime);
metrics.config().recordLevel(Sensor.RecordingLevel.DEBUG);
expect(context.applicationId()).andStubReturn(APPLICATION_ID);
expect(context.metrics()).andStubReturn(new StreamsMetricsImpl(metrics, "test", StreamsConfig.METRICS_LATEST, mockTime));
expect(context.taskId()).andStubReturn(taskId);
expect(context.changelogFor(STORE_NAME)).andStubReturn(CHANGELOG_TOPIC);
expect(innerStore.name()).andStubReturn(STORE_NAME);
tags = mkMap(mkEntry(THREAD_ID_TAG_KEY, threadId), mkEntry("task-id", taskId.toString()), mkEntry(STORE_TYPE + "-state-id", STORE_NAME));
}
use of org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl in project kafka by apache.
the class TaskManagerTest method setUpTaskManager.
private void setUpTaskManager(final StreamsConfigUtils.ProcessingMode processingMode) {
taskManager = new TaskManager(time, changeLogReader, UUID.randomUUID(), "taskManagerTest", new StreamsMetricsImpl(new Metrics(), "clientId", StreamsConfig.METRICS_LATEST, time), activeTaskCreator, standbyTaskCreator, new TopologyMetadata(topologyBuilder, new DummyStreamsConfig(processingMode)), adminClient, stateDirectory);
taskManager.setMainConsumer(consumer);
reset(topologyBuilder);
expect(topologyBuilder.hasNamedTopology()).andStubReturn(false);
activeTaskCreator.removeRevokedUnknownTasks(anyObject());
expectLastCall().asStub();
standbyTaskCreator.removeRevokedUnknownTasks(anyObject());
expectLastCall().asStub();
}
Aggregations