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

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

Introduction

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

Prototype

public String[] getStrings(String name, String... defaultValue) 

Source Link

Document

Get the comma delimited values of the name property as an array of Strings.

Usage

From source file:org.trafodion.rest.zookeeper.ZKConfig.java

License:Apache License

/**
 * Make a Properties object holding ZooKeeper config equivalent to zoo.cfg.
 * If there is a zoo.cfg in the classpath, simply read it in. Otherwise parse
 * the corresponding config options from the Rest XML configs and generate
 * the appropriate ZooKeeper properties.
 * @param conf Configuration to read from.
 * @return Properties holding mappings representing ZooKeeper zoo.cfg file.
 *//*from w w w  .  jav  a  2  s  . c  o m*/
public static Properties makeZKProps(Configuration conf) {
    // First check if there is a zoo.cfg in the CLASSPATH. If so, simply read
    // it and grab its configuration properties.
    ClassLoader cl = ZkQuorumPeer.class.getClassLoader();
    final InputStream inputStream = cl.getResourceAsStream(Constants.ZOOKEEPER_CONFIG_NAME);
    if (inputStream != null) {
        try {
            return parseZooCfg(conf, inputStream);
        } catch (IOException e) {
            LOG.warn("Cannot read " + Constants.ZOOKEEPER_CONFIG_NAME + ", loading from XML files", e);
        }
    }

    // Otherwise, use the configuration options from Rest's XML files.
    Properties zkProperties = new Properties();

    // Directly map all of the Rest.zookeeper.property.KEY properties.
    for (Entry<String, String> entry : conf) {
        String key = entry.getKey();
        if (key.startsWith(Constants.ZK_CFG_PROPERTY_PREFIX)) {
            String zkKey = key.substring(Constants.ZK_CFG_PROPERTY_PREFIX_LEN);
            String value = entry.getValue();
            // If the value has variables substitutions, need to do a get.
            if (value.contains(VARIABLE_START)) {
                value = conf.get(key);
            }
            zkProperties.put(zkKey, value);
        }
    }

    // If clientPort is not set, assign the default.
    if (zkProperties.getProperty(Constants.CLIENT_PORT_STR) == null) {
        zkProperties.put(Constants.CLIENT_PORT_STR, Constants.DEFAULT_ZOOKEEPER_CLIENT_PORT);
    }

    // Create the server.X properties.
    int peerPort = conf.getInt("rest.zookeeper.peerport", 2888);
    int leaderPort = conf.getInt("rest.zookeeper.leaderport", 3888);

    final String[] serverHosts = conf.getStrings(Constants.ZOOKEEPER_QUORUM, Constants.LOCALHOST);
    for (int i = 0; i < serverHosts.length; ++i) {
        String serverHost = serverHosts[i];
        String address = serverHost + ":" + peerPort + ":" + leaderPort;
        String key = "server." + i;
        zkProperties.put(key, address);
    }

    return zkProperties;
}

From source file:org.voltdb.hadoop.VoltConfiguration.java

License:Open Source License

public static void loadVoltClientJar(Configuration conf) {
    String voltJar = ClientImpl.class.getProtectionDomain().getCodeSource().getLocation().toString();

    if (voltJar.toLowerCase().endsWith(".jar")) {
        String[] jars = conf.getStrings(TMPJARS_PROP, new String[0]);
        jars = Arrays.copyOf(jars, jars.length + 1);
        jars[jars.length - 1] = voltJar;
        conf.setStrings(TMPJARS_PROP, jars);
    }/*  w w w .jav a2 s .  c o m*/
}

From source file:org.voltdb.hadoop.VoltConfiguration.java

License:Open Source License

/**
 * Reads volt specific configuration parameters from the
 * given {@linkplain JobConf} job configuration
 *
 * @param conf job configuration//from  www  .  j a  v a2 s.  c  o  m
 */
public VoltConfiguration(Configuration conf) {
    this(new Config(conf.get(TABLENAME_PROP), conf.getStrings(HOSTNAMES_PROP, new String[] {}),
            conf.get(USERNAME_PROP), conf.get(PASSWORD_PROP), conf.getInt(BATCHSIZE_PROP, BATCHSIZE_DFLT),
            conf.getLong(CLIENT_TIMEOUT_PROP, TIMEOUT_DFLT),
            conf.getInt(BULKLOADER_MAX_ERRORS_PROP, FaultCollector.MAXFAULTS),
            conf.getBoolean(BULKLOADER_UPSERT_PROP, false)));
}

From source file:simsql.runtime.VGWrapperReducer.java

License:Apache License

/** Loads up the cross product relations into a VGWrapper object. */
public static void addCrossRelations(Configuration conf, VGWrapper vgw) {

    // get the properties with the file information.
    String[] fileNames = conf.getStrings("simsql.crossFiles", new String[0]);
    String[] typeCodes = conf.getStrings("simsql.crossTypeCodes", new String[0]);
    String[] attCounts = conf.getStrings("simsql.crossAttCounts", new String[0]);

    if (fileNames.length != typeCodes.length || typeCodes.length != attCounts.length) {
        throw new RuntimeException("Cross product relations incorrectly set up!");
    }/*from  w  w w.  java 2 s .  c  o m*/

    // pass them all to the VGWrapper.
    for (int i = 0; i < fileNames.length; i++) {
        vgw.addCrossRelation(fileNames[i], Integer.parseInt(attCounts[i]), Short.parseShort(typeCodes[i]));
    }
}

From source file:simsql.runtime.VGWrapperReducer.java

License:Apache License

/** Plugs in the sorted relations into a VGWrapper object. */
public static void addSortedRelations(Configuration conf, VGWrapper vgw, int part) {

    // get the properties with the file information.
    String[] fileNames = conf.getStrings("simsql.sortedFiles", new String[0]);
    String[] typeCodes = conf.getStrings("simsql.sortedTypeCodes", new String[0]);
    String[] attCounts = conf.getStrings("simsql.sortedAttCounts", new String[0]);

    if (fileNames.length != typeCodes.length || typeCodes.length != attCounts.length) {
        throw new RuntimeException("Sorted relations incorrectly set up!");
    }/* w w w .  j  av  a2  s  .c  om*/

    // pass them all to the VGWrapper.
    for (int i = 0; i < fileNames.length; i++) {
        vgw.addSortedRelation(fileNames[i], part, Integer.parseInt(attCounts[i]),
                Short.parseShort(typeCodes[i]));
    }
}

From source file:yarnkit.utils.YarnUtils.java

License:Apache License

public static void configureClasspath(@Nonnull final Map<String, String> env,
        @Nonnull final Configuration conf) {
    for (String c : conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
            YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) {
        Apps.addToEnvironment(env, ApplicationConstants.Environment.CLASSPATH.name(), c.trim(), ":");
    }//from www .ja  v a 2s  . co  m
    Apps.addToEnvironment(env, ApplicationConstants.Environment.CLASSPATH.name(),
            ApplicationConstants.Environment.PWD.$() + File.separator + "*", ":");
}