Search in sources :

Example 11 with TopologySpec

use of org.apache.gobblin.runtime.api.TopologySpec in project incubator-gobblin by apache.

the class OrchestratorTest method initTopologySpec.

private TopologySpec initTopologySpec() {
    Properties properties = new Properties();
    properties.put("specStore.fs.dir", TOPOLOGY_SPEC_STORE_DIR);
    properties.put("specExecInstance.capabilities", "source:destination");
    Config config = ConfigUtils.propertiesToConfig(properties);
    SpecExecutor specExecutorInstance = new InMemorySpecExecutor(config);
    TopologySpec.Builder topologySpecBuilder = TopologySpec.builder(computeTopologySpecURI(SPEC_STORE_PARENT_DIR, TOPOLOGY_SPEC_STORE_DIR)).withConfig(config).withDescription(SPEC_DESCRIPTION).withVersion(SPEC_VERSION).withSpecExecutor(specExecutorInstance);
    return topologySpecBuilder.build();
}
Also used : Config(com.typesafe.config.Config) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) InMemorySpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.InMemorySpecExecutor) Properties(java.util.Properties) InMemorySpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.InMemorySpecExecutor) TopologySpec(org.apache.gobblin.runtime.api.TopologySpec)

Example 12 with TopologySpec

use of org.apache.gobblin.runtime.api.TopologySpec in project incubator-gobblin by apache.

the class ConfigBasedTopologySpecFactoryTest method testGetTopologies.

@Test
public void testGetTopologies() {
    Collection<TopologySpec> topologySpecs = _configBasedTopologySpecFactory.getTopologies();
    Assert.assertTrue(topologySpecs.size() == 2, "Expected 2 topologies but received: " + topologySpecs.size());
    Iterator<TopologySpec> topologySpecIterator = topologySpecs.iterator();
    TopologySpec topologySpec1 = topologySpecIterator.next();
    Assert.assertTrue(topologySpec1.getDescription().equals("Topology for cluster"), "Description did not match with construction");
    Assert.assertTrue(topologySpec1.getVersion().equals("1"), "Version did not match with construction");
    TopologySpec topologySpec2 = topologySpecIterator.next();
    Assert.assertTrue(topologySpec2.getDescription().equals("Topology for Azkaban"), "Description did not match with construction");
    Assert.assertTrue(topologySpec2.getVersion().equals("2"), "Version did not match with construction");
}
Also used : TopologySpec(org.apache.gobblin.runtime.api.TopologySpec) Test(org.testng.annotations.Test)

Example 13 with TopologySpec

use of org.apache.gobblin.runtime.api.TopologySpec in project incubator-gobblin by apache.

the class ConfigBasedTopologySpecFactory method getTopologies.

@Override
public Collection<TopologySpec> getTopologies() {
    if (!_config.hasPath(ServiceConfigKeys.TOPOLOGY_FACTORY_TOPOLOGY_NAMES_KEY)) {
        return Collections.EMPTY_LIST;
    }
    Collection<TopologySpec> topologySpecs = Lists.newArrayList();
    Collection<String> topologyNames = SPLIT_BY_COMMA.splitToList(_config.getString(ServiceConfigKeys.TOPOLOGY_FACTORY_TOPOLOGY_NAMES_KEY));
    for (String topologyName : topologyNames) {
        Preconditions.checkArgument(_config.hasPath(ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + topologyName), "Config does not contain Topology Factory descriptor for Topology " + topologyName);
        Config topologyConfig = _config.getConfig(ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + topologyName);
        String description = ConfigUtils.getString(topologyConfig, ServiceConfigKeys.TOPOLOGYSPEC_DESCRIPTION_KEY, "NA");
        String version = ConfigUtils.getString(topologyConfig, ServiceConfigKeys.TOPOLOGYSPEC_VERSION_KEY, "-1");
        String specExecutorClass = ServiceConfigKeys.DEFAULT_SPEC_EXECUTOR;
        if (topologyConfig.hasPath(ServiceConfigKeys.SPEC_EXECUTOR_KEY)) {
            specExecutorClass = topologyConfig.getString(ServiceConfigKeys.SPEC_EXECUTOR_KEY);
        }
        SpecExecutor specExecutor;
        try {
            _log.info("Using SpecProducer class name/alias " + specExecutorClass);
            specExecutor = (SpecExecutor) ConstructorUtils.invokeConstructor(Class.forName(_aliasResolver.resolve(specExecutorClass)), topologyConfig);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        TopologySpec.Builder topologySpecBuilder = TopologySpec.builder(topologyConfig.getString(ServiceConfigKeys.TOPOLOGYSPEC_URI_KEY)).withConfig(topologyConfig).withDescription(description).withVersion(version).withSpecExecutor(specExecutor);
        topologySpecs.add(topologySpecBuilder.build());
    }
    return topologySpecs;
}
Also used : Config(com.typesafe.config.Config) TopologySpec(org.apache.gobblin.runtime.api.TopologySpec) InvocationTargetException(java.lang.reflect.InvocationTargetException) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor)

