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));
}
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);
}
});
}
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()]));
}
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();
}
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());
}
Aggregations