private TaskLauncher findTaskLaucher(String platformName) { Launcher launcher = this.launcherRepository.findByName(platformName); if (launcher == null) { List<String> launcherNames = StreamSupport.stream(launcherRepository.findAll().spliterator(), false) .map(Launcher::getName) .collect(Collectors.toList()); throw new IllegalStateException(String.format("No Launcher found for the platform named '%s'. " + "Available platform names are %s", platformName, launcherNames)); } TaskLauncher taskLauncher = launcher.getTaskLauncher(); if (taskLauncher == null) { throw new IllegalStateException(String.format("No TaskLauncher found for the platform named '%s'", platformName)); } return taskLauncher; }
@Override public void cleanupExecution(long id) { TaskExecution taskExecution = taskExplorer.getTaskExecution(id); Assert.notNull(taskExecution, "There was no task execution with id " + id); String launchId = taskExecution.getExternalExecutionId(); Assert.hasLength(launchId, "The TaskExecution for id " + id + " did not have an externalExecutionId"); TaskDeployment taskDeployment = this.taskDeploymentRepository.findByTaskDeploymentId(String.valueOf(id)); if (taskDeployment == null) { logger.warn(String.format("Did not find TaskDeployment for taskName = [%s], taskId = [%s]. Nothing to clean up.", taskExecution.getTaskName(), id)); return; } Launcher launcher = launcherRepository.findByName(taskDeployment.getPlatformName()); if (launcher != null) { TaskLauncher taskLauncher = launcher.getTaskLauncher(); taskLauncher.cleanup(launchId); } else { logger.info( "Could clean up execution for task id " + id + ". Did not find a task platform named " + taskDeployment.getPlatformName()); } }
private void destroyTask(TaskDefinition taskDefinition) { taskDefinitionRepository.deleteById(taskDefinition.getName()); TaskDeployment taskDeployment = this.taskDeploymentRepository.findTopByTaskDefinitionNameOrderByCreatedOnAsc(taskDefinition.getTaskName()); if (taskDeployment != null) { Launcher launcher = launcherRepository.findByName(taskDeployment.getPlatformName()); if (launcher != null) { TaskLauncher taskLauncher = launcher.getTaskLauncher(); taskLauncher.destroy(taskDefinition.getName()); } } else { logger.info("TaskLauncher.destroy not invoked for task " + taskDefinition.getTaskName() + ". Did not find a previously launched task to destroy."); } } }
final List<RuntimeEnvironmentDetails> taskLauncherInfoList = new ArrayList<RuntimeEnvironmentDetails>(); for (Launcher launcher : this.launcherRepository.findAll()) { TaskLauncher taskLauncher = launcher.getTaskLauncher(); RuntimeEnvironmentDetails taskLauncherInfo = new RuntimeEnvironmentDetails(); final RuntimeEnvironmentInfo taskLauncherEnvironmentInfo = taskLauncher.environmentInfo();