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

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

Introduction

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

Prototype

@Override
    public void readFields(DataInput in) throws IOException 

Source Link

Usage

From source file:org.apache.hama.bsp.MesosExecutor.java

License:Apache License

private HamaConfiguration configure(final TaskInfo task) {
    Configuration conf = new Configuration(false);
    try {/*  w  w w  .  ja  v  a2s. c  o m*/
        byte[] bytes = task.getData().toByteArray();
        conf.readFields(new DataInputStream(new ByteArrayInputStream(bytes)));
    } catch (IOException e) {
        LOG.warn("Failed to deserialize configuraiton.", e);
        System.exit(1);
    }

    // Set the local directories inside the executor sandbox, so that
    // different Grooms on the same host do not step on each other.
    conf.set("bsp.local.dir", System.getProperty("user.dir") + "/bsp/local");
    conf.set("bsp.tmp.dir", System.getProperty("user.dir") + "/bsp/tmp");
    conf.set("bsp.disk.queue.dir", System.getProperty("user.dir") + "/bsp/diskQueue");
    conf.set("hama.disk.vertices.path", System.getProperty("user.dir") + "/bsp/graph");

    return new HamaConfiguration(conf);
}

From source file:org.kiji.mapreduce.tools.KijiJobHistory.java

License:Apache License

/**
 * Prints a representation of the Configuration for the Job.
 * @param data A row data containing a serialization of the configuraton.
 * @throws IOException If there is an error retrieving the configuration.
 *///from www  . j a  v  a2s .co  m
private void printConfiguration(KijiRowData data) throws IOException {
    OutputStreamWriter osw = null;
    try {
        PrintStream ps = getPrintStream();
        osw = new OutputStreamWriter(ps, "UTF-8");
        Configuration config = new Configuration();
        ByteBuffer configByteBuffer = data.getMostRecentValue("info", "configuration");
        config.readFields(new DataInputStream(new ByteArrayInputStream(configByteBuffer.array())));

        ps.print("Configuration:\n");
        Configuration.dumpConfiguration(config, osw);
        ps.print("\n");
    } finally {
        IOUtils.closeQuietly(osw);
    }
}

From source file:uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.AbstractGetRDDHandler.java

License:Apache License

protected Configuration getConfiguration(final GetOperation<?, ?> operation) throws OperationException {
    final Configuration conf = new Configuration();
    final String serialisedConf = operation.getOption(AbstractGetRDDHandler.HADOOP_CONFIGURATION_KEY);
    if (serialisedConf != null) {
        try {//from   w w  w.  java 2  s  .c o  m
            final ByteArrayInputStream bais = new ByteArrayInputStream(
                    serialisedConf.getBytes(CommonConstants.UTF_8));
            conf.readFields(new DataInputStream(bais));
        } catch (final IOException e) {
            throw new OperationException("Exception decoding Configuration from options", e);
        }
    }
    return conf;
}

From source file:uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.AbstractImportKeyValuePairRDDToAccumuloHandler.java

License:Apache License

protected Configuration getConfiguration(final T operation) throws OperationException {
    final Configuration conf = new Configuration();
    final String serialisedConf = operation.getOption(AbstractGetRDDHandler.HADOOP_CONFIGURATION_KEY);
    if (serialisedConf != null) {
        try {/* w  ww . j  a  va2 s  .  c om*/
            final ByteArrayInputStream bais = new ByteArrayInputStream(
                    serialisedConf.getBytes(CommonConstants.UTF_8));
            conf.readFields(new DataInputStream(bais));
        } catch (final IOException e) {
            throw new OperationException("Exception decoding Configuration from options", e);
        }
    }
    return conf;
}