Example usage for org.apache.hadoop.conf Configuration get

List of usage examples for org.apache.hadoop.conf Configuration get

Introduction

In this page you can find the example usage for org.apache.hadoop.conf Configuration get.

Prototype

public String get(String name, String defaultValue) 

Source Link

Document

Get the value of the name.

Usage

From source file:com.cloudera.impala.service.JniFrontend.java

License:Apache License

/**
 *  Checks the data node's server side configuration by reading the CONF from the data
 *  node./*from   w w w  .  ja  v a2s  .co  m*/
 *  This appends error messages to errorCause prefixed by prefix if data node
 *  configuration is not properly set.
 */
private void cdh41ShortCircuitReadDatanodeCheck(StringBuilder errorCause, String prefix) {
    String dnWebUiAddr = CONF.get(DFSConfigKeys.DFS_DATANODE_HTTP_ADDRESS_KEY,
            DFSConfigKeys.DFS_DATANODE_HTTP_ADDRESS_DEFAULT);
    URL dnWebUiUrl = null;
    try {
        dnWebUiUrl = new URL("http://" + dnWebUiAddr + "/conf");
    } catch (Exception e) {
        LOG.info(e.toString());
    }
    Configuration dnConf = new Configuration(false);
    dnConf.addResource(dnWebUiUrl);

    // dfs.datanode.data.dir.perm should be at least 750
    int permissionInt = 0;
    try {
        String permission = dnConf.get(DFSConfigKeys.DFS_DATANODE_DATA_DIR_PERMISSION_KEY,
                DFSConfigKeys.DFS_DATANODE_DATA_DIR_PERMISSION_DEFAULT);
        permissionInt = Integer.parseInt(permission);
    } catch (Exception e) {
    }
    if (permissionInt < 750) {
        errorCause.append(prefix);
        errorCause.append("Data node configuration ");
        errorCause.append(DFSConfigKeys.DFS_DATANODE_DATA_DIR_PERMISSION_KEY);
        errorCause.append(" is not properly set. It should be set to 750.\n");
    }

    // dfs.block.local-path-access.user should contain the user account impala is running
    // under
    String accessUser = dnConf.get(DFSConfigKeys.DFS_BLOCK_LOCAL_PATH_ACCESS_USER_KEY);
    if (accessUser == null || !accessUser.contains(System.getProperty("user.name"))) {
        errorCause.append(prefix);
        errorCause.append("Data node configuration ");
        errorCause.append(DFSConfigKeys.DFS_BLOCK_LOCAL_PATH_ACCESS_USER_KEY);
        errorCause.append(" is not properly set. It should contain ");
        errorCause.append(System.getProperty("user.name"));
        errorCause.append("\n");
    }
}

From source file:com.cloudera.llama.am.LlamaAdminClient.java

License:Apache License

public static int execute(String[] args) throws Exception {
    int exitCode = 1;
    CLIParser parser = createParser();//from   ww  w  . j ava  2 s.co m
    try {
        CLIParser.Command command = parser.parse(args);
        CommandLine cl = command.getCommandLine();

        Configuration conf = new Configuration(false);
        conf.addResource(LLAMAADMIN_CONFIG);
        if (cl.hasOption(SECURE)) {
            conf.setBoolean(LLAMAADMIN_SERVER_SECURE_KEY, true);
        }
        if (cl.hasOption(LLAMA)) {
            conf.set(LLAMAADMIN_SERVER_ADDRESS_KEY, cl.getOptionValue(LLAMA));
        }
        String llama = conf.get(LLAMAADMIN_SERVER_ADDRESS_KEY, LLAMAADMIN_SERVER_ADDRESS_DEFAULT);
        boolean secure = conf.getBoolean(LLAMAADMIN_SERVER_SECURE_KEY, LLAMAADMIN_SERVER_SECURE_DEFAULT);

        if (command.getName().equals(HELP_CMD)) {
            parser.showHelp(command.getCommandLine());
            exitCode = 0;
        } else if (command.getName().equals(RELEASE_CMD)) {
            boolean doNotCache = cl.hasOption(DO_NOT_CACHE);
            List<UUID> handles = optToHandles(cl.getOptionValue(HANDLES));
            List<UUID> reservations = optToHandles(cl.getOptionValue(RESERVATIONS));
            List<String> queues = optToStrings(cl.getOptionValue(QUEUES));

            if (handles.isEmpty() && reservations.isEmpty() && queues.isEmpty()) {
                System.err.print("At least one of the -queues, -handles or "
                        + "-reservations options must be specified");
                exitCode = 1;
            } else {
                release(secure, getHost(llama), getPort(llama, LLAMAADMIN_SERVER_PORT_DEFAULT), handles,
                        reservations, queues, doNotCache);
                exitCode = 0;
            }
        } else if (command.getName().equals(EMPTY_CACHE_CMD)) {
            boolean allQueues = cl.hasOption(ALL_QUEUES);
            List<String> queues = optToStrings(cl.getOptionValue(QUEUES));
            if ((!allQueues && queues.isEmpty()) || (allQueues && !queues.isEmpty())) {
                System.err.print("Either the -allqueues or the -queues option must " + "be specified");
                exitCode = 1;
            } else {
                emptyCache(secure, getHost(llama), getPort(llama, LLAMAADMIN_SERVER_PORT_DEFAULT), queues,
                        allQueues);
                exitCode = 0;
            }
        } else if (command.getName().equals(ERROR_CODES_CMD)) {
            System.out.println();
            System.out.println("Error codes for Llama version: " + VersionInfo.getVersion());
            System.out.println();
            for (String description : ErrorCode.ERROR_CODE_DESCRIPTIONS) {
                System.out.println("  " + description);
            }
            System.out.println();
        } else if (command.getName().equals(VERSION_CMD)) {
            System.out.println(VersionInfo.getVersion());
        } else {
            System.err.println("Sub-command missing");
            System.err.println();
            System.err.println(parser.shortHelp());
            exitCode = 1;
        }
    } catch (ParseException ex) {
        System.err.println("Invalid sub-command: " + ex.getMessage());
        System.err.println();
        System.err.println(parser.shortHelp());
        exitCode = 1;
    } catch (Throwable ex) {
        System.err.println("Error: " + ex.getMessage());
        ex.printStackTrace(System.err);
        exitCode = 2;
    }
    return exitCode;
}

From source file:com.cloudera.spark.bulkload.TotalOrderPartitioner.java

License:Apache License

/**
   * Get the path to the SequenceFile storing the sorted partition keyset.
   * @see #setPartitionFile(Configuration, Path)
   *//*from   w  w  w  .ja v  a 2  s  .  c  om*/
  public static String getPartitionFile(Configuration conf) {
      return conf.get(PARTITIONER_PATH, DEFAULT_PATH);
  }