当前位置: 首页>>代码示例>>Java>>正文


Java TaskStatus类代码示例

本文整理汇总了Java中org.springframework.cloud.deployer.spi.task.TaskStatus的典型用法代码示例。如果您正苦于以下问题:Java TaskStatus类的具体用法?Java TaskStatus怎么用?Java TaskStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TaskStatus类属于org.springframework.cloud.deployer.spi.task包,在下文中一共展示了TaskStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: launch

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Override
public String launch(AppDeploymentRequest request) {
	String appId = createDeploymentId(request);
	TaskStatus status = status(appId);
	if (!status.getState().equals(LaunchState.unknown)) {
		throw new IllegalStateException("Task " + appId + " already exists with a state of " + status);
	}
	Map<String, String> idMap = createIdMap(appId, request);

	logger.debug(String.format("Launching pod for task: %s", appId));
	try {
		createPod(appId, request, idMap);
		return appId;
	} catch (RuntimeException e) {
		logger.error(e.getMessage(), e);
		throw e;
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:19,代码来源:KubernetesTaskLauncher.java

示例2: testSimpleLaunch

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Test
public void testSimpleLaunch() throws InterruptedException {
	Map<String, String> appProperties = new HashMap<>();
	appProperties.put("killDelay", "0");
	appProperties.put("exitCode", "0");
	AppDefinition definition = new AppDefinition(randomName(), appProperties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Launching {}...", request.getDefinition().getName());
	String launchId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause));

	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:19,代码来源:AbstractTaskLauncherIntegrationTests.java

示例3: testErrorExit

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Test
public void testErrorExit() throws InterruptedException {
	Map<String, String> appProperties = new HashMap<>();
	appProperties.put("killDelay", "0");
	appProperties.put("exitCode", "1");
	AppDefinition definition = new AppDefinition(randomName(), appProperties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Launching {}...", request.getDefinition().getName());
	String launchId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.failed))), timeout.maxAttempts, timeout.pause));

	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:19,代码来源:AbstractTaskLauncherIntegrationTests.java

示例4: testSimpleCancel

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Test
public void testSimpleCancel() throws InterruptedException {
	Map<String, String> appProperties = new HashMap<>();
	appProperties.put("killDelay", "-1");
	appProperties.put("exitCode", "0");
	AppDefinition definition = new AppDefinition(randomName(), appProperties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Launching {}...", request.getDefinition().getName());
	String launchId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.running))), timeout.maxAttempts, timeout.pause));

	log.info("Cancelling {}...", request.getDefinition().getName());
	taskLauncher().cancel(launchId);

	timeout = undeploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.cancelled))), timeout.maxAttempts, timeout.pause));

	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:26,代码来源:AbstractTaskLauncherIntegrationTests.java

示例5: testCommandLineArgs

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
/**
 * Tests that command line args can be passed in.
 */
@Test
public void testCommandLineArgs() {
	Map<String, String> properties = new HashMap<>();
	properties.put("killDelay", "1000");
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.<String, String>emptyMap(),
			Collections.singletonList("--exitCode=0"));
	log.info("Launching {}...", request.getDefinition().getName());
	String deploymentId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(complete))), timeout.maxAttempts, timeout.pause));
	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:20,代码来源:AbstractTaskLauncherIntegrationTests.java

