Search in sources :

Example 6 with NodesInfoResponse

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

the class PutPipelineTransportAction method masterOperation.

@Override
protected void masterOperation(PutPipelineRequest request, ClusterState state, ActionListener<WritePipelineResponse> listener) throws Exception {
    NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
    nodesInfoRequest.clear();
    nodesInfoRequest.ingest(true);
    nodesInfoAction.execute(nodesInfoRequest, new ActionListener<NodesInfoResponse>() {

        @Override
        public void onResponse(NodesInfoResponse nodeInfos) {
            try {
                Map<DiscoveryNode, IngestInfo> ingestInfos = new HashMap<>();
                for (NodeInfo nodeInfo : nodeInfos.getNodes()) {
                    ingestInfos.put(nodeInfo.getNode(), nodeInfo.getIngest());
                }
                pipelineStore.put(clusterService, ingestInfos, request, listener);
            } catch (Exception e) {
                onFailure(e);
            }
        }

        @Override
        public void onFailure(Exception e) {
            listener.onFailure(e);
        }
    });
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) HashMap(java.util.HashMap) Map(java.util.Map) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException)

Example 7 with NodesInfoResponse

use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project elasticsearch-skywalker by jprante.

the class AbstractNodeTest method createIndices.

@BeforeMethod
public void createIndices() throws Exception {
    startNode("1");
    NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
    NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
    InetSocketTransportAddress address = (InetSocketTransportAddress) response.iterator().next().getTransport().getAddress().publishAddress();
    addresses.put("1", address);
    client("1").admin().indices().create(new CreateIndexRequest(INDEX)).actionGet();
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) CreateIndexRequest(org.elasticsearch.action.admin.indices.create.CreateIndexRequest) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with NodesInfoResponse

use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project elasticsearch-suggest-plugin by spinscale.

the class RestSuggestActionTest method setPort.

@Before
public void setPort() {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setHttp(true).execute().actionGet();
    port = ((InetSocketTransportAddress) response.getNodes()[0].getHttp().address().boundAddress()).address().getPort();
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress) Before(org.junit.Before)

Example 9 with NodesInfoResponse

use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse 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)

Example 10 with NodesInfoResponse

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

the class Netty4TransportMultiPortIntegrationIT method testThatInfosAreExposed.

@Network
public void testThatInfosAreExposed() throws Exception {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().clear().setTransport(true).get();
    for (NodeInfo nodeInfo : response.getNodes()) {
        assertThat(nodeInfo.getTransport().getProfileAddresses().keySet(), hasSize(1));
        assertThat(nodeInfo.getTransport().getProfileAddresses(), hasKey("client1"));
        BoundTransportAddress boundTransportAddress = nodeInfo.getTransport().getProfileAddresses().get("client1");
        for (TransportAddress transportAddress : boundTransportAddress.boundAddresses()) {
            assertThat(transportAddress, instanceOf(TransportAddress.class));
        }
        // bound addresses
        for (TransportAddress transportAddress : boundTransportAddress.boundAddresses()) {
            assertThat(transportAddress, instanceOf(TransportAddress.class));
            assertThat(transportAddress.address().getPort(), is(allOf(greaterThanOrEqualTo(randomPort), lessThanOrEqualTo(randomPort + 10))));
        }
        // publish address
        assertThat(boundTransportAddress.publishAddress(), instanceOf(TransportAddress.class));
        TransportAddress publishAddress = boundTransportAddress.publishAddress();
        assertThat(NetworkAddress.format(publishAddress.address().getAddress()), is("127.0.0.7"));
        assertThat(publishAddress.address().getPort(), is(4321));
    }
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) TransportAddress(org.elasticsearch.common.transport.TransportAddress) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) Network(org.elasticsearch.test.junit.annotations.Network)

Aggregations

NodesInfoResponse (org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse)20 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)13 NodesInfoRequest (org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)7 Settings (org.elasticsearch.common.settings.Settings)6 TransportAddress (org.elasticsearch.common.transport.TransportAddress)5 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)4 ClusterStateRequest (org.elasticsearch.action.admin.cluster.state.ClusterStateRequest)4 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)4 NodeClient (org.elasticsearch.client.node.NodeClient)4 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)4 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)4 Table (org.elasticsearch.common.Table)4 RestController (org.elasticsearch.rest.RestController)4 RestRequest (org.elasticsearch.rest.RestRequest)4 GET (org.elasticsearch.rest.RestRequest.Method.GET)4 RestResponse (org.elasticsearch.rest.RestResponse)4 RestActionListener (org.elasticsearch.rest.action.RestActionListener)4 RestResponseListener (org.elasticsearch.rest.action.RestResponseListener)4 Map (java.util.Map)3 HashMap (java.util.HashMap)2