Search in sources :

Example 16 with NodeInfo

use of org.elasticsearch.action.admin.cluster.node.info.NodeInfo in project elasticsearch by elastic.

the class ESIntegTestCase method createRestClient.

protected static RestClient createRestClient(RestClientBuilder.HttpClientConfigCallback httpClientConfigCallback, String protocol) {
    final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
    final List<NodeInfo> nodes = nodeInfos.getNodes();
    assertFalse(nodeInfos.hasFailures());
    List<HttpHost> hosts = new ArrayList<>();
    for (NodeInfo node : nodes) {
        if (node.getHttp() != null) {
            TransportAddress publishAddress = node.getHttp().address().publishAddress();
            InetSocketAddress address = publishAddress.address();
            hosts.add(new HttpHost(NetworkAddress.format(address.getAddress()), address.getPort(), protocol));
        }
    }
    RestClientBuilder builder = RestClient.builder(hosts.toArray(new HttpHost[hosts.size()]));
    if (httpClientConfigCallback != null) {
        builder.setHttpClientConfigCallback(httpClientConfigCallback);
    }
    return builder.build();
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) HttpHost(org.apache.http.HttpHost) TransportAddress(org.elasticsearch.common.transport.TransportAddress) InetSocketAddress(java.net.InetSocketAddress) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) RestClientBuilder(org.elasticsearch.client.RestClientBuilder)

Example 17 with NodeInfo

use of org.elasticsearch.action.admin.cluster.node.info.NodeInfo in project elasticsearch by elastic.

the class AckClusterUpdateSettingsIT method testClusterUpdateSettingsNoAcknowledgement.

public void testClusterUpdateSettingsNoAcknowledgement() {
    client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put("number_of_shards", between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS)).put("number_of_replicas", 0)).get();
    ensureGreen();
    // now that the cluster is stable, remove timeout
    removePublishTimeout();
    NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().get();
    String excludedNodeId = null;
    for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
        if (nodeInfo.getNode().isDataNode()) {
            excludedNodeId = nodeInfo.getNode().getId();
            break;
        }
    }
    assertNotNull(excludedNodeId);
    ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTimeout("0s").setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
    assertThat(clusterUpdateSettingsResponse.isAcknowledged(), equalTo(false));
    assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)

Example 18 with NodeInfo

use of org.elasticsearch.action.admin.cluster.node.info.NodeInfo in project elasticsearch by elastic.

the class AckClusterUpdateSettingsIT method testClusterUpdateSettingsAcknowledgement.

public void testClusterUpdateSettingsAcknowledgement() {
    createIndex("test");
    ensureGreen();
    // now that the cluster is stable, remove timeout
    removePublishTimeout();
    NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().get();
    String excludedNodeId = null;
    for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
        if (nodeInfo.getNode().isDataNode()) {
            excludedNodeId = nodeInfo.getNode().getId();
            break;
        }
    }
    assertNotNull(excludedNodeId);
    ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
    assertAcked(clusterUpdateSettingsResponse);
    assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
    for (Client client : clients()) {
        ClusterState clusterState = getLocalClusterState(client);
        assertThat(clusterState.metaData().transientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
        for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) {
            for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
                for (ShardRouting shardRouting : indexShardRoutingTable) {
                    assert clusterState.nodes() != null;
                    if (shardRouting.unassigned() == false && clusterState.nodes().get(shardRouting.currentNodeId()).getId().equals(excludedNodeId)) {
                        //if the shard is still there it must be relocating and all nodes need to know, since the request was acknowledged
                        //reroute happens as part of the update settings and we made sure no throttling comes into the picture via settings
                        assertThat(shardRouting.relocating(), equalTo(true));
                    }
                }
            }
        }
    }
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) ClusterState(org.elasticsearch.cluster.ClusterState) IndexRoutingTable(org.elasticsearch.cluster.routing.IndexRoutingTable) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) Client(org.elasticsearch.client.Client) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting)

Example 19 with NodeInfo

use of org.elasticsearch.action.admin.cluster.node.info.NodeInfo in project elasticsearch by elastic.

the class SettingsFilteringIT method testNodeInfoIsFiltered.

public void testNodeInfoIsFiltered() {
    NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setSettings(true).get();
    for (NodeInfo info : nodeInfos.getNodes()) {
        Settings settings = info.getSettings();
        assertNotNull(settings);
        assertNull(settings.get(SettingsFilteringPlugin.SOME_NODE_SETTING.getKey()));
        assertTrue(settings.getAsBoolean(SettingsFilteringPlugin.SOME_OTHER_NODE_SETTING.getKey(), false));
        assertEquals(settings.get("node.name"), info.getNode().getName());
    }
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) Settings(org.elasticsearch.common.settings.Settings)

Example 20 with NodeInfo

use of org.elasticsearch.action.admin.cluster.node.info.NodeInfo in project elasticsearch-jdbc by jprante.

the class NodeTestUtils method findNodeAddresses.

protected void findNodeAddresses() {
    NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
    NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
    Iterator<NodeInfo> it = response.iterator();
    hosts = new LinkedList<>();
    hosts = new LinkedList<>();
    while (it.hasNext()) {
        NodeInfo nodeInfo = it.next();
        TransportInfo transportInfo = nodeInfo.getTransport();
        TransportAddress address = transportInfo.getAddress().publishAddress();
        if (address instanceof InetSocketTransportAddress) {
            InetSocketTransportAddress inetSocketTransportAddress = (InetSocketTransportAddress) address;
            hosts.add(inetSocketTransportAddress.address().getHostName() + ":" + inetSocketTransportAddress.address().getPort());
        }
    }
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) TransportInfo(org.elasticsearch.transport.TransportInfo) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress) TransportAddress(org.elasticsearch.common.transport.TransportAddress) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress)

Aggregations

NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)22 NodesInfoResponse (org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse)9 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)6 TransportAddress (org.elasticsearch.common.transport.TransportAddress)6 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)5 Map (java.util.Map)4 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)4 Table (org.elasticsearch.common.Table)4 BoundTransportAddress (org.elasticsearch.common.transport.BoundTransportAddress)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 NodesInfoRequest (org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)3 Settings (org.elasticsearch.common.settings.Settings)3 JvmInfo (org.elasticsearch.monitor.jvm.JvmInfo)3 ClusterUpdateSettingsResponse (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)2 HttpInfo (org.elasticsearch.http.HttpInfo)2 ProcessStats (org.elasticsearch.monitor.process.ProcessStats)2 PluginInfo (org.elasticsearch.plugins.PluginInfo)2 ThreadPool (org.elasticsearch.threadpool.ThreadPool)2 TransportInfo (org.elasticsearch.transport.TransportInfo)2