Skip to content

Commit 23cea4a

Browse files
committed
re-use ProtobufUtils.protoToDuration() for stats conversion
1 parent 4e117f7 commit 23cea4a

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

topic/src/main/java/tech/ydb/topic/write/impl/WriterImpl.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import tech.ydb.core.Issue;
2222
import tech.ydb.core.Status;
2323
import tech.ydb.core.StatusCode;
24+
import tech.ydb.core.utils.ProtobufUtils;
2425
import tech.ydb.proto.StatusCodesProtos;
2526
import tech.ydb.proto.topic.YdbTopic;
2627
import tech.ydb.topic.TopicRpc;
@@ -321,13 +322,6 @@ protected void onShutdown(String reason) {
321322
}
322323
}
323324

324-
private static Duration convertDuration(com.google.protobuf.Duration d) {
325-
if (d == null) {
326-
return Duration.ZERO;
327-
}
328-
return Duration.ofSeconds(d.getSeconds(), d.getNanos());
329-
}
330-
331325
private class WriteSessionImpl extends WriteSession {
332326
protected String sessionId;
333327
private final MessageSender messageSender;
@@ -433,11 +427,11 @@ private void onWriteResponse(YdbTopic.StreamWriteMessage.WriteResponse response)
433427
if (response.getWriteStatistics() != null) {
434428
YdbTopic.StreamWriteMessage.WriteResponse.WriteStatistics src = response.getWriteStatistics();
435429
statistics = new WriteAck.Statistics(
436-
convertDuration(src.getPersistingTime()),
437-
convertDuration(src.getPartitionQuotaWaitTime()),
438-
convertDuration(src.getTopicQuotaWaitTime()),
439-
convertDuration(src.getMaxQueueWaitTime()),
440-
convertDuration(src.getMinQueueWaitTime())
430+
ProtobufUtils.protoToDuration(src.getPersistingTime()),
431+
ProtobufUtils.protoToDuration(src.getPartitionQuotaWaitTime()),
432+
ProtobufUtils.protoToDuration(src.getTopicQuotaWaitTime()),
433+
ProtobufUtils.protoToDuration(src.getMaxQueueWaitTime()),
434+
ProtobufUtils.protoToDuration(src.getMinQueueWaitTime())
441435
);
442436
}
443437
int inFlightFreed = 0;

0 commit comments

Comments
 (0)