Package org.elasticsearch.action.support
Class NodeResponseTracker
java.lang.Object
org.elasticsearch.action.support.NodeResponseTracker
This class tracks the intermediate responses that will be used to create aggregated cluster response to a request. It also gives the
possibility to discard the intermediate results when asked, for example when the initial request is cancelled, in order to release the
resources.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This exception is thrown when theNodeResponseTracker
is asked to give information about the responses after they have been discarded. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method discards the results collected so far to free up the resources.int
getResponse
(int nodeIndex) Returns the tracked response or null if the response hasn't been received yet for a specific index that represents a node of the cluster.boolean
boolean
trackResponseAndCheckIfLast
(int nodeIndex, Object response) This method stores a new node response if the intermediate responses haven't been discarded yet.
-
Constructor Details
-
NodeResponseTracker
public NodeResponseTracker(int size) -
NodeResponseTracker
-
-
Method Details
-
discardIntermediateResponses
This method discards the results collected so far to free up the resources.- Parameters:
cause
- the discarding, this will be communicated if they try to access the discarded results
-
responsesDiscarded
public boolean responsesDiscarded() -
trackResponseAndCheckIfLast
This method stores a new node response if the intermediate responses haven't been discarded yet. If the responses are not discarded the method asserts that this is the first response encountered from this node to protect from miscounting the responses in case of a double invocation. If the responses have been discarded we accept this risk for simplicity.- Parameters:
nodeIndex
- , the index that represents a single node of the clusterresponse
- , a response can be either a NodeResponse or an error- Returns:
- true if all the nodes' responses have been received, else false
-
getResponse
Returns the tracked response or null if the response hasn't been received yet for a specific index that represents a node of the cluster.- Throws:
NodeResponseTracker.DiscardedResponsesException
- if the responses have been discarded
-
getExpectedResponseCount
public int getExpectedResponseCount()
-