org.springframework.cloud.deployer.spi.task.TaskLauncher Java Examples

The following examples show how to use org.springframework.cloud.deployer.spi.task.TaskLauncher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultTaskExecutionService.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
private TaskLauncher findTaskLauncher(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;
}
 
Example #2
Source File: AllPlatformsTaskExecutionInformation.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
private List<PlatformTaskExecutionInformation> buildTaskExecutionInformation(List<TaskPlatform> taskPlatforms) {
	taskExecutionInformation = new ArrayList<>();
	taskPlatforms.forEach(taskPlatform -> {
	taskPlatform.getLaunchers().forEach(launcher -> {
		TaskLauncher taskLauncher = launcher.getTaskLauncher();
		taskExecutionInformation.add(
			new PlatformTaskExecutionInformation(launcher.getName(),
				launcher.getType(), taskLauncher.getMaximumConcurrentTasks(),
				taskLauncher.getRunningTaskExecutionCount()));
		});
	});

	Collections.sort(taskExecutionInformation,
		Comparator.comparing(PlatformTaskExecutionInformation::getType)
	);

	return taskExecutionInformation;
}
 
Example #3
Source File: TestDependencies.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Bean
public AboutController aboutController(VersionInfoProperties versionInfoProperties,
		FeaturesProperties featuresProperties, StreamDeployer streamDeployer, GrafanaInfoProperties grafanaInfoProperties) {

	Launcher launcher = mock(Launcher.class);
	TaskLauncher taskLauncher = mock(TaskLauncher.class);
	LauncherRepository launcherRepository = mock(LauncherRepository.class);

	RuntimeEnvironmentInfo taskDeployerEnvInfo = new RuntimeEnvironmentInfo.Builder()
			.implementationName("testTaskDepImplementationName")
			.implementationVersion("testTaskDepImplementationVersion")
			.platformType("testTaskDepPlatformType")
			.platformApiVersion("testTaskDepPlatformApiVersion")
			.platformClientVersion("testTaskDepPlatformClientVersion")
			.spiClass(Class.class)
			.platformHostVersion("testTaskDepPlatformHostVersion").build();

	when(taskLauncher.environmentInfo()).thenReturn(taskDeployerEnvInfo);
	when(launcher.getTaskLauncher()).thenReturn(taskLauncher);
	when(launcherRepository.findByName("default")).thenReturn(launcher);

	return new AboutController(streamDeployer, launcherRepository,
			featuresProperties, versionInfoProperties,
			mock(SecurityStateBean.class), grafanaInfoProperties);
}
 
Example #4
Source File: TaskLauncherIT.java    From spring-cloud-deployer-yarn with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskTimestampAsHdfsResourceNotExist() throws Exception {
	assertThat(context.containsBean("taskLauncher"), is(true));
	assertThat(context.getBean("taskLauncher"), instanceOf(YarnTaskLauncher.class));
	TaskLauncher deployer = context.getBean("taskLauncher", TaskLauncher.class);

	@SuppressWarnings("resource")
	HdfsResourceLoader resourceLoader = new HdfsResourceLoader(getConfiguration());
	resourceLoader.setHandleNoprefix(true);
	Resource resource = resourceLoader.getResource("hdfs:/dataflow/artifacts/cache/timestamp-task-1.0.0.BUILD-SNAPSHOT-exec.jar");

	AppDefinition definition = new AppDefinition("timestamp-task", null);
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	Exception deployException = null;

	try {
		deployer.launch(request);
	} catch (Exception e) {
		deployException = e;
	}
	assertThat("Expected deploy exception", deployException, notNullValue());
}
 
Example #5
Source File: DefaultTaskDeleteService.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@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(launchId);
	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());
	}
}
 
Example #6
Source File: DefaultTaskDeleteService.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
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.");
	}
}
 
Example #7
Source File: DeployerPartitionHandlerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void validateConstructorValidation(TaskLauncher taskLauncher,
		JobExplorer jobExplorer, Resource resource, String stepName,
		TaskRepository taskRepository, String expectedMessage) {
	try {
		new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, stepName,
				taskRepository);
	}
	catch (IllegalArgumentException iae) {
		assertThat(iae.getMessage()).isEqualTo(expectedMessage);
	}
}
 
Example #8
Source File: YarnTaskLauncher.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return new RuntimeEnvironmentInfo.Builder()
			.spiClass(TaskLauncher.class)
			.implementationName(getClass().getSimpleName())
			.implementationVersion(RuntimeVersionUtils.getVersion(this.getClass()))
			.platformType("Yarn")
			.platformApiVersion(System.getProperty("os.name") + " " + System.getProperty("os.version"))
			.platformClientVersion(System.getProperty("os.version"))
			.platformHostVersion(System.getProperty("os.version"))
			.build();
}
 
