Throw MasterNotDiscoveredException whenever retry logic of TransportMasterNodeAction times out

Closes #14737
This commit is contained in:
Yannick Welsch 2015-11-13 12:21:45 +01:00
parent be64bfb135
commit 9673ddc5d0
3 changed files with 17 additions and 3 deletions

View File

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

View File

@ -34,6 +34,10 @@ public class MasterNotDiscoveredException extends ElasticsearchException {
super("");
}
public MasterNotDiscoveredException(Throwable cause) {
super(cause);
}
public MasterNotDiscoveredException(String message) {
super(message);
}

View File

@ -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 {