use of org.eclipse.jgit.util.FS in project incubator-gobblin by apache.
the class MultiHopFlowCompilerTest method buildTopologySpecMap.
/**
* A helper method to return a {@link TopologySpec} map, given a {@link org.apache.gobblin.runtime.spec_catalog.TopologyCatalog}.
* @param topologyCatalogUri pointing to the location of the {@link org.apache.gobblin.runtime.spec_catalog.TopologyCatalog}
* @return a {@link TopologySpec} map.
*/
public static Map<URI, TopologySpec> buildTopologySpecMap(URI topologyCatalogUri) throws IOException, URISyntaxException, ReflectiveOperationException {
FileSystem fs = FileSystem.get(topologyCatalogUri, new Configuration());
PathFilter extensionFilter = file -> {
for (String extension : Lists.newArrayList(".properties")) {
if (file.getName().endsWith(extension)) {
return true;
}
}
return false;
};
Map<URI, TopologySpec> topologySpecMap = new HashMap<>();
for (FileStatus fileStatus : fs.listStatus(new Path(topologyCatalogUri.getPath()), extensionFilter)) {
URI topologySpecUri = new URI(Files.getNameWithoutExtension(fileStatus.getPath().getName()));
Config topologyConfig = ConfigFactory.parseFile(new File(PathUtils.getPathWithoutSchemeAndAuthority(fileStatus.getPath()).toString()));
Class specExecutorClass = Class.forName(topologyConfig.getString(ServiceConfigKeys.SPEC_EXECUTOR_KEY));
SpecExecutor specExecutor = (SpecExecutor) GobblinConstructorUtils.invokeLongestConstructor(specExecutorClass, topologyConfig);
TopologySpec.Builder topologySpecBuilder = TopologySpec.builder(topologySpecUri).withConfig(topologyConfig).withDescription("").withVersion("1").withSpecExecutor(specExecutor);
TopologySpec topologySpec = topologySpecBuilder.build();
topologySpecMap.put(topologySpecUri, topologySpec);
}
return topologySpecMap;
}
Aggregations