[Rename] ElasticsearchTimeoutException class in server module (#173)

This commit refactors the ElasticsearchTimeoutException class in the server
module to OpenSearchTimeoutException. References and usages throught the rest of
the codebase are fully refactored.

Signed-off-by: Nicholas Knize <nknize@amazon.com>
This commit is contained in:
Nick Knize 2021-03-03 17:27:56 -06:00
parent 64d7e7e9ca
commit 7788250e9e
21 changed files with 48 additions and 48 deletions

View File

@ -19,7 +19,7 @@
package org.elasticsearch.action.admin.cluster.node.tasks;
import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionFuture;
@ -669,7 +669,7 @@ public class TasksIT extends ESIntegTestCase {
for (Throwable failure : failures) {
assertNotNull(
ExceptionsHelper.unwrap(failure, ElasticsearchTimeoutException.class, ReceiveTimeoutTransportException.class));
ExceptionsHelper.unwrap(failure, OpenSearchTimeoutException.class, ReceiveTimeoutTransportException.class));
}
} finally {
// Now we can unblock those requests

View File

@ -19,7 +19,7 @@
package org.elasticsearch.update;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.DocWriteResponse;
@ -752,7 +752,7 @@ public class UpdateIT extends ESIntegTestCase {
try {
waitForOutstandingRequests(TimeValue.timeValueSeconds(60), updateRequestsOutstanding, maxUpdateRequests, "Update");
waitForOutstandingRequests(TimeValue.timeValueSeconds(60), deleteRequestsOutstanding, maxDeleteRequests, "Delete");
} catch (ElasticsearchTimeoutException ete) {
} catch (OpenSearchTimeoutException ete) {
failures.add(ete);
}
latch.countDown();
@ -779,7 +779,7 @@ public class UpdateIT extends ESIntegTestCase {
//Just keep swimming
}
} while ((System.currentTimeMillis() - start) < timeOut.getMillis());
throw new ElasticsearchTimeoutException("Requests were still outstanding after the timeout [" + timeOut + "] for type [" +
throw new OpenSearchTimeoutException("Requests were still outstanding after the timeout [" + timeOut + "] for type [" +
name + "]" );
}
}

View File

