Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
updated wordings and method name in BatcherEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulKQL committed Dec 18, 2019
1 parent 9ae5409 commit e99ad37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
13 changes: 6 additions & 7 deletions gax/src/main/java/com/google/api/gax/batching/BatchEntry.java
Expand Up @@ -42,10 +42,9 @@
* @param <ElementT> The type of each individual element to be batched.
* @param <ElementResultT> The type of the result for each individual element.
*/
@BetaApi("The surface for batching is not stable yet and may change in the resultFuture.")
@BetaApi("The surface for batching is not stable yet and may change in the future.")
@InternalExtensionOnly("For google-cloud-java client use only.")
public class BatchEntry<ElementT, ElementResultT> {

private final ElementT element;
private final SettableApiFuture<ElementResultT> resultFuture;

Expand All @@ -54,16 +53,16 @@ private BatchEntry(ElementT element, SettableApiFuture<ElementResultT> resultFut
this.resultFuture = resultFuture;
}

static <ElementT, ElementResultT> BatchEntry<ElementT, ElementResultT> add(
ElementT element, SettableApiFuture<ElementResultT> future) {
return new BatchEntry<>(element, future);
}

public ElementT getElement() {
return element;
}

public SettableApiFuture<ElementResultT> getResultFuture() {
return resultFuture;
}

static <ElementT, ElementResultT> BatchEntry<ElementT, ElementResultT> create(
ElementT element, SettableApiFuture<ElementResultT> future) {
return new BatchEntry<>(element, future);
}
}
Expand Up @@ -251,7 +251,7 @@ private Batch(

void add(ElementT element, SettableApiFuture<ElementResultT> result) {
builder.add(element);
results.add(BatchEntry.add(element, result));
results.add(BatchEntry.create(element, result));
elementCounter++;
byteCounter += descriptor.countBytes(element);
}
Expand Down
Expand Up @@ -73,13 +73,15 @@ public void testEntryFailureOnly() {

SettableApiFuture<Integer> batchOneResult = SettableApiFuture.create();
batchOneResult.setException(new IllegalStateException("local element failure"));
batcherStats.recordBatchElementsCompletion(ImmutableList.of(BatchEntry.add(1, batchOneResult)));
batcherStats.recordBatchElementsCompletion(
ImmutableList.of(BatchEntry.create(1, batchOneResult)));

SettableApiFuture<Integer> batchTwoResult = SettableApiFuture.create();
batchTwoResult.setException(
ApiExceptionFactory.createException(
new RuntimeException(), FakeStatusCode.of(StatusCode.Code.UNAVAILABLE), false));
batcherStats.recordBatchElementsCompletion(ImmutableList.of(BatchEntry.add(2, batchTwoResult)));
batcherStats.recordBatchElementsCompletion(
ImmutableList.of(BatchEntry.create(2, batchTwoResult)));

BatchingException ex = batcherStats.asException();
assertThat(ex)
Expand All @@ -100,7 +102,7 @@ public void testRequestAndEntryFailures() {
ApiExceptionFactory.createException(
new RuntimeException(), FakeStatusCode.of(StatusCode.Code.ALREADY_EXISTS), false));

batcherStats.recordBatchElementsCompletion(ImmutableList.of(BatchEntry.add(1, future)));
batcherStats.recordBatchElementsCompletion(ImmutableList.of(BatchEntry.create(1, future)));

BatchingException ex = batcherStats.asException();
assertThat(ex)
Expand Down

0 comments on commit e99ad37

Please sign in to comment.