You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by aa...@apache.org on 2022/06/22 12:16:37 UTC

[rocketmq-clients] branch master updated: Java: exit early if metric is off (#11)

This is an automated email from the ASF dual-hosted git repository.

aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new 856c123  Java: exit early if metric is off (#11)
856c123 is described below

commit 856c1234f1cd2fbcfc265923d7007149b8d4f470
Author: Aaron Ai <ya...@gmail.com>
AuthorDate: Wed Jun 22 20:16:33 2022 +0800

    Java: exit early if metric is off (#11)
---
 .../java/org/apache/rocketmq/client/java/metrics/MessageMeter.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/client/src/main/java/org/apache/rocketmq/client/java/metrics/MessageMeter.java b/java/client/src/main/java/org/apache/rocketmq/client/java/metrics/MessageMeter.java
index edec539..5732516 100644
--- a/java/client/src/main/java/org/apache/rocketmq/client/java/metrics/MessageMeter.java
+++ b/java/client/src/main/java/org/apache/rocketmq/client/java/metrics/MessageMeter.java
@@ -146,7 +146,9 @@ public class MessageMeter {
     public synchronized void refresh(Metric metric) {
         try {
             if (!metric.isOn()) {
+                LOGGER.info("Metric is off, skip refresh");
                 shutdown();
+                return;
             }
             final Optional<Endpoints> optionalEndpoints = metric.tryGetMetricEndpoints();
             if (!optionalEndpoints.isPresent()) {
@@ -214,8 +216,8 @@ public class MessageMeter {
     }
 
     public void shutdown() {
-        LOGGER.info("Begin to shutdown the message meter, clientId={}", client.getClientId());
         if (null != provider) {
+            LOGGER.info("Begin to shutdown the message meter, clientId={}", client.getClientId());
             final CountDownLatch latch = new CountDownLatch(1);
             provider.shutdown().whenComplete(latch::countDown);
             try {
@@ -224,8 +226,8 @@ public class MessageMeter {
                 LOGGER.error("Exception raised while waiting for the shutdown of meter, clientId={}",
                     client.getClientId());
             }
+            LOGGER.info("Shutdown the message meter, clientId={}", client.getClientId());
         }
-        LOGGER.info("Shutdown the message meter, clientId={}", client.getClientId());
     }
 
     public Meter getMeter() {