Search in sources :

Example 6 with ArtifactSelectorConfig

use of co.cask.cdap.etl.proto.ArtifactSelectorConfig in project cdap by caskdata.

the class ETLBatchConfigTest method testUpgrade.

@Test
public void testUpgrade() throws Exception {
    final ArtifactSelectorConfig artifact = new ArtifactSelectorConfig("SYSTEM", "universal", "1.0.0");
    ETLStage source = new ETLStage("DataGenerator", ImmutableMap.of("p1", "v1"), null);
    co.cask.cdap.etl.proto.v1.ETLStage sourceNew = new co.cask.cdap.etl.proto.v1.ETLStage("DataGenerator.1", new Plugin(source.getName(), source.getProperties(), artifact), source.getErrorDatasetName());
    ETLStage transform1 = new ETLStage("Script", ImmutableMap.of("script", "something"), null);
    co.cask.cdap.etl.proto.v1.ETLStage transform1New = new co.cask.cdap.etl.proto.v1.ETLStage("Script.2", new Plugin(transform1.getName(), transform1.getProperties(), artifact), transform1.getErrorDatasetName());
    ETLStage transform2 = new ETLStage("Script", null, null);
    co.cask.cdap.etl.proto.v1.ETLStage transform2New = new co.cask.cdap.etl.proto.v1.ETLStage("Script.3", new Plugin(transform2.getName(), transform2.getProperties(), artifact), transform2.getErrorDatasetName());
    ETLStage transform3 = new ETLStage("Validator", ImmutableMap.of("p1", "v1", "p2", "v2"), "errorDS");
    co.cask.cdap.etl.proto.v1.ETLStage transform3New = new co.cask.cdap.etl.proto.v1.ETLStage("Validator.4", new Plugin(transform3.getName(), transform3.getProperties(), artifact), transform3.getErrorDatasetName());
    ETLStage sink1 = new ETLStage("Table", ImmutableMap.of("rowkey", "xyz"), null);
    co.cask.cdap.etl.proto.v1.ETLStage sink1New = new co.cask.cdap.etl.proto.v1.ETLStage("Table.5", new Plugin(sink1.getName(), sink1.getProperties(), artifact), sink1.getErrorDatasetName());
    ETLStage sink2 = new ETLStage("HDFS", ImmutableMap.of("name", "abc"), null);
    co.cask.cdap.etl.proto.v1.ETLStage sink2New = new co.cask.cdap.etl.proto.v1.ETLStage("HDFS.6", new Plugin(sink2.getName(), sink2.getProperties(), artifact), sink2.getErrorDatasetName());
    ETLStage action = new ETLStage("Email", ImmutableMap.of("email", "slj@example.com"), null);
    co.cask.cdap.etl.proto.v1.ETLStage actionNew = new co.cask.cdap.etl.proto.v1.ETLStage("Email.1", new Plugin(action.getName(), action.getProperties(), artifact), action.getErrorDatasetName());
    List<Connection> connections = new ArrayList<>();
    connections.add(new Connection(sourceNew.getName(), transform1New.getName()));
    connections.add(new Connection(transform1New.getName(), transform2New.getName()));
    connections.add(new Connection(transform2New.getName(), transform3New.getName()));
    connections.add(new Connection(transform3New.getName(), sink1New.getName()));
    connections.add(new Connection(transform3New.getName(), sink2New.getName()));
    String schedule = "*/5 * * * *";
    Resources resources = new Resources(1024, 1);
    ETLBatchConfig config = new ETLBatchConfig(schedule, source, ImmutableList.of(sink1, sink2), ImmutableList.of(transform1, transform2, transform3), resources, ImmutableList.of(action));
    co.cask.cdap.etl.proto.v1.ETLBatchConfig configNew = co.cask.cdap.etl.proto.v1.ETLBatchConfig.builder(schedule).setSource(sourceNew).addSink(sink1New).addSink(sink2New).addTransform(transform1New).addTransform(transform2New).addTransform(transform3New).addConnections(connections).setResources(resources).setDriverResources(resources).addAction(actionNew).build();
    Assert.assertEquals(configNew, config.upgrade(new UpgradeContext() {

        @Nullable
        @Override
        public ArtifactSelectorConfig getPluginArtifact(String pluginType, String pluginName) {
            return new ArtifactSelectorConfig(ArtifactScope.SYSTEM.name(), "universal", "1.0.0");
        }
    }));
}
Also used : ArtifactSelectorConfig(co.cask.cdap.etl.proto.ArtifactSelectorConfig) ArrayList(java.util.ArrayList) Connection(co.cask.cdap.etl.proto.Connection) UpgradeContext(co.cask.cdap.etl.proto.UpgradeContext) Resources(co.cask.cdap.api.Resources) Plugin(co.cask.cdap.etl.proto.v1.Plugin) Test(org.junit.Test)

