Class DistributedApiAsyncTracker
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 Summary
FieldsModifier and TypeFieldDescriptionstatic intCorresponds to Overseer.NUM_RESPONSES_TO_STORE. -
Constructor Summary
ConstructorsConstructorDescriptionDistributedApiAsyncTracker(org.apache.solr.common.cloud.SolrZkClient zkClient, String rootPath) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelAsyncId(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.voidDeletes 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.org.apache.solr.common.util.Pair<org.apache.solr.client.solrj.response.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.
-
Field Details
-
MAX_TRACKED_ASYNC_TASKS
public static int MAX_TRACKED_ASYNC_TASKSCorresponds to Overseer.NUM_RESPONSES_TO_STORE. The size of the persistent store of async ID's put in Zookeeper. This is the max total tracked async request ID's over all nodes running in the distributed Collection API.
-
-
Constructor Details
-
DistributedApiAsyncTracker
public DistributedApiAsyncTracker(org.apache.solr.common.cloud.SolrZkClient zkClient, String rootPath)
-
-
Method Details
-
createNewAsyncJobTracker
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- ifnullthis method will do nothing.- Returns:
trueif the asyncId was not already in use (or isnull) andfalseif it is already in use and can't be allocated again.
-
setTaskRunning
Initially an async task is submitted. Just before it actually starts execution it is set to running. -
setTaskCompleted
Mark the completion (success or error) of an async task. The success or error is judged by the contents of theOverseerSolrResponse. -
cancelAsyncId
Cancels the tracking of an asyncId, if the corresponding command could not be executed. -
getAsyncTaskRequestStatus
public org.apache.solr.common.util.Pair<org.apache.solr.client.solrj.response.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
-
deleteSingleAsyncId
Deletes a single async tracking ID if the corresponding job has completed or failed.- Returns:
trueif theasyncIdwas 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
-
deleteAllAsyncIds
Deletes all async id's for completed or failed async jobs. Does not touch id's for submitted or running jobs.- Throws:
Exception
-