Search in sources :

Example 1 with LTRStatsNodeResponse

use of com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeResponse in project elasticsearch-learning-to-rank by o19s.

the class TransportLTRStatsActionTests method testNewResponse.

public void testNewResponse() {
    String[] nodeIds = null;
    LTRStatsNodesRequest ltrStatsRequest = new LTRStatsNodesRequest(nodeIds);
    ltrStatsRequest.setStatsToBeRetrieved(ltrStats.getStats().keySet());
    List<LTRStatsNodeResponse> responses = new ArrayList<>();
    List<FailedNodeException> failures = new ArrayList<>();
    LTRStatsNodesResponse ltrStatsResponse = action.newResponse(ltrStatsRequest, responses, failures);
    assertEquals(1, ltrStatsResponse.getClusterStats().size());
}
Also used : LTRStatsNodesResponse(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodesResponse) LTRStatsNodesRequest(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodesRequest) ArrayList(java.util.ArrayList) FailedNodeException(org.elasticsearch.action.FailedNodeException) LTRStatsNodeResponse(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeResponse)

Example 2 with LTRStatsNodeResponse

use of com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeResponse in project elasticsearch-learning-to-rank by o19s.

the class TransportLTRStatsActionTests method testNodeOperation.

public void testNodeOperation() {
    String[] nodeIds = null;
    LTRStatsNodesRequest ltrStatsRequest = new LTRStatsNodesRequest(nodeIds);
    ltrStatsRequest.setStatsToBeRetrieved(ltrStats.getStats().keySet());
    LTRStatsNodeResponse response = action.nodeOperation(new LTRStatsNodeRequest(ltrStatsRequest));
    Map<String, Object> stats = response.getStatsMap();
    assertEquals(1, stats.size());
}
Also used : LTRStatsNodeRequest(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeRequest) LTRStatsNodesRequest(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodesRequest) LTRStatsNodeResponse(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeResponse)

Example 3 with LTRStatsNodeResponse

use of com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeResponse in project elasticsearch-learning-to-rank by o19s.

the class TransportLTRStatsAction method nodeOperation.

@Override
protected LTRStatsNodeResponse nodeOperation(LTRStatsNodeRequest request) {
    LTRStatsNodesRequest nodesRequest = request.getLTRStatsNodesRequest();
    Set<String> statsToBeRetrieved = nodesRequest.getStatsToBeRetrieved();
    Map<String, Object> statValues = ltrStats.getNodeStats().entrySet().stream().filter(e -> statsToBeRetrieved.contains(e.getKey())).collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getStatValue()));
    return new LTRStatsNodeResponse(clusterService.localNode(), statValues);
}
Also used : LTRStats(com.o19s.es.ltr.stats.LTRStats) LTRStatsNodesResponse(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodesResponse) ActionFilters(org.elasticsearch.action.support.ActionFilters) FailedNodeException(org.elasticsearch.action.FailedNodeException) ClusterService(org.elasticsearch.cluster.service.ClusterService) LTRStatsNodeRequest(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeRequest) Set(java.util.Set) LTRStatsNodeResponse(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeResponse) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) TransportNodesAction(org.elasticsearch.action.support.nodes.TransportNodesAction) Inject(org.elasticsearch.common.inject.Inject) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) List(java.util.List) StreamInput(org.elasticsearch.common.io.stream.StreamInput) Map(java.util.Map) LTRStatsNodesRequest(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodesRequest) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TransportService(org.elasticsearch.transport.TransportService) LTRStatsNodesRequest(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodesRequest) LTRStatsNodeResponse(com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeResponse) Map(java.util.Map)

Aggregations

LTRStatsNodeResponse (com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeResponse)3 LTRStatsNodesRequest (com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodesRequest)3 LTRStatsNodeRequest (com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodeRequest)2 LTRStatsNodesResponse (com.o19s.es.ltr.action.LTRStatsAction.LTRStatsNodesResponse)2 FailedNodeException (org.elasticsearch.action.FailedNodeException)2 LTRStats (com.o19s.es.ltr.stats.LTRStats)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ActionFilters (org.elasticsearch.action.support.ActionFilters)1 TransportNodesAction (org.elasticsearch.action.support.nodes.TransportNodesAction)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 ClusterService (org.elasticsearch.cluster.service.ClusterService)1 Inject (org.elasticsearch.common.inject.Inject)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1 ThreadPool (org.elasticsearch.threadpool.ThreadPool)1 TransportService (org.elasticsearch.transport.TransportService)1