|
@@ -81,7 +81,6 @@ import org.apache.hadoop.hdds.security.x509.certificate.authority.DefaultCAServe
|
|
import org.apache.hadoop.hdds.server.ServiceRuntimeInfoImpl;
|
|
import org.apache.hadoop.hdds.server.ServiceRuntimeInfoImpl;
|
|
import org.apache.hadoop.hdds.server.events.EventPublisher;
|
|
import org.apache.hadoop.hdds.server.events.EventPublisher;
|
|
import org.apache.hadoop.hdds.server.events.EventQueue;
|
|
import org.apache.hadoop.hdds.server.events.EventQueue;
|
|
-import org.apache.hadoop.hdds.tracing.TracingUtil;
|
|
|
|
import org.apache.hadoop.hdfs.DFSUtil;
|
|
import org.apache.hadoop.hdfs.DFSUtil;
|
|
import org.apache.hadoop.io.IOUtils;
|
|
import org.apache.hadoop.io.IOUtils;
|
|
import org.apache.hadoop.ipc.RPC;
|
|
import org.apache.hadoop.ipc.RPC;
|
|
@@ -90,7 +89,6 @@ import org.apache.hadoop.metrics2.util.MBeans;
|
|
import org.apache.hadoop.ozone.OzoneConfigKeys;
|
|
import org.apache.hadoop.ozone.OzoneConfigKeys;
|
|
import org.apache.hadoop.ozone.OzoneSecurityUtil;
|
|
import org.apache.hadoop.ozone.OzoneSecurityUtil;
|
|
import org.apache.hadoop.ozone.common.Storage.StorageState;
|
|
import org.apache.hadoop.ozone.common.Storage.StorageState;
|
|
-import org.apache.hadoop.ozone.common.StorageInfo;
|
|
|
|
import org.apache.hadoop.ozone.lease.LeaseManager;
|
|
import org.apache.hadoop.ozone.lease.LeaseManager;
|
|
import org.apache.hadoop.ozone.lock.LockManager;
|
|
import org.apache.hadoop.ozone.lock.LockManager;
|
|
import org.apache.hadoop.ozone.protocol.commands.RetriableDatanodeEventWatcher;
|
|
import org.apache.hadoop.ozone.protocol.commands.RetriableDatanodeEventWatcher;
|
|
@@ -98,16 +96,13 @@ import org.apache.hadoop.security.SecurityUtil;
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
|
|
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
|
|
import org.apache.hadoop.security.authentication.client.AuthenticationException;
|
|
import org.apache.hadoop.security.authentication.client.AuthenticationException;
|
|
-import org.apache.hadoop.util.GenericOptionsParser;
|
|
|
|
import org.apache.hadoop.util.JvmPauseMonitor;
|
|
import org.apache.hadoop.util.JvmPauseMonitor;
|
|
-import org.apache.hadoop.util.StringUtils;
|
|
|
|
import org.apache.hadoop.utils.HddsVersionInfo;
|
|
import org.apache.hadoop.utils.HddsVersionInfo;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import javax.management.ObjectName;
|
|
import javax.management.ObjectName;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.io.PrintStream;
|
|
|
|
import java.net.InetAddress;
|
|
import java.net.InetAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
@@ -120,7 +115,6 @@ import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_SCM_KERBEROS_KEYTAB_
|
|
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_SCM_KERBEROS_PRINCIPAL_KEY;
|
|
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_SCM_KERBEROS_PRINCIPAL_KEY;
|
|
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_SCM_WATCHER_TIMEOUT_DEFAULT;
|
|
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_SCM_WATCHER_TIMEOUT_DEFAULT;
|
|
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ENABLED;
|
|
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ENABLED;
|
|
-import static org.apache.hadoop.util.ExitUtil.terminate;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* StorageContainerManager is the main entry point for the service that
|
|
* StorageContainerManager is the main entry point for the service that
|
|
@@ -140,19 +134,7 @@ public final class StorageContainerManager extends ServiceRuntimeInfoImpl
|
|
|
|
|
|
private static final Logger LOG = LoggerFactory
|
|
private static final Logger LOG = LoggerFactory
|
|
.getLogger(StorageContainerManager.class);
|
|
.getLogger(StorageContainerManager.class);
|
|
- private static final String USAGE =
|
|
|
|
- "Usage: \n ozone scm [genericOptions] "
|
|
|
|
- + "[ "
|
|
|
|
- + StartupOption.INIT.getName()
|
|
|
|
- + " [ "
|
|
|
|
- + StartupOption.CLUSTERID.getName()
|
|
|
|
- + " <cid> ] ]\n "
|
|
|
|
- + "ozone scm [genericOptions] [ "
|
|
|
|
- + StartupOption.GENCLUSTERID.getName()
|
|
|
|
- + " ]\n "
|
|
|
|
- + "ozone scm [ "
|
|
|
|
- + StartupOption.HELP.getName()
|
|
|
|
- + " ]\n";
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* SCM metrics.
|
|
* SCM metrics.
|
|
*/
|
|
*/
|
|
@@ -586,114 +568,22 @@ public final class StorageContainerManager extends ServiceRuntimeInfoImpl
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Main entry point for starting StorageContainerManager.
|
|
|
|
- *
|
|
|
|
- * @param argv arguments
|
|
|
|
- * @throws IOException if startup fails due to I/O error
|
|
|
|
- */
|
|
|
|
- public static void main(String[] argv) throws IOException {
|
|
|
|
- if (DFSUtil.parseHelpArgument(argv, USAGE, System.out, true)) {
|
|
|
|
- System.exit(0);
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- TracingUtil.initTracing("StorageContainerManager");
|
|
|
|
- OzoneConfiguration conf = new OzoneConfiguration();
|
|
|
|
- GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
|
|
|
|
- if (!hParser.isParseSuccessful()) {
|
|
|
|
- System.err.println("USAGE: " + USAGE + "\n");
|
|
|
|
- hParser.printGenericCommandUsage(System.err);
|
|
|
|
- System.exit(1);
|
|
|
|
- }
|
|
|
|
- StorageContainerManager scm = createSCM(
|
|
|
|
- hParser.getRemainingArgs(), conf, true);
|
|
|
|
- if (scm != null) {
|
|
|
|
- scm.start();
|
|
|
|
- scm.join();
|
|
|
|
- }
|
|
|
|
- } catch (Throwable t) {
|
|
|
|
- LOG.error("Failed to start the StorageContainerManager.", t);
|
|
|
|
- terminate(1, t);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private static void printUsage(PrintStream out) {
|
|
|
|
- out.println(USAGE + "\n");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Create an SCM instance based on the supplied command-line arguments.
|
|
|
|
- * <p>
|
|
|
|
- * This method is intended for unit tests only. It suppresses the
|
|
|
|
- * startup/shutdown message and skips registering Unix signal
|
|
|
|
- * handlers.
|
|
|
|
|
|
+ * Create an SCM instance based on the supplied configuration.
|
|
*
|
|
*
|
|
- * @param args command line arguments.
|
|
|
|
- * @param conf HDDS configuration
|
|
|
|
- * @return SCM instance
|
|
|
|
- * @throws IOException, AuthenticationException
|
|
|
|
- */
|
|
|
|
- @VisibleForTesting
|
|
|
|
- public static StorageContainerManager createSCM(
|
|
|
|
- String[] args, OzoneConfiguration conf)
|
|
|
|
- throws IOException, AuthenticationException {
|
|
|
|
- return createSCM(args, conf, false);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Create an SCM instance based on the supplied command-line arguments.
|
|
|
|
- *
|
|
|
|
- * @param args command-line arguments.
|
|
|
|
* @param conf HDDS configuration
|
|
* @param conf HDDS configuration
|
|
- * @param printBanner if true, then log a verbose startup message.
|
|
|
|
* @return SCM instance
|
|
* @return SCM instance
|
|
* @throws IOException, AuthenticationException
|
|
* @throws IOException, AuthenticationException
|
|
*/
|
|
*/
|
|
- private static StorageContainerManager createSCM(
|
|
|
|
- String[] args,
|
|
|
|
- OzoneConfiguration conf,
|
|
|
|
- boolean printBanner)
|
|
|
|
|
|
+ public static StorageContainerManager createSCM(
|
|
|
|
+ OzoneConfiguration conf)
|
|
throws IOException, AuthenticationException {
|
|
throws IOException, AuthenticationException {
|
|
- String[] argv = (args == null) ? new String[0] : args;
|
|
|
|
if (!HddsUtils.isHddsEnabled(conf)) {
|
|
if (!HddsUtils.isHddsEnabled(conf)) {
|
|
System.err.println(
|
|
System.err.println(
|
|
"SCM cannot be started in secure mode or when " + OZONE_ENABLED + "" +
|
|
"SCM cannot be started in secure mode or when " + OZONE_ENABLED + "" +
|
|
" is set to false");
|
|
" is set to false");
|
|
System.exit(1);
|
|
System.exit(1);
|
|
}
|
|
}
|
|
- StartupOption startOpt = parseArguments(argv);
|
|
|
|
- if (startOpt == null) {
|
|
|
|
- printUsage(System.err);
|
|
|
|
- terminate(1);
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- switch (startOpt) {
|
|
|
|
- case INIT:
|
|
|
|
- if (printBanner) {
|
|
|
|
- StringUtils.startupShutdownMessage(StorageContainerManager.class, argv,
|
|
|
|
- LOG);
|
|
|
|
- }
|
|
|
|
- terminate(scmInit(conf) ? 0 : 1);
|
|
|
|
- return null;
|
|
|
|
- case GENCLUSTERID:
|
|
|
|
- if (printBanner) {
|
|
|
|
- StringUtils.startupShutdownMessage(StorageContainerManager.class, argv,
|
|
|
|
- LOG);
|
|
|
|
- }
|
|
|
|
- System.out.println("Generating new cluster id:");
|
|
|
|
- System.out.println(StorageInfo.newClusterID());
|
|
|
|
- terminate(0);
|
|
|
|
- return null;
|
|
|
|
- case HELP:
|
|
|
|
- printUsage(System.err);
|
|
|
|
- terminate(0);
|
|
|
|
- return null;
|
|
|
|
- default:
|
|
|
|
- if (printBanner) {
|
|
|
|
- StringUtils.startupShutdownMessage(StorageContainerManager.class, argv,
|
|
|
|
- LOG);
|
|
|
|
- }
|
|
|
|
- return new StorageContainerManager(conf);
|
|
|
|
- }
|
|
|
|
|
|
+ return new StorageContainerManager(conf);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -703,12 +593,12 @@ public final class StorageContainerManager extends ServiceRuntimeInfoImpl
|
|
* @return true if SCM initialization is successful, false otherwise.
|
|
* @return true if SCM initialization is successful, false otherwise.
|
|
* @throws IOException if init fails due to I/O error
|
|
* @throws IOException if init fails due to I/O error
|
|
*/
|
|
*/
|
|
- public static boolean scmInit(OzoneConfiguration conf) throws IOException {
|
|
|
|
|
|
+ public static boolean scmInit(OzoneConfiguration conf,
|
|
|
|
+ String clusterId) throws IOException {
|
|
SCMStorageConfig scmStorageConfig = new SCMStorageConfig(conf);
|
|
SCMStorageConfig scmStorageConfig = new SCMStorageConfig(conf);
|
|
StorageState state = scmStorageConfig.getState();
|
|
StorageState state = scmStorageConfig.getState();
|
|
if (state != StorageState.INITIALIZED) {
|
|
if (state != StorageState.INITIALIZED) {
|
|
try {
|
|
try {
|
|
- String clusterId = StartupOption.INIT.getClusterId();
|
|
|
|
if (clusterId != null && !clusterId.isEmpty()) {
|
|
if (clusterId != null && !clusterId.isEmpty()) {
|
|
scmStorageConfig.setClusterId(clusterId);
|
|
scmStorageConfig.setClusterId(clusterId);
|
|
}
|
|
}
|
|
@@ -735,48 +625,6 @@ public final class StorageContainerManager extends ServiceRuntimeInfoImpl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private static StartupOption parseArguments(String[] args) {
|
|
|
|
- int argsLen = (args == null) ? 0 : args.length;
|
|
|
|
- StartupOption startOpt = null;
|
|
|
|
- if (argsLen == 0) {
|
|
|
|
- startOpt = StartupOption.REGULAR;
|
|
|
|
- }
|
|
|
|
- for (int i = 0; i < argsLen; i++) {
|
|
|
|
- String cmd = args[i];
|
|
|
|
- if (StartupOption.INIT.getName().equalsIgnoreCase(cmd)) {
|
|
|
|
- startOpt = StartupOption.INIT;
|
|
|
|
- if (argsLen > 3) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- for (i = i + 1; i < argsLen; i++) {
|
|
|
|
- if (args[i].equalsIgnoreCase(StartupOption.CLUSTERID.getName())) {
|
|
|
|
- i++;
|
|
|
|
- if (i < argsLen && !args[i].isEmpty()) {
|
|
|
|
- startOpt.setClusterId(args[i]);
|
|
|
|
- } else {
|
|
|
|
- // if no cluster id specified or is empty string, return null
|
|
|
|
- LOG.error(
|
|
|
|
- "Must specify a valid cluster ID after the "
|
|
|
|
- + StartupOption.CLUSTERID.getName()
|
|
|
|
- + " flag");
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (StartupOption.GENCLUSTERID.getName().equalsIgnoreCase(cmd)) {
|
|
|
|
- if (argsLen > 1) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- startOpt = StartupOption.GENCLUSTERID;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return startOpt;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Initialize SCM metrics.
|
|
* Initialize SCM metrics.
|
|
*/
|
|
*/
|
|
@@ -1219,35 +1067,4 @@ public final class StorageContainerManager extends ServiceRuntimeInfoImpl
|
|
public SCMMetadataStore getScmMetadataStore() {
|
|
public SCMMetadataStore getScmMetadataStore() {
|
|
return scmMetadataStore;
|
|
return scmMetadataStore;
|
|
}
|
|
}
|
|
- /**
|
|
|
|
- * Startup options.
|
|
|
|
- */
|
|
|
|
- public enum StartupOption {
|
|
|
|
- INIT("--init"),
|
|
|
|
- CLUSTERID("--clusterid"),
|
|
|
|
- GENCLUSTERID("--genclusterid"),
|
|
|
|
- REGULAR("--regular"),
|
|
|
|
- HELP("-help");
|
|
|
|
-
|
|
|
|
- private final String name;
|
|
|
|
- private String clusterId = null;
|
|
|
|
-
|
|
|
|
- StartupOption(String arg) {
|
|
|
|
- this.name = arg;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public String getClusterId() {
|
|
|
|
- return clusterId;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void setClusterId(String cid) {
|
|
|
|
- if (cid != null && !cid.isEmpty()) {
|
|
|
|
- clusterId = cid;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public String getName() {
|
|
|
|
- return name;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|