Example usage for org.apache.hadoop.hdfs.server.namenode NameNode NameNode

List of usage examples for org.apache.hadoop.hdfs.server.namenode NameNode NameNode

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.namenode NameNode NameNode.

Prototype

public NameNode(Configuration conf) throws IOException 

Source Link

Document

Start NameNode.

Usage

From source file:org.wso2.carbon.hdfs.namenode.HDFSNameNode.java

License:Open Source License

public HDFSNameNode() {

    Configuration conf = new Configuration(false);
    String carbonHome = System.getProperty(ServerConstants.CARBON_HOME);
    String krb5ConfFileLocation = carbonHome + File.separator + "repository" + File.separator + "conf"
            + File.separator + "krb5.conf";
    String hadoopConf = carbonHome + File.separator + "repository" + File.separator + "conf" + File.separator
            + "etc" + File.separator + "hadoop";
    String hadoopCoreSiteConf = carbonHome + File.separator + "repository" + File.separator + "conf"
            + File.separator + "etc" + File.separator + "hadoop" + File.separator + CORE_SITE_XML;
    String hdfsCoreSiteConf = carbonHome + File.separator + "repository" + File.separator + "conf"
            + File.separator + "etc" + File.separator + "hadoop" + File.separator + HDFS_SITE_XML;
    String hadoopPolicyConf = carbonHome + File.separator + "repository" + File.separator + "conf"
            + File.separator + "etc" + File.separator + "hadoop" + File.separator + HADOOP_POLICY_XML;
    System.setProperty("java.security.krb5.conf", krb5ConfFileLocation);
    conf.addResource(new Path(hadoopCoreSiteConf));
    conf.addResource(new Path(hdfsCoreSiteConf));
    conf.addResource(new Path(hadoopPolicyConf));
    String alterdJobNameNodeKeyTabPath = hadoopConf + File.separator + conf.get("dfs.namenode.keytab.file");
    conf.set("dfs.namenode.keytab.file", alterdJobNameNodeKeyTabPath);

    try {//from  w w w. ja v a2 s  . co  m
        new NameNode(conf);
    } catch (Throwable e) {
        log.error("NameNode initialization error." + e);
    }
}