Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbernstein2 committed Aug 29, 2024
1 parent c889736 commit 323e5a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ public interface Batcher<ElementT, ElementResultT> extends AutoCloseable {
*/
void sendOutstanding();

/**
* Cancels all outstanding batch RPCs.
*/
/** Cancels all outstanding batch RPCs. */
void cancelOutstanding();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public class BatcherImpl<ElementT, ElementResultT, RequestT, ResponseT>
private final BatcherReference currentBatcherReference;

private Batch<ElementT, ElementResultT, RequestT, ResponseT> currentOpenBatch;
private final ConcurrentMap<Batch<ElementT, ElementResultT, RequestT, ResponseT>, Boolean> outstandingBatches = new ConcurrentHashMap<>();
private final ConcurrentMap<Batch<ElementT, ElementResultT, RequestT, ResponseT>, Boolean>
outstandingBatches = new ConcurrentHashMap<>();
private final Object flushLock = new Object();
private final Object elementLock = new Object();
private final Future<?> scheduledFuture;
Expand Down Expand Up @@ -370,7 +371,7 @@ private void awaitAllOutstandingBatches() throws InterruptedException {

@Override
public void cancelOutstanding() {
for (Batch<?,?,?,?> batch : outstandingBatches.keySet()) {
for (Batch<?, ?, ?, ?> batch : outstandingBatches.keySet()) {
batch.cancel();
}
}
Expand Down Expand Up @@ -399,7 +400,8 @@ public void close(@Nullable Duration timeout) throws InterruptedException {
}
} catch (TimeoutException e) {
StringJoiner batchesStr = new StringJoiner(",");
for (Batch<ElementT, ElementResultT, RequestT, ResponseT> batch : outstandingBatches.keySet()) {
for (Batch<ElementT, ElementResultT, RequestT, ResponseT> batch :
outstandingBatches.keySet()) {
batchesStr.add(batch.toString());
}
String msg = "Timed out trying to close batcher after " + timeout + ".";
Expand Down Expand Up @@ -503,7 +505,6 @@ void cancel() {
}
}


void onBatchSuccess(ResponseT response) {
try {
descriptor.splitResponse(response, entries);
Expand Down Expand Up @@ -533,10 +534,7 @@ public String toString() {
StringJoiner elementsStr = new StringJoiner(",");
for (BatchEntry<ElementT, ElementResultT> entry : entries) {
elementsStr.add(
Optional.ofNullable(entry.getElement())
.map(Object::toString)
.orElse("null")
);
Optional.ofNullable(entry.getElement()).map(Object::toString).orElse("null"));
}
return MoreObjects.toStringHelper(this)
.add("operation", operation)
Expand Down

0 comments on commit 323e5a1

Please sign in to comment.