Example usage for org.apache.hadoop.hdfs.server.datanode DataNode createDataNode

List of usage examples for org.apache.hadoop.hdfs.server.datanode DataNode createDataNode

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.datanode DataNode createDataNode.

Prototype

@VisibleForTesting
@InterfaceAudience.Private
public static DataNode createDataNode(String args[], Configuration conf, SecureResources resources)
        throws IOException 

Source Link

Document

Instantiate & Start a single datanode daemon and wait for it to finish.

Usage

From source file:com.mellanox.r4h.MiniDFSCluster.java

License:Apache License

/**
 * Restart a datanode, on the same port if requested
 * // ww w  .  jav  a  2  s.  c  o  m
 * @param dnprop
 *            the datanode to restart
 * @param keepPort
 *            whether to use the same port
 * @return true if restarting is successful
 * @throws IOException
 */
public synchronized boolean restartDataNode(DataNodeProperties dnprop, boolean keepPort) throws IOException {
    Configuration conf = dnprop.conf;
    String[] args = dnprop.dnArgs;
    SecureResources secureResources = dnprop.secureResources;
    Configuration newconf = new HdfsConfiguration(conf); // save cloned config
    if (keepPort) {
        InetSocketAddress addr = dnprop.datanode.getXferAddress();
        conf.set(DFS_DATANODE_ADDRESS_KEY, addr.getAddress().getHostAddress() + ":" + addr.getPort());
        conf.set(DFS_DATANODE_IPC_ADDRESS_KEY, addr.getAddress().getHostAddress() + ":" + dnprop.ipcPort);
    }
    DataNode newDn = DataNode.createDataNode(args, conf, secureResources);
    dataNodes.add(new DataNodeProperties(newDn, newconf, args, secureResources, newDn.getIpcPort()));
    numDataNodes++;
    return true;
}

From source file:org.wso2.carbon.hdfs.datanode.HDFSDataNode.java

License:Open Source License

public HDFSDataNode() {
    Configuration configuration = new Configuration(false);
    String carbonHome = System.getProperty(ServerConstants.CARBON_HOME);
    //   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;
    //        String mapredSiteConf = carbonHome + File.separator + "repository" + File.separator +
    //                "conf" + File.separator + "etc" + File.separator + "hadoop" + File.separator + MAPRED_SITE_XML;
    String hadoopMetrics2Properties = carbonHome + File.separator + "repository" + File.separator + "conf"
            + File.separator + "etc" + File.separator + "hadoop" + File.separator + METRICS2_PROPERTIES;
    //   configuration.addResource(new Path(hadoopConf));
    configuration.addResource(new Path(hadoopCoreSiteConf));
    configuration.addResource(new Path(hdfsCoreSiteConf));
    configuration.addResource(new Path(hadoopPolicyConf));
    configuration.addResource(new Path(hadoopMetrics2Properties));
    System.out.println("VAR = " + configuration.get("dfs.datanode.startup"));

    try {//  w  w w.  j  av  a2s .  co  m
        DataNode datanode = DataNode.createDataNode(null, configuration, null);
        //   DataNode.runDatanodeDaemon(datanode);
    } catch (Throwable e) {
        log.error(e);
        //System.exit(-1);
    }
}