Source:
public void processRecords(final List<Record> records, final IRecordProcessorCheckpointer iRecordProcessorCheckpointer) { LOGGER.debug("Size = {}", records.size()); final ArrayList<TrackerMotion> trackerData = new ArrayList<>(records.size()); for (final Record record : records) { try { final InputProtos.PillDataKinesis data = InputProtos.PillDataKinesis.parseFrom(record.getData().array()); final Optional<byte[]> decryptionKey = pillKeyStore.get(data.getPillId()); if(!decryptionKey.isPresent()) { LOGGER.error("Missing decryption key for pill: {}", data.getPillId()); continue; } final TrackerMotion trackerMotion = new TrackerMotion.Builder().withPillKinesisData(decryptionKey.get(), data).build(); trackerData.add(trackerMotion); if(data.hasBatteryLevel()){ final int batteryLevel = data.getBatteryLevel(); final int upTime = data.getUpTime(); final int firmwareVersion = data.getFirmwareVersion(); final DateTime lastUpdated = new DateTime(data.getTimestamp()); pillHeartBeatDAO.silentInsert(trackerMotion.trackerId, batteryLevel, upTime, firmwareVersion, lastUpdated); } } catch (InvalidProtocolBufferException e) { LOGGER.error("Failed to decode protobuf: {}", e.getMessage()); } catch (IllegalArgumentException e) { LOGGER.error("Failed to decrypted pill data {}, error: {}", record.getData().array(), e.getMessage()); } } if (trackerData.size() > 0) { this.trackerMotionDAO.batchInsertTrackerMotionData(trackerData, this.batchSize); try { iRecordProcessorCheckpointer.checkpoint(); } catch (InvalidStateException e) { LOGGER.error("checkpoint {}", e.getMessage()); } catch (ShutdownException e) { LOGGER.error("Received shutdown command at checkpoint, bailing. {}", e.getMessage()); } } }

Target:
public void processRecords(final List<Record> records, final IRecordProcessorCheckpointer iRecordProcessorCheckpointer) { LOGGER.debug("Size = {}", records.size()); final ArrayList<TrackerMotion> trackerData = new ArrayList<>(records.size()); for (final Record record : records) { try { final InputProtos.PillDataKinesis data = InputProtos.PillDataKinesis.parseFrom(record.getData().array()); final Optional<byte[]> decryptionKey = pillKeyStore.get(data.getPillId()); if(!decryptionKey.isPresent()) { LOGGER.error("Missing decryption key for pill: {}", data.getPillId()); continue; } final TrackerMotion trackerMotion = new TrackerMotion.Builder().withPillKinesisData(decryptionKey.get(), data).build(); trackerData.add(trackerMotion); if(data.hasBatteryLevel()){ final int batteryLevel = data.getBatteryLevel(); final int upTime = data.getUpTime(); final int firmwareVersion = data.getFirmwareVersion(); final DateTime lastUpdated = new DateTime(data.getTimestamp(), DateTimeZone.UTC); pillHeartBeatDAO.silentInsert(trackerMotion.trackerId, batteryLevel, upTime, firmwareVersion, lastUpdated); } } catch (InvalidProtocolBufferException e) { LOGGER.error("Failed to decode protobuf: {}", e.getMessage()); } catch (IllegalArgumentException e) { LOGGER.error("Failed to decrypted pill data {}, error: {}", record.getData().array(), e.getMessage()); } } if (trackerData.size() > 0) { this.trackerMotionDAO.batchInsertTrackerMotionData(trackerData, this.batchSize); try { iRecordProcessorCheckpointer.checkpoint(); } catch (InvalidStateException e) { LOGGER.error("checkpoint {}", e.getMessage()); } catch (ShutdownException e) { LOGGER.error("Received shutdown command at checkpoint, bailing. {}", e.getMessage()); } } }