com.amazonaws.services.kinesis.connectors.interfaces.ITransformer Java Examples

The following examples show how to use com.amazonaws.services.kinesis.connectors.interfaces.ITransformer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KinesisConnectorRecordProcessorTests.java    From amazon-kinesis-connectors with Apache License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings("unchecked")
public void setUp() {
    // control object used to create mock dependencies
    control = EasyMock.createControl();

    // mock dependencies
    emitter = control.createMock(IEmitter.class);
    transformer = control.createMock(ITransformer.class);
    buffer = control.createMock(IBuffer.class);
    filter = control.createMock(IFilter.class);
    checkpointer = control.createMock(IRecordProcessorCheckpointer.class);
    // use a real configuration to get actual default values (not anything created by EasyMock)
    configuration = new KinesisConnectorConfiguration(new Properties(), new DefaultAWSCredentialsProviderChain());

}
 
Example #2
Source File: KinesisConnectorRecordProcessor.java    From amazon-kinesis-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public void processRecords(List<Record> records, IRecordProcessorCheckpointer checkpointer) {
    // Note: This method will be called even for empty record lists. This is needed for checking the buffer time
    // threshold.
    if (isShutdown) {
        LOG.warn("processRecords called on shutdown record processor for shardId: " + shardId);
        return;
    }
    if (shardId == null) {
        throw new IllegalStateException("Record processor not initialized");
    }

    // Transform each Amazon Kinesis Record and add the result to the buffer
    for (Record record : records) {
        try {
            if (transformer instanceof ITransformer) {
                ITransformer<T, U> singleTransformer = (ITransformer<T, U>) transformer;
                filterAndBufferRecord(singleTransformer.toClass(record), record);
            } else if (transformer instanceof ICollectionTransformer) {
                ICollectionTransformer<T, U> listTransformer = (ICollectionTransformer<T, U>) transformer;
                Collection<T> transformedRecords = listTransformer.toClass(record);
                for (T transformedRecord : transformedRecords) {
                    filterAndBufferRecord(transformedRecord, record);
                }
            } else {
                throw new RuntimeException("Transformer must implement ITransformer or ICollectionTransformer");
            }
        } catch (IOException e) {
            LOG.error(e);
        }
    }

    if (buffer.shouldFlush()) {
        List<U> emitItems = transformToOutput(buffer.getRecords());
        emit(checkpointer, emitItems);
    }
}
 
Example #3
Source File: DynamoDBMasterToReplicasPipeline.java    From dynamodb-cross-region-library with Apache License 2.0 4 votes vote down vote up
@Override
public ITransformer<Record, Record> getTransformer(final KinesisConnectorConfiguration configuration) {
    return new DynamoDBStreamsRecordTransformer();
}
 
Example #4
Source File: HBasePipeline.java    From aws-big-data-blog with Apache License 2.0 4 votes vote down vote up
@Override
public ITransformer<KinesisMessageModel, Map<String,String>> getTransformer(KinesisConnectorConfiguration configuration) {
    return new KinesisMessageModelHBaseTransformer();
}
 
Example #5
Source File: S3ManifestPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ITransformer<KinesisMessageModel, byte[]> getTransformer(KinesisConnectorConfiguration configuration) {
    return new KinesisMessageModelRedshiftTransformer(configuration);
}
 
Example #6
Source File: RedshiftManifestPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ITransformer<String, String> getTransformer(KinesisConnectorConfiguration configuration) {
    return new StringToStringTransformer();
}
 
Example #7
Source File: RedshiftBasicPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ITransformer<KinesisMessageModel, byte[]> getTransformer(KinesisConnectorConfiguration configuration) {
    return new KinesisMessageModelRedshiftTransformer(configuration);
}
 
Example #8
Source File: DynamoDBMessageModelPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ITransformer<KinesisMessageModel, Map<String, AttributeValue>>
        getTransformer(KinesisConnectorConfiguration configuration) {
    return new KinesisMessageModelDynamoDBTransformer();
}
 
Example #9
Source File: S3Pipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public ITransformer<KinesisMessageModel, byte[]> getTransformer(KinesisConnectorConfiguration configuration) {
    return new JsonToByteArrayTransformer<KinesisMessageModel>(KinesisMessageModel.class);
}