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

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

Introduction

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

Prototype

public void set(String name, String value) 

Source Link

Document

Set the value of the name property.

Usage

From source file:com.alibaba.wasp.zookeeper.ZKUtil.java

License:Apache License

/**
 * Apply the settings in the given key to the given configuration, this is
 * used to communicate with distant clusters
 *
 * @param conf//  w  ww.j a v  a2  s  . c  om
 *          configuration object to configure
 * @param key
 *          string that contains the 3 required configuratins
 * @throws java.io.IOException
 */
public static void applyClusterKeyToConf(Configuration conf, String key) throws IOException {
    String[] parts = transformClusterKey(key);
    conf.set(HConstants.ZOOKEEPER_QUORUM, parts[0]);
    conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, parts[1]);
    conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, parts[2]);
}

From source file:com.aliyun.fs.oss.AliyunOSSTestUtils.java

License:Apache License

/**
 * Create the test filesystem.//from   w w w. j a v a2  s.  co  m
 *
 * If the test.fs.oss.name property is not set,
 * tests will fail.
 *
 * @param conf configuration
 * @return the FS
 * @throws IOException
 */
public static NativeOssFileSystem createTestFileSystem(Configuration conf) throws IOException {
    String fsname = conf.getTrimmed(TestAliyunOSSFileSystemContract.TEST_FS_OSS_NAME, "");

    boolean liveTest = StringUtils.isNotEmpty(fsname);
    URI testURI = null;
    if (liveTest) {
        testURI = URI.create(fsname);
        liveTest = testURI.getScheme().equals("oss");
    }

    if (!liveTest) {
        throw new AssumptionViolatedException(
                "No test filesystem in " + TestAliyunOSSFileSystemContract.TEST_FS_OSS_NAME);
    }
    conf.set("mapreduce.job.run-local", "true");
    conf.set("fs.oss.buffer.dirs", "/tmp");
    NativeOssFileSystem ossfs = new NativeOssFileSystem();
    ossfs.initialize(testURI, conf);
    return ossfs;
}

From source file:com.aliyun.fs.oss.TestAliyunOSSBlockOutputStream.java

License:Apache License

@Before
public void setUp() throws Exception {
    Configuration conf = new Configuration();
    conf.set("mapreduce.job.run-local", "true");
    conf.set("fs.oss.buffer.dirs", "/tmp");
    conf.setLong("fs.oss.local.block.size", 5 * 1024 * 1024);
    fs = AliyunOSSTestUtils.createTestFileSystem(conf);
}

From source file:com.aliyun.fs.oss.TestAliyunOSSFileSystemContract.java

License:Apache License

@Before
public void setUp() throws Exception {
    Configuration conf = new Configuration();
    conf.set("mapreduce.job.run-local", "true");
    conf.set("fs.oss.buffer.dirs", "/tmp");
    fs = AliyunOSSTestUtils.createTestFileSystem(conf);
    assumeNotNull(fs);/*from  ww  w.  j  av a 2 s  .c om*/
}

From source file:com.aliyun.fs.oss.TestAliyunOSSInputStream.java

License:Apache License

@Before
public void setUp() throws Exception {
    Configuration conf = new Configuration();
    conf.set("mapreduce.job.run-local", "true");
    conf.set("fs.oss.buffer.dirs", "/tmp");
    fs = AliyunOSSTestUtils.createTestFileSystem(conf);
}

From source file:com.aliyun.openservices.tablestore.hadoop.TableStore.java

License:Apache License

/**
 * Set credential(access-key id/secret and security token) into a Configuration.
 *///from   w w w .  j ava2 s.co  m
public static void setCredential(Configuration conf, Credential cred) {
    Preconditions.checkNotNull(conf, "conf must be nonnull");
    Preconditions.checkNotNull(cred, "cred must be nonnull");
    conf.set(CREDENTIAL, cred.serialize());
}

From source file:com.aliyun.openservices.tablestore.hadoop.TableStore.java

License:Apache License

/**
 * Set an endpoint(with/without instance name) into a Configuration.
 *///from   w w w. j  av a 2 s .c  o m
public static void setEndpoint(Configuration conf, Endpoint ep) {
    Preconditions.checkNotNull(conf, "conf must be nonnull");
    Preconditions.checkNotNull(ep, "ep must be nonnull");
    conf.set(ENDPOINT, ep.serialize());
}

From source file:com.aliyun.openservices.tablestore.hadoop.TableStoreInputFormat.java

License:Apache License

/**
 * Add a RangeRowQueryCriteria object as data source.
 *//*from   www .j a va2s . co m*/
public static void addCriteria(Configuration conf, RangeRowQueryCriteria criteria) {
    Preconditions.checkNotNull(criteria, "criteria must be nonnull");
    Preconditions.checkArgument(criteria.getDirection() == Direction.FORWARD, "criteria must be forward");
    String cur = conf.get(CRITERIA);
    MultiCriteria cri = null;
    if (cur == null) {
        cri = new MultiCriteria();
    } else {
        cri = MultiCriteria.deserialize(cur);
    }
    cri.addCriteria(criteria);
    conf.set(CRITERIA, cri.serialize());
}

From source file:com.aliyun.openservices.tablestore.hadoop.TableStoreOutputFormat.java

License:Apache License

/**
 * Set a table in TableStore as data sink.
 *//*from   w  ww  . j  ava 2  s  .co  m*/
public static void setOutputTable(Configuration conf, String outputTable) {
    Preconditions.checkNotNull(outputTable, "Output table must be nonnull.");
    conf.set(OUTPUT_TABLE, outputTable);
}

From source file:com.ambiata.ivory.operation.hadoop.MultipleInputs.java

License:Apache License

/**
 * Add a {@link Path} with a custom {@link InputFormat} to the list of
 * inputs for the map-reduce job./*from   w  w  w.ja  v a 2 s  .  c om*/
 *
 * @param job The {@link Job}
 * @param path {@link Path} to be added to the list of inputs for the job
 * @param inputFormatClass {@link InputFormat} class to use for this path
 */
@SuppressWarnings("unchecked")
public static void addInputPath(Job job, Path path, Class<? extends InputFormat> inputFormatClass) {
    /* WAS not encoded */
    String inputFormatMapping = encode(path.toString() + ";" + inputFormatClass.getName());
    Configuration conf = job.getConfiguration();
    String inputFormats = conf.get(DIR_FORMATS);
    conf.set(DIR_FORMATS, inputFormats == null ? inputFormatMapping : inputFormats + "," + inputFormatMapping);

    job.setInputFormatClass(DelegatingInputFormat.class);
}