Search in sources :

Example 6 with StreamEntity

use of org.apache.gobblin.stream.StreamEntity in project incubator-gobblin by apache.

the class ConverterTest method testSingleOutputIterable.

@Test
public void testSingleOutputIterable() throws Exception {
    MyConverter converter = new MyConverter();
    BasicAckableForTesting ackable = new BasicAckableForTesting();
    RecordStreamWithMetadata<Integer, String> stream = new RecordStreamWithMetadata<>(Flowable.just(new RecordEnvelope<>(1)), GlobalMetadata.<String>builder().schema("schema").build()).mapRecords(r -> {
        r.addCallBack(ackable);
        return r;
    });
    List<StreamEntity<Integer>> outputRecords = Lists.newArrayList();
    converter.processStream(stream, new WorkUnitState()).getRecordStream().subscribe(outputRecords::add);
    Assert.assertEquals(outputRecords.size(), 1);
    // output record has not been acked
    Assert.assertEquals(ackable.acked, 0);
    outputRecords.get(0).ack();
    // output record acked
    Assert.assertEquals(ackable.acked, 1);
}
Also used : WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) StreamEntity(org.apache.gobblin.stream.StreamEntity) BasicAckableForTesting(org.apache.gobblin.ack.BasicAckableForTesting) Test(org.testng.annotations.Test)

Example 7 with StreamEntity

use of org.apache.gobblin.stream.StreamEntity in project incubator-gobblin by apache.

the class ConverterTest method testEmptyOutputIterable.

@Test
public void testEmptyOutputIterable() throws Exception {
    MyConverter converter = new MyConverter();
    BasicAckableForTesting ackable = new BasicAckableForTesting();
    RecordStreamWithMetadata<Integer, String> stream = new RecordStreamWithMetadata<>(Flowable.just(new RecordEnvelope<>(0)), GlobalMetadata.<String>builder().schema("schema").build()).mapRecords(r -> {
        r.addCallBack(ackable);
        return r;
    });
    List<StreamEntity<Integer>> outputRecords = Lists.newArrayList();
    converter.processStream(stream, new WorkUnitState()).getRecordStream().subscribe(outputRecords::add);
    Assert.assertEquals(outputRecords.size(), 0);
    // record got filtered, acked immediately
    Assert.assertEquals(ackable.acked, 1);
}
Also used : WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) StreamEntity(org.apache.gobblin.stream.StreamEntity) BasicAckableForTesting(org.apache.gobblin.ack.BasicAckableForTesting) Test(org.testng.annotations.Test)

Aggregations

StreamEntity (org.apache.gobblin.stream.StreamEntity)7 Test (org.testng.annotations.Test)6 BasicAckableForTesting (org.apache.gobblin.ack.BasicAckableForTesting)5 WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)5 RecordEnvelope (org.apache.gobblin.stream.RecordEnvelope)3 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1 IdentityForkOperator (org.apache.gobblin.fork.IdentityForkOperator)1 TaskPublisher (org.apache.gobblin.publisher.TaskPublisher)1 RowLevelPolicyChecker (org.apache.gobblin.qualitychecker.row.RowLevelPolicyChecker)1 TaskLevelPolicyCheckResults (org.apache.gobblin.qualitychecker.task.TaskLevelPolicyCheckResults)1 TaskLevelPolicyChecker (org.apache.gobblin.qualitychecker.task.TaskLevelPolicyChecker)1 RecordStreamWithMetadata (org.apache.gobblin.records.RecordStreamWithMetadata)1 BasicTestControlMessage (org.apache.gobblin.runtime.BasicTestControlMessage)1 ControlMessage (org.apache.gobblin.stream.ControlMessage)1 MetadataUpdateControlMessage (org.apache.gobblin.stream.MetadataUpdateControlMessage)1 Configuration (org.apache.hadoop.conf.Configuration)1