Example #9
Source File: SpringCloudSchedulerIntegrationTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Scheduler scheduler(ReactorSchedulerClient client,
		CloudFoundryOperations operations,
		CloudFoundryConnectionProperties properties,
		TaskLauncher taskLauncher,
		CloudFoundrySchedulerProperties schedulerProperties) {
	return new CloudFoundryAppScheduler(client, operations, properties,
			(CloudFoundryTaskLauncher) taskLauncher,
			schedulerProperties);
}
 
Example #10
Source File: TaskLauncherIT.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskTimestampAsHdfsResource() throws Exception {
	assertThat(context.containsBean("taskLauncher"), is(true));
	assertThat(context.getBean("taskLauncher"), instanceOf(YarnTaskLauncher.class));
	TaskLauncher deployer = context.getBean("taskLauncher", TaskLauncher.class);
	YarnCloudAppService yarnCloudAppService = context.getBean(YarnCloudAppService.class);

	MavenProperties m2Properties = new MavenProperties();
	Map<String, RemoteRepository> remoteRepositories = new HashMap<>();
	remoteRepositories.put("default", new RemoteRepository("https://repo.spring.io/libs-snapshot-local"));
	m2Properties.setRemoteRepositories(remoteRepositories);

	MavenResource base = new MavenResource.Builder(m2Properties)
			.artifactId("timestamp-task")
			.groupId(GROUP_ID)
			.version(artifactVersion)
			.extension("jar")
			.classifier("exec")
			.build();
	copyFile(base, "/dataflow/artifacts/repo/");

	@SuppressWarnings("resource")
	HdfsResourceLoader resourceLoader = new HdfsResourceLoader(getConfiguration());
	resourceLoader.setHandleNoprefix(true);
	Resource resource = resourceLoader.getResource("hdfs:/dataflow/artifacts/repo/timestamp-task-1.0.0.BUILD-SNAPSHOT-exec.jar");

	AppDefinition definition = new AppDefinition("timestamp-task", null);
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);
	String id = deployer.launch(request);
	assertThat(id, notNullValue());

	ApplicationId applicationId = assertWaitApp(2, TimeUnit.MINUTES, yarnCloudAppService);
	assertWaitFileContent(2, TimeUnit.MINUTES, applicationId, "Started TaskApplication");

	List<Resource> resources = ContainerLogUtils.queryContainerLogs(
			getYarnCluster(), applicationId);

	assertThat(resources, notNullValue());
	assertThat(resources.size(), is(4));
}
 
Example #11
Source File: TaskLauncherIT.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskTimestamp() throws Exception {
	assertThat(context.containsBean("taskLauncher"), is(true));
	assertThat(context.getBean("taskLauncher"), instanceOf(YarnTaskLauncher.class));
	TaskLauncher deployer = context.getBean("taskLauncher", TaskLauncher.class);
	YarnCloudAppService yarnCloudAppService = context.getBean(YarnCloudAppService.class);

	MavenProperties m2Properties = new MavenProperties();
	Map<String, RemoteRepository> remoteRepositories = new HashMap<>();
	remoteRepositories.put("default", new RemoteRepository("https://repo.spring.io/libs-snapshot-local"));
	m2Properties.setRemoteRepositories(remoteRepositories);

	MavenResource resource = new MavenResource.Builder(m2Properties)
			.artifactId("timestamp-task")
			.groupId(GROUP_ID)
			.version(artifactVersion)
			.extension("jar")
			.classifier("exec")
			.build();

	AppDefinition definition = new AppDefinition("timestamp-task", null);
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);
	String id = deployer.launch(request);
	assertThat(id, notNullValue());

	ApplicationId applicationId = assertWaitApp(2, TimeUnit.MINUTES, yarnCloudAppService);
	assertWaitFileContent(2, TimeUnit.MINUTES, applicationId, "Started TaskApplication");

	List<Resource> resources = ContainerLogUtils.queryContainerLogs(
			getYarnCluster(), applicationId);

	assertThat(resources, notNullValue());
	assertThat(resources.size(), is(4));
}
 
Example #12
Source File: JdbchdfsLocalTaskConfiguration.java    From spring-cloud-task-app-starters with Apache License 2.0 5 votes vote down vote up
@Bean
public TaskLauncher taskLauncher() {
	LocalDeployerProperties localDeployerProperties = new LocalDeployerProperties();

	localDeployerProperties.setDeleteFilesOnExit(false);

	return new LocalTaskLauncher(localDeployerProperties);
}
 
