Search in sources :

Example 1 with ProcessRecordsInput

use of com.amazonaws.services.kinesis.clientlibrary.types.ProcessRecordsInput in project samza by apache.

the class TestKinesisRecordProcessor method generateRecords.

static Map<KinesisRecordProcessor, List<Record>> generateRecords(int numRecordsPerShard, List<KinesisRecordProcessor> processors) {
    Map<KinesisRecordProcessor, List<Record>> processorRecordMap = new HashMap<>();
    processors.forEach(processor -> {
        try {
            // Create records and call process records
            IRecordProcessorCheckpointer checkpointer = Mockito.mock(IRecordProcessorCheckpointer.class);
            doNothing().when(checkpointer).checkpoint(anyString());
            doNothing().when(checkpointer).checkpoint();
            ProcessRecordsInput processRecordsInput = Mockito.mock(ProcessRecordsInput.class);
            when(processRecordsInput.getCheckpointer()).thenReturn(checkpointer);
            when(processRecordsInput.getMillisBehindLatest()).thenReturn(1000L);
            List<Record> inputRecords = createRecords(numRecordsPerShard);
            processorRecordMap.put(processor, inputRecords);
            when(processRecordsInput.getRecords()).thenReturn(inputRecords);
            processor.processRecords(processRecordsInput);
        } catch (ShutdownException | InvalidStateException ex) {
            throw new RuntimeException(ex);
        }
    });
    return processorRecordMap;
}
Also used : HashMap(java.util.HashMap) ProcessRecordsInput(com.amazonaws.services.kinesis.clientlibrary.types.ProcessRecordsInput) IRecordProcessorCheckpointer(com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer) ShutdownException(com.amazonaws.services.kinesis.clientlibrary.exceptions.ShutdownException) ArrayList(java.util.ArrayList) List(java.util.List) Record(com.amazonaws.services.kinesis.model.Record) InvalidStateException(com.amazonaws.services.kinesis.clientlibrary.exceptions.InvalidStateException)

Aggregations

InvalidStateException (com.amazonaws.services.kinesis.clientlibrary.exceptions.InvalidStateException)1 ShutdownException (com.amazonaws.services.kinesis.clientlibrary.exceptions.ShutdownException)1 IRecordProcessorCheckpointer (com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer)1 ProcessRecordsInput (com.amazonaws.services.kinesis.clientlibrary.types.ProcessRecordsInput)1 Record (com.amazonaws.services.kinesis.model.Record)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1