Source:
public void processRecords(final List<Record> records, final IRecordProcessorCheckpointer iRecordProcessorCheckpointer) { final Set<String> senseIds = new HashSet<String>(); LOGGER.info("Got records.", records.size()); for (final Record record : records) { try { final DataInputProtos.BatchPeriodicDataWorker pb = DataInputProtos.BatchPeriodicDataWorker.parseFrom(record.getData().array()); if(!pb.getData().hasDeviceId() || pb.getData().getDeviceId().isEmpty()) { LOGGER.warn("Found a periodic_data without a device_id {}"); continue; } final String senseId = pb.getData().getDeviceId(); if (isRecordTooOld(pb.getReceivedAt()) && hasAlarmWorkerDropIfTooOldEnabled(senseId)) continue; senseIds.add(senseId); } catch (InvalidProtocolBufferException e) { LOGGER.error("Failed to decode protobuf: {}", e.getMessage()); } } LOGGER.info("Processing unique senseIds.", senseIds.size()); for(final String senseId : senseIds) { try { RingProcessor.updateAndReturnNextRingTimeForSense(this.mergedUserInfoDynamoDB, this.scheduledRingTimeHistoryDAODynamoDB, this.smartAlarmLoggerDynamoDB, this.trackerMotionDAO, senseId, DateTime.now(), this.configuration.getProcessAheadTimeInMinutes(), this.configuration.getAggregateWindowSizeInMinute(), this.configuration.getLightSleepThreshold(), flipper ); }catch (Exception ex){ LOGGER.error("Update next ring time for sense failed at {}, error {}", senseId, DateTime.now(), ex.getMessage()); } } LOGGER.info("Successfully updated smart ring time for sense", senseIds.size()); try { iRecordProcessorCheckpointer.checkpoint(); } catch (InvalidStateException e) { LOGGER.error("checkpoint {}", e.getMessage()); } catch (ShutdownException e) { LOGGER.error("Received shutdown command at checkpoint, bailing. {}", e.getMessage()); } if(records.size() < 5) { LOGGER.info("Batch size was small. Sleeping for 10s"); try { Thread.sleep(10000L); } catch (InterruptedException e) { LOGGER.error("Interrupted Thread while sleeping: {}", e.getMessage()); } } }

Target:
public void processRecords(final List<Record> records, final IRecordProcessorCheckpointer iRecordProcessorCheckpointer) { final Set<String> senseIds = new HashSet<String>(); LOGGER.info("Got records.", records.size()); for (final Record record : records) { try { final DataInputProtos.BatchPeriodicDataWorker pb = DataInputProtos.BatchPeriodicDataWorker.parseFrom(record.getData().array()); if(!pb.getData().hasDeviceId() || pb.getData().getDeviceId().isEmpty()) { LOGGER.warn("Found a periodic_data without a device_id {}"); continue; } final String senseId = pb.getData().getDeviceId(); if (isRecordTooOld(DateTime.now(), new DateTime(pb.getReceivedAt())) && hasAlarmWorkerDropIfTooOldEnabled(senseId)) { continue; } senseIds.add(senseId); } catch (InvalidProtocolBufferException e) { LOGGER.error("Failed to decode protobuf: {}", e.getMessage()); } } LOGGER.info("Processing unique senseIds.", senseIds.size()); for(final String senseId : senseIds) { try { RingProcessor.updateAndReturnNextRingTimeForSense(this.mergedUserInfoDynamoDB, this.scheduledRingTimeHistoryDAODynamoDB, this.smartAlarmLoggerDynamoDB, this.trackerMotionDAO, senseId, DateTime.now(), this.configuration.getProcessAheadTimeInMinutes(), this.configuration.getAggregateWindowSizeInMinute(), this.configuration.getLightSleepThreshold(), flipper ); }catch (Exception ex){ LOGGER.error("Update next ring time for sense failed at {}, error {}", senseId, DateTime.now(), ex.getMessage()); } } LOGGER.info("Successfully updated smart ring time for sense", senseIds.size()); try { iRecordProcessorCheckpointer.checkpoint(); } catch (InvalidStateException e) { LOGGER.error("checkpoint {}", e.getMessage()); } catch (ShutdownException e) { LOGGER.error("Received shutdown command at checkpoint, bailing. {}", e.getMessage()); } if(records.size() < 5) { LOGGER.info("Batch size was small. Sleeping for 10s"); try { Thread.sleep(10000L); } catch (InterruptedException e) { LOGGER.error("Interrupted Thread while sleeping: {}", e.getMessage()); } } }