Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'branch-3.0' into branch-3.0.0.1-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
BewareMyPower committed Apr 27, 2023
2 parents 79edf13 + 17fab5d commit 8f1c1b2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void onComplete() {
replicaManager.readFromLocalLog(
readCommitted, fetchMaxBytes, maxReadEntriesNum, readPartitionInfo, context
).thenAccept(readRecordsResult -> {
this.context.getStatsLogger().getWaitingFetchesTriggered().add(1);
this.context.getStatsLogger().getWaitingFetchesTriggered().addCount(1);
this.callback.complete(readRecordsResult);
}).thenAccept(__ -> {
// Ensure the old decode result are recycled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected boolean channelReady() {
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
// Get a buffer that contains the full frame
ByteBuf buffer = (ByteBuf) msg;
requestStats.getNetworkTotalBytesIn().add(buffer.readableBytes());
requestStats.getNetworkTotalBytesIn().addCount(buffer.readableBytes());

// Update parse request latency metrics
final BiConsumer<Long, Throwable> registerRequestParseLatency = (timeBeforeParse, throwable) -> {
Expand Down Expand Up @@ -448,7 +448,7 @@ protected void writeAndFlushResponseToClient(Channel channel) {
if (!future.isSuccess()) {
log.error("[{}] Failed to write {}", channel, request.getHeader(), future.cause());
} else {
requestStats.getNetworkTotalBytesOut().add(resultSize);
requestStats.getNetworkTotalBytesOut().addCount(resultSize);
}
});
requestStats.getRequestStatsLogger(apiKey, KopServerStats.REQUEST_QUEUED_LATENCY)
Expand All @@ -474,7 +474,7 @@ private void sendErrorResponse(KafkaHeaderAndRequest request, Channel channel, T
final int resultSize = result.readableBytes();
channel.writeAndFlush(result).addListener(future -> {
if (future.isSuccess()) {
requestStats.getNetworkTotalBytesOut().add(resultSize);
requestStats.getNetworkTotalBytesOut().addCount(resultSize);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void updateConsumerStats(final TopicPartition topicPartition,

final StatsLogger statsLoggerForThisPartition = statsLogger.getStatsLoggerForTopicPartition(topicPartition);

statsLoggerForThisPartition.getCounter(CONSUME_MESSAGE_CONVERSIONS).add(conversionCount);
statsLoggerForThisPartition.getCounter(CONSUME_MESSAGE_CONVERSIONS).addCount(conversionCount);
statsLoggerForThisPartition.getOpStatsLogger(CONSUME_MESSAGE_CONVERSIONS_TIME_NANOS)
.registerSuccessfulEvent(conversionTimeNanos, TimeUnit.NANOSECONDS);
final StatsLogger statsLoggerForThisGroup;
Expand All @@ -108,9 +108,9 @@ public void updateConsumerStats(final TopicPartition topicPartition,
} else {
statsLoggerForThisGroup = statsLoggerForThisPartition;
}
statsLoggerForThisGroup.getCounter(BYTES_OUT).add(records.sizeInBytes());
statsLoggerForThisGroup.getCounter(MESSAGE_OUT).add(numMessages);
statsLoggerForThisGroup.getCounter(ENTRIES_OUT).add(entrySize);
statsLoggerForThisGroup.getCounter(BYTES_OUT).addCount(records.sizeInBytes());
statsLoggerForThisGroup.getCounter(MESSAGE_OUT).addCount(numMessages);
statsLoggerForThisGroup.getCounter(ENTRIES_OUT).addCount(entrySize);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public void updateProducerStats(final TopicPartition topicPartition,

final StatsLogger statsLoggerForThisPartition = requestStats.getStatsLoggerForTopicPartition(topicPartition);

statsLoggerForThisPartition.getCounter(BYTES_IN).add(numBytes);
statsLoggerForThisPartition.getCounter(MESSAGE_IN).add(numMessages);
statsLoggerForThisPartition.getCounter(PRODUCE_MESSAGE_CONVERSIONS).add(conversionCount);
statsLoggerForThisPartition.getCounter(BYTES_IN).addCount(numBytes);
statsLoggerForThisPartition.getCounter(MESSAGE_IN).addCount(numMessages);
statsLoggerForThisPartition.getCounter(PRODUCE_MESSAGE_CONVERSIONS).addCount(conversionCount);
statsLoggerForThisPartition.getOpStatsLogger(PRODUCE_MESSAGE_CONVERSIONS_TIME_NANOS)
.registerSuccessfulEvent(conversionTimeNanos, TimeUnit.NANOSECONDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.streamnative.pulsar.handlers.kop.stats;

import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.LongAdder;
import org.apache.bookkeeper.stats.Counter;

Expand Down Expand Up @@ -48,10 +49,15 @@ public void dec() {
}

@Override
public void add(long delta) {
public void addCount(long delta) {
counter.add(delta);
}

@Override
public void addLatency(long l, TimeUnit timeUnit) {
// No-op
}

@Override
public Long get() {
return counter.sum();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ public void dec() {
}

@Override
public void add(long delta) {
public void addCount(long delta) {
// nop
}

@Override
public void addLatency(long l, TimeUnit timeUnit) {
// nop
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
import org.apache.kafka.common.serialization.StringSerializer;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.impl.BatchMessageIdImpl;
import org.apache.pulsar.client.impl.TopicMessageIdImpl;
import org.apache.pulsar.client.api.MessageIdAdv;
import org.apache.pulsar.common.policies.data.RetentionPolicies;
import org.apache.pulsar.common.util.FutureUtil;
import org.testng.annotations.AfterClass;
Expand Down Expand Up @@ -158,8 +157,7 @@ public void testKafkaProduceMessageOrder(int batchSize) throws Exception {

consumer.acknowledge(msg);

BatchMessageIdImpl id =
(BatchMessageIdImpl) ((TopicMessageIdImpl) msg.getMessageId()).getInnerMessageId();
MessageIdAdv id = (MessageIdAdv) msg.getMessageId();
if (id.getBatchIndex() == 0) {
numBatches++;
}
Expand Down

0 comments on commit 8f1c1b2

Please sign in to comment.