Class DistributedApiAsyncTracker
- java.lang.Object
- 
- org.apache.solr.cloud.DistributedApiAsyncTracker
 
- 
 public class DistributedApiAsyncTracker extends Object Class holding the implementation required for tracking asynchronous Collection API (or other) tasks when the Collection API is distributed.This replaces the features provided by the distributed maps on ZK paths /overseer/collection-map-completed, /overseer/collection-map-failure and /overseer/async_ids when the Collection API commands are handled by the Overseer. It works by using two Zookeeper directories, one for persistent nodes for each new async id and one for ephemeral nodes for each async id currently being processed (in flight). 
 A persistent async node has either no data, or has a serialized OverseerSolrResponse as content. An ephemeral async node has two possible states (content): 'S' or 'R'.The actual state of an async task is built from a combination of the two nodes: +===================+=========================================+=================================================+====================+ | | persistent=success OverseerSolrResponse | persistent=null or failed OverseerSolrResponse | No persistent node | +===================+=========================================+=================================================+====================+ | ephemeral="S" | Task completed successfully | Task submitted | Unknown task | +-------------------+-----------------------------------------+-------------------------------------------------+--------------------+ | ephemeral="R" | Task completed successfully | Task running | Unknown task | +-------------------+-----------------------------------------+-------------------------------------------------+--------------------+ | No ephemeral node | Task completed successfully | Task failed (see response or null=node failure) | Unknown task | +-------------------+-----------------------------------------+-------------------------------------------------+--------------------+ 
- 
- 
Field SummaryFields Modifier and Type Field Description static intMAX_TRACKED_ASYNC_TASKSCorresponds to Overseer.NUM_RESPONSES_TO_STORE.
 - 
Constructor SummaryConstructors Constructor Description DistributedApiAsyncTracker(SolrZkClient zkClient, String rootPath)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancelAsyncId(String asyncId)Cancels the tracking of an asyncId, if the corresponding command could not be executed.booleancreateNewAsyncJobTracker(String asyncId)After a successful call to this method, caller MUST eventually callsetTaskCompleted(java.lang.String, org.apache.solr.cloud.OverseerSolrResponse)orcancelAsyncId(java.lang.String)otherwise the task will forever be considered as in progress.voiddeleteAllAsyncIds()Deletes all async id's for completed or failed async jobs.booleandeleteSingleAsyncId(String asyncId)Deletes a single async tracking ID if the corresponding job has completed or failed.Pair<RequestStatusState,OverseerSolrResponse>getAsyncTaskRequestStatus(String asyncId)This method implements the logic described in the class Javadoc table (DistributedApiAsyncTracker), using the two sets of tracking info to build the actual state of an async task.voidsetTaskCompleted(String asyncId, OverseerSolrResponse solrResponse)Mark the completion (success or error) of an async task.voidsetTaskRunning(String asyncId)Initially an async task is submitted.
 
- 
- 
- 
Constructor Detail- 
DistributedApiAsyncTrackerpublic DistributedApiAsyncTracker(SolrZkClient zkClient, String rootPath) 
 
- 
 - 
Method Detail- 
createNewAsyncJobTrackerpublic boolean createNewAsyncJobTracker(String asyncId) After a successful call to this method, caller MUST eventually callsetTaskCompleted(java.lang.String, org.apache.solr.cloud.OverseerSolrResponse)orcancelAsyncId(java.lang.String)otherwise the task will forever be considered as in progress.- Parameters:
- asyncId- if- nullthis method will do nothing.
- Returns:
- trueif the asyncId was not already in use (or is- null) and- falseif it is already in use and can't be allocated again.
 
 - 
setTaskRunningpublic void setTaskRunning(String asyncId) Initially an async task is submitted. Just before it actually starts execution it is set to running.
 - 
setTaskCompletedpublic void setTaskCompleted(String asyncId, OverseerSolrResponse solrResponse) Mark the completion (success or error) of an async task. The success or error is judged by the contents of theOverseerSolrResponse.
 - 
cancelAsyncIdpublic void cancelAsyncId(String asyncId) Cancels the tracking of an asyncId, if the corresponding command could not be executed.
 - 
getAsyncTaskRequestStatuspublic Pair<RequestStatusState,OverseerSolrResponse> getAsyncTaskRequestStatus(String asyncId) throws Exception This method implements the logic described in the class Javadoc table (DistributedApiAsyncTracker), using the two sets of tracking info to build the actual state of an async task.Returns the status of an async task, and when relevant the corresponding response from the command execution. The returned OverseerSolrResponsewill not benullwhen the returnedRequestStatusStateisRequestStatusState.COMPLETEDorRequestStatusState.FAILED(and will benullin all other cases).- Throws:
- Exception
 
 - 
deleteSingleAsyncIdpublic boolean deleteSingleAsyncId(String asyncId) throws Exception Deletes a single async tracking ID if the corresponding job has completed or failed.- Returns:
- trueif the- asyncIdwas found to be of a completed or failed job and was successfully removed,- falseif the id was not found or was found for a submitted or running job (these are not removed).
- Throws:
- Exception
 
 
- 
 
-