Throw MasterNotDiscoveredException whenever retry logic of TransportMasterNodeAction times out
Closes #14737
This commit is contained in:
parent
be64bfb135
commit
9673ddc5d0
|
@ -164,7 +164,7 @@ public abstract class TransportMasterNodeAction<Request extends MasterNodeReques
|
|||
} else {
|
||||
if (nodes.masterNode() == null) {
|
||||
logger.debug("no known master node, scheduling a retry");
|
||||
retry(new MasterNotDiscoveredException(), masterNodeChangedPredicate);
|
||||
retry(null, masterNodeChangedPredicate);
|
||||
} else {
|
||||
transportService.sendRequest(nodes.masterNode(), actionName, request, new ActionListenerResponseHandler<Response>(listener) {
|
||||
@Override
|
||||
|
@ -205,7 +205,7 @@ public abstract class TransportMasterNodeAction<Request extends MasterNodeReques
|
|||
@Override
|
||||
public void onTimeout(TimeValue timeout) {
|
||||
logger.debug("timed out while retrying [{}] after failure (timeout [{}])", failure, actionName, timeout);
|
||||
listener.onFailure(failure);
|
||||
listener.onFailure(new MasterNotDiscoveredException(failure));
|
||||
}
|
||||
}, changePredicate
|
||||
);
|
||||
|
|
|
@ -34,6 +34,10 @@ public class MasterNotDiscoveredException extends ElasticsearchException {
|
|||
super("");
|
||||
}
|
||||
|
||||
public MasterNotDiscoveredException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public MasterNotDiscoveredException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
|
@ -214,7 +214,17 @@ public class TransportMasterNodeActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
assertTrue(listener.isDone());
|
||||
assertListenerThrows("ClusterBlockException should be thrown", listener, ClusterBlockException.class);
|
||||
if (retryableBlock) {
|
||||
try {
|
||||
listener.get();
|
||||
fail("Expected exception but returned proper result");
|
||||
} catch (ExecutionException ex) {
|
||||
assertThat(ex.getCause(), instanceOf(MasterNotDiscoveredException.class));
|
||||
assertThat(ex.getCause().getCause(), instanceOf(ClusterBlockException.class));
|
||||
}
|
||||
} else {
|
||||
assertListenerThrows("ClusterBlockException should be thrown", listener, ClusterBlockException.class);
|
||||
}
|
||||
}
|
||||
|
||||
public void testForceLocalOperation() throws ExecutionException, InterruptedException {
|
||||
|
|
Loading…
Reference in New Issue