Example usage for org.apache.hadoop.hdfs DFSUtil setGenericConf

List of usage examples for org.apache.hadoop.hdfs DFSUtil setGenericConf

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DFSUtil setGenericConf.

Prototype

public static void setGenericConf(Configuration conf, String nameserviceId, String nnId, String... keys) 

Source Link

Document

Sets the node specific setting into generic configuration key.

Usage

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

License:Apache License

private void createNameNode(int nnIndex, Configuration conf, int numDataNodes, boolean format,
        StartupOption operation, String clusterId, String nameserviceId, String nnId) throws IOException {
    // Format and clean out DataNode directories
    if (format) {
        DFSTestUtil.formatNameNode(conf);
    }// w w w. j av a2  s .  c  o  m
    if (operation == StartupOption.UPGRADE) {
        operation.setClusterId(clusterId);
    }

    // Start the NameNode after saving the default file system.
    String originalDefaultFs = conf.get(FS_DEFAULT_NAME_KEY);
    String[] args = createArgs(operation);
    NameNode nn = NameNode.createNameNode(args, conf);
    if (operation == StartupOption.RECOVER) {
        return;
    }

    // After the NN has started, set back the bound ports into
    // the conf
    conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_RPC_ADDRESS_KEY, nameserviceId, nnId),
            nn.getNameNodeAddressHostPortString());
    if (nn.getHttpAddress() != null) {
        conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_HTTP_ADDRESS_KEY, nameserviceId, nnId),
                NetUtils.getHostPortString(nn.getHttpAddress()));
    }
    if (nn.getHttpsAddress() != null) {
        conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_HTTPS_ADDRESS_KEY, nameserviceId, nnId),
                NetUtils.getHostPortString(nn.getHttpsAddress()));
    }

    DFSUtil.setGenericConf(conf, nameserviceId, nnId, DFS_NAMENODE_HTTP_ADDRESS_KEY);
    nameNodes[nnIndex] = new NameNodeInfo(nn, nameserviceId, nnId, operation, new Configuration(conf));
    // Restore the default fs name
    if (originalDefaultFs == null) {
        conf.set(FS_DEFAULT_NAME_KEY, "");
    } else {
        conf.set(FS_DEFAULT_NAME_KEY, originalDefaultFs);
    }
}