Skip to content

Commit

Permalink
[Rename] ElasticsearchTimeoutException class in server module (#173)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nknize committed Mar 22, 2021
1 parent 64d7e7e commit 7788250
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -669,7 +669,7 @@ private void waitForTimeoutTestCase(Function<TaskId, ? extends Iterable<? extend

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -752,7 +752,7 @@ public void run(){
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();
Expand All @@ -779,7 +779,7 @@ private void waitForOutstandingRequests(TimeValue timeOut, Semaphore requestsOut
//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 + "]" );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,8 @@ private enum OpenSearchExceptionHandle {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@
*
*
*/
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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;
Expand Down Expand Up @@ -146,7 +146,7 @@ public void onClusterServiceClose() {

@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"));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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;
Expand Down Expand Up @@ -104,7 +104,7 @@ public void onClusterServiceClose() {

@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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -46,7 +46,7 @@ public static <Response> ActionListener<Response> wrapWithTimeout(ThreadPool thr
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));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -75,7 +75,7 @@ public static <T> T get(Future<T> future, long timeout, TimeUnit unit) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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;
Expand Down Expand Up @@ -217,7 +217,7 @@ protected synchronized void processAsyncFetch(List<T> responses, List<FailedNode
// 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 [{}]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
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;
Expand Down Expand Up @@ -383,7 +383,7 @@ public void onClusterServiceClose() {
@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 + "])"));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

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;
Expand Down Expand Up @@ -279,7 +279,7 @@ protected void doRun() throws Exception {
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;
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/org/elasticsearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
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;
Expand Down Expand Up @@ -881,7 +881,7 @@ public void onTimeout(TimeValue timeout) {
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");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

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;
Expand Down Expand Up @@ -129,7 +129,7 @@ protected void processResponse(GetMappingsResponse getMappingsResponse) {
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();
Expand Down
6 changes: 3 additions & 3 deletions server/src/main/java/org/elasticsearch/tasks/TaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
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;
Expand Down Expand Up @@ -433,7 +433,7 @@ public void waitForTaskCompletion(Task task, long untilInNanos) {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -59,7 +59,7 @@ public V txGet(long timeout, TimeUnit unit) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ public void testIds() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -506,7 +506,7 @@ public void testTimesOut() throws InterruptedException {

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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,7 +149,7 @@ public void testTimesOutIfWaitingForNodesThatAreNotRemoved() throws InterruptedE
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. ["));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void testListenerTimeout() {
wrapped.onFailure(new IOException("incorrect exception"));

assertFalse(success.get());
assertThat(exception.get(), instanceOf(ElasticsearchTimeoutException.class));
assertThat(exception.get(), instanceOf(OpenSearchTimeoutException.class));
}

public void testFinishNormallyBeforeTimeout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -245,7 +245,7 @@ public <Request extends ActionRequest, Response extends ActionResponse> void exe
@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(""));
}
}
}
Expand Down
Loading

0 comments on commit 7788250

Please sign in to comment.