Updating with array changed to list.
Original commit: elastic/x-pack-elasticsearch@552227458f
This commit is contained in:
parent
ec0a4646ea
commit
080000a595
|
@ -20,6 +20,7 @@ import org.elasticsearch.xpack.XPackPlugin;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
||||||
|
@ -104,10 +105,10 @@ public class ShieldTransportClientIT extends ESIntegTestCase {
|
||||||
|
|
||||||
TransportClient transportClient(Settings extraSettings) {
|
TransportClient transportClient(Settings extraSettings) {
|
||||||
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
||||||
NodeInfo[] nodes = nodeInfos.getNodes();
|
List<NodeInfo> nodes = nodeInfos.getNodes();
|
||||||
assertTrue(nodes.length > 0);
|
assertTrue(nodes.isEmpty() == false);
|
||||||
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
|
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
|
||||||
String clusterName = nodeInfos.getClusterNameAsString();
|
String clusterName = nodeInfos.getClusterName().value();
|
||||||
|
|
||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.put(extraSettings)
|
.put(extraSettings)
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.elasticsearch.xpack.XPackPlugin;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
@ -58,10 +59,10 @@ public class CustomRealmIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testTransportClient() throws Exception {
|
public void testTransportClient() throws Exception {
|
||||||
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
||||||
NodeInfo[] nodes = nodeInfos.getNodes();
|
List<NodeInfo> nodes = nodeInfos.getNodes();
|
||||||
assertTrue(nodes.length > 0);
|
assertTrue(nodes.isEmpty() == false);
|
||||||
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
|
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
|
||||||
String clusterName = nodeInfos.getClusterNameAsString();
|
String clusterName = nodeInfos.getClusterName().value();
|
||||||
|
|
||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.put("cluster.name", clusterName)
|
.put("cluster.name", clusterName)
|
||||||
|
@ -78,10 +79,10 @@ public class CustomRealmIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testTransportClientWrongAuthentication() throws Exception {
|
public void testTransportClientWrongAuthentication() throws Exception {
|
||||||
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
||||||
NodeInfo[] nodes = nodeInfos.getNodes();
|
List<NodeInfo> nodes = nodeInfos.getNodes();
|
||||||
assertTrue(nodes.length > 0);
|
assertTrue(nodes.isEmpty() == false);
|
||||||
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
|
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
|
||||||
String clusterName = nodeInfos.getClusterNameAsString();
|
String clusterName = nodeInfos.getClusterName().value();
|
||||||
|
|
||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.put("cluster.name", clusterName)
|
.put("cluster.name", clusterName)
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
@ -117,12 +118,12 @@ public class SmokeTestMonitoringWithShieldIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private InetSocketAddress[] httpAddresses() {
|
private InetSocketAddress[] httpAddresses() {
|
||||||
NodeInfo[] nodes = client().admin().cluster().prepareNodesInfo().clear().setHttp(true).get().getNodes();
|
List<NodeInfo> nodes = client().admin().cluster().prepareNodesInfo().clear().setHttp(true).get().getNodes();
|
||||||
assertThat(nodes.length, greaterThan(0));
|
assertThat(nodes.size(), greaterThan(0));
|
||||||
|
|
||||||
InetSocketAddress[] httpAddresses = new InetSocketAddress[nodes.length];
|
InetSocketAddress[] httpAddresses = new InetSocketAddress[nodes.size()];
|
||||||
for (int i = 0; i < nodes.length; i++) {
|
for (int i = 0; i < nodes.size(); i++) {
|
||||||
httpAddresses[i] = ((InetSocketTransportAddress) nodes[i].getHttp().address().publishAddress()).address();
|
httpAddresses[i] = ((InetSocketTransportAddress) nodes.get(i).getHttp().address().publishAddress()).address();
|
||||||
}
|
}
|
||||||
return httpAddresses;
|
return httpAddresses;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,10 @@ public class NodeStatsCollector extends AbstractCollector<NodeStatsCollector> {
|
||||||
|
|
||||||
// if there's a failure, then we failed to work with the _local node (guaranteed a single exception)
|
// if there's a failure, then we failed to work with the _local node (guaranteed a single exception)
|
||||||
if (response.hasFailures()) {
|
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
|
// 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
|
// It would be nicer to use a settings API like documented in #6732
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase {
|
||||||
|
|
||||||
private void assertPluginIsLoaded() {
|
private void assertPluginIsLoaded() {
|
||||||
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
|
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
|
||||||
for (NodeInfo nodeInfo : response) {
|
for (NodeInfo nodeInfo : response.getNodes()) {
|
||||||
assertNotNull(nodeInfo.getPlugins());
|
assertNotNull(nodeInfo.getPlugins());
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
@ -103,7 +103,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase {
|
||||||
internalCluster().getDataNodeInstance(klass);
|
internalCluster().getDataNodeInstance(klass);
|
||||||
fail("should have thrown an exception about missing implementation");
|
fail("should have thrown an exception about missing implementation");
|
||||||
} catch (Exception ce) {
|
} 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));
|
ce.getMessage().contains("No implementation"), equalTo(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase {
|
||||||
assertThat(clusterInfoMarvelDoc.getClusterName(),
|
assertThat(clusterInfoMarvelDoc.getClusterName(),
|
||||||
equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getClusterName().value()));
|
equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getClusterName().value()));
|
||||||
assertThat(clusterInfoMarvelDoc.getVersion(),
|
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());
|
assertThat(clusterInfoMarvelDoc.getLicense(), notNullValue());
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
package org.elasticsearch.marvel.agent.resolver.cluster;
|
package org.elasticsearch.marvel.agent.resolver.cluster;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
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.action.admin.cluster.stats.ClusterStatsResponse;
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
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.exporter.MarvelTemplateUtils;
|
||||||
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolverTestCase;
|
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolverTestCase;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
|
@ -47,7 +46,7 @@ public class ClusterInfoResolverTests extends MonitoringIndexNameResolverTestCas
|
||||||
doc.setLicense(licenseBuilder.build());
|
doc.setLicense(licenseBuilder.build());
|
||||||
doc.setClusterName(randomAsciiOfLength(5));
|
doc.setClusterName(randomAsciiOfLength(5));
|
||||||
doc.setClusterStats(new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT,
|
doc.setClusterStats(new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT,
|
||||||
randomAsciiOfLength(5), new ClusterStatsNodeResponse[]{}, new FailedNodeException[0]));
|
randomAsciiOfLength(5), Collections.emptyList(), Collections.emptyList()));
|
||||||
return doc;
|
return doc;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException("Failed to generated random ClusterInfoMarvelDoc", e);
|
throw new IllegalStateException("Failed to generated random ClusterInfoMarvelDoc", e);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.marvel.agent.resolver.cluster;
|
package org.elasticsearch.marvel.agent.resolver.cluster;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
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.NodeInfo;
|
||||||
import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
|
import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
|
||||||
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
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.
|
* @return a testing {@link ClusterStatsResponse} used to resolve a marvel document.
|
||||||
*/
|
*/
|
||||||
private ClusterStatsResponse randomClusterStats() {
|
private ClusterStatsResponse randomClusterStats() {
|
||||||
ClusterStatsNodeResponse[] responses = {
|
List<ClusterStatsNodeResponse> responses = Collections.singletonList(
|
||||||
new ClusterStatsNodeResponse(new DiscoveryNode("node_0", DummyTransportAddress.INSTANCE,
|
new ClusterStatsNodeResponse(new DiscoveryNode("node_0", DummyTransportAddress.INSTANCE,
|
||||||
emptyMap(), emptySet(), Version.CURRENT),
|
emptyMap(), emptySet(), Version.CURRENT),
|
||||||
ClusterHealthStatus.GREEN, randomNodeInfo(), randomNodeStats(), randomShardStats())
|
ClusterHealthStatus.GREEN, randomNodeInfo(), randomNodeStats(), randomShardStats())
|
||||||
};
|
);
|
||||||
return new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, UUID.randomUUID().toString(), responses,
|
return new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, UUID.randomUUID().toString(),
|
||||||
new FailedNodeException[0]);
|
responses, Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -26,26 +27,24 @@ public class ClearRealmCacheResponse extends BaseNodesResponse<ClearRealmCacheRe
|
||||||
public ClearRealmCacheResponse() {
|
public ClearRealmCacheResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClearRealmCacheResponse(ClusterName clusterName, Node[] nodes, FailedNodeException[] failures) {
|
public ClearRealmCacheResponse(ClusterName clusterName, List<Node> nodes, List<FailedNodeException> failures) {
|
||||||
super(clusterName, nodes, failures);
|
super(clusterName, nodes, failures);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
nodes = in.readArray(Node[]::new, Node::readNodeResponse);
|
nodes = in.readList(Node::readNodeResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
out.writeArray(nodes);
|
out.writeStreamableList(nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
super.toInnerXContent(builder, params);
|
|
||||||
|
|
||||||
builder.startObject("nodes");
|
builder.startObject("nodes");
|
||||||
for (ClearRealmCacheResponse.Node node : getNodes()) {
|
for (ClearRealmCacheResponse.Node node : getNodes()) {
|
||||||
builder.startObject(node.getNode().getId());
|
builder.startObject(node.getNode().getId());
|
||||||
|
|
|
@ -20,6 +20,8 @@ import org.elasticsearch.shield.authc.support.CachingRealm;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -41,7 +43,7 @@ public class TransportClearRealmCacheAction extends TransportNodesAction<ClearRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClearRealmCacheResponse newResponse(ClearRealmCacheRequest request,
|
protected ClearRealmCacheResponse newResponse(ClearRealmCacheRequest request,
|
||||||
ClearRealmCacheResponse.Node[] responses, FailedNodeException[] failures) {
|
List<ClearRealmCacheResponse.Node> responses, List<FailedNodeException> failures) {
|
||||||
return new ClearRealmCacheResponse(clusterName, responses, failures);
|
return new ClearRealmCacheResponse(clusterName, responses, failures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The response object that will be returned when clearing the cache of native roles
|
* The response object that will be returned when clearing the cache of native roles
|
||||||
|
@ -26,26 +27,24 @@ public class ClearRolesCacheResponse extends BaseNodesResponse<ClearRolesCacheRe
|
||||||
public ClearRolesCacheResponse() {
|
public ClearRolesCacheResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClearRolesCacheResponse(ClusterName clusterName, Node[] nodes, FailedNodeException[] failures) {
|
public ClearRolesCacheResponse(ClusterName clusterName, List<Node> nodes, List<FailedNodeException> failures) {
|
||||||
super(clusterName, nodes, failures);
|
super(clusterName, nodes, failures);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
nodes = in.readArray(Node[]::new, Node::readNodeResponse);
|
nodes = in.readList(Node::readNodeResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
out.writeArray(nodes);
|
out.writeStreamableList(nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
super.toInnerXContent(builder, params);
|
|
||||||
|
|
||||||
builder.startObject("nodes");
|
builder.startObject("nodes");
|
||||||
for (ClearRolesCacheResponse.Node node: getNodes()) {
|
for (ClearRolesCacheResponse.Node node: getNodes()) {
|
||||||
builder.startObject(node.getNode().getId());
|
builder.startObject(node.getNode().getId());
|
||||||
|
|
|
@ -17,6 +17,8 @@ import org.elasticsearch.shield.authz.store.NativeRolesStore;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +39,7 @@ public class TransportClearRolesCacheAction extends TransportNodesAction<ClearRo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClearRolesCacheResponse newResponse(ClearRolesCacheRequest request,
|
protected ClearRolesCacheResponse newResponse(ClearRolesCacheRequest request,
|
||||||
ClearRolesCacheResponse.Node[] responses, FailedNodeException[] failures) {
|
List<ClearRolesCacheResponse.Node> responses, List<FailedNodeException> failures) {
|
||||||
return new ClearRolesCacheResponse(clusterName, responses, failures);
|
return new ClearRolesCacheResponse(clusterName, responses, failures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,18 +8,12 @@ package org.elasticsearch.shield.rest.action.realm;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
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.BaseRestHandler;
|
||||||
import org.elasticsearch.rest.BytesRestResponse;
|
|
||||||
import org.elasticsearch.rest.RestChannel;
|
import org.elasticsearch.rest.RestChannel;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.rest.RestResponse;
|
import org.elasticsearch.rest.action.support.RestActions.NodesResponseRestListener;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
|
||||||
import org.elasticsearch.rest.action.support.RestBuilderListener;
|
|
||||||
import org.elasticsearch.shield.action.realm.ClearRealmCacheRequest;
|
import org.elasticsearch.shield.action.realm.ClearRealmCacheRequest;
|
||||||
import org.elasticsearch.shield.action.realm.ClearRealmCacheResponse;
|
|
||||||
import org.elasticsearch.shield.client.SecurityClient;
|
import org.elasticsearch.shield.client.SecurityClient;
|
||||||
|
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
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);
|
ClearRealmCacheRequest req = new ClearRealmCacheRequest().realms(realms).usernames(usernames);
|
||||||
|
|
||||||
new SecurityClient(client).clearRealmCache(req, new RestBuilderListener<ClearRealmCacheResponse>(channel) {
|
new SecurityClient(client).clearRealmCache(req, new NodesResponseRestListener<>(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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,12 @@ package org.elasticsearch.shield.rest.action.role;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
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.BaseRestHandler;
|
||||||
import org.elasticsearch.rest.BytesRestResponse;
|
|
||||||
import org.elasticsearch.rest.RestChannel;
|
import org.elasticsearch.rest.RestChannel;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.rest.RestResponse;
|
import org.elasticsearch.rest.action.support.RestActions.NodesResponseRestListener;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
|
||||||
import org.elasticsearch.rest.action.support.RestBuilderListener;
|
|
||||||
import org.elasticsearch.shield.action.role.ClearRolesCacheRequest;
|
import org.elasticsearch.shield.action.role.ClearRolesCacheRequest;
|
||||||
import org.elasticsearch.shield.action.role.ClearRolesCacheResponse;
|
|
||||||
import org.elasticsearch.shield.client.SecurityClient;
|
import org.elasticsearch.shield.client.SecurityClient;
|
||||||
|
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||||
|
@ -42,15 +36,6 @@ public class RestClearRolesCacheAction extends BaseRestHandler {
|
||||||
|
|
||||||
ClearRolesCacheRequest req = new ClearRolesCacheRequest().names(roles);
|
ClearRolesCacheRequest req = new ClearRolesCacheRequest().names(roles);
|
||||||
|
|
||||||
new SecurityClient(client).clearRolesCache(req, new RestBuilderListener<ClearRolesCacheResponse>(channel) {
|
new SecurityClient(client).clearRolesCache(req, new NodesResponseRestListener<>(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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class ClearRealmsCacheTests extends ShieldIntegTestCase {
|
||||||
securityClient.clearRealmCache(request, new ActionListener<ClearRealmCacheResponse>() {
|
securityClient.clearRealmCache(request, new ActionListener<ClearRealmCacheResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(ClearRealmCacheResponse response) {
|
public void onResponse(ClearRealmCacheResponse response) {
|
||||||
assertThat(response.getNodes().length, equalTo(internalCluster().getNodeNames().length));
|
assertThat(response.getNodes().size(), equalTo(internalCluster().getNodeNames().length));
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase {
|
||||||
final List<String> addresses = new ArrayList<>();
|
final List<String> addresses = new ArrayList<>();
|
||||||
// get addresses for current cluster
|
// get addresses for current cluster
|
||||||
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
|
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
|
||||||
final String clusterName = response.getClusterNameAsString();
|
final String clusterName = response.getClusterName().value();
|
||||||
for (NodeInfo nodeInfo : response.getNodes()) {
|
for (NodeInfo nodeInfo : response.getNodes()) {
|
||||||
InetSocketTransportAddress address = (InetSocketTransportAddress) nodeInfo.getTransport().address().publishAddress();
|
InetSocketTransportAddress address = (InetSocketTransportAddress) nodeInfo.getTransport().address().publishAddress();
|
||||||
addresses.add(address.address().getHostString() + ":" + address.address().getPort());
|
addresses.add(address.address().getHostString() + ":" + address.address().getPort());
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.xpack.XPackPlugin;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
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...
|
// build our own here to better mimic an actual client...
|
||||||
TransportClient getTransportClient(Settings extraSettings) {
|
TransportClient getTransportClient(Settings extraSettings) {
|
||||||
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
||||||
NodeInfo[] nodes = nodeInfos.getNodes();
|
List<NodeInfo> nodes = nodeInfos.getNodes();
|
||||||
assertTrue(nodes.length > 0);
|
assertTrue(nodes.isEmpty() == false);
|
||||||
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
|
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
|
||||||
String clusterName = nodeInfos.getClusterNameAsString();
|
String clusterName = nodeInfos.getClusterName().value();
|
||||||
|
|
||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.put(extraSettings)
|
.put(extraSettings)
|
||||||
|
|
|
@ -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
|
//before methods from the superclass are run before this, which means that the current cluster is ready to go
|
||||||
public void assertShieldIsInstalled() {
|
public void assertShieldIsInstalled() {
|
||||||
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get();
|
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?
|
// TODO: disable this assertion for now, due to random runs with mock plugins. perhaps run without mock plugins?
|
||||||
// assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2));
|
// assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2));
|
||||||
Collection<String> pluginNames =
|
Collection<String> pluginNames =
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class WatcherPluginDisableTests extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testThreadPools() throws Exception {
|
public void testThreadPools() throws Exception {
|
||||||
NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().setThreadPool(true).get();
|
NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().setThreadPool(true).get();
|
||||||
for (NodeInfo nodeInfo : nodesInfo) {
|
for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
|
||||||
ThreadPoolInfo threadPoolInfo = nodeInfo.getThreadPool();
|
ThreadPoolInfo threadPoolInfo = nodeInfo.getThreadPool();
|
||||||
for (ThreadPool.Info info : threadPoolInfo) {
|
for (ThreadPool.Info info : threadPoolInfo) {
|
||||||
assertThat(info.getName(), not(is(InternalWatchExecutor.THREAD_POOL_NAME)));
|
assertThat(info.getName(), not(is(InternalWatchExecutor.THREAD_POOL_NAME)));
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class WatcherScheduleEngineBenchmark {
|
||||||
try {
|
try {
|
||||||
while (start.get()) {
|
while (start.get()) {
|
||||||
NodesStatsResponse response = client.admin().cluster().prepareNodesStats("_master").setJvm(true).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());
|
jvmUsedHeapSpace.inc(heapUsed.bytes());
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ public class WatcherScheduleEngineBenchmark {
|
||||||
sampleThread.join();
|
sampleThread.join();
|
||||||
|
|
||||||
NodesStatsResponse response = client.admin().cluster().prepareNodesStats().setThreadPool(true).get();
|
NodesStatsResponse response = client.admin().cluster().prepareNodesStats().setThreadPool(true).get();
|
||||||
for (NodeStats nodeStats : response) {
|
for (NodeStats nodeStats : response.getNodes()) {
|
||||||
for (ThreadPoolStats.Stats threadPoolStats : nodeStats.getThreadPool()) {
|
for (ThreadPoolStats.Stats threadPoolStats : nodeStats.getThreadPool()) {
|
||||||
if ("watcher".equals(threadPoolStats.getName())) {
|
if ("watcher".equals(threadPoolStats.getName())) {
|
||||||
stats.setWatcherThreadPoolStats(threadPoolStats);
|
stats.setWatcherThreadPoolStats(threadPoolStats);
|
||||||
|
|
Loading…
Reference in New Issue