use of me.retrodaredevil.solarthing.database.MillisDatabase in project solarthing by wildmountainfarms.
the class SendPacketAction method onStart.
@Override
protected void onStart() {
super.onStart();
Instant now = Instant.now();
MillisDatabase millisDatabase = millisDatabaseSupplier.get();
PacketCollection packetCollection = packetCollectionCreator.create(now);
executorService.execute(() -> {
int retryCounter = 0;
while (true) {
boolean success = upload(millisDatabase, packetCollection);
if (success) {
nextAction = onSuccessAction;
break;
}
if (retryCounter == maxRetries) {
nextAction = onMaxRetriesAction;
LOGGER.info("Reached max retries for packet id: " + packetCollection.getDbId() + " will not try again.");
break;
}
retryCounter++;
if (retryWaitMillis > 0) {
try {
Thread.sleep(retryWaitMillis);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.info("A SendPacketAction's sleep was interrupted.");
// We don't set nextAction to something because we assume someone just called end() on us and won't be using our next action
break;
}
}
}
setDone(true);
});
}
Aggregations