use of co.cask.cdap.etl.proto.v2.ETLRealtimeConfig in project cdap by caskdata.
the class ETLRealtimeApplication method configure.
@Override
public void configure() {
ETLRealtimeConfig config = getConfig().convertOldConfig();
setDescription(DEFAULT_DESCRIPTION);
addWorker(new ETLWorker(config));
createDataset(STATE_TABLE, KeyValueTable.class, DatasetProperties.EMPTY);
}
use of co.cask.cdap.etl.proto.v2.ETLRealtimeConfig in project cdap by caskdata.
the class ETLWorkerTest method testDAG.
@Test
public void testDAG() throws Exception {
Schema schema = Schema.recordOf("testRecord", Schema.Field.of("x", Schema.of(Schema.Type.INT)));
StructuredRecord record1 = StructuredRecord.builder(schema).set("x", 1).build();
StructuredRecord record2 = StructuredRecord.builder(schema).set("x", 2).build();
StructuredRecord record3 = StructuredRecord.builder(schema).set("x", 3).build();
List<StructuredRecord> input = ImmutableList.of(record1, record2, record3);
/*
* ----- value filter ------- sink1
* |
* source --------- double --------
* | |---- sink2
* ----- identity ------
*/
File sink1Out = TMP_FOLDER.newFolder();
File sink2Out = TMP_FOLDER.newFolder();
ETLRealtimeConfig etlConfig = ETLRealtimeConfig.builder().addStage(new ETLStage("source", MockSource.getPlugin(input))).addStage(new ETLStage("sink1", MockSink.getPlugin(sink1Out))).addStage(new ETLStage("sink2", MockSink.getPlugin(sink2Out))).addStage(new ETLStage("valueFilter", IntValueFilterTransform.getPlugin("x", 2))).addStage(new ETLStage("double", DoubleTransform.getPlugin())).addStage(new ETLStage("identity", IdentityTransform.getPlugin())).addConnection("source", "valueFilter").addConnection("source", "double").addConnection("source", "identity").addConnection("valueFilter", "sink1").addConnection("double", "sink2").addConnection("identity", "sink2").build();
ApplicationId appId = NamespaceId.DEFAULT.app("dagTest");
AppRequest<ETLRealtimeConfig> appRequest = new AppRequest<>(APP_ARTIFACT, etlConfig);
ApplicationManager appManager = deployApplication(appId, appRequest);
Assert.assertNotNull(appManager);
WorkerManager workerManager = appManager.getWorkerManager(ETLWorker.NAME);
workerManager.start();
workerManager.waitForStatus(true, 10, 1);
try {
List<StructuredRecord> sink1output = MockSink.getRecords(sink1Out, 0, 10, TimeUnit.SECONDS);
List<StructuredRecord> sink1expected = ImmutableList.of(record1, record3);
Assert.assertEquals(sink1expected, sink1output);
List<StructuredRecord> sink2output = MockSink.getRecords(sink2Out, 0, 10, TimeUnit.SECONDS);
Assert.assertEquals(9, sink2output.size());
} finally {
stopWorker(workerManager);
}
validateMetric(3, appId, "source.records.out");
validateMetric(3, appId, "valueFilter.records.in");
validateMetric(2, appId, "valueFilter.records.out");
validateMetric(3, appId, "double.records.in");
validateMetric(6, appId, "double.records.out");
validateMetric(3, appId, "identity.records.in");
validateMetric(3, appId, "identity.records.out");
validateMetric(2, appId, "sink1.records.in");
validateMetric(9, appId, "sink2.records.in");
}
Aggregations