|
@@ -18,7 +18,6 @@
|
|
package org.apache.hadoop.hdfs.qjournal.client;
|
|
package org.apache.hadoop.hdfs.qjournal.client;
|
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
@@ -29,8 +28,6 @@ import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
|
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
|
|
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
|
|
import org.apache.hadoop.metrics2.lib.MutableQuantiles;
|
|
import org.apache.hadoop.metrics2.lib.MutableQuantiles;
|
|
|
|
|
|
-import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* The metrics for a journal from the writer's perspective.
|
|
* The metrics for a journal from the writer's perspective.
|
|
*/
|
|
*/
|
|
@@ -43,21 +40,6 @@ class IPCLoggerChannelMetrics {
|
|
private final MutableQuantiles[] writeEndToEndLatencyQuantiles;
|
|
private final MutableQuantiles[] writeEndToEndLatencyQuantiles;
|
|
private final MutableQuantiles[] writeRpcLatencyQuantiles;
|
|
private final MutableQuantiles[] writeRpcLatencyQuantiles;
|
|
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * In the case of the NN transitioning between states, edit logs are closed
|
|
|
|
- * and reopened. Thus, the IPCLoggerChannel instance that writes to a
|
|
|
|
- * given JournalNode may change over the lifetime of the process.
|
|
|
|
- * However, metrics2 doesn't have a function to unregister a set of metrics
|
|
|
|
- * and fails if a new metrics class is registered with the same name
|
|
|
|
- * as the existing one. Hence, we have to maintain our own registry
|
|
|
|
- * ("multiton") here, so that we have exactly one metrics instance
|
|
|
|
- * per JournalNode, and switch out the pointer to the underlying
|
|
|
|
- * IPCLoggerChannel instance.
|
|
|
|
- */
|
|
|
|
- private static final Map<String, IPCLoggerChannelMetrics> REGISTRY =
|
|
|
|
- Maps.newHashMap();
|
|
|
|
-
|
|
|
|
private IPCLoggerChannelMetrics(IPCLoggerChannel ch) {
|
|
private IPCLoggerChannelMetrics(IPCLoggerChannel ch) {
|
|
this.ch = ch;
|
|
this.ch = ch;
|
|
|
|
|
|
@@ -81,25 +63,16 @@ class IPCLoggerChannelMetrics {
|
|
writeRpcLatencyQuantiles = null;
|
|
writeRpcLatencyQuantiles = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- private void setChannel(IPCLoggerChannel ch) {
|
|
|
|
- assert ch.getRemoteAddress().equals(this.ch.getRemoteAddress());
|
|
|
|
- this.ch = ch;
|
|
|
|
|
|
+
|
|
|
|
+ public void unregister() {
|
|
|
|
+ DefaultMetricsSystem.instance().unregisterSource(getName(ch));
|
|
}
|
|
}
|
|
|
|
|
|
static IPCLoggerChannelMetrics create(IPCLoggerChannel ch) {
|
|
static IPCLoggerChannelMetrics create(IPCLoggerChannel ch) {
|
|
String name = getName(ch);
|
|
String name = getName(ch);
|
|
- synchronized (REGISTRY) {
|
|
|
|
- IPCLoggerChannelMetrics m = REGISTRY.get(name);
|
|
|
|
- if (m != null) {
|
|
|
|
- m.setChannel(ch);
|
|
|
|
- } else {
|
|
|
|
- m = new IPCLoggerChannelMetrics(ch);
|
|
|
|
- DefaultMetricsSystem.instance().register(name, null, m);
|
|
|
|
- REGISTRY.put(name, m);
|
|
|
|
- }
|
|
|
|
- return m;
|
|
|
|
- }
|
|
|
|
|
|
+ IPCLoggerChannelMetrics m = new IPCLoggerChannelMetrics(ch);
|
|
|
|
+ DefaultMetricsSystem.instance().register(name, null, m);
|
|
|
|
+ return m;
|
|
}
|
|
}
|
|
|
|
|
|
private static String getName(IPCLoggerChannel ch) {
|
|
private static String getName(IPCLoggerChannel ch) {
|