Java Code Examples for org.springframework.cloud.deployer.spi.local.LocalTaskLauncher

The following examples show how to use org.springframework.cloud.deployer.spi.local.LocalTaskLauncher. These examples are extracted from open source projects. 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 Project: spring-cloud-dataflow   Source File: LocalPlatformTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void defaultLocalPlatform() {
	ApplicationContext context = new SpringApplicationBuilder(TestConfig.class)
			.web(WebApplicationType.NONE)
			.bannerMode(Banner.Mode.OFF)
			.properties(testProperties())
			.run();
	Map<String, TaskPlatform> taskPlatforms = context.getBeansOfType(TaskPlatform.class);
	assertThat(taskPlatforms).hasSize(1);
	TaskPlatform taskPlatform = taskPlatforms.values().iterator().next();
	assertThat(taskPlatform.getName()).isEqualTo("Local");
	assertThat(taskPlatform.getLaunchers()).hasSize(1);
	assertThat(taskPlatform.getLaunchers().get(0).getName()).isEqualTo("default");
	assertThat(taskPlatform.getLaunchers().get(0).getType()).isEqualTo("Local");
	assertThat(taskPlatform.getLaunchers().get(0).getTaskLauncher()).isInstanceOf(LocalTaskLauncher.class);
}
 
Example 2
@Bean
public TaskLauncher taskLauncher() {
	LocalDeployerProperties localDeployerProperties = new LocalDeployerProperties();

	localDeployerProperties.setDeleteFilesOnExit(false);

	return new LocalTaskLauncher(localDeployerProperties);
}
 
Example 3
Source Project: spring-cloud-deployer-local   Source File: TimeStamp.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
	LocalTaskLauncher launcher = new LocalTaskLauncher(new LocalDeployerProperties());
	String timestampId = launcher.launch(createAppDeploymentRequest("timestamp-task"));
	for (int i = 0; i < 50; i++) {
		Thread.sleep(100);
		System.out.println("timestamp: " + launcher.status(timestampId));
	}
	// timestamp completes quickly, but we can 'cancel' the running task
	launcher.cancel(timestampId);
	System.out.println("timestamp after cancel: " + launcher.status(timestampId));
}
 
Example 4
@Test
public void localTaskPlatform() {
	assertThat(taskPlatforms).hasSize(3);

	TaskPlatform localDefault = taskPlatforms.stream()
			.filter(taskPlatform -> taskPlatform.getName().equals("Local")).findFirst().get();

	assertThat(localDefault.isPrimary());
	assertThat(localDefault).isNotNull();
	assertThat(localDefault.getLaunchers()).hasSize(1);
	assertThat(localDefault.getLaunchers().get(0).getType()).isEqualTo(localDefault.getName());
	assertThat(localDefault.getLaunchers().get(0).getName()).isEqualTo("default");
	assertThat(localDefault.getLaunchers().get(0).getTaskLauncher()).isInstanceOf(LocalTaskLauncher.class);
}
 
Example 5
@Override
protected void before() {
	originalDataflowServerPort = System.getProperty(DATAFLOW_PORT_PROPERTY);

	this.dataflowServerPort = SocketUtils.findAvailableTcpPort();

	logger.info("Setting Dataflow Server port to " + this.dataflowServerPort);

	System.setProperty(DATAFLOW_PORT_PROPERTY, String.valueOf(this.dataflowServerPort));

	originalConfigLocation = System.getProperty("spring.config.additional-locationn");

	if (!StringUtils.isEmpty(configurationLocation)) {
		final Resource resource = new PathMatchingResourcePatternResolver().getResource(configurationLocation);
		if (!resource.exists()) {
		  throw new IllegalArgumentException(String.format("Resource 'configurationLocation' ('%s') does not exist.", configurationLocation));
		}
		System.setProperty("spring.config.additional-location", configurationLocation);
	}

	app = new SpringApplication(TestConfig.class);

	configurableApplicationContext = (WebApplicationContext) app.run(new String[] {
			"--spring.cloud.kubernetes.enabled=false",
			"--" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.STREAMS_ENABLED + "="
					+ this.streamsEnabled,
			"--" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.TASKS_ENABLED + "="
					+ this.tasksEnabled,
			"--" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.SCHEDULES_ENABLED + "="
					+ this.schedulesEnabled,
			"--spring.cloud.skipper.client.serverUri=http://localhost:" + this.skipperServerPort + "/api"
	});
	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)
			.addFilters(filters.toArray(new Filter[filters.size()])).build();
	dataflowPort = configurableApplicationContext.getEnvironment().resolvePlaceholders("${server.port}");
}
 
Example 6
@Test
public void createsDefaultPlatform() {
	LocalPlatformProperties platformProperties = new LocalPlatformProperties();
	LocalTaskPlatformFactory taskPlatformFactory = new LocalTaskPlatformFactory(platformProperties, null);
	TaskPlatform taskPlatform = taskPlatformFactory.createTaskPlatform();
	assertThat(taskPlatform.getLaunchers()).hasSize(1);
	assertThat(taskPlatform.getName()).isEqualTo("Local");
	assertThat(taskPlatform.getLaunchers().get(0).getType()).isEqualTo(taskPlatform.getName());
	assertThat(taskPlatform.getLaunchers().get(0).getName()).isEqualTo("default");
	assertThat(taskPlatform.getLaunchers().get(0).getTaskLauncher()).isInstanceOf(LocalTaskLauncher.class);
	assertThat(taskPlatform.getLaunchers().get(0).getDescription()).isNotEmpty();
}
 
Example 7
@Test
public void createsConfiguredPlatform() {
	LocalPlatformProperties platformProperties = new LocalPlatformProperties();
	platformProperties.setAccounts(Collections.singletonMap("custom",new LocalDeployerProperties()));
	LocalTaskPlatformFactory taskPlatformFactory = new LocalTaskPlatformFactory(platformProperties, null);
	TaskPlatform taskPlatform = taskPlatformFactory.createTaskPlatform();
	assertThat(taskPlatform.getLaunchers()).hasSize(1);
	assertThat(taskPlatform.getName()).isEqualTo("Local");
	assertThat(taskPlatform.getLaunchers().get(0).getType()).isEqualTo(taskPlatform.getName());
	assertThat(taskPlatform.getLaunchers().get(0).getName()).isEqualTo("custom");
	assertThat(taskPlatform.getLaunchers().get(0).getTaskLauncher()).isInstanceOf(LocalTaskLauncher.class);
	assertThat(taskPlatform.getLaunchers().get(0).getDescription()).isNotEmpty();
}
 
Example 8
@Test
public void testTaskLauncher() {
	LocalTaskLauncher taskLauncher = this.context.getBean(LocalTaskLauncher.class);
	assertThat(testTaskLauncher).isNotNull();
	assertThat(taskLauncher).isNotNull();
	assertThat(taskLauncher).isEqualTo(testTaskLauncher);
}
 
Example 9
Source Project: spring-cloud-task   Source File: TaskLauncherSinkTests.java    License: 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 10
private Launcher doCreateLauncher(String account, LocalDeployerProperties deployerProperties) {
	LocalTaskLauncher localTaskLauncher = new LocalTaskLauncher(deployerProperties);
	Launcher launcher = new Launcher(account, LOCAL_PLATFORM_TYPE, localTaskLauncher, localScheduler);
	launcher.setDescription(prettyPrintLocalDeployerProperties(deployerProperties));
	return launcher;
}
 
Example 11
@Bean
public TaskLauncher taskLauncher() {
	testTaskLauncher = new LocalTaskLauncher(new LocalDeployerProperties());
	return testTaskLauncher;
}