distributedlog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [16/29] incubator-distributedlog git commit: Remove guage when the log segment writer is removed
Date Wed, 21 Dec 2016 08:00:24 GMT
Remove guage when the log segment writer is removed

RB_ID=849452


Project: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/commit/bc70b770
Tree: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/tree/bc70b770
Diff: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/diff/bc70b770

Branch: refs/heads/merge/DL-98
Commit: bc70b7706e2a5cf2af26ab7e92ecf5ec2b1a955e
Parents: b7ae590
Author: Sijie Guo <sijieg@twitter.com>
Authored: Mon Jul 11 11:11:15 2016 -0700
Committer: Sijie Guo <sijieg@twitter.com>
Committed: Mon Dec 12 18:27:37 2016 -0800

----------------------------------------------------------------------
 .../distributedlog/BKLogSegmentWriter.java      | 12 ++++++++---
 .../stats/BroadCastStatsLogger.java             | 22 ++++++++++++++++++++
 pom.xml                                         |  2 +-
 3 files changed, 32 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bc70b770/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogSegmentWriter.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogSegmentWriter.java
b/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogSegmentWriter.java
index 1b52951..8276125 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogSegmentWriter.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogSegmentWriter.java
@@ -156,8 +156,10 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable,
Siz
 
     // stats
     private final StatsLogger envelopeStatsLogger;
+    private final StatsLogger transmitOutstandingLogger;
     private final Counter transmitDataSuccesses;
     private final Counter transmitDataMisses;
+    private final Gauge<Number> transmitOutstandingGauge;
     private final OpStatsLogger transmitDataPacketSize;
     private final Counter transmitControlSuccesses;
     private final Counter pFlushSuccesses;
@@ -255,8 +257,8 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable,
Siz
         pendingWrites = segWriterStatsLogger.getCounter("pending");
 
         // outstanding transmit requests
-        StatsLogger transmitOutstandingLogger = perLogStatsLogger.scope("transmit").scope("outstanding");
-        transmitOutstandingLogger.registerGauge("requests", new Gauge<Number>() {
+        transmitOutstandingLogger = perLogStatsLogger.scope("transmit").scope("outstanding");
+        transmitOutstandingGauge = new Gauge<Number>() {
             @Override
             public Number getDefaultValue() {
                 return 0;
@@ -265,7 +267,8 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable,
Siz
             public Number getSample() {
                 return outstandingTransmits.get();
             }
-        });
+        };
+        transmitOutstandingLogger.registerGauge("requests", transmitOutstandingGauge);
 
         outstandingTransmits = new AtomicInteger(0);
         this.fullyQualifiedLogSegment = streamName + ":" + logSegmentName;
@@ -531,6 +534,9 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable,
Siz
     private void closeInternal(final boolean abort,
                                final AtomicReference<Throwable> throwExc,
                                final Promise<Void> closePromise) {
+        // remove stats
+        this.transmitOutstandingLogger.unregisterGauge("requests", transmitOutstandingGauge);
+
         // Cancel the periodic keep alive schedule first
         if (null != periodicKeepAliveSchedule) {
             if (!periodicKeepAliveSchedule.cancel(false)) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bc70b770/distributedlog-core/src/main/java/com/twitter/distributedlog/stats/BroadCastStatsLogger.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/stats/BroadCastStatsLogger.java
b/distributedlog-core/src/main/java/com/twitter/distributedlog/stats/BroadCastStatsLogger.java
index e29cc47..10a7011 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/stats/BroadCastStatsLogger.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/stats/BroadCastStatsLogger.java
@@ -133,9 +133,26 @@ public class BroadCastStatsLogger {
         }
 
         @Override
+        public <T extends Number> void unregisterGauge(String statName, Gauge<T>
gauge) {
+            // no-op
+        }
+
+        @Override
         public StatsLogger scope(final String scope) {
             return new Two(first.scope(scope), second.scope(scope));
         }
+
+        @Override
+        public void removeScope(String scope, StatsLogger statsLogger) {
+            if (!(statsLogger instanceof Two)) {
+                return;
+            }
+
+            Two another = (Two) statsLogger;
+
+            first.removeScope(scope, another.first);
+            second.removeScope(scope, another.second);
+        }
     }
 
     /**
@@ -165,6 +182,11 @@ public class BroadCastStatsLogger {
         }
 
         @Override
+        public <T extends Number> void unregisterGauge(String statName, Gauge<T>
gauge) {
+            first.unregisterGauge(statName, gauge);
+        }
+
+        @Override
         public StatsLogger scope(String scope) {
             return new MasterSlave(first.scope(scope), second.scope(scope));
         }

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bc70b770/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index db07f12..1c70aa6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,7 +87,7 @@
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <zookeeper.version>3.5.1-alpha</zookeeper.version>
-    <bookkeeper.version>4.3.5-TWTTR-OSS</bookkeeper.version>
+    <bookkeeper.version>4.3.6-TWTTR-OSS</bookkeeper.version>
     <birdcage.sha>6.34.0</birdcage.sha>
     <scrooge.version>4.6.0</scrooge.version>
     <scrooge-maven-plugin.version>3.17.0</scrooge-maven-plugin.version>


Mime
View raw message