Skip to content

Commit

Permalink
Merge pull request #152 from GoogleCloudPlatform/jk/149
Browse files Browse the repository at this point in the history
fixes #149
  • Loading branch information
danielbeaudreau authored Nov 9, 2022
2 parents 8a9a26e + 66b8928 commit 5e9437f
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BackupUploadService implements IBackupUploadService {

private final static Executor uploadThreadPool = Executors.newCachedThreadPool();
private final DelayCalculator delayCalculator;
private final IBackupUploader backupUploader;
private final ImmutableList<Integer> httpErrorCodesToRetry;
Expand Down Expand Up @@ -94,11 +96,13 @@ public UploadAsyncJob(BackupState backupState) {
}

protected void logUploadFailed(Exception e) {
log.error("sopInstanceUID={}, upload attempt № {} - failed.", uniqueFileName, attemptNumber, e);
log.error(
"sopInstanceUID={}, upload attempt № {} - failed.", uniqueFileName, attemptNumber, e);
}

protected void logSuccessUpload() {
log.debug("sopInstanceUID={}, upload attempt № {}, - successful.", uniqueFileName, attemptNumber);
log.debug(
"sopInstanceUID={}, upload attempt № {}, - successful.", uniqueFileName, attemptNumber);
}

protected InputStream readBackupExceptionally() throws CompletionException {
Expand Down Expand Up @@ -239,8 +243,9 @@ private CompletableFuture scheduleUploadWithDelay(BackupState backupState, Runna
return CompletableFuture.runAsync(
uploadJob,
CompletableFuture.delayedExecutor(
delayMillis,
TimeUnit.MILLISECONDS));
delayMillis,
TimeUnit.MILLISECONDS,
uploadThreadPool));
} else {
MonitoringService.addEvent(Event.CSTORE_ERROR);
throw getNoResendAttemptLeftException(null, uniqueFileName);
Expand Down

0 comments on commit 5e9437f

Please sign in to comment.