@ -946,8 +946,8 @@ public class OpenSearchException extends RuntimeException implements ToXContentF
org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException::new, 116, UNKNOWN_VERSION_ADDED),
RETRY_ON_PRIMARY_EXCEPTION(ReplicationOperation.RetryOnPrimaryException.class,
ReplicationOperation.RetryOnPrimaryException::new, 117, UNKNOWN_VERSION_ADDED),
ELASTICSEARCH_TIMEOUT_EXCEPTION(org.elasticsearch.ElasticsearchTimeoutException.class,
org.elasticsearch.ElasticsearchTimeoutException::new, 118, UNKNOWN_VERSION_ADDED),
ELASTICSEARCH_TIMEOUT_EXCEPTION(org.elasticsearch.OpenSearchTimeoutException.class,
org.elasticsearch.OpenSearchTimeoutException::new, 118, UNKNOWN_VERSION_ADDED),
QUERY_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.search.query.QueryPhaseExecutionException.class,
org.elasticsearch.search.query.QueryPhaseExecutionException::new, 119, UNKNOWN_VERSION_ADDED),
REPOSITORY_VERIFICATION_EXCEPTION(org.elasticsearch.repositories.RepositoryVerificationException.class,

View File

@ -28,20 +28,20 @@ import java.io.IOException;
*
*
*/
public class ElasticsearchTimeoutException extends OpenSearchException {
public ElasticsearchTimeoutException(StreamInput in) throws IOException {
public class OpenSearchTimeoutException extends OpenSearchException {
public OpenSearchTimeoutException(StreamInput in) throws IOException {
super(in);
}
public ElasticsearchTimeoutException(Throwable cause) {
public OpenSearchTimeoutException(Throwable cause) {
super(cause);
}
public ElasticsearchTimeoutException(String message, Object... args) {
public OpenSearchTimeoutException(String message, Object... args) {
super(message, args);
}
public ElasticsearchTimeoutException(String message, Throwable cause, Object... args) {
public OpenSearchTimeoutException(String message, Throwable cause, Object... args) {
super(message, cause, args);
}
}

View File

@ -21,7 +21,7 @@ package org.elasticsearch.action.admin.cluster.configuration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
@ -146,7 +146,7 @@ public class TransportAddVotingConfigExclusionsAction extends TransportMasterNod
@Override
public void onTimeout(TimeValue timeout) {
listener.onFailure(new ElasticsearchTimeoutException("timed out waiting for voting config exclusions "
listener.onFailure(new OpenSearchTimeoutException("timed out waiting for voting config exclusions "
+ resolvedExclusions + " to take effect"));
}
};

View File

@ -21,7 +21,7 @@ package org.elasticsearch.action.admin.cluster.configuration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
@ -104,7 +104,7 @@ public class TransportClearVotingConfigExclusionsAction
@Override
public void onTimeout(TimeValue timeout) {
listener.onFailure(new ElasticsearchTimeoutException(
listener.onFailure(new OpenSearchTimeoutException(
"timed out waiting for removal of nodes; if nodes should not be removed, set waitForRemoval to false. "
+ initialState.getVotingConfigExclusions()));
}

View File

@ -19,7 +19,7 @@
package org.elasticsearch.action.support;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.threadpool.Scheduler;
@ -33,7 +33,7 @@ public class ListenerTimeouts {
/**
* Wraps a listener with a listener that can timeout. After the timeout period the
* {@link ActionListener#onFailure(Exception)} will be called with a
* {@link ElasticsearchTimeoutException} if the listener has not already been completed.
* {@link OpenSearchTimeoutException} if the listener has not already been completed.
*
* @param threadPool used to schedule the timeout
* @param listener to that can timeout
@ -46,7 +46,7 @@ public class ListenerTimeouts {
TimeValue timeout, String executor, String listenerName) {
return wrapWithTimeout(threadPool, timeout, executor, listener, (ignore) -> {
String timeoutMessage = "[" + listenerName + "]" + " timed out after [" + timeout + "]";
listener.onFailure(new ElasticsearchTimeoutException(timeoutMessage));
listener.onFailure(new OpenSearchTimeoutException(timeoutMessage));
});
}

View File

@ -19,7 +19,7 @@
package org.elasticsearch.common.util.concurrent;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.SuppressForbidden;
@ -75,7 +75,7 @@ public class FutureUtils {
try {
return future.get(timeout, unit);
} catch (TimeoutException e) {
throw new ElasticsearchTimeoutException(e);
throw new OpenSearchTimeoutException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Future got interrupted", e);

View File

@ -21,7 +21,7 @@ package org.elasticsearch.gateway;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.FailedNodeException;
@ -217,7 +217,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
// if the request got rejected or timed out, we need to try it again next time...
if (unwrappedCause instanceof EsRejectedExecutionException ||
unwrappedCause instanceof ReceiveTimeoutTransportException ||
unwrappedCause instanceof ElasticsearchTimeoutException) {
unwrappedCause instanceof OpenSearchTimeoutException) {
nodeEntry.restartFetching();
} else {
logger.warn(() -> new ParameterizedMessage("{}: failed to list shard for {} on node [{}]",

View File

@ -25,7 +25,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.RateLimiter;
import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
@ -383,7 +383,7 @@ public class PeerRecoveryTargetService implements IndexEventListener {
@Override
public void onTimeout(TimeValue timeout) {
// note that we do not use a timeout (see comment above)
listener.onFailure(new ElasticsearchTimeoutException("timed out waiting for mapping updates " +
listener.onFailure(new OpenSearchTimeoutException("timed out waiting for mapping updates " +
"(timeout [" + timeout + "])"));
}
});

View File

@ -21,7 +21,7 @@ package org.elasticsearch.indices.recovery;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
@ -279,7 +279,7 @@ public class RecoveriesCollection {
if (accessTime == lastSeenAccessTime) {
String message = "no activity after [" + checkInterval + "]";
failRecovery(recoveryId,
new RecoveryFailedException(status.state(), message, new ElasticsearchTimeoutException(message)),
new RecoveryFailedException(status.state(), message, new OpenSearchTimeoutException(message)),
true // to be safe, we don't know what go stuck
);
return;

View File

@ -26,7 +26,7 @@ import org.apache.lucene.util.SetOnce;
import org.elasticsearch.Assertions;
import org.elasticsearch.Build;
import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionModule;
import org.elasticsearch.action.ActionType;
@ -881,7 +881,7 @@ public class Node implements Closeable {
try {
latch.await();
} catch (InterruptedException e) {
throw new ElasticsearchTimeoutException("Interrupted while waiting for initial discovery state");
throw new OpenSearchTimeoutException("Interrupted while waiting for initial discovery state");
}
}
}

View File

@ -23,7 +23,7 @@ import com.carrotsearch.hppc.cursors.ObjectCursor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.action.ActionRunnable;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
@ -129,7 +129,7 @@ public class RestGetMappingAction extends BaseRestHandler {
public RestResponse buildResponse(final GetMappingsResponse response,
final XContentBuilder builder) throws Exception {
if (threadPool.relativeTimeInMillis() - startTimeMs > timeout.millis()) {
throw new ElasticsearchTimeoutException("Timed out getting mappings");
throw new OpenSearchTimeoutException("Timed out getting mappings");
}
final ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetadata>> mappingsByIndex =
response.getMappings();

View File

@ -26,9 +26,9 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.Assertions;
import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.OpenSearchException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.ClusterChangedEvent;
@ -433,7 +433,7 @@ public class TaskManager implements ClusterStateApplier {
throw new OpenSearchException("Interrupted waiting for completion of [{}]", e, task);
}
}
throw new ElasticsearchTimeoutException("Timed out waiting for completion of [{}]", task);
throw new OpenSearchTimeoutException("Timed out waiting for completion of [{}]", task);
}
private static class CancellableTaskHolder {

View File

@ -20,7 +20,7 @@
package org.elasticsearch.transport;
import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.util.concurrent.BaseFuture;
@ -59,7 +59,7 @@ public class PlainTransportFuture<V extends TransportResponse> extends BaseFutur
try {
return get(timeout, unit);
} catch (TimeoutException e) {
throw new ElasticsearchTimeoutException(e);
throw new OpenSearchTimeoutException(e);
} catch (InterruptedException e) {
throw new IllegalStateException("Future got interrupted", e);
} catch (ExecutionException e) {

View File

@ -789,7 +789,7 @@ public class ExceptionSerializationTests extends ESTestCase {
ids.put(115, org.elasticsearch.index.translog.TranslogException.class);
ids.put(116, org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class);
ids.put(117, ReplicationOperation.RetryOnPrimaryException.class);
ids.put(118, org.elasticsearch.ElasticsearchTimeoutException.class);
ids.put(118, org.elasticsearch.OpenSearchTimeoutException.class);
ids.put(119, org.elasticsearch.search.query.QueryPhaseExecutionException.class);
ids.put(120, org.elasticsearch.repositories.RepositoryVerificationException.class);
ids.put(121, org.elasticsearch.search.aggregations.InvalidAggregationPathException.class);

View File

@ -19,7 +19,7 @@
package org.elasticsearch.action.admin.cluster.configuration;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterName;
@ -506,7 +506,7 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
final Throwable rootCause = exceptionHolder.get().getRootCause();
assertThat(rootCause,instanceOf(ElasticsearchTimeoutException.class));
assertThat(rootCause,instanceOf(OpenSearchTimeoutException.class));
assertThat(rootCause.getMessage(), startsWith("timed out waiting for voting config exclusions [{other1}"));
assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);

View File

@ -19,7 +19,7 @@
package org.elasticsearch.action.admin.cluster.configuration;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterName;
@ -149,7 +149,7 @@ public class TransportClearVotingConfigExclusionsActionTests extends ESTestCase
assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(),
containsInAnyOrder(otherNode1Exclusion, otherNode2Exclusion));
final Throwable rootCause = responseHolder.get().getRootCause();
assertThat(rootCause, instanceOf(ElasticsearchTimeoutException.class));
assertThat(rootCause, instanceOf(OpenSearchTimeoutException.class));
assertThat(rootCause.getMessage(),
startsWith("timed out waiting for removal of nodes; if nodes should not be removed, set waitForRemoval to false. ["));
}

View File

@ -19,7 +19,7 @@
package org.elasticsearch.action.support;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.cluster.coordination.DeterministicTaskQueue;
import org.elasticsearch.common.settings.Settings;
@ -62,7 +62,7 @@ public class ListenerTimeoutsTests extends ESTestCase {
wrapped.onFailure(new IOException("incorrect exception"));
assertFalse(success.get());
assertThat(exception.get(), instanceOf(ElasticsearchTimeoutException.class));
assertThat(exception.get(), instanceOf(OpenSearchTimeoutException.class));
}
public void testFinishNormallyBeforeTimeout() {

View File

@ -19,7 +19,7 @@
package org.elasticsearch.action.support;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
@ -245,7 +245,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
@Override
public <Request extends ActionRequest, Response extends ActionResponse> void execute(Task task, String action, Request request,
ActionListener<Response> listener, ActionFilterChain<Request, Response> actionFilterChain) {
listener.onFailure(new ElasticsearchTimeoutException(""));
listener.onFailure(new OpenSearchTimeoutException(""));
}
}
}

View File

@ -21,7 +21,7 @@ package org.elasticsearch.cluster;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.OpenSearchTimeoutException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.PlainActionFuture;
@ -258,7 +258,7 @@ public class NodeConnectionsServiceTests extends ESTestCase {
// however, now node0 is considered to be a new node so we will block on a subsequent attempt to connect to it
final PlainActionFuture<Void> future3 = new PlainActionFuture<>();
service.connectToNodes(nodes01, () -> future3.onResponse(null));
expectThrows(ElasticsearchTimeoutException.class, () -> future3.actionGet(timeValueMillis(scaledRandomIntBetween(1, 1000))));
expectThrows(OpenSearchTimeoutException.class, () -> future3.actionGet(timeValueMillis(scaledRandomIntBetween(1, 1000))));
// once the connection is unblocked we successfully connect to it.
connectionBarrier.await(10, TimeUnit.SECONDS);
@ -288,7 +288,7 @@ public class NodeConnectionsServiceTests extends ESTestCase {
// if we disconnect from a node while blocked trying to connect to it then the listener is notified
final PlainActionFuture<Void> future6 = new PlainActionFuture<>();
service.connectToNodes(nodes01, () -> future6.onResponse(null));
expectThrows(ElasticsearchTimeoutException.class, () -> future6.actionGet(timeValueMillis(scaledRandomIntBetween(1, 1000))));
expectThrows(OpenSearchTimeoutException.class, () -> future6.actionGet(timeValueMillis(scaledRandomIntBetween(1, 1000))));
service.disconnectFromNodesExcept(nodes1);
future6.actionGet(); // completed even though the connection attempt is still blocked