static void print(PrintWriter writer, DirectDataSourceProfile profile, int indent) { writer.printf("%sID: %s%n", indent(indent), profile.getId()); writer.printf("%sbase-path: %s%n", indent(indent), BasePath.of(profile.getPath())); writer.printf("%sclass: %s%n", indent(indent), profile.getTargetClass().getName()); writer.printf("%sattributes:%n", indent(indent)); profile.getAttributes().forEach((k, v) -> writer.printf("%s- %s: %s%n", indent(indent), k, v)); }
/** * Loads a simple profile. */ @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())); }
throw new IllegalArgumentException("conf must not be null"); //$NON-NLS-1$ Map<String, String> attributes = new HashMap<>(profile.getAttributes()); Path fsPath = takeFsPath(profile, attributes, conf); if (fsPath == null) {
/** * Loads a profile with path. */ @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())); }
/** * Loads a profile with attributes. */ @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"))); }
/** * Loads multiple profiles. */ @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())); }