Search in sources :

Example 1 with NodeInfo

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

the class NodeStatsContextFieldResolverTest method testPSQLPortResolution.

@Test
public void testPSQLPortResolution() throws IOException {
    NodeInfo nodeInfo = mock(NodeInfo.class);
    when(nodeService.info()).thenReturn(nodeInfo);
    NodeStats stats = mock(NodeStats.class);
    when(nodeService.stats()).thenReturn(stats);
    when(stats.getNode()).thenReturn(mock(DiscoveryNode.class));
    InetSocketTransportAddress inetAddress = new InetSocketTransportAddress(Inet4Address.getLocalHost(), 5432);
    BoundTransportAddress boundAddress = new BoundTransportAddress(new TransportAddress[] { inetAddress }, inetAddress);
    when(postgresNetty.boundAddress()).thenReturn(boundAddress);
    NodeStatsContext context = resolver.forTopColumnIdents(ImmutableSet.of(SysNodesTableInfo.Columns.PORT));
    assertThat(context.isComplete(), is(true));
    assertThat(context.port().get("psql"), is(5432));
}
Also used : NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ExtendedNodeInfo(io.crate.monitor.ExtendedNodeInfo) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress) Test(org.junit.Test)

Example 2 with NodeInfo

use of org.elasticsearch.action.admin.cluster.node.info.NodeInfo 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 3 with NodeInfo

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

the class TransportClusterStatsAction method nodeOperation.

@Override
protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeRequest) {
    NodeInfo nodeInfo = nodeService.info(true, true, false, true, false, true, false, true, false, false);
    NodeStats nodeStats = nodeService.stats(CommonStatsFlags.NONE, true, true, true, false, true, false, false, false, false, false, false);
    List<ShardStats> shardsStats = new ArrayList<>();
    for (IndexService indexService : indicesService) {
        for (IndexShard indexShard : indexService) {
            if (indexShard.routingEntry() != null && indexShard.routingEntry().active()) {
                // only report on fully started shards
                shardsStats.add(new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indicesService.getIndicesQueryCache(), indexShard, SHARD_STATS_FLAGS), indexShard.commitStats(), indexShard.seqNoStats()));
            }
        }
    }
    ClusterHealthStatus clusterStatus = null;
    if (clusterService.state().nodes().isLocalNodeElectedMaster()) {
        clusterStatus = new ClusterStateHealth(clusterService.state()).getStatus();
    }
    return new ClusterStatsNodeResponse(nodeInfo.getNode(), clusterStatus, nodeInfo, nodeStats, shardsStats.toArray(new ShardStats[shardsStats.size()]));
}
Also used : ShardStats(org.elasticsearch.action.admin.indices.stats.ShardStats) ClusterHealthStatus(org.elasticsearch.cluster.health.ClusterHealthStatus) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) ClusterStateHealth(org.elasticsearch.cluster.health.ClusterStateHealth) CommonStats(org.elasticsearch.action.admin.indices.stats.CommonStats) IndexService(org.elasticsearch.index.IndexService) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) IndexShard(org.elasticsearch.index.shard.IndexShard) ArrayList(java.util.ArrayList)

Example 4 with NodeInfo

use of org.elasticsearch.action.admin.cluster.node.info.NodeInfo in project graylog2-server by Graylog2.

the class Cluster method getAllNodes.

public Map<String, NodeInfo> getAllNodes() {
    final ClusterAdminClient clusterAdminClient = c.admin().cluster();
    final NodesInfoRequest request = clusterAdminClient.prepareNodesInfo().all().request();
    final ImmutableMap.Builder<String, NodeInfo> builder = ImmutableMap.builder();
    for (NodeInfo nodeInfo : clusterAdminClient.nodesInfo(request).actionGet().getNodes()) {
        builder.put(nodeInfo.getNode().id(), nodeInfo);
    }
    return builder.build();
}
Also used : ClusterAdminClient(org.elasticsearch.client.ClusterAdminClient) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 5 with NodeInfo

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

the class NodePortExpressionTest method testNoHttpServerAvailable.

@Test
public void testNoHttpServerAvailable() throws Exception {
    NodeService nodeService = mock(NodeService.class);
    NodeInfo nodeInfo = mock(NodeInfo.class);
    when(nodeService.info()).thenReturn(nodeInfo);
    when(nodeInfo.getHttp()).thenReturn(null);
    NodePortExpression nodePortExpression = new NodePortExpression(nodeService);
    Object value = nodePortExpression.getChildImplementation("http").value();
    assertThat(value, Matchers.nullValue());
}
Also used : NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) NodeService(org.elasticsearch.node.service.NodeService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

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