}
return taskHandles;
}
private TaskOptions toTaskOptions(Task task) {
final QueueSettings queueSettings = task.getQueueSettings();
TaskOptions taskOptions = TaskOptions.Builder.withUrl(TaskHandler.HANDLE_TASK_URL);
if (queueSettings.getOnBackend() != null) {
taskOptions.header("Host", BackendServiceFactory.getBackendService().getBackendAddress(
queueSettings.getOnBackend()));
} else {
String versionHostname = RetryHelper.runWithRetries(new Callable<String>() {
@Override
public String call() {
ModulesService service = ModulesServiceFactory.getModulesService();
String module = queueSettings.getOnModule();
String version = queueSettings.getModuleVersion();
if (module == null) {
module = service.getCurrentModule();
version = service.getCurrentVersion();
}
return service.getVersionHostname(module, version);
}
}, RetryParams.getDefaultInstance(), MODULES_EXCEPTION_HANDLER);
taskOptions.header("Host", versionHostname);
}
Long delayInSeconds = queueSettings.getDelayInSeconds();
if (null != delayInSeconds) {
taskOptions.countdownMillis(delayInSeconds * 1000L);
queueSettings.setDelayInSeconds(null);
}
addProperties(taskOptions, task.toProperties());
String taskName = task.getName();
if (null != taskName) {
taskOptions.taskName(taskName);