Example #13
Source File: DefaultTaskExecutionService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * A task should not be allowed to be launched when one is running (allowing the upgrade
 * to proceed may kill running task instances of that definition on certain platforms).
 *
 * @param taskName task name to check
 * @param taskExecution the candidate TaskExecution
 * @param taskLauncher the TaskLauncher used to verify the status of a recorded task execution.
 */
private void verifyTaskIsNotRunning(String taskName, TaskExecution taskExecution, TaskLauncher taskLauncher) {
	Page<TaskExecution> runningTaskExecutions =
			this.taskExplorer.findRunningTaskExecutions(taskName, PageRequest.of(0, 1));

	//Found only the candidate TaskExecution
	if(runningTaskExecutions.getTotalElements() == 1 && runningTaskExecutions.toList().get(0).getExecutionId() == taskExecution.getExecutionId()) {
		return;
	}

	/*
	 * The task repository recorded a different task execution for the task which is started but not completed.
	 * It is possible that the task failed and terminated before updating the task repository.
	 * Use the TaskLauncher to verify the actual state.
	 */
	if (runningTaskExecutions.getTotalElements() > 0) {

		LaunchState launchState = taskLauncher.status(runningTaskExecutions.toList().get(0).getExternalExecutionId()).getState();
		if (launchState.equals(LaunchState.running) || launchState.equals(LaunchState.launching)) {
			throw new IllegalStateException("Unable to update application due to currently running applications");
		}
		else {
			logger.warn("Task repository shows a running task execution for task {} but the actual state is {}."
					+ launchState.toString(), taskName, launchState);
		}
	}
}
 
Example #14
Source File: DefaultTaskExecutionService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private void cancelTaskExecution(TaskExecution taskExecution, String platformName) {
	String platformNameToUse;
	if (StringUtils.hasText(platformName)) {
		platformNameToUse = platformName;
	} else {
		TaskDeployment taskDeployment = this.taskDeploymentRepository.findByTaskDeploymentId(taskExecution.getExternalExecutionId());
		platformNameToUse = taskDeployment.getPlatformName();
	}
	TaskLauncher taskLauncher = findTaskLauncher(platformNameToUse);
	taskLauncher.cancel(taskExecution.getExternalExecutionId());
	this.logger.info(String.format("Task execution stop request for id %s for platform %s has been submitted", taskExecution.getExecutionId(), platformNameToUse));

}
 
Example #15
Source File: DefaultTaskExecutionService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private void isCTRSplitValidForCurrentCTR(TaskLauncher taskLauncher, TaskDefinition taskDefinition) {
	TaskParser taskParser = new TaskParser("composed-task-runner", taskDefinition.getProperties().get("graph"), true, true);
	TaskNode taskNode = taskParser.parse();
	ComposedTaskRunnerVisitor composedRunnerVisitor = new ComposedTaskRunnerVisitor();
	taskNode.accept(composedRunnerVisitor);
	if(composedRunnerVisitor.getHighCount() > taskLauncher.getMaximumConcurrentTasks()) {
		throw new IllegalArgumentException(String.format("One or more of the " +
				"splits in the composed task contains a task count that exceeds " +
				"the maximumConcurrentTasks count of %s",
				taskLauncher.getMaximumConcurrentTasks()));
	}
}
 
Example #16
Source File: TaskPlatformControllerTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Before
public void setupMockMVC() {
	this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
			.defaultRequest(get("/").accept(MediaType.APPLICATION_JSON)).build();
	Launcher launcher = new Launcher("default", "local", taskLauncher);
	Launcher cfLauncher = new Launcher("cf", "Cloud Foundry", mock(TaskLauncher.class));
	Launcher cfLauncherWithScheduler = new Launcher("cfsched", "Cloud Foundry", mock(TaskLauncher.class), mock(Scheduler.class));
	this.launcherRepository.save(launcher);
	this.launcherRepository.save(cfLauncher);
	this.launcherRepository.save(cfLauncherWithScheduler);
}
 
Example #17
Source File: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private SchedulerService getMockedKubernetesSchedulerService() {
	Launcher launcher = new Launcher(KUBERNETES_PLATFORM, "Kubernetes", Mockito.mock(TaskLauncher.class), scheduler);
	List<Launcher> launchers = new ArrayList<>();
	launchers.add(launcher);
	List<TaskPlatform> taskPlatform = Collections.singletonList(new TaskPlatform(KUBERNETES_PLATFORM, launchers));

	return  new DefaultSchedulerService(this.commonApplicationProperties,
			taskPlatform, this.taskDefinitionRepository,
			this.appRegistry, this.resourceLoader,
			this.taskConfigurationProperties, mock(DataSourceProperties.class), null,
			this.metaDataResolver, this.schedulerServiceProperties, this.auditRecordService);
}
 
