use of io.crate.operation.reference.sys.node.NodeStatsContext in project crate by crate.
the class TransportNodeStatsAction method nodeOperation.
@Override
public void nodeOperation(NodeStatsRequest request, ActionListener<NodeStatsResponse> listener) {
try {
NodeStatsContext context = nodeContextFieldsResolver.forTopColumnIdents(request.columnIdents());
listener.onResponse(new NodeStatsResponse(context));
} catch (Throwable t) {
listener.onFailure(t);
}
}
use of io.crate.operation.reference.sys.node.NodeStatsContext in project crate by crate.
the class NodeStatsIterator method getNodeStatsContextFromRemoteState.
private CompletableFuture<List<NodeStatsContext>> getNodeStatsContextFromRemoteState(Set<ColumnIdent> toCollect) {
final CompletableFuture<List<NodeStatsContext>> nodeStatsContextsFuture = new CompletableFuture<>();
final List<NodeStatsContext> rows = Collections.synchronizedList(new ArrayList<NodeStatsContext>(nodes.size()));
final AtomicInteger remainingNodesToCollect = new AtomicInteger(nodes.size());
for (final DiscoveryNode node : nodes) {
final String nodeId = node.getId();
final NodeStatsRequest request = new NodeStatsRequest(toCollect);
transportStatTablesAction.execute(nodeId, request, new ActionListener<NodeStatsResponse>() {
@Override
public void onResponse(NodeStatsResponse response) {
rows.add(response.nodeStatsContext());
if (remainingNodesToCollect.decrementAndGet() == 0) {
nodeStatsContextsFuture.complete(rows);
}
}
@Override
public void onFailure(Throwable t) {
if (t instanceof ReceiveTimeoutTransportException) {
rows.add(new NodeStatsContext(nodeId, node.name()));
if (remainingNodesToCollect.decrementAndGet() == 0) {
nodeStatsContextsFuture.complete(rows);
}
} else {
nodeStatsContextsFuture.completeExceptionally(t);
}
}
}, TimeValue.timeValueMillis(3000L));
}
return nodeStatsContextsFuture;
}
use of io.crate.operation.reference.sys.node.NodeStatsContext in project crate by crate.
the class NodeStatsCollectSource method nodeIds.
@Nullable
static Collection<DiscoveryNode> nodeIds(WhereClause whereClause, Collection<DiscoveryNode> nodes, Functions functions) {
if (!whereClause.hasQuery()) {
return nodes;
}
LocalSysColReferenceResolver localSysColReferenceResolver = new LocalSysColReferenceResolver(ImmutableList.of(SysNodesTableInfo.Columns.NAME, SysNodesTableInfo.Columns.ID));
EvaluatingNormalizer normalizer = new EvaluatingNormalizer(functions, RowGranularity.DOC, ReplaceMode.COPY, localSysColReferenceResolver, null);
List<DiscoveryNode> newNodes = new ArrayList<>();
for (DiscoveryNode node : nodes) {
String nodeId = node.getId();
for (RowCollectExpression<NodeStatsContext, ?> expression : localSysColReferenceResolver.expressions()) {
expression.setNextRow(new NodeStatsContext(nodeId, node.name()));
}
Symbol normalized = normalizer.normalize(whereClause.query(), null);
if (normalized.equals(whereClause.query())) {
// No local available sys nodes columns in where clause
return nodes;
}
if (WhereClause.canMatch(normalized)) {
newNodes.add(node);
}
}
return newNodes;
}
Aggregations