List of usage examples for org.apache.hadoop.conf Configuration set
public void set(String name, String value)
value
of the name
property. From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtilTest.java
License:Apache License
/** * Loads a simple profile.//from w w w .ja v a 2 s . co m */ @Test public void loadProfiles_simple() { Configuration conf = new Configuration(); conf.set(key("root"), MockHadoopDataSource.class.getName()); conf.set(key("root", "path"), "/"); List<DirectDataSourceProfile> profiles = HadoopDataSourceUtil.loadProfiles(conf); assertThat(profiles.size(), is(1)); DirectDataSourceProfile profile = find(profiles, ""); assertThat(profile.getTargetClass(), equalTo((Object) MockHadoopDataSource.class)); assertThat(profile.getAttributes(), is(map())); }
From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtilTest.java
License:Apache License
/** * Loads a profile with path./* w ww. j a v a 2 s .c o m*/ */ @Test public void loadProfiles_path() { Configuration conf = new Configuration(); conf.set(key("root"), MockHadoopDataSource.class.getName()); conf.set(key("root", "path"), "example/path"); List<DirectDataSourceProfile> profiles = HadoopDataSourceUtil.loadProfiles(conf); assertThat(profiles.size(), is(1)); DirectDataSourceProfile profile = find(profiles, "example/path"); assertThat(profile.getTargetClass(), equalTo((Object) MockHadoopDataSource.class)); assertThat(profile.getAttributes(), is(map())); }
From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtilTest.java
License:Apache License
/** * Loads a profile with attributes.// w w w . j av a2s . c o m */ @Test public void loadProfiles_attribute() { Configuration conf = new Configuration(); conf.set(key("root"), MockHadoopDataSource.class.getName()); conf.set(key("root", "path"), "/"); conf.set(key("root", "hello1"), "world1"); conf.set(key("root", "hello2"), "world2"); conf.set(key("root", "hello3"), "world3"); List<DirectDataSourceProfile> profiles = HadoopDataSourceUtil.loadProfiles(conf); assertThat(profiles.size(), is(1)); DirectDataSourceProfile profile = find(profiles, ""); assertThat(profile.getTargetClass(), equalTo((Object) MockHadoopDataSource.class)); assertThat(profile.getAttributes(), is(map("hello1", "world1", "hello2", "world2", "hello3", "world3"))); }
From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtilTest.java
License:Apache License
/** * Loads multiple profiles./*from w w w . j a va2 s .c om*/ */ @Test public void loadProfiles_multiple() { Configuration conf = new Configuration(); conf.set(key("a"), MockHadoopDataSource.class.getName()); conf.set(key("a", "path"), "aaa"); conf.set(key("b"), MockHadoopDataSource.class.getName()); conf.set(key("b", "path"), "bbb"); conf.set(key("c"), MockHadoopDataSource.class.getName()); conf.set(key("c", "path"), "ccc"); List<DirectDataSourceProfile> profiles = HadoopDataSourceUtil.loadProfiles(conf); assertThat(profiles.size(), is(3)); DirectDataSourceProfile a = find(profiles, "aaa"); assertThat(a.getTargetClass(), equalTo((Object) MockHadoopDataSource.class)); assertThat(a.getAttributes(), is(map())); DirectDataSourceProfile b = find(profiles, "bbb"); assertThat(b.getTargetClass(), equalTo((Object) MockHadoopDataSource.class)); assertThat(b.getAttributes(), is(map())); DirectDataSourceProfile c = find(profiles, "ccc"); assertThat(c.getTargetClass(), equalTo((Object) MockHadoopDataSource.class)); assertThat(c.getAttributes(), is(map())); }
From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtilTest.java
License:Apache License
/** * create simple repository.// www . j a va2s .co m * @throws Exception if failed */ @Test public void loadRepository() throws Exception { Configuration conf = new Configuration(); conf.set(key("testing"), MockHadoopDataSource.class.getName()); conf.set(key("testing", "path"), "testing"); conf.set(key("testing", "hello"), "world"); DirectDataSourceRepository repo = HadoopDataSourceUtil.loadRepository(conf); DirectDataSource ds = repo.getRelatedDataSource("testing"); assertThat(ds, instanceOf(MockHadoopDataSource.class)); MockHadoopDataSource mock = (MockHadoopDataSource) ds; assertThat(mock.conf, is(notNullValue())); assertThat(mock.profile.getPath(), is("testing")); }
From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtilTest.java
License:Apache License
/** * Test for transaction info.//from w w w . j av a 2 s. c om * @throws Exception if failed */ @Test public void transactionInfo() throws Exception { Configuration conf = new Configuration(); conf.set(HadoopDataSourceUtil.KEY_SYSTEM_DIR, folder.getRoot().getAbsoluteFile().toURI().toString()); assertThat("empty system dir", folder.getRoot().listFiles(), is(new File[0])); assertThat(HadoopDataSourceUtil.findAllTransactionInfoFiles(conf).size(), is(0)); Path t1 = HadoopDataSourceUtil.getTransactionInfoPath(conf, "ex1"); assertThat(HadoopDataSourceUtil.getTransactionInfoExecutionId(t1), is("ex1")); t1.getFileSystem(conf).create(t1).close(); assertThat(folder.getRoot().listFiles().length, is(greaterThan(0))); Path t2 = HadoopDataSourceUtil.getTransactionInfoPath(conf, "ex2"); assertThat(t2, is(not(t1))); assertThat(HadoopDataSourceUtil.getTransactionInfoExecutionId(t2), is("ex2")); t2.getFileSystem(conf).create(t2).close(); Path c2 = HadoopDataSourceUtil.getCommitMarkPath(conf, "ex2"); assertThat(c2, is(not(t2))); c2.getFileSystem(conf).create(c2).close(); List<Path> paths = new ArrayList<>(); for (FileStatus stat : HadoopDataSourceUtil.findAllTransactionInfoFiles(conf)) { paths.add(stat.getPath()); } assertThat(paths.size(), is(2)); assertThat(paths, hasItem(t1)); assertThat(paths, hasItem(t2)); }
From source file:com.asakusafw.runtime.flow.RuntimeResourceManagerTest.java
License:Apache License
/** * setup single resource./* w w w.ja va2 s .c om*/ * @throws Exception if failed */ @Test public void setup() throws Exception { final AtomicInteger passed = new AtomicInteger(); Configuration conf = new Configuration(); conf.set("test", "OK"); RuntimeResourceManager manager = new RuntimeResourceManager(conf) { @Override protected List<RuntimeResource> load() throws IOException { return Arrays.<RuntimeResource>asList(new Adapter() { @Override public void setup(ResourceConfiguration configuration) { passed.incrementAndGet(); assertThat(configuration.get("test", null), is("OK")); } }); } }; manager.setup(); assertThat(passed.get(), is(1)); }
From source file:com.asakusafw.runtime.flow.RuntimeResourceManagerTest.java
License:Apache License
/** * setup multiple resources./* ww w .ja v a 2 s . co m*/ * @throws Exception if failed */ @Test public void setup_multi() throws Exception { final AtomicInteger passed = new AtomicInteger(); Configuration conf = new Configuration(); conf.set("test", "OK"); RuntimeResourceManager manager = new RuntimeResourceManager(conf) { @Override protected List<RuntimeResource> load() throws IOException { RuntimeResource adapter = new Adapter() { @Override public void setup(ResourceConfiguration configuration) { passed.addAndGet(1); assertThat(configuration.get("test", null), is("OK")); } }; return Arrays.asList(adapter, adapter, adapter); } }; manager.setup(); assertThat(passed.get(), is(3)); }
From source file:com.asakusafw.runtime.flow.RuntimeResourceManagerTest.java
License:Apache License
/** * cleanup single resource.// w ww.j a va 2 s. c o m * @throws Exception if failed */ @Test public void cleanup() throws Exception { final AtomicInteger passed = new AtomicInteger(); Configuration conf = new Configuration(); conf.set("test", "OK"); RuntimeResourceManager manager = new RuntimeResourceManager(conf) { @Override protected List<RuntimeResource> load() throws IOException { return Arrays.<RuntimeResource>asList(new Adapter() { @Override public void cleanup(ResourceConfiguration configuration) { passed.incrementAndGet(); assertThat(configuration.get("test", null), is("OK")); } }); } }; manager.setup(); assertThat(passed.get(), is(0)); manager.cleanup(); assertThat(passed.get(), is(1)); }
From source file:com.asakusafw.runtime.flow.RuntimeResourceManagerTest.java
License:Apache License
/** * cleanup multiple resources./* www . j a v a 2 s. c o m*/ * @throws Exception if failed */ @Test public void cleanup_multi() throws Exception { final AtomicInteger passed = new AtomicInteger(); Configuration conf = new Configuration(); conf.set("test", "OK"); RuntimeResourceManager manager = new RuntimeResourceManager(conf) { @Override protected List<RuntimeResource> load() throws IOException { RuntimeResource adapter = new Adapter() { @Override public void cleanup(ResourceConfiguration configuration) { passed.addAndGet(1); assertThat(configuration.get("test", null), is("OK")); } }; return Arrays.asList(adapter, adapter, adapter); } }; manager.setup(); manager.cleanup(); assertThat(passed.get(), is(3)); }