|
@@ -20,6 +20,7 @@ import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.io.IOUtils;
|
|
|
import org.apache.hadoop.ipc.ProtobufRpcEngine;
|
|
|
import org.apache.hadoop.ipc.RPC;
|
|
|
+import org.apache.hadoop.metrics2.util.MBeans;
|
|
|
import org.apache.hadoop.net.NetUtils;
|
|
|
import org.apache.hadoop.ozone.client.OzoneClientUtils;
|
|
|
import org.apache.hadoop.ozone.protocolPB
|
|
@@ -29,12 +30,11 @@ import org.apache.hadoop.security.UserGroupInformation;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
+import javax.management.ObjectName;
|
|
|
import java.io.Closeable;
|
|
|
import java.io.IOException;
|
|
|
import java.net.InetSocketAddress;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.locks.ReadWriteLock;
|
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
|
|
|
@@ -42,7 +42,8 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
|
* SCMConnectionManager - Acts as a class that manages the membership
|
|
|
* information of the SCMs that we are working with.
|
|
|
*/
|
|
|
-public class SCMConnectionManager implements Closeable{
|
|
|
+public class SCMConnectionManager
|
|
|
+ implements Closeable, SCMConnectionManagerMXBean {
|
|
|
private static final Logger LOG =
|
|
|
LoggerFactory.getLogger(SCMConnectionManager.class);
|
|
|
|
|
@@ -51,7 +52,7 @@ public class SCMConnectionManager implements Closeable{
|
|
|
|
|
|
private final int rpcTimeout;
|
|
|
private final Configuration conf;
|
|
|
-
|
|
|
+ private final ObjectName jmxBean;
|
|
|
|
|
|
public SCMConnectionManager(Configuration conf) {
|
|
|
this.mapLock = new ReentrantReadWriteLock();
|
|
@@ -59,8 +60,12 @@ public class SCMConnectionManager implements Closeable{
|
|
|
this.rpcTimeout = timeOut.intValue();
|
|
|
this.scmMachines = new HashMap<>();
|
|
|
this.conf = conf;
|
|
|
+ jmxBean = MBeans.register("OzoneDataNode",
|
|
|
+ "SCMConnectionManager",
|
|
|
+ this);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Returns Config.
|
|
|
*
|
|
@@ -179,5 +184,18 @@ public class SCMConnectionManager implements Closeable{
|
|
|
public void close() throws IOException {
|
|
|
getValues().forEach(endpointStateMachine
|
|
|
-> IOUtils.cleanupWithLogger(LOG, endpointStateMachine));
|
|
|
+ MBeans.unregister(jmxBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<EndpointStateMachineMBean> getSCMServers() {
|
|
|
+ readLock();
|
|
|
+ try {
|
|
|
+ return Collections
|
|
|
+ .unmodifiableList(new ArrayList<>(scmMachines.values()));
|
|
|
+
|
|
|
+ } finally {
|
|
|
+ readUnlock();
|
|
|
+ }
|
|
|
}
|
|
|
}
|