private int doFetch(final TaskContext taskContext) {
        int executingTaskCount = 0;
        info(taskContext, () -> "Starting task fetch");

        // Get the trackers.
        info(taskContext, () -> "Getting trackers");
        final JobNodeTrackers trackers = jobNodeTrackerCache.getTrackers();

        // Get this node.
        final String nodeName = nodeInfo.getThisNodeName();

        // Find out how many tasks we need in total.
        info(taskContext, () -> "Get required task count");
        int totalTaskLimit = getTotalTaskLimit(trackers);

        // If there are some tasks we need to get then get them.
        if (totalTaskLimit > 0) {
            if (targetNodeSetFactory.isClusterStateInitialised()) {
                for (final Entry<String, DistributedTaskFactory> entry :
                        distributedTaskFactoryRegistry.getFactoryMap().entrySet()) {
                    if (totalTaskLimit > 0) {
                        final String jobName = entry.getKey();
                        final DistributedTaskFactory distributedTaskFactory = entry.getValue();

                        LOGGER.debug(() -> LogUtil.message("Task request: node=\"{}\"",
                                nodeName));
                        LOGGER.trace(() -> LogUtil.message("\nTask request: node=\"{}\"\n{}",
                                nodeName,
                                distributedTaskFactory));

                        info(taskContext, () -> "Calling distributed task factory");
                        final List<DistributedTask> tasks = distributedTaskFactory.fetch(
                                nodeName,
                                totalTaskLimit);
                        info(taskContext, () -> "Executing " + tasks.size() + " new tasks");
                        handleResult(nodeName, jobName, tasks);
                        executingTaskCount += tasks.size();
                        totalTaskLimit -= tasks.size();
                    }
                }
            }
        }
        return executingTaskCount;
    }
Tries to fetch tasks asynchronously if we aren't already fetching tasks.
If we are it will make sure we immediately try and fetch tasks again
after the previous fetch.
stroom-job/stroom-job-impl/src/main/java/stroom/job/impl/DistributedTaskFetcher.java