use of com.enonic.xp.impl.task.distributed.DistributableTask in project xp by enonic.
the class TaskServiceImpl method submitTask.
@Override
public TaskId submitTask(SubmitTaskParams params) {
TaskManager taskManager;
taskManager = clusteredTaskManagerRef.getNow(null);
if (taskManager == null) {
if (acceptOffloaded) {
LOG.debug("Clustered task manager is unavailable, falling back to local task manager.");
taskManager = localTaskManager;
} else {
try {
LOG.info("Clustered task manager is unavailable, waiting...");
taskManager = clusteredTaskManagerRef.get(5, TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException e) {
throw new RuntimeException(e);
}
}
}
final DistributableTask task = new DistributableTask(params.getDescriptorKey(), params.getData(), buildContext());
taskManager.submitTask(task);
return task.getTaskId();
}
Aggregations