Skip to content

Commit

Permalink
Remove redundant LatchedActionListener from ESIntegTestCase (#121244) (
Browse files Browse the repository at this point in the history
…#121262)

This is effectively the same as the other class. The logging is
irrelevant and the dead `addError` is too => lets remove this.
  • Loading branch information
original-brownbear authored Jan 30, 2025
1 parent 0db2f0a commit 1261557
Showing 1 changed file with 6 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.LatchedActionListener;
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest;
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse;
import org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction;
Expand Down Expand Up @@ -1711,7 +1712,8 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma
logger.info("Index [{}] docs async: [{}] bulk: [{}]", builders.size(), true, false);
for (IndexRequestBuilder indexRequestBuilder : builders) {
indexRequestBuilder.execute(
new LatchedActionListener<DocWriteResponse>(newLatch(inFlightAsyncOperations)).delegateResponse((l, e) -> fail(e))
new LatchedActionListener<DocWriteResponse>(ActionListener.noop(), newLatch(inFlightAsyncOperations))
.delegateResponse((l, e) -> fail(e))
);
postIndexAsyncActions(indicesArray, inFlightAsyncOperations, maybeFlush);
}
Expand Down Expand Up @@ -1803,17 +1805,17 @@ private void postIndexAsyncActions(String[] indices, List<CountDownLatch> inFlig
if (rarely()) {
indicesAdmin().prepareRefresh(indices)
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
.execute(new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
.execute(new LatchedActionListener<>(ActionListener.noop(), newLatch(inFlightAsyncOperations)));
} else if (maybeFlush && rarely()) {
indicesAdmin().prepareFlush(indices)
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
.execute(new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
.execute(new LatchedActionListener<>(ActionListener.noop(), newLatch(inFlightAsyncOperations)));
} else if (rarely()) {
indicesAdmin().prepareForceMerge(indices)
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
.setMaxNumSegments(between(1, 10))
.setFlush(maybeFlush && randomBoolean())
.execute(new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
.execute(new LatchedActionListener<>(ActionListener.noop(), newLatch(inFlightAsyncOperations)));
}
}
while (inFlightAsyncOperations.size() > MAX_IN_FLIGHT_ASYNC_INDEXES) {
Expand Down Expand Up @@ -1897,32 +1899,6 @@ public enum Scope {
int numClientNodes() default InternalTestCluster.DEFAULT_NUM_CLIENT_NODES;
}

private class LatchedActionListener<Response> implements ActionListener<Response> {
private final CountDownLatch latch;

LatchedActionListener(CountDownLatch latch) {
this.latch = latch;
}

@Override
public final void onResponse(Response response) {
latch.countDown();
}

@Override
public final void onFailure(Exception t) {
try {
logger.info("Action Failed", t);
addError(t);
} finally {
latch.countDown();
}
}

protected void addError(Exception e) {}

}

/**
* Clears the given scroll Ids
*/
Expand Down

0 comments on commit 1261557

Please sign in to comment.