use of org.apache.kafka.streams.StreamsMetrics in project kafka by apache.
the class StreamTaskTest method shouldCheckpointOffsetsOnCommit.
@SuppressWarnings("unchecked")
@Test
public void shouldCheckpointOffsetsOnCommit() throws Exception {
final String storeName = "test";
final String changelogTopic = ProcessorStateManager.storeChangelogTopic("appId", storeName);
final InMemoryKeyValueStore inMemoryStore = new InMemoryKeyValueStore(storeName, null, null) {
@Override
public void init(final ProcessorContext context, final StateStore root) {
context.register(root, true, null);
}
@Override
public boolean persistent() {
return true;
}
};
final ProcessorTopology topology = new ProcessorTopology(Collections.<ProcessorNode>emptyList(), Collections.<String, SourceNode>emptyMap(), Collections.<String, SinkNode>emptyMap(), Collections.<StateStore>singletonList(inMemoryStore), Collections.singletonMap(storeName, changelogTopic), Collections.<StateStore>emptyList());
final TopicPartition partition = new TopicPartition(changelogTopic, 0);
final NoOpRecordCollector recordCollector = new NoOpRecordCollector() {
@Override
public Map<TopicPartition, Long> offsets() {
return Collections.singletonMap(partition, 543L);
}
};
restoreStateConsumer.updatePartitions(changelogTopic, Collections.singletonList(new PartitionInfo(changelogTopic, 0, null, new Node[0], new Node[0])));
restoreStateConsumer.updateEndOffsets(Collections.singletonMap(partition, 0L));
restoreStateConsumer.updateBeginningOffsets(Collections.singletonMap(partition, 0L));
final StreamsMetrics streamsMetrics = new MockStreamsMetrics(new Metrics());
final TaskId taskId = new TaskId(0, 0);
final MockTime time = new MockTime();
final StreamsConfig config = createConfig(baseDir);
final StreamTask streamTask = new StreamTask(taskId, "appId", partitions, topology, consumer, changelogReader, config, streamsMetrics, stateDirectory, new ThreadCache("testCache", 0, streamsMetrics), time, recordCollector);
time.sleep(config.getLong(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG));
streamTask.commit();
final OffsetCheckpoint checkpoint = new OffsetCheckpoint(new File(stateDirectory.directoryForTask(taskId), ProcessorStateManager.CHECKPOINT_FILE_NAME));
assertThat(checkpoint.read(), equalTo(Collections.singletonMap(partition, 544L)));
}
use of org.apache.kafka.streams.StreamsMetrics in project kafka by apache.
the class StreamTaskTest method shouldFlushRecordCollectorOnFlushState.
@Test
public void shouldFlushRecordCollectorOnFlushState() throws Exception {
final AtomicBoolean flushed = new AtomicBoolean(false);
final NoOpRecordCollector recordCollector = new NoOpRecordCollector() {
@Override
public void flush() {
flushed.set(true);
}
};
final StreamsMetrics streamsMetrics = new MockStreamsMetrics(new Metrics());
final StreamTask streamTask = new StreamTask(taskId00, "appId", partitions, topology, consumer, changelogReader, createConfig(baseDir), streamsMetrics, stateDirectory, testCache, time, recordCollector);
streamTask.flushState();
assertTrue(flushed.get());
}
use of org.apache.kafka.streams.StreamsMetrics in project kafka by apache.
the class RocksDBWindowStoreSupplierTest method shouldHaveMeteredStoreWhenNotLoggedOrCached.
@SuppressWarnings("unchecked")
@Test
public void shouldHaveMeteredStoreWhenNotLoggedOrCached() throws Exception {
store = createStore(false, false);
store.init(context, store);
final StreamsMetrics metrics = context.metrics();
assertFalse(metrics.metrics().isEmpty());
}
use of org.apache.kafka.streams.StreamsMetrics in project kafka by apache.
the class RocksDBSessionStoreSupplierTest method shouldHaveMeteredStoreWhenNotLoggedOrCached.
@SuppressWarnings("unchecked")
@Test
public void shouldHaveMeteredStoreWhenNotLoggedOrCached() throws Exception {
store = createStore(false, false);
store.init(context, store);
final StreamsMetrics metrics = context.metrics();
assertFalse(metrics.metrics().isEmpty());
}
use of org.apache.kafka.streams.StreamsMetrics in project kafka by apache.
the class RocksDBSessionStoreSupplierTest method shouldHaveMeteredStoreWhenCached.
@SuppressWarnings("unchecked")
@Test
public void shouldHaveMeteredStoreWhenCached() throws Exception {
store = createStore(false, true);
store.init(context, store);
final StreamsMetrics metrics = context.metrics();
assertFalse(metrics.metrics().isEmpty());
}
Aggregations