Example 14 with TopologySpec

use of org.apache.gobblin.runtime.api.TopologySpec in project incubator-gobblin by apache.

the class TopologyCatalogTest method initTopologySpec.

private TopologySpec initTopologySpec() {
    Properties properties = new Properties();
    properties.put("specStore.fs.dir", SPEC_STORE_DIR);
    properties.put("specExecInstance.capabilities", "source:destination");
    Config config = ConfigUtils.propertiesToConfig(properties);
    SpecExecutor specExecutorInstanceProducer = new InMemorySpecExecutor(config);
    TopologySpec.Builder topologySpecBuilder = TopologySpec.builder(computeTopologySpecURI()).withConfig(config).withDescription(SPEC_DESCRIPTION).withVersion(SPEC_VERSION).withSpecExecutor(specExecutorInstanceProducer);
    return topologySpecBuilder.build();
}
Also used : Config(com.typesafe.config.Config) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) InMemorySpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.InMemorySpecExecutor) Properties(java.util.Properties) InMemorySpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.InMemorySpecExecutor) TopologySpec(org.apache.gobblin.runtime.api.TopologySpec)

Example 15 with TopologySpec

use of org.apache.gobblin.runtime.api.TopologySpec in project incubator-gobblin by apache.

the class TopologyCatalogTest method createTopologySpec.

@Test
public void createTopologySpec() {
    // List Current Specs
    Collection<Spec> specs = topologyCatalog.getSpecs();
    logger.info("[Before Create] Number of specs: " + specs.size());
    int i = 0;
    for (Spec spec : specs) {
        TopologySpec topologySpec = (TopologySpec) spec;
        logger.info("[Before Create] Spec " + i++ + ": " + gson.toJson(topologySpec));
    }
    Assert.assertTrue(specs.size() == 0, "Spec store should be empty before addition");
    // Create and add Spec
    this.topologyCatalog.put(topologySpec);
    // List Specs after adding
    specs = topologyCatalog.getSpecs();
    logger.info("[After Create] Number of specs: " + specs.size());
    i = 0;
    for (Spec spec : specs) {
        topologySpec = (TopologySpec) spec;
        logger.info("[After Create] Spec " + i++ + ": " + gson.toJson(topologySpec));
    }
    Assert.assertTrue(specs.size() == 1, "Spec store should contain 1 Spec after addition");
}
Also used : TopologySpec(org.apache.gobblin.runtime.api.TopologySpec) Spec(org.apache.gobblin.runtime.api.Spec) FlowSpec(org.apache.gobblin.runtime.api.FlowSpec) TopologySpec(org.apache.gobblin.runtime.api.TopologySpec) Test(org.testng.annotations.Test)

Aggregations

TopologySpec (org.apache.gobblin.runtime.api.TopologySpec)15 FlowSpec (org.apache.gobblin.runtime.api.FlowSpec)7 Test (org.testng.annotations.Test)7 SpecExecutor (org.apache.gobblin.runtime.api.SpecExecutor)6 Config (com.typesafe.config.Config)5 Properties (java.util.Properties)5 Spec (org.apache.gobblin.runtime.api.Spec)4 InMemorySpecExecutor (org.apache.gobblin.runtime.spec_executorInstance.InMemorySpecExecutor)4 FlowEdge (org.apache.gobblin.runtime.api.FlowEdge)3 ServiceNode (org.apache.gobblin.runtime.api.ServiceNode)3 Map (java.util.Map)2 LoadBasedFlowEdgeImpl (org.apache.gobblin.service.modules.flow.LoadBasedFlowEdgeImpl)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ExecutionException (java.util.concurrent.ExecutionException)1 JobSpec (org.apache.gobblin.runtime.api.JobSpec)1 IdentityFlowToJobSpecCompiler (org.apache.gobblin.service.modules.flow.IdentityFlowToJobSpecCompiler)1 MultiHopsFlowToJobSpecCompiler (org.apache.gobblin.service.modules.flow.MultiHopsFlowToJobSpecCompiler)1 ControllerChangeListener (org.apache.helix.ControllerChangeListener)1 NotificationContext (org.apache.helix.NotificationContext)1