Search in sources :

Example 1 with NamenodeRole

use of org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole in project hadoop by apache.

the class NameNode method createNameNode.

public static NameNode createNameNode(String[] argv, Configuration conf) throws IOException {
    LOG.info("createNameNode " + Arrays.asList(argv));
    if (conf == null)
        conf = new HdfsConfiguration();
    // Parse out some generic args into Configuration.
    GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
    argv = hParser.getRemainingArgs();
    // Parse the rest, NN specific args.
    StartupOption startOpt = parseArguments(argv);
    if (startOpt == null) {
        printUsage(System.err);
        return null;
    }
    setStartupOption(conf, startOpt);
    boolean aborted = false;
    switch(startOpt) {
        case FORMAT:
            aborted = format(conf, startOpt.getForceFormat(), startOpt.getInteractiveFormat());
            terminate(aborted ? 1 : 0);
            // avoid javac warning
            return null;
        case GENCLUSTERID:
            System.err.println("Generating new cluster id:");
            System.out.println(NNStorage.newClusterID());
            terminate(0);
            return null;
        case ROLLBACK:
            aborted = doRollback(conf, true);
            terminate(aborted ? 1 : 0);
            // avoid warning
            return null;
        case BOOTSTRAPSTANDBY:
            String[] toolArgs = Arrays.copyOfRange(argv, 1, argv.length);
            int rc = BootstrapStandby.run(toolArgs, conf);
            terminate(rc);
            // avoid warning
            return null;
        case INITIALIZESHAREDEDITS:
            aborted = initializeSharedEdits(conf, startOpt.getForceFormat(), startOpt.getInteractiveFormat());
            terminate(aborted ? 1 : 0);
            // avoid warning
            return null;
        case BACKUP:
        case CHECKPOINT:
            NamenodeRole role = startOpt.toNodeRole();
            DefaultMetricsSystem.initialize(role.toString().replace(" ", ""));
            return new BackupNode(conf, role);
        case RECOVER:
            NameNode.doRecovery(startOpt, conf);
            return null;
        case METADATAVERSION:
            printMetadataVersion(conf);
            terminate(0);
            // avoid javac warning
            return null;
        case UPGRADEONLY:
            DefaultMetricsSystem.initialize("NameNode");
            new NameNode(conf);
            terminate(0);
            return null;
        default:
            DefaultMetricsSystem.initialize("NameNode");
            return new NameNode(conf);
    }
}
Also used : StartupOption(org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption) RollingUpgradeStartupOption(org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) GenericOptionsParser(org.apache.hadoop.util.GenericOptionsParser) NamenodeRole(org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole)

Example 2 with NamenodeRole

use of org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole in project hadoop by apache.

the class NameNode method getNNRole.

// NameNodeStatusMXBean
@Override
public String getNNRole() {
    String roleStr = "";
    NamenodeRole role = getRole();
    if (null != role) {
        roleStr = role.toString();
    }
    return roleStr;
}
Also used : NamenodeRole(org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole)

Aggregations

NamenodeRole (org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole)2 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)1 RollingUpgradeStartupOption (org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption)1 StartupOption (org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption)1 GenericOptionsParser (org.apache.hadoop.util.GenericOptionsParser)1