@Override public String getPath() { return profile.getPath(); }
private DirectDataSourceProfile find(List<DirectDataSourceProfile> profiles, String path) { for (DirectDataSourceProfile p : profiles) { if (p.getPath().equals(path)) { return p; } } throw new AssertionError(path); }
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)); }
@Override public void configure(DirectDataSourceProfile profile) throws IOException, InterruptedException { if (conf == null) { throw new IllegalStateException(); } if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Start configuring Hadoop data source (id={0}, path={1})", //$NON-NLS-1$ profile.getId(), profile.getPath())); } HadoopDataSourceProfile hProfile = HadoopDataSourceProfile.convert(profile, conf); this.core = new HadoopDataSourceCore(hProfile); if (hProfile.getKeepAliveInterval() > 0) { this.core = new KeepAliveDataSource(core, hProfile.getKeepAliveInterval()); } if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Finish configuring Hadoop data source: {0}", //$NON-NLS-1$ hProfile)); } }
"The directio configuration \"{0} ({1})\" does not have \"{2}\"", profile.getId(), profile.getPath().isEmpty() ? ROOT_REPRESENTATION : profile.getPath(), fqn(profile, KEY_PATH))); HadoopDataSourceProfile result = new HadoopDataSourceProfile( conf, profile.getId(), profile.getPath(), fsPath, tempPath); long minFragment = takeMinFragment(profile, attributes, conf);
/** * create simple repository. * @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")); }