|
@@ -26,6 +26,7 @@ import org.apache.hadoop.hdfs.DFSUtil;
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
|
import org.apache.hadoop.ipc.ProtobufRpcEngine;
|
|
import org.apache.hadoop.ipc.ProtobufRpcEngine;
|
|
import org.apache.hadoop.ipc.RPC;
|
|
import org.apache.hadoop.ipc.RPC;
|
|
|
|
+import org.apache.hadoop.metrics2.util.MBeans;
|
|
import org.apache.hadoop.ozone.OzoneClientUtils;
|
|
import org.apache.hadoop.ozone.OzoneClientUtils;
|
|
import org.apache.hadoop.ozone.OzoneConfiguration;
|
|
import org.apache.hadoop.ozone.OzoneConfiguration;
|
|
import org.apache.hadoop.scm.protocol.LocatedContainer;
|
|
import org.apache.hadoop.scm.protocol.LocatedContainer;
|
|
@@ -73,12 +74,15 @@ import org.apache.hadoop.util.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
+import javax.management.ObjectName;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
import static org.apache.hadoop.ozone.OzoneConfigKeys
|
|
import static org.apache.hadoop.ozone.OzoneConfigKeys
|
|
.OZONE_SCM_CLIENT_ADDRESS_KEY;
|
|
.OZONE_SCM_CLIENT_ADDRESS_KEY;
|
|
@@ -107,7 +111,7 @@ import static org.apache.hadoop.util.ExitUtil.terminate;
|
|
@InterfaceAudience.LimitedPrivate({"HDFS", "CBLOCK", "OZONE", "HBASE"})
|
|
@InterfaceAudience.LimitedPrivate({"HDFS", "CBLOCK", "OZONE", "HBASE"})
|
|
public class StorageContainerManager
|
|
public class StorageContainerManager
|
|
implements StorageContainerDatanodeProtocol,
|
|
implements StorageContainerDatanodeProtocol,
|
|
- StorageContainerLocationProtocol {
|
|
|
|
|
|
+ StorageContainerLocationProtocol, SCMMXBean {
|
|
|
|
|
|
private static final Logger LOG =
|
|
private static final Logger LOG =
|
|
LoggerFactory.getLogger(StorageContainerManager.class);
|
|
LoggerFactory.getLogger(StorageContainerManager.class);
|
|
@@ -126,6 +130,9 @@ public class StorageContainerManager
|
|
private final RPC.Server clientRpcServer;
|
|
private final RPC.Server clientRpcServer;
|
|
private final InetSocketAddress clientRpcAddress;
|
|
private final InetSocketAddress clientRpcAddress;
|
|
|
|
|
|
|
|
+ /** SCM mxbean*/
|
|
|
|
+ private ObjectName scmInfoBeanName;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Creates a new StorageContainerManager. Configuration will be updated with
|
|
* Creates a new StorageContainerManager. Configuration will be updated with
|
|
* information on the actual listening addresses used for RPC servers.
|
|
* information on the actual listening addresses used for RPC servers.
|
|
@@ -161,7 +168,6 @@ public class StorageContainerManager
|
|
datanodeRpcAddress = updateListenAddress(conf,
|
|
datanodeRpcAddress = updateListenAddress(conf,
|
|
OZONE_SCM_DATANODE_ADDRESS_KEY, datanodeRpcAddr, datanodeRpcServer);
|
|
OZONE_SCM_DATANODE_ADDRESS_KEY, datanodeRpcAddr, datanodeRpcServer);
|
|
|
|
|
|
-
|
|
|
|
BlockingService storageProtoPbService =
|
|
BlockingService storageProtoPbService =
|
|
StorageContainerLocationProtocolProtos
|
|
StorageContainerLocationProtocolProtos
|
|
.StorageContainerLocationProtocolService
|
|
.StorageContainerLocationProtocolService
|
|
@@ -176,6 +182,8 @@ public class StorageContainerManager
|
|
handlerCount);
|
|
handlerCount);
|
|
clientRpcAddress = updateListenAddress(conf,
|
|
clientRpcAddress = updateListenAddress(conf,
|
|
OZONE_SCM_CLIENT_ADDRESS_KEY, scmAddress, clientRpcServer);
|
|
OZONE_SCM_CLIENT_ADDRESS_KEY, scmAddress, clientRpcServer);
|
|
|
|
+
|
|
|
|
+ registerMXBean();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -222,6 +230,18 @@ public class StorageContainerManager
|
|
return rpcServer;
|
|
return rpcServer;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void registerMXBean() {
|
|
|
|
+ this.scmInfoBeanName = MBeans.register("StorageContainerManager",
|
|
|
|
+ "StorageContainerManagerInfo", this);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void unregisterMXBean() {
|
|
|
|
+ if(this.scmInfoBeanName != null) {
|
|
|
|
+ MBeans.unregister(this.scmInfoBeanName);
|
|
|
|
+ this.scmInfoBeanName = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* After starting an RPC server, updates configuration with the actual
|
|
* After starting an RPC server, updates configuration with the actual
|
|
* listening address of that server. The listening address may be different
|
|
* listening address of that server. The listening address may be different
|
|
@@ -334,6 +354,12 @@ public class StorageContainerManager
|
|
return clientRpcAddress;
|
|
return clientRpcAddress;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String getClientRpcPort() {
|
|
|
|
+ InetSocketAddress addr = getClientRpcAddress();
|
|
|
|
+ return addr == null ? "0" : Integer.toString(addr.getPort());
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Returns listening address of StorageDatanode Protocol RPC server.
|
|
* Returns listening address of StorageDatanode Protocol RPC server.
|
|
*
|
|
*
|
|
@@ -343,6 +369,12 @@ public class StorageContainerManager
|
|
return datanodeRpcAddress;
|
|
return datanodeRpcAddress;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String getDatanodeRpcPort() {
|
|
|
|
+ InetSocketAddress addr = getDatanodeRpcAddress();
|
|
|
|
+ return addr == null ? "0" : Integer.toString(addr.getPort());
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Start service.
|
|
* Start service.
|
|
*/
|
|
*/
|
|
@@ -363,6 +395,7 @@ public class StorageContainerManager
|
|
clientRpcServer.stop();
|
|
clientRpcServer.stop();
|
|
LOG.info("Stopping the RPC server for DataNodes");
|
|
LOG.info("Stopping the RPC server for DataNodes");
|
|
datanodeRpcServer.stop();
|
|
datanodeRpcServer.stop();
|
|
|
|
+ unregisterMXBean();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -437,6 +470,15 @@ public class StorageContainerManager
|
|
return scmNodeManager.getNodeCount(nodestate);
|
|
return scmNodeManager.getNodeCount(nodestate);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Integer> getNodeCount() {
|
|
|
|
+ Map<String, Integer> countMap = new HashMap<String, Integer>();
|
|
|
|
+ for (SCMNodeManager.NODESTATE state : SCMNodeManager.NODESTATE.values()) {
|
|
|
|
+ countMap.put(state.toString(), scmNodeManager.getNodeCount(state));
|
|
|
|
+ }
|
|
|
|
+ return countMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Returns node manager.
|
|
* Returns node manager.
|
|
* @return - Node Manager
|
|
* @return - Node Manager
|