diff --git a/elasticsearch/qa/shield-client-tests/src/test/java/org/elasticsearch/shield/qa/ShieldTransportClientIT.java b/elasticsearch/qa/shield-client-tests/src/test/java/org/elasticsearch/shield/qa/ShieldTransportClientIT.java index b0522871545..bc8cb9aa510 100644 --- a/elasticsearch/qa/shield-client-tests/src/test/java/org/elasticsearch/shield/qa/ShieldTransportClientIT.java +++ b/elasticsearch/qa/shield-client-tests/src/test/java/org/elasticsearch/shield/qa/ShieldTransportClientIT.java @@ -20,6 +20,7 @@ import org.elasticsearch.xpack.XPackPlugin; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.concurrent.TimeUnit; import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue; @@ -104,10 +105,10 @@ public class ShieldTransportClientIT extends ESIntegTestCase { TransportClient transportClient(Settings extraSettings) { NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); - NodeInfo[] nodes = nodeInfos.getNodes(); - assertTrue(nodes.length > 0); + List nodes = nodeInfos.getNodes(); + assertTrue(nodes.isEmpty() == false); TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress(); - String clusterName = nodeInfos.getClusterNameAsString(); + String clusterName = nodeInfos.getClusterName().value(); Settings settings = Settings.builder() .put(extraSettings) diff --git a/elasticsearch/qa/shield-example-realm/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java b/elasticsearch/qa/shield-example-realm/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java index 2c6b60b7b8f..0e46268b2a2 100644 --- a/elasticsearch/qa/shield-example-realm/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java +++ b/elasticsearch/qa/shield-example-realm/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java @@ -21,6 +21,7 @@ import org.elasticsearch.xpack.XPackPlugin; import java.util.Collection; import java.util.Collections; +import java.util.List; import static org.hamcrest.Matchers.is; @@ -58,10 +59,10 @@ public class CustomRealmIT extends ESIntegTestCase { public void testTransportClient() throws Exception { NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); - NodeInfo[] nodes = nodeInfos.getNodes(); - assertTrue(nodes.length > 0); + List nodes = nodeInfos.getNodes(); + assertTrue(nodes.isEmpty() == false); TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress(); - String clusterName = nodeInfos.getClusterNameAsString(); + String clusterName = nodeInfos.getClusterName().value(); Settings settings = Settings.builder() .put("cluster.name", clusterName) @@ -78,10 +79,10 @@ public class CustomRealmIT extends ESIntegTestCase { public void testTransportClientWrongAuthentication() throws Exception { NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); - NodeInfo[] nodes = nodeInfos.getNodes(); - assertTrue(nodes.length > 0); + List nodes = nodeInfos.getNodes(); + assertTrue(nodes.isEmpty() == false); TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress(); - String clusterName = nodeInfos.getClusterNameAsString(); + String clusterName = nodeInfos.getClusterName().value(); Settings settings = Settings.builder() .put("cluster.name", clusterName) diff --git a/elasticsearch/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithShieldIT.java b/elasticsearch/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithShieldIT.java index f4f74d20c3f..23dc1b4a34a 100644 --- a/elasticsearch/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithShieldIT.java +++ b/elasticsearch/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithShieldIT.java @@ -28,6 +28,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; import java.util.Collections; +import java.util.List; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; @@ -117,12 +118,12 @@ public class SmokeTestMonitoringWithShieldIT extends ESIntegTestCase { } private InetSocketAddress[] httpAddresses() { - NodeInfo[] nodes = client().admin().cluster().prepareNodesInfo().clear().setHttp(true).get().getNodes(); - assertThat(nodes.length, greaterThan(0)); + List nodes = client().admin().cluster().prepareNodesInfo().clear().setHttp(true).get().getNodes(); + assertThat(nodes.size(), greaterThan(0)); - InetSocketAddress[] httpAddresses = new InetSocketAddress[nodes.length]; - for (int i = 0; i < nodes.length; i++) { - httpAddresses[i] = ((InetSocketTransportAddress) nodes[i].getHttp().address().publishAddress()).address(); + InetSocketAddress[] httpAddresses = new InetSocketAddress[nodes.size()]; + for (int i = 0; i < nodes.size(); i++) { + httpAddresses[i] = ((InetSocketTransportAddress) nodes.get(i).getHttp().address().publishAddress()).address(); } return httpAddresses; } diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java index 4a9784bcea8..680596fdf1c 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java @@ -76,10 +76,10 @@ public class NodeStatsCollector extends AbstractCollector { // if there's a failure, then we failed to work with the _local node (guaranteed a single exception) if (response.hasFailures()) { - throw response.failures()[0]; + throw response.failures().get(0); } - NodeStats nodeStats = response.getAt(0); + NodeStats nodeStats = response.getNodes().get(0); // Here we are calling directly the DiskThresholdDecider to retrieve the high watermark value // It would be nicer to use a settings API like documented in #6732 diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java index 63b4753e673..9e7d39fd542 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java @@ -72,7 +72,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase { private void assertPluginIsLoaded() { NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get(); - for (NodeInfo nodeInfo : response) { + for (NodeInfo nodeInfo : response.getNodes()) { assertNotNull(nodeInfo.getPlugins()); boolean found = false; @@ -103,7 +103,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase { internalCluster().getDataNodeInstance(klass); fail("should have thrown an exception about missing implementation"); } catch (Exception ce) { - assertThat("message contains error about missing implemention: " + ce.getMessage(), + assertThat("message contains error about missing implementation: " + ce.getMessage(), ce.getMessage().contains("No implementation"), equalTo(true)); } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java index 8d6c4120677..84d2bbe2e5f 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java @@ -50,7 +50,7 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase { assertThat(clusterInfoMarvelDoc.getClusterName(), equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getClusterName().value())); assertThat(clusterInfoMarvelDoc.getVersion(), - equalTo(client().admin().cluster().prepareNodesInfo().get().getNodes()[0].getVersion().toString())); + equalTo(client().admin().cluster().prepareNodesInfo().get().getNodes().get(0).getVersion().toString())); assertThat(clusterInfoMarvelDoc.getLicense(), notNullValue()); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoResolverTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoResolverTests.java index c9c4e412ed7..514f75351fa 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoResolverTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoResolverTests.java @@ -6,8 +6,6 @@ package org.elasticsearch.marvel.agent.resolver.cluster; import org.elasticsearch.Version; -import org.elasticsearch.action.FailedNodeException; -import org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodeResponse; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -19,6 +17,7 @@ import org.elasticsearch.marvel.agent.collector.cluster.ClusterInfoMonitoringDoc import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils; import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolverTestCase; +import java.util.Collections; import java.util.UUID; import static java.util.Collections.emptyMap; @@ -47,7 +46,7 @@ public class ClusterInfoResolverTests extends MonitoringIndexNameResolverTestCas doc.setLicense(licenseBuilder.build()); doc.setClusterName(randomAsciiOfLength(5)); doc.setClusterStats(new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, - randomAsciiOfLength(5), new ClusterStatsNodeResponse[]{}, new FailedNodeException[0])); + randomAsciiOfLength(5), Collections.emptyList(), Collections.emptyList())); return doc; } catch (Exception e) { throw new IllegalStateException("Failed to generated random ClusterInfoMarvelDoc", e); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsResolverTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsResolverTests.java index fe5479891b7..dc470d63388 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsResolverTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsResolverTests.java @@ -6,7 +6,6 @@ package org.elasticsearch.marvel.agent.resolver.cluster; import org.elasticsearch.Version; -import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; @@ -93,13 +92,13 @@ public class ClusterStatsResolverTests extends MonitoringIndexNameResolverTestCa * @return a testing {@link ClusterStatsResponse} used to resolve a marvel document. */ private ClusterStatsResponse randomClusterStats() { - ClusterStatsNodeResponse[] responses = { + List responses = Collections.singletonList( new ClusterStatsNodeResponse(new DiscoveryNode("node_0", DummyTransportAddress.INSTANCE, emptyMap(), emptySet(), Version.CURRENT), ClusterHealthStatus.GREEN, randomNodeInfo(), randomNodeStats(), randomShardStats()) - }; - return new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, UUID.randomUUID().toString(), responses, - new FailedNodeException[0]); + ); + return new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, UUID.randomUUID().toString(), + responses, Collections.emptyList()); } /** diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/ClearRealmCacheResponse.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/ClearRealmCacheResponse.java index 37b4143b498..04dc2a26e34 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/ClearRealmCacheResponse.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/ClearRealmCacheResponse.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import java.io.IOException; +import java.util.List; /** * @@ -26,28 +27,26 @@ public class ClearRealmCacheResponse extends BaseNodesResponse nodes, List failures) { super(clusterName, nodes, failures); } @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - nodes = in.readArray(Node[]::new, Node::readNodeResponse); + nodes = in.readList(Node::readNodeResponse); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeArray(nodes); + out.writeStreamableList(nodes); } @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - super.toInnerXContent(builder, params); - builder.startObject("nodes"); - for (ClearRealmCacheResponse.Node node: getNodes()) { + for (ClearRealmCacheResponse.Node node : getNodes()) { builder.startObject(node.getNode().getId()); builder.field("name", node.getNode().getName()); builder.endObject(); diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/TransportClearRealmCacheAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/TransportClearRealmCacheAction.java index 5085be2d18d..c2a4c81a63b 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/TransportClearRealmCacheAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/TransportClearRealmCacheAction.java @@ -20,6 +20,8 @@ import org.elasticsearch.shield.authc.support.CachingRealm; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.List; + /** * */ @@ -41,7 +43,7 @@ public class TransportClearRealmCacheAction extends TransportNodesAction responses, List failures) { return new ClearRealmCacheResponse(clusterName, responses, failures); } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/ClearRolesCacheResponse.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/ClearRolesCacheResponse.java index 011cf5d5951..88cd1477689 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/ClearRolesCacheResponse.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/ClearRolesCacheResponse.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import java.io.IOException; +import java.util.List; /** * The response object that will be returned when clearing the cache of native roles @@ -26,26 +27,24 @@ public class ClearRolesCacheResponse extends BaseNodesResponse nodes, List failures) { super(clusterName, nodes, failures); } @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - nodes = in.readArray(Node[]::new, Node::readNodeResponse); + nodes = in.readList(Node::readNodeResponse); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeArray(nodes); + out.writeStreamableList(nodes); } @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - super.toInnerXContent(builder, params); - builder.startObject("nodes"); for (ClearRolesCacheResponse.Node node: getNodes()) { builder.startObject(node.getNode().getId()); diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/TransportClearRolesCacheAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/TransportClearRolesCacheAction.java index a02fc372831..0d1498ac9ff 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/TransportClearRolesCacheAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/TransportClearRolesCacheAction.java @@ -17,6 +17,8 @@ import org.elasticsearch.shield.authz.store.NativeRolesStore; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.List; + /** * */ @@ -37,7 +39,7 @@ public class TransportClearRolesCacheAction extends TransportNodesAction responses, List failures) { return new ClearRolesCacheResponse(clusterName, responses, failures); } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/realm/RestClearRealmCacheAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/realm/RestClearRealmCacheAction.java index 111bcd9c0fa..a33ded253fb 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/realm/RestClearRealmCacheAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/realm/RestClearRealmCacheAction.java @@ -8,18 +8,12 @@ package org.elasticsearch.shield.rest.action.realm; import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestResponse; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.support.RestBuilderListener; +import org.elasticsearch.rest.action.support.RestActions.NodesResponseRestListener; import org.elasticsearch.shield.action.realm.ClearRealmCacheRequest; -import org.elasticsearch.shield.action.realm.ClearRealmCacheResponse; import org.elasticsearch.shield.client.SecurityClient; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -41,16 +35,7 @@ public class RestClearRealmCacheAction extends BaseRestHandler { ClearRealmCacheRequest req = new ClearRealmCacheRequest().realms(realms).usernames(usernames); - new SecurityClient(client).clearRealmCache(req, new RestBuilderListener(channel) { - @Override - public RestResponse buildResponse(ClearRealmCacheResponse response, XContentBuilder builder) throws Exception { - builder.startObject(); - response.toXContent(builder, ToXContent.EMPTY_PARAMS); - builder.endObject(); - - return new BytesRestResponse(RestStatus.OK, builder); - } - }); + new SecurityClient(client).clearRealmCache(req, new NodesResponseRestListener<>(channel)); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/role/RestClearRolesCacheAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/role/RestClearRolesCacheAction.java index b3b8f959560..1c142f6f90a 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/role/RestClearRolesCacheAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/role/RestClearRolesCacheAction.java @@ -8,18 +8,12 @@ package org.elasticsearch.shield.rest.action.role; import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestResponse; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.support.RestBuilderListener; +import org.elasticsearch.rest.action.support.RestActions.NodesResponseRestListener; import org.elasticsearch.shield.action.role.ClearRolesCacheRequest; -import org.elasticsearch.shield.action.role.ClearRolesCacheResponse; import org.elasticsearch.shield.client.SecurityClient; import static org.elasticsearch.rest.RestRequest.Method.POST; @@ -42,15 +36,6 @@ public class RestClearRolesCacheAction extends BaseRestHandler { ClearRolesCacheRequest req = new ClearRolesCacheRequest().names(roles); - new SecurityClient(client).clearRolesCache(req, new RestBuilderListener(channel) { - @Override - public RestResponse buildResponse(ClearRolesCacheResponse response, XContentBuilder builder) throws Exception { - builder.startObject(); - response.toXContent(builder, ToXContent.EMPTY_PARAMS); - builder.endObject(); - - return new BytesRestResponse(RestStatus.OK, builder); - } - }); + new SecurityClient(client).clearRolesCache(req, new NodesResponseRestListener<>(channel)); } } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java index 070f7c7eb44..303b3e90ca0 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java @@ -147,7 +147,7 @@ public class ClearRealmsCacheTests extends ShieldIntegTestCase { securityClient.clearRealmCache(request, new ActionListener() { @Override public void onResponse(ClearRealmCacheResponse response) { - assertThat(response.getNodes().length, equalTo(internalCluster().getNodeNames().length)); + assertThat(response.getNodes().size(), equalTo(internalCluster().getNodeNames().length)); latch.countDown(); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java index 5f7df4fbe55..d0bc8f7bb5a 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java @@ -82,7 +82,7 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase { final List addresses = new ArrayList<>(); // get addresses for current cluster NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet(); - final String clusterName = response.getClusterNameAsString(); + final String clusterName = response.getClusterName().value(); for (NodeInfo nodeInfo : response.getNodes()) { InetSocketTransportAddress address = (InetSocketTransportAddress) nodeInfo.getTransport().address().publishAddress(); addresses.add(address.address().getHostString() + ":" + address.address().getPort()); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/RunAsIntegTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/RunAsIntegTests.java index b43a7465b17..5da10e734b3 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/RunAsIntegTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/RunAsIntegTests.java @@ -25,6 +25,7 @@ import org.elasticsearch.xpack.XPackPlugin; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import static org.hamcrest.Matchers.containsString; @@ -207,10 +208,10 @@ public class RunAsIntegTests extends ShieldIntegTestCase { // build our own here to better mimic an actual client... TransportClient getTransportClient(Settings extraSettings) { NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); - NodeInfo[] nodes = nodeInfos.getNodes(); - assertTrue(nodes.length > 0); + List nodes = nodeInfos.getNodes(); + assertTrue(nodes.isEmpty() == false); TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress(); - String clusterName = nodeInfos.getClusterNameAsString(); + String clusterName = nodeInfos.getClusterName().value(); Settings settings = Settings.builder() .put(extraSettings) diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java index 8e137009f49..0b7f24a04ff 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java @@ -140,7 +140,7 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase { //before methods from the superclass are run before this, which means that the current cluster is ready to go public void assertShieldIsInstalled() { NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get(); - for (NodeInfo nodeInfo : nodeInfos) { + for (NodeInfo nodeInfo : nodeInfos.getNodes()) { // TODO: disable this assertion for now, due to random runs with mock plugins. perhaps run without mock plugins? // assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2)); Collection pluginNames = diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java index 005786d48e8..54d266b47fa 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java @@ -81,7 +81,7 @@ public class WatcherPluginDisableTests extends ESIntegTestCase { public void testThreadPools() throws Exception { NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().setThreadPool(true).get(); - for (NodeInfo nodeInfo : nodesInfo) { + for (NodeInfo nodeInfo : nodesInfo.getNodes()) { ThreadPoolInfo threadPoolInfo = nodeInfo.getThreadPool(); for (ThreadPool.Info info : threadPoolInfo) { assertThat(info.getName(), not(is(InternalWatchExecutor.THREAD_POOL_NAME))); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java index 379fcd91f8a..ff75b1bf78a 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java @@ -165,7 +165,7 @@ public class WatcherScheduleEngineBenchmark { try { while (start.get()) { NodesStatsResponse response = client.admin().cluster().prepareNodesStats("_master").setJvm(true).get(); - ByteSizeValue heapUsed = response.getNodes()[0].getJvm().getMem().getHeapUsed(); + ByteSizeValue heapUsed = response.getNodes().get(0).getJvm().getMem().getHeapUsed(); jvmUsedHeapSpace.inc(heapUsed.bytes()); Thread.sleep(1000); } @@ -179,7 +179,7 @@ public class WatcherScheduleEngineBenchmark { sampleThread.join(); NodesStatsResponse response = client.admin().cluster().prepareNodesStats().setThreadPool(true).get(); - for (NodeStats nodeStats : response) { + for (NodeStats nodeStats : response.getNodes()) { for (ThreadPoolStats.Stats threadPoolStats : nodeStats.getThreadPool()) { if ("watcher".equals(threadPoolStats.getName())) { stats.setWatcherThreadPoolStats(threadPoolStats);