|
51 | 51 | import org.junit.BeforeClass;
|
52 | 52 |
|
53 | 53 | import java.io.IOException;
|
| 54 | +import java.util.Arrays; |
54 | 55 | import java.util.Random;
|
55 | 56 | import java.util.concurrent.CountDownLatch;
|
56 | 57 | import java.util.concurrent.TimeUnit;
|
|
65 | 66 | import static org.hamcrest.Matchers.equalTo;
|
66 | 67 | import static org.hamcrest.Matchers.instanceOf;
|
67 | 68 | import static org.hamcrest.Matchers.startsWith;
|
| 69 | +import static org.hamcrest.core.Is.is; |
68 | 70 | import static org.mockito.Mockito.mock;
|
69 | 71 | import static org.mockito.Mockito.verifyZeroInteractions;
|
70 | 72 |
|
@@ -289,6 +291,55 @@ public void handleException(TransportException exp) {
|
289 | 291 |
|
290 | 292 | assertTrue(countDownLatch.await(10, TimeUnit.SECONDS));
|
291 | 293 | }
|
| 294 | + |
| 295 | + { |
| 296 | + final CountDownLatch countDownLatch = new CountDownLatch(1); |
| 297 | + final GetDiscoveredNodesRequest getDiscoveredNodesRequest = new GetDiscoveredNodesRequest(); |
| 298 | + getDiscoveredNodesRequest.setRequiredNodes( |
| 299 | + Arrays.asList(localNode.getAddress().toString(), otherNode.getAddress().toString()) |
| 300 | + ); |
| 301 | + getDiscoveredNodesRequest.setTimeout(TimeValue.ZERO); |
| 302 | + transportService.sendRequest(localNode, GetDiscoveredNodesAction.NAME, getDiscoveredNodesRequest, new ResponseHandler() { |
| 303 | + @Override |
| 304 | + public void handleResponse(GetDiscoveredNodesResponse response) { |
| 305 | + assertThat(response.getNodes(), containsInAnyOrder(localNode, otherNode)); |
| 306 | + countDownLatch.countDown(); |
| 307 | + } |
| 308 | + |
| 309 | + @Override |
| 310 | + public void handleException(TransportException exp) { |
| 311 | + throw new AssertionError("should not be called", exp); |
| 312 | + } |
| 313 | + }); |
| 314 | + |
| 315 | + assertTrue(countDownLatch.await(10, TimeUnit.SECONDS)); |
| 316 | + } |
| 317 | + |
| 318 | + { |
| 319 | + final CountDownLatch countDownLatch = new CountDownLatch(1); |
| 320 | + final GetDiscoveredNodesRequest getDiscoveredNodesRequest = new GetDiscoveredNodesRequest(); |
| 321 | + getDiscoveredNodesRequest.setRequiredNodes( |
| 322 | + Arrays.asList(localNode.getAddress().toString(), localNode.getName()) |
| 323 | + ); |
| 324 | + getDiscoveredNodesRequest.setTimeout(TimeValue.ZERO); |
| 325 | + transportService.sendRequest(localNode, GetDiscoveredNodesAction.NAME, getDiscoveredNodesRequest, new ResponseHandler() { |
| 326 | + @Override |
| 327 | + public void handleResponse(GetDiscoveredNodesResponse response) { |
| 328 | + throw new AssertionError("should not be called"); |
| 329 | + } |
| 330 | + |
| 331 | + @Override |
| 332 | + public void handleException(TransportException exp) { |
| 333 | + Throwable t = exp.getRootCause(); |
| 334 | + assertThat(t, instanceOf(IllegalArgumentException.class)); |
| 335 | + assertThat(t.getMessage(), is("Node [" + localNode + "] matched both a name as well as an address entry" + |
| 336 | + " in the nodes list specified in setting [cluster.initial_master_nodes].")); |
| 337 | + countDownLatch.countDown(); |
| 338 | + } |
| 339 | + }); |
| 340 | + |
| 341 | + assertTrue(countDownLatch.await(10, TimeUnit.SECONDS)); |
| 342 | + } |
292 | 343 | }
|
293 | 344 |
|
294 | 345 | private abstract class ResponseHandler implements TransportResponseHandler<GetDiscoveredNodesResponse> {
|
|
0 commit comments