Skip to content

Commit

Permalink
revert re-request for page size
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalinas committed Jan 10, 2017
1 parent b5b82b1 commit 6545a4a
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,7 @@ public List<S3ObjectSummaryHolder> call() throws Exception {
continuationTokens.putIfAbsent(key, new ContinuationToken(result.getNextContinuationToken(), true));
return Collections.emptyList();
} else {
int newTotal = incrementIfLessThan(resultCount, result.getObjectSummaries().size(), targetResultCount);
if (newTotal != -1) {
if (newTotal > DEFAULT_TARGET_MAX_RESULTS) {
request.setMaxKeys(Math.abs(DEFAULT_TARGET_MAX_RESULTS - newTotal));
result = s3Client.listObjectsV2(request);
}
if (incrementIfLessThan(resultCount, result.getObjectSummaries().size(), targetResultCount)) {
continuationTokens.putIfAbsent(key, new ContinuationToken(result.getNextContinuationToken(), !result.isTruncated()));
List<S3ObjectSummaryHolder> objectSummaryHolders = new ArrayList<>();
for (S3ObjectSummary objectSummary : result.getObjectSummaries()) {
Expand Down Expand Up @@ -420,14 +415,14 @@ public SingularityS3LogMetadata call() throws Exception {
return Futures.allAsList(logFutures).get(s3Configuration.getWaitForS3LinksSeconds(), TimeUnit.SECONDS);
}

private int incrementIfLessThan(AtomicInteger count, int add, int threshold) {
private boolean incrementIfLessThan(AtomicInteger count, int add, int threshold) {
while (true) {
int current = count.get();
if (current >= threshold) {
return -1;
return false;
}
if (count.compareAndSet(current, current + add)) {
return current + add;
return true;
}
}
}
Expand Down

0 comments on commit 6545a4a

Please sign in to comment.