Search in sources :

Example 16 with FS

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;
}
Also used : AzkabanProjectConfig(org.apache.gobblin.service.modules.orchestration.AzkabanProjectConfig) SpecProducer(org.apache.gobblin.runtime.api.SpecProducer) FileSystem(org.apache.hadoop.fs.FileSystem) URISyntaxException(java.net.URISyntaxException) Test(org.testng.annotations.Test) FileStatus(org.apache.hadoop.fs.FileStatus) FlowGraphConfigurationKeys(org.apache.gobblin.service.modules.flowgraph.FlowGraphConfigurationKeys) GobblinConstructorUtils(org.apache.gobblin.util.reflection.GobblinConstructorUtils) Future(java.util.concurrent.Future) ConfigBuilder(org.apache.gobblin.config.ConfigBuilder) FlowEdgeFactory(org.apache.gobblin.service.modules.flowgraph.FlowEdgeFactory) Optional(com.google.common.base.Optional) Map(java.util.Map) Configuration(org.apache.hadoop.conf.Configuration) Path(org.apache.hadoop.fs.Path) CompletedFuture(org.apache.gobblin.util.CompletedFuture) PathUtils(org.apache.gobblin.util.PathUtils) URI(java.net.URI) ServiceConfigKeys(org.apache.gobblin.service.ServiceConfigKeys) RepositoryCache(org.eclipse.jgit.lib.RepositoryCache) FlowEdge(org.apache.gobblin.service.modules.flowgraph.FlowEdge) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) RefSpec(org.eclipse.jgit.transport.RefSpec) BeforeClass(org.testng.annotations.BeforeClass) Set(java.util.Set) AbstractSpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.AbstractSpecExecutor) Collectors(java.util.stream.Collectors) DataNode(org.apache.gobblin.service.modules.flowgraph.DataNode) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) FS(org.eclipse.jgit.util.FS) FSFlowTemplateCatalog(org.apache.gobblin.service.modules.template_catalog.FSFlowTemplateCatalog) Joiner(com.google.common.base.Joiner) FlowSpec(org.apache.gobblin.runtime.api.FlowSpec) PathFilter(org.apache.hadoop.fs.PathFilter) HashMap(java.util.HashMap) ConfigUtils(org.apache.gobblin.util.ConfigUtils) ArrayList(java.util.ArrayList) TopologySpec(org.apache.gobblin.runtime.api.TopologySpec) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) Charset(java.nio.charset.Charset) Assert(org.testng.Assert) JobSpec(org.apache.gobblin.runtime.api.JobSpec) Files(com.google.common.io.Files) ConfigFactory(com.typesafe.config.ConfigFactory) BaseFlowGraph(org.apache.gobblin.service.modules.flowgraph.BaseFlowGraph) Spec(org.apache.gobblin.runtime.api.Spec) AfterClass(org.testng.annotations.AfterClass) Charsets(com.google.common.base.Charsets) Properties(java.util.Properties) ConfigSyntax(com.typesafe.config.ConfigSyntax) Dag(org.apache.gobblin.service.modules.flowgraph.Dag) Config(com.typesafe.config.Config) SystemUtils(org.apache.commons.lang3.SystemUtils) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) ConfigurationKeys(org.apache.gobblin.configuration.ConfigurationKeys) InputStreamReader(java.io.InputStreamReader) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) ConfigurableGlobDatasetFinder(org.apache.gobblin.data.management.retention.profile.ConfigurableGlobDatasetFinder) FlowGraph(org.apache.gobblin.service.modules.flowgraph.FlowGraph) ConfigParseOptions(com.typesafe.config.ConfigParseOptions) DagNode(org.apache.gobblin.service.modules.flowgraph.Dag.DagNode) Git(org.eclipse.jgit.api.Git) Repository(org.eclipse.jgit.lib.Repository) JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) InputStream(java.io.InputStream) GitFlowGraphMonitor(org.apache.gobblin.service.modules.core.GitFlowGraphMonitor) Path(org.apache.hadoop.fs.Path) PathFilter(org.apache.hadoop.fs.PathFilter) FileStatus(org.apache.hadoop.fs.FileStatus) Configuration(org.apache.hadoop.conf.Configuration) HashMap(java.util.HashMap) AzkabanProjectConfig(org.apache.gobblin.service.modules.orchestration.AzkabanProjectConfig) Config(com.typesafe.config.Config) URI(java.net.URI) TopologySpec(org.apache.gobblin.runtime.api.TopologySpec) FileSystem(org.apache.hadoop.fs.FileSystem) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) AbstractSpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.AbstractSpecExecutor) BeforeClass(org.testng.annotations.BeforeClass) AfterClass(org.testng.annotations.AfterClass) File(java.io.File)

Aggregations

FS (org.eclipse.jgit.util.FS)16 File (java.io.File)9 JSch (com.jcraft.jsch.JSch)8 Session (com.jcraft.jsch.Session)7 Config (org.eclipse.jgit.lib.Config)6 FileBasedConfig (org.eclipse.jgit.storage.file.FileBasedConfig)6 JschConfigSessionFactory (org.eclipse.jgit.transport.JschConfigSessionFactory)6 IOException (java.io.IOException)5 TransportConfigCallback (org.eclipse.jgit.api.TransportConfigCallback)5 SshTransport (org.eclipse.jgit.transport.SshTransport)5 JSchException (com.jcraft.jsch.JSchException)4 SshSessionFactory (org.eclipse.jgit.transport.SshSessionFactory)4 UserInfo (com.jcraft.jsch.UserInfo)3 MockSystemReader (org.eclipse.jgit.junit.MockSystemReader)3 OpenSshConfig (org.eclipse.jgit.transport.OpenSshConfig)3 Transport (org.eclipse.jgit.transport.Transport)3 SystemReader (org.eclipse.jgit.util.SystemReader)3 DelegateSystemReader (com.google.gerrit.server.util.git.DelegateSystemReader)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2