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

The following examples show how to use com.amazonaws.services.kinesis.connectors.interfaces.IBuffer. 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: KinesisConnectorRecordProcessor.java    From amazon-kinesis-connectors with Apache License 2.0 6 votes vote down vote up
public KinesisConnectorRecordProcessor(IBuffer<T> buffer,
        IFilter<T> filter,
        IEmitter<U> emitter,
        ITransformerBase<T, U> transformer,
        KinesisConnectorConfiguration configuration) {
    if (buffer == null || filter == null || emitter == null || transformer == null) {
        throw new IllegalArgumentException("buffer, filter, emitter, and transformer must not be null");
    }
    this.buffer = buffer;
    this.filter = filter;
    this.emitter = emitter;
    this.transformer = transformer;
    // Limit must be greater than zero
    if (configuration.RETRY_LIMIT <= 0) {
        retryLimit = 1;
    } else {
        retryLimit = configuration.RETRY_LIMIT;
    }
    this.backoffInterval = configuration.BACKOFF_INTERVAL;
}
 
Example #2
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 #3
Source File: DynamoDBMasterToReplicasPipeline.java    From dynamodb-cross-region-library with Apache License 2.0 5 votes vote down vote up
@Override
public IBuffer<Record> getBuffer(final KinesisConnectorConfiguration configuration) {
    if (configuration instanceof DynamoDBStreamsConnectorConfiguration) {
        return new DynamoDBBuffer((DynamoDBStreamsConnectorConfiguration) configuration);
    } else {
        throw new IllegalArgumentException(this + " needs a DynamoDBStreamsConnectorConfiguration argument.");
    }
}
 
Example #4
Source File: KinesisConnectorRecordProcessorFactory.java    From amazon-kinesis-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public IRecordProcessor createProcessor() {
    try {
        IBuffer<T> buffer = pipeline.getBuffer(configuration);
        IEmitter<U> emitter = pipeline.getEmitter(configuration);
        ITransformerBase<T, U> transformer = pipeline.getTransformer(configuration);
        IFilter<T> filter = pipeline.getFilter(configuration);
        KinesisConnectorRecordProcessor<T, U> processor =
                new KinesisConnectorRecordProcessor<T, U>(buffer, filter, emitter, transformer, configuration);
        return processor;
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
}
 
Example #5
Source File: HBasePipeline.java    From aws-big-data-blog with Apache License 2.0 4 votes vote down vote up
@Override
public IBuffer<KinesisMessageModel> getBuffer(KinesisConnectorConfiguration configuration) {
    return new BasicMemoryBuffer<KinesisMessageModel>(configuration);
}
 
Example #6
Source File: UnmodifiableBuffer.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
public UnmodifiableBuffer(IBuffer<T> buf) {
    this.buf = buf;
    this.records = buf.getRecords();
}
 
Example #7
Source File: UnmodifiableBuffer.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
public UnmodifiableBuffer(IBuffer<?> buf, List<T> records) {
    this.buf = buf;
    this.records = records;
}
 
Example #8
Source File: UnmodifiableBufferTests.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testUnmodifiableBuffer() {
    long bytesToBuffer = 10;
    long recordsToBuffer = 10;
    String firstSequenceNumber = "firstSequenceNumber";
    String lastSequenceNumber = "lastSequenceNumber";
    List<Integer> records = new ArrayList<Integer>();

    buffer = (IBuffer<Integer>) control.createMock(IBuffer.class);
    control.reset();

    // Modifiable Buffer Behavior
    EasyMock.expect(buffer.getBytesToBuffer()).andReturn(bytesToBuffer);
    EasyMock.expect(buffer.getNumRecordsToBuffer()).andReturn(recordsToBuffer);
    EasyMock.expect(buffer.getFirstSequenceNumber()).andReturn(firstSequenceNumber);
    EasyMock.expect(buffer.getLastSequenceNumber()).andReturn(lastSequenceNumber);
    EasyMock.expect(buffer.getRecords()).andReturn(records);
    control.replay();

    UnmodifiableBuffer<Integer> umb = new UnmodifiableBuffer<Integer>(buffer);

    // Test getters behave like buffer
    assertEquals(umb.getBytesToBuffer(), bytesToBuffer);
    assertEquals(umb.getNumRecordsToBuffer(), recordsToBuffer);
    assertEquals(umb.getFirstSequenceNumber(), firstSequenceNumber);
    assertEquals(umb.getLastSequenceNumber(), lastSequenceNumber);
    List<Integer> testRecords = umb.getRecords();
    // Verify buffer methods were called
    control.verify();

    // Expect exceptions on the following operations
    exception.expect(UnsupportedOperationException.class);
    umb.consumeRecord(1, 1, "");

    exception.expect(UnsupportedOperationException.class);
    umb.clear();

    exception.expect(UnsupportedOperationException.class);
    testRecords.clear();
}
 
Example #9
Source File: S3ManifestPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public IBuffer<KinesisMessageModel> getBuffer(KinesisConnectorConfiguration configuration) {
    return new BasicMemoryBuffer<KinesisMessageModel>(configuration);
}
 
Example #10
Source File: RedshiftManifestPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public IBuffer<String> getBuffer(KinesisConnectorConfiguration configuration) {
    return new BasicMemoryBuffer<>(configuration);
}
 
Example #11
Source File: RedshiftBasicPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public IBuffer<KinesisMessageModel> getBuffer(KinesisConnectorConfiguration configuration) {
    return new BasicMemoryBuffer<KinesisMessageModel>(configuration);
}
 
Example #12
Source File: DynamoDBMessageModelPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public IBuffer<KinesisMessageModel> getBuffer(KinesisConnectorConfiguration configuration) {
    return new BasicMemoryBuffer<KinesisMessageModel>(configuration);
}
 
Example #13
Source File: ElasticsearchPipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public IBuffer<KinesisMessageModel> getBuffer(KinesisConnectorConfiguration configuration) {
    return new BasicMemoryBuffer<KinesisMessageModel>(configuration);
}
 
Example #14
Source File: S3Pipeline.java    From amazon-kinesis-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public IBuffer<KinesisMessageModel> getBuffer(KinesisConnectorConfiguration configuration) {
    return new BasicMemoryBuffer<KinesisMessageModel>(configuration);
}