Java Code Examples for org.springframework.cloud.deployer.spi.task.TaskLauncher#launch()
The following examples show how to use
org.springframework.cloud.deployer.spi.task.TaskLauncher#launch() .
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: TaskLauncherIT.java From spring-cloud-deployer-yarn with Apache License 2.0 | 6 votes |
@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 2
Source File: TaskLauncherIT.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@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 3
Source File: TaskLauncherIT.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@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 4
Source File: TaskLauncherIT.java From spring-cloud-deployer-yarn with Apache License 2.0 | 4 votes |
@Test public void testTaskTimestampCommandlineArgs() 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); List<String> commandlineArgs = new ArrayList<String>(); commandlineArgs.add("--format=yyyyMMdd yyyy"); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, null, commandlineArgs); 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)); for (Resource res : resources) { File file = res.getFile(); String content = ContainerLogUtils.getFileContent(file); if (file.getName().endsWith("stdout")) { assertThat(file.length(), greaterThan(0l)); } if (file.getName().endsWith("Container.stdout")) { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd yyyy"); String expect = format.format(new Date()); assertThat(content, containsString(expect)); } } }
Example 5
Source File: TaskLauncherIT.java From spring-cloud-deployer-yarn with Apache License 2.0 | 4 votes |
@Test public void testTaskTimestampCancel() 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(); Map<String, String> properties = new HashMap<String, String>(); // let it run max 60 sec to get status and cancel. properties.put("repeat", "60"); AppDefinition definition = new AppDefinition("timestamp-task", properties); 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, "Sleeping"); assertThat(deployer.status(id).getState(), is(LaunchState.running)); deployer.cancel(id); assertWaitFileContent(2, TimeUnit.MINUTES, applicationId, "Stopping beans"); assertThat(deployer.status(id).getState(), is(LaunchState.unknown)); List<Resource> resources = ContainerLogUtils.queryContainerLogs( getYarnCluster(), applicationId); assertThat(resources, notNullValue()); assertThat(resources.size(), is(4)); for (Resource res : resources) { File file = res.getFile(); String content = ContainerLogUtils.getFileContent(file); if (file.getName().endsWith("stdout")) { assertThat(file.length(), greaterThan(0l)); } else if (file.getName().endsWith("Container.stderr")) { assertThat("stderr with content: " + content, file.length(), is(0l)); } } }