Java源码示例:org.springframework.cloud.deployer.spi.local.LocalTaskLauncher

示例1
@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);
}
 
示例2
@Bean
public TaskLauncher taskLauncher() {
	LocalDeployerProperties localDeployerProperties = new LocalDeployerProperties();

	localDeployerProperties.setDeleteFilesOnExit(false);

	return new LocalTaskLauncher(localDeployerProperties);
}
 
示例3
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));
}
 
示例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);
}
 
示例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}");
}
 
示例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();
}
 
示例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();
}
 
示例8
@Test
public void testTaskLauncher() {
	LocalTaskLauncher taskLauncher = this.context.getBean(LocalTaskLauncher.class);
	assertThat(testTaskLauncher).isNotNull();
	assertThat(taskLauncher).isNotNull();
	assertThat(taskLauncher).isEqualTo(testTaskLauncher);
}
 
示例9
@Bean
public TaskLauncher taskLauncher() {
	LocalDeployerProperties props = new LocalDeployerProperties();
	props.setDeleteFilesOnExit(false);

	return new LocalTaskLauncher(props);
}
 
示例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;
}
 
示例11
@Bean
public TaskLauncher taskLauncher() {
	testTaskLauncher = new LocalTaskLauncher(new LocalDeployerProperties());
	return testTaskLauncher;
}