Search in sources :

Example 1 with IRecordProcessorCheckpointer

use of com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer in project samza by apache.

the class TestKinesisRecordProcessor method getCheckpointer.

static IRecordProcessorCheckpointer getCheckpointer(KinesisRecordProcessor processor) throws NoSuchFieldException, IllegalAccessException {
    Field f = processor.getClass().getDeclaredField("checkpointer");
    f.setAccessible(true);
    return (IRecordProcessorCheckpointer) f.get(processor);
}
Also used : Field(java.lang.reflect.Field) IRecordProcessorCheckpointer(com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer)

Example 2 with IRecordProcessorCheckpointer

use of com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer 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

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