@Bean @Conditional(OnLocalPlatform.class) public TaskPlatform localTaskPlatform(LocalPlatformProperties localPlatformProperties) { List<Launcher> launchers = new ArrayList<>(); Map<String, LocalDeployerProperties> localDeployerPropertiesMap = localPlatformProperties.getAccounts(); for (Map.Entry<String, LocalDeployerProperties> entry : localDeployerPropertiesMap .entrySet()) { LocalTaskLauncher localTaskLauncher = new LocalTaskLauncher(entry.getValue()); Launcher launcher = new Launcher(entry.getKey(), "local", localTaskLauncher); launcher.setDescription(prettyPrintLocalDeployerProperties(entry.getValue())); launchers.add(launcher); } return new TaskPlatform("Local", launchers); }
public LauncherResource(Launcher launcher) { this.name = launcher.getName(); this.type = launcher.getType(); this.description = launcher.getDescription(); }
@Override public LauncherResource toResource(Launcher launcher) { return createResourceWithId(launcher.getId(), launcher); }
@EventListener @Transactional public void initialize(ApplicationReadyEvent event) { if (noTaskLauncherExists()) { LocalDeployerProperties localDeployerProperties = new LocalDeployerProperties(); LocalTaskLauncher localTaskLauncher = new LocalTaskLauncher(localDeployerProperties); Launcher launcher = new Launcher("default", "local", localTaskLauncher); launcher.setDescription(prettyPrintLocalDeployerProperties(localDeployerProperties)); List<Launcher> localLaunchers = new ArrayList<>(); localLaunchers.add(launcher); for (TaskPlatform taskPlatform : taskPlatforms) { if (taskPlatform.getName().equalsIgnoreCase("Local")) { logger.info("Creating Local Task Launcher named 'default' since no Task Launchers configured."); taskPlatform.setLaunchers(localLaunchers); } } } this.taskPlatforms.forEach(platform -> { platform.getLaunchers().forEach(launcher -> { this.launcherRepository.save(launcher); logger.info(String.format( "Added '%s' platform account '%s' into Task Launcher repository.", platform.getName(), launcher.getName())); }); }); }
skipperClient = configurableApplicationContext.getBean(SkipperClient.class); LauncherRepository launcherRepository = configurableApplicationContext.getBean(LauncherRepository.class); launcherRepository.save(new Launcher("default", "local", new LocalTaskLauncher(new LocalDeployerProperties()))); Collection<Filter> filters = configurableApplicationContext.getBeansOfType(Filter.class).values(); mockMvc = MockMvcBuilders.webAppContextSetup(configurableApplicationContext)
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()); } }
protected Launcher createAndSaveKubernetesTaskLaunchers(String account, KubernetesDeployerProperties kubernetesProperties) { KubernetesClient kubernetesClient = KubernetesClientFactory.getKubernetesClient(kubernetesProperties); ContainerFactory containerFactory = new DefaultContainerFactory( kubernetesProperties); KubernetesTaskLauncher kubernetesTaskLauncher = new KubernetesTaskLauncher( kubernetesProperties, kubernetesClient, containerFactory); Launcher launcher = new Launcher(account, "kubernetes", kubernetesTaskLauncher); launcher.setDescription( String.format("master url = [%s], namespace = [%s], api version = [%s]", kubernetesClient.getMasterUrl(), kubernetesClient.getNamespace(), kubernetesClient.getApiVersion())); return launcher; }
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."); } } }
cloudFoundryClient, deploymentProperties, cloudFoundryOperations, runtimeEnvironmentInfo); Launcher launcher = new Launcher(account, "cloudfoundry", cfTaskLauncher); launcher.setDescription(String.format("org = [%s], space = [%s], url = [%s]", connectionProperties.getOrg(), connectionProperties.getSpace(), connectionProperties.getUrl()));
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();
cloudFoundryClient, deploymentProperties, cloudFoundryOperations, runtimeEnvironmentInfo); Launcher launcher = new Launcher(account, "cloudfoundry", cfTaskLauncher); launcher.setDescription(String.format("org = [%s], space = [%s], url = [%s]", connectionProperties.getOrg(), connectionProperties.getSpace(), connectionProperties.getUrl()));