示例6: toTaskStatus

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
protected TaskStatus toTaskStatus(GetTaskResponse response) {
	switch (response.getState()) {
		case SUCCEEDED:
			return new TaskStatus(response.getId(), LaunchState.complete, null);
		case RUNNING:
			return new TaskStatus(response.getId(), LaunchState.running, null);
		case PENDING:
			return new TaskStatus(response.getId(), LaunchState.launching, null);
		case CANCELING:
			return new TaskStatus(response.getId(), LaunchState.cancelled, null);
		case FAILED:
			return new TaskStatus(response.getId(), LaunchState.failed, null);
		default:
			throw new IllegalStateException(String.format("Unsupported CF task state %s", response.getState()));
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:17,代码来源:AbstractCloudFoundryTaskLauncher.java

示例7: instantiateResource

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Override
public TaskDefinitionResource instantiateResource(TaskDefinition taskDefinition) {
	String key = DeploymentKey.forTaskDefinition(taskDefinition);
	String id = deploymentIdRepository.findOne(key);
	boolean composed = taskService.isComposedDefinition(taskDefinition.getDslText());
	TaskStatus status = null;
	if (id != null) {
		status = taskLauncher.status(id);
	}
	String state = (status != null) ? status.getState().name() : "unknown";
	TaskDefinitionResource taskDefinitionResource = new TaskDefinitionResource(taskDefinition.getName(),
			taskDefinition.getDslText());
	taskDefinitionResource.setComposed(composed);
	taskDefinitionResource.setStatus(state);
	return taskDefinitionResource;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:17,代码来源:TaskDefinitionController.java

示例8: buildTaskStatus

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
TaskStatus buildTaskStatus(String id) {
	Pod pod = client.pods().inNamespace(client.getNamespace()).withName(id).get();
	if (pod == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}
	PodStatus podStatus = pod.getStatus();
	if (podStatus == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}
	if (podStatus.getPhase() != null) {
		if (podStatus.getPhase().equals("Pending")) {
			return new TaskStatus(id, LaunchState.launching, new HashMap<>());
		}
		else if (podStatus.getPhase().equals("Failed")) {
			return new TaskStatus(id, LaunchState.failed, new HashMap<>());
		}
		else if (podStatus.getPhase().equals("Succeeded")) {
			return new TaskStatus(id, LaunchState.complete, new HashMap<>());
		}
		else {
			return new TaskStatus(id, LaunchState.running, new HashMap<>());
		}
	}
	else {
		return new TaskStatus(id, LaunchState.launching, new HashMap<>());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:28,代码来源:KubernetesTaskLauncher.java

示例9: testReLaunch

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Test
public void testReLaunch() throws InterruptedException {
	Map<String, String> appProperties = new HashMap<>();
	appProperties.put("killDelay", "0");
	appProperties.put("exitCode", "0");
	AppDefinition definition = new AppDefinition(randomName(), appProperties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Launching {}...", request.getDefinition().getName());
	String launchId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause));

	log.info("Re-Launching {}...", request.getDefinition().getName());
	String newLaunchId = taskLauncher().launch(request);

	assertThat(newLaunchId, not(is(launchId)));

	timeout = deploymentTimeout();
	assertThat(newLaunchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause));

	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:28,代码来源:AbstractTaskLauncherIntegrationTests.java

示例10: buildTaskStatus

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
protected TaskStatus buildTaskStatus(ChronosTaskLauncherProperties properties, String id, Job job, String csv) {
	if (job == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}
	String last = null;
	String state= null;
	if (StringUtils.hasText(csv)) {
		List<String> csvLines = Arrays.asList(csv.split("\\r?\\n"));
		for (String line : csvLines) {
			if (line.startsWith("node")) {
				List<String> values = Arrays.asList(line.split("\\s*,\\s*"));
				if (values.size() >= 4) {
					if (id.equals(values.get(1))) {
						last = values.get(2);
						state = values.get(3);
						break;
					}
				}
			}
		}
	}
	if ("running".equals(state)) {
		return new TaskStatus(id, LaunchState.running, new HashMap<>());
	}
	if ("queued".equals(state)) {
		return new TaskStatus(id, LaunchState.launching, new HashMap<>());
	}
	if ("success".equals(last)) {
		return new TaskStatus(id, LaunchState.complete, new HashMap<>());
	}
	else {
		// TODO: state == idle could indicate cancelled?
		return new TaskStatus(id, LaunchState.failed, new HashMap<>());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:36,代码来源:ChronosTaskLauncher.java

示例11: status

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
/**
 * Lookup the current status based on task id.
 *
 * @param id taskId as returned from the {@link TaskLauncher#launch(AppDeploymentRequest)}
 * @return the current task status
 */
@Override
public TaskStatus status(String id) {
	try {
		return getStatus(id)
			.doOnSuccess(v -> logger.info("Successfully computed status [{}] for id={}", v, id))
			.doOnError(logError(String.format("Failed to compute status for %s", id)))
			.block(Duration.ofMillis(this.deploymentProperties.getStatusTimeout()));
	} catch (Exception timeoutDueToBlock) {
		logger.error("Caught exception while querying for status of id={}", id, timeoutDueToBlock);
		return createErrorTaskStatus(id);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:19,代码来源:AbstractCloudFoundryTaskLauncher.java

示例12: getStatus

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
private Mono<TaskStatus> getStatus(String id) {
	return requestGetTask(id)
		.map(this::toTaskStatus)
		.onErrorResume(isNotFoundError(), t -> {
			logger.debug("Task for id={} does not exist", id);
			return Mono.just(new TaskStatus(id, LaunchState.unknown, null));
		})
		.transform(statusRetry(id))
		.onErrorReturn(createErrorTaskStatus(id));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:11,代码来源:AbstractCloudFoundryTaskLauncher.java

示例13: testNonExistentAppsStatus

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Test
public void testNonExistentAppsStatus() {
	assertThat(randomName(), hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", is(LaunchState.unknown))));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:6,代码来源:AbstractTaskLauncherIntegrationTests.java

示例14: status

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Override
public TaskStatus status(String id) {
	return wrapped.status(id);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:5,代码来源:AbstractTaskLauncherIntegrationTests.java

示例15: status

import org.springframework.cloud.deployer.spi.task.TaskStatus; //导入依赖的package包/类
@Override
public TaskStatus status(String id) {
	throw failure();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:5,代码来源:UnsupportedVersionTaskLauncher.java


注:本文中的org.springframework.cloud.deployer.spi.task.TaskStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。