use of org.apache.kafka.streams.state.StateSerdes in project apache-kafka-on-k8s by banzaicloud.
the class ProcessorNodeTest method testMetrics.
@Test
public void testMetrics() {
final StateSerdes anyStateSerde = StateSerdes.withBuiltinTypes("anyName", Bytes.class, Bytes.class);
final Metrics metrics = new Metrics();
final InternalMockProcessorContext context = new InternalMockProcessorContext(anyStateSerde, new RecordCollectorImpl(null, null, new LogContext("processnode-test "), new DefaultProductionExceptionHandler()), metrics);
final ProcessorNode node = new ProcessorNode("name", new NoOpProcessor(), Collections.emptySet());
node.init(context);
String[] latencyOperations = { "process", "punctuate", "create", "destroy" };
String throughputOperation = "forward";
String groupName = "stream-processor-node-metrics";
final Map<String, String> metricTags = new LinkedHashMap<>();
metricTags.put("processor-node-id", node.name());
metricTags.put("task-id", context.taskId().toString());
for (String operation : latencyOperations) {
assertNotNull(metrics.getSensor(operation));
}
assertNotNull(metrics.getSensor(throughputOperation));
for (String opName : latencyOperations) {
testSpecificMetrics(metrics, groupName, opName, metricTags);
}
assertNotNull(metrics.metrics().get(metrics.metricName(throughputOperation + "-rate", groupName, "The average number of occurrence of " + throughputOperation + " operation per second.", metricTags)));
// test "all"
metricTags.put("processor-node-id", "all");
for (String opName : latencyOperations) {
testSpecificMetrics(metrics, groupName, opName, metricTags);
}
assertNotNull(metrics.metrics().get(metrics.metricName(throughputOperation + "-rate", groupName, "The average number of occurrence of " + throughputOperation + " operation per second.", metricTags)));
context.close();
}
use of org.apache.kafka.streams.state.StateSerdes in project apache-kafka-on-k8s by banzaicloud.
the class RecordQueueTest method shouldNotThrowStreamsExceptionWhenKeyDeserializationFailsWithSkipHandler.
@Test
public void shouldNotThrowStreamsExceptionWhenKeyDeserializationFailsWithSkipHandler() throws Exception {
final byte[] key = Serdes.Long().serializer().serialize("foo", 1L);
final List<ConsumerRecord<byte[], byte[]>> records = Collections.singletonList(new ConsumerRecord<>("topic", 1, 1, 0L, TimestampType.CREATE_TIME, 0L, 0, 0, key, recordValue));
final StateSerdes anyStateSerde = StateSerdes.withBuiltinTypes("anyName", Bytes.class, Bytes.class);
queueThatSkipsDeserializeErrors.addRawRecords(records);
assertEquals(0, queueThatSkipsDeserializeErrors.size());
}
Aggregations