Example 7 with ArtifactSelectorConfig

use of co.cask.cdap.etl.proto.ArtifactSelectorConfig in project cdap by caskdata.

the class ETLStage method upgradeStage.

public co.cask.cdap.etl.proto.v2.ETLStage upgradeStage(String type, UpgradeContext upgradeContext) {
    ArtifactSelectorConfig artifactSelectorConfig = upgradeContext.getPluginArtifact(type, plugin.getName());
    if (artifactSelectorConfig == null) {
        artifactSelectorConfig = plugin.getArtifact();
    }
    co.cask.cdap.etl.proto.v2.ETLPlugin etlPlugin = new co.cask.cdap.etl.proto.v2.ETLPlugin(plugin.getName(), type, plugin.getProperties(), artifactSelectorConfig);
    return new co.cask.cdap.etl.proto.v2.ETLStage(name, etlPlugin, errorDatasetName);
}
Also used : ArtifactSelectorConfig(co.cask.cdap.etl.proto.ArtifactSelectorConfig)

Example 8 with ArtifactSelectorConfig

use of co.cask.cdap.etl.proto.ArtifactSelectorConfig in project cdap by caskdata.

the class ETLStage method upgradeStage.

// used by UpgradeTool to upgrade a 3.4.x stage to 3.5.x, which may include an update of the plugin artifact
public ETLStage upgradeStage(UpgradeContext upgradeContext) {
    ArtifactSelectorConfig artifactSelectorConfig = upgradeContext.getPluginArtifact(plugin.getType(), plugin.getName());
    co.cask.cdap.etl.proto.v2.ETLPlugin etlPlugin = new co.cask.cdap.etl.proto.v2.ETLPlugin(plugin.getName(), plugin.getType(), plugin.getProperties(), artifactSelectorConfig);
    return new co.cask.cdap.etl.proto.v2.ETLStage(name, etlPlugin, errorDatasetName);
}
Also used : ArtifactSelectorConfig(co.cask.cdap.etl.proto.ArtifactSelectorConfig)

Example 9 with ArtifactSelectorConfig

use of co.cask.cdap.etl.proto.ArtifactSelectorConfig in project cdap by caskdata.

the class ArtifactSelectorProviderTest method testInvalidVersion.

@Test(expected = IllegalArgumentException.class)
public void testInvalidVersion() {
    ArtifactSelectorConfig config = new ArtifactSelectorConfig(ArtifactScope.USER.name(), "abc", "abc");
    PROVIDER.getPluginSelector(config);
}
Also used : ArtifactSelectorConfig(co.cask.cdap.etl.proto.ArtifactSelectorConfig) Test(org.junit.Test)

Example 10 with ArtifactSelectorConfig

use of co.cask.cdap.etl.proto.ArtifactSelectorConfig in project cdap by caskdata.

the class ArtifactSelectorProviderTest method testInvalidScope.

@Test(expected = IllegalArgumentException.class)
public void testInvalidScope() {
    ArtifactSelectorConfig config = new ArtifactSelectorConfig("usr", "abc", "1.0.0");
    PROVIDER.getPluginSelector(config);
}
Also used : ArtifactSelectorConfig(co.cask.cdap.etl.proto.ArtifactSelectorConfig) Test(org.junit.Test)

Aggregations

ArtifactSelectorConfig (co.cask.cdap.etl.proto.ArtifactSelectorConfig)10 Test (org.junit.Test)6 Resources (co.cask.cdap.api.Resources)3 Connection (co.cask.cdap.etl.proto.Connection)3 UpgradeContext (co.cask.cdap.etl.proto.UpgradeContext)3 Plugin (co.cask.cdap.etl.proto.v1.Plugin)2 ETLPlugin (co.cask.cdap.etl.proto.v2.ETLPlugin)2 HashSet (java.util.HashSet)2 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)1 PluginInfo (co.cask.cdap.proto.artifact.PluginInfo)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1