Example #18
Source File: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Bean
public TaskPlatform taskCFPlatform(Scheduler scheduler) {
	Launcher launcher = new Launcher(KUBERNETES_PLATFORM, "Kubernetes", Mockito.mock(TaskLauncher.class), scheduler);
	List<Launcher> launchers = new ArrayList<>();
	launchers.add(launcher);
	TaskPlatform taskPlatform = new TaskPlatform(KUBERNETES_PLATFORM, launchers);
	return taskPlatform;
}
 
Example #19
Source File: DefaultTaskExecutionServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
static AppDeploymentRequest getAppDeploymentRequestForToken(Map<String, String> taskDeploymentProperties,
		List<String> commandLineArgs, TaskExecutionService taskExecutionService,
		TaskLauncher taskLauncher) {
	assertEquals(1L, taskExecutionService.executeTask("seqTask", taskDeploymentProperties, commandLineArgs));

	ArgumentCaptor<AppDeploymentRequest> argumentCaptor = ArgumentCaptor.forClass(AppDeploymentRequest.class);
	verify(taskLauncher, atLeast(1)).launch(argumentCaptor.capture());

	final AppDeploymentRequest request = argumentCaptor.getValue();

	return request;
}
 
Example #20
Source File: DefaultTaskExecutionServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
static Map<String, String> prepareEnvironmentForTokenTests(TaskSaveService taskSaveService,
		TaskLauncher taskLauncher, AppRegistryService appRegistry) {
	taskSaveService.saveTaskDefinition(new TaskDefinition("seqTask", "AAA && BBB"));
	when(taskLauncher.launch(any())).thenReturn("0");
	when(appRegistry.appExist(anyString(), any(ApplicationType.class))).thenReturn(true);
	Map<String, String> properties = new HashMap<>();
	properties.put("app.foo", "bar");
	properties.put("app.seqTask.AAA.timestamp.format", "YYYY");
	properties.put("deployer.seqTask.AAA.memory", "1240m");
	properties.put("app.composed-task-runner.interval-time-between-checks", "1000");
	return properties;
}
 
Example #21
Source File: DefaultSchedulerServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private SchedulerService getMockedKubernetesSchedulerService() {
	Launcher launcher = new Launcher("default", "Kubernetes", Mockito.mock(TaskLauncher.class), scheduler);
	List<Launcher> launchers = new ArrayList<>();
	launchers.add(launcher);
	List<TaskPlatform> taskPlatform = Collections.singletonList(new TaskPlatform("testTaskPlatform", launchers));

	return  new DefaultSchedulerService(this.commonApplicationProperties,
			taskPlatform, this.taskDefinitionRepository,
			this.appRegistry, this.resourceLoader,
			this.taskConfigurationProperties, mock(DataSourceProperties.class), null,
			this.metaDataResolver, this.schedulerServiceProperties, this.auditRecordService);
}
 
Example #22
Source File: CloudFoundrySchedulerConfiguration.java    From spring-cloud-dataflow-server-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Scheduler scheduler(ReactorSchedulerClient client,
		CloudFoundryOperations operations,
		CloudFoundryConnectionProperties properties,
		TaskLauncher taskLauncher,
		CloudFoundrySchedulerProperties schedulerProperties) {
	return new CloudFoundryAppScheduler(client, operations, properties,
			(CloudFoundry2630AndLaterTaskLauncher) taskLauncher,
			schedulerProperties);
}
 
Example #23
Source File: TaskSinkApplicationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testLaunch() throws IOException {
	assertThat(this.sink.input()).isNotNull();

	TaskLauncher testTaskLauncher =
		this.context.getBean(TaskLauncher.class);

	Map<String, String> properties = new HashMap();
	properties.put("server.port", "0");
	TaskLaunchRequest request = new TaskLaunchRequest(
		"maven://org.springframework.cloud.task.app:"
			+ "timestamp-task:jar:1.0.1.RELEASE", null, properties,
		null, null);
	GenericMessage<TaskLaunchRequest> message = new GenericMessage<>(request);
	this.sink.input().send(message);

	ArgumentCaptor<AppDeploymentRequest> deploymentRequest = ArgumentCaptor
		.forClass(AppDeploymentRequest.class);

	verify(testTaskLauncher).launch(deploymentRequest.capture());

	AppDeploymentRequest actualRequest = deploymentRequest.getValue();

	assertThat(actualRequest.getCommandlineArguments().isEmpty()).isTrue();
	assertThat(actualRequest.getDefinition().getProperties()
		.get("server.port")).isEqualTo("0");
	assertThat(actualRequest.getResource().toString()
		.contains("maven://org.springframework.cloud.task.app:timestamp-task:jar:1.0.1.RELEASE"))
		.isTrue();
}
 
Example #24
Source File: TaskLauncherSinkTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Bean
public TaskLauncher taskLauncher() {
	LocalDeployerProperties props = new LocalDeployerProperties();
	props.setDeleteFilesOnExit(false);

	return new LocalTaskLauncher(props);
}
 
Example #25
Source File: DeployerPartitionHandler.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor initializing the DeployerPartitionHandler instance.
 * @param taskLauncher the launcher used to execute partitioned tasks.
 * @param jobExplorer used to acquire the status of the job.
 * @param resource the url to the app to be launched.
 * @param stepName the name of the step.
 * @deprecated Use the constructor that accepts {@link TaskRepository} as well as the
 * this constructor's set of parameters.
 */
@Deprecated
public DeployerPartitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer,
		Resource resource, String stepName) {
	Assert.notNull(taskLauncher, "A taskLauncher is required");
	Assert.notNull(jobExplorer, "A jobExplorer is required");
	Assert.notNull(resource, "A resource is required");
	Assert.hasText(stepName, "A step name is required");

	this.taskLauncher = taskLauncher;
	this.jobExplorer = jobExplorer;
	this.resource = resource;
	this.stepName = stepName;
}
 
Example #26
Source File: DeployerPartitionHandler.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
public DeployerPartitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer,
		Resource resource, String stepName, TaskRepository taskRepository) {
	Assert.notNull(taskLauncher, "A taskLauncher is required");
	Assert.notNull(jobExplorer, "A jobExplorer is required");
	Assert.notNull(resource, "A resource is required");
	Assert.hasText(stepName, "A step name is required");
	Assert.notNull(taskRepository, "A TaskRepository is required");

	this.taskLauncher = taskLauncher;
	this.jobExplorer = jobExplorer;
	this.resource = resource;
	this.stepName = stepName;
	this.taskRepository = taskRepository;
}
 
Example #27
Source File: DeployerPartitionHandlerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void validateDeprecatedConstructorValidation(TaskLauncher taskLauncher,
		JobExplorer jobExplorer, Resource resource, String stepName,
		String expectedMessage) {
	try {
		new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, stepName,
				this.taskRepository);
	}
	catch (IllegalArgumentException iae) {
		assertThat(iae.getMessage()).isEqualTo(expectedMessage);
	}
}
 
Example #28
Source File: SpringCloudTaskSinkApplicationIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testTaskLaunch() throws IOException {

    TaskLauncher taskLauncher =
        context.getBean(TaskLauncher.class);

    Map<String, String> prop = new HashMap<String, String>();
    prop.put("server.port", "0");
    TaskLaunchRequest request = new TaskLaunchRequest(
        "maven://org.springframework.cloud.task.app:"
            + "timestamp-task:jar:1.0.1.RELEASE", null,
        prop,
        null, null);
    GenericMessage<TaskLaunchRequest> message = new GenericMessage<TaskLaunchRequest>(
        request);
    this.sink.input().send(message);

    ArgumentCaptor<AppDeploymentRequest> deploymentRequest = ArgumentCaptor
        .forClass(AppDeploymentRequest.class);

    verify(taskLauncher).launch(
        deploymentRequest.capture());

    AppDeploymentRequest actualRequest = deploymentRequest
        .getValue();

    // Verifying the co-ordinate of launched Task here.
    assertTrue(actualRequest.getCommandlineArguments()
        .isEmpty());
    assertEquals("0", actualRequest.getDefinition()
        .getProperties().get("server.port"));
    assertTrue(actualRequest
        .getResource()
        .toString()
        .contains(
            "org.springframework.cloud.task.app:timestamp-task:jar:1.0.1.RELEASE"));
}
 
Example #29
Source File: KubernetesTaskLauncherIntegrationTests.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 4 votes vote down vote up
@Override
protected TaskLauncher provideTaskLauncher() {
	return taskLauncher;
}
 
Example #30
Source File: Launcher.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
public void setTaskLauncher(TaskLauncher taskLauncher) {
	this.taskLauncher = taskLauncher;
}