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


Java DeploymentState类代码示例

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


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

示例1: stop

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
/**
 * Start a given module on the CF
 *
 * @param name
 */
public void stop(String name, URL apiEndpoint, String org, String space, String email, String password, String namespace) {

	CloudFoundryOperations operations = appDeployerFactory.getOperations(email, password, apiEndpoint, org, space);

	CloudFoundryAppDeployer appDeployer = appDeployerFactory.getAppDeployer(apiEndpoint, org, space, email, password, namespace);

	operations.applications()
		.stop(StopApplicationRequest.builder()
			.name(name)
			.build())
		.then(() -> Mono.defer(() -> Mono.just(appDeployer.status(name)))
			.filter(appStatus -> appStatus.getState() == DeploymentState.unknown)
			.repeatWhenEmpty(exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15), Duration.ofMinutes(15)))
			.doOnSuccess(v -> log.debug(String.format("Successfully stopped %s", name)))
			.doOnError(e -> log.error(String.format("Unable to stop %s", name))))
		.block(Duration.ofSeconds(30));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-spinnaker,代码行数:23,代码来源:ModuleService.java

示例2: isHealthy

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
public boolean isHealthy(Release replacingRelease) {
	AppDeployerData replacingAppDeployerData = this.appDeployerDataRepository
			.findByReleaseNameAndReleaseVersionRequired(
					replacingRelease.getName(), replacingRelease.getVersion());

	Map<String, String> appNamesAndDeploymentIds = replacingAppDeployerData.getDeploymentDataAsMap();

	AppDeployer appDeployer = this.deployerRepository
			.findByNameRequired(replacingRelease.getPlatformName())
			.getAppDeployer();

	logger.debug("Getting status for apps in replacing release {}-v{}", replacingRelease.getName(),
			replacingRelease.getVersion());
	for (Map.Entry<String, String> appNameAndDeploymentId : appNamesAndDeploymentIds.entrySet()) {
		AppStatus status = appDeployer.status(appNameAndDeploymentId.getValue());
		if (status.getState() == DeploymentState.deployed) {
			return true;
		}
	}

	return false;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:23,代码来源:HealthCheckStep.java

示例3: deploy

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@RequestMapping(value = "/{name}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void deploy(@PathVariable("name") String name,
		@RequestParam(required = false) String properties) {
	ApplicationDefinition application = this.definitionRepository.findOne(name);
	if (application == null) {
		throw new NoSuchApplicationDefinitionException(name);
	}
	String status = calculateApplicationState(name);
	if (DeploymentState.deployed.equals(DeploymentState.valueOf(status))) {
		throw new ApplicationAlreadyDeployedException(name);
	}
	else if (DeploymentState.deploying.equals(DeploymentState.valueOf(status))) {
		throw new ApplicationAlreadyDeployingException(name);
	}
	deployApplication(application, DeploymentPropertiesUtils.parse(properties));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:18,代码来源:ApplicationDeploymentController.java

示例4: calculateApplicationState

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
private String calculateApplicationState(String name) {
	ApplicationDefinition application = definitionRepository.findOne(name);
	logger.debug("Calcuating application state for stream " + application.getName());

	String key = forApplicationDefinition(application);
	String id = this.deploymentIdRepository.findOne(key);

	logger.debug("Application Deployment Key = {},  Id = {}", key, id);

	if (id != null) {
		AppStatus status = appDeployer.status(id);
		DeploymentState deploymentState = status.getState();
		logger.debug("Stream Deployment Key = {}, Deployment State = {}", key, deploymentState);
		return deploymentState.toString();
	} else {
		return DeploymentState.unknown.toString();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:19,代码来源:ApplicationDefinitionController.java

示例5: start

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
/**
 * Start a given module on the CF
 *
 * @param name
 */
public void start(String name, URL apiEndpoint, String org, String space, String email, String password, String namespace) {

	CloudFoundryOperations operations = appDeployerFactory.getOperations(email, password, apiEndpoint, org, space);

	CloudFoundryAppDeployer appDeployer = appDeployerFactory.getAppDeployer(apiEndpoint, org, space, email, password, namespace);

	operations.applications()
		.start(StartApplicationRequest.builder()
			.name(name)
			.build())
		.then(() -> Mono.defer(() -> Mono.just(appDeployer.status(name)))
			.filter(appStatus ->
				appStatus.getState() == DeploymentState.deployed || appStatus.getState() == DeploymentState.failed)
			.repeatWhenEmpty(exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15), Duration.ofMinutes(15)))
			.doOnSuccess(v -> log.debug(String.format("Successfully started %s", name)))
			.doOnError(e -> log.error(String.format("Unable to start %s", name))))
		.block(Duration.ofMinutes(10));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-spinnaker,代码行数:24,代码来源:ModuleService.java

示例6: resolve

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
public DeploymentState resolve(ContainerStatus containerStatus) {

		Stream<Predicate<ContainerStatus>> conditionsStream = Stream.of(conditions);
		Boolean allConditionsMet = conditionsStream.reduce((x, y) -> x.and(y)).get().test(containerStatus);

		if (allConditionsMet) {
			logger.debug("deployment state is " + resolvedState.name());
			return this.resolvedState;
		}
		else {
			Stream<ContainerStatusCondition> report = Stream.of(conditions);
			report.filter(c -> {
				boolean result= false;
				try {
					result = c.test(containerStatus);
				}
				catch (NullPointerException e) {

				}
				return !result;

			}).forEach(c -> logger.debug(c + " is not satisfied"));

		}
		return null;
	}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:27,代码来源:PredicateRunningPhaseDeploymentStateResolver.java

示例7: mapState

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
/**
 * Maps Kubernetes phases/states onto Spring Cloud Deployer states
 */
private DeploymentState mapState() {
	logger.debug(String.format("%s - Phase [ %s ]", pod.getMetadata().getName(), pod.getStatus().getPhase()));
	logger.debug(String.format("%s - ContainerStatus [ %s ]", pod.getMetadata().getName(), containerStatus));
	switch (pod.getStatus().getPhase()) {

	case "Pending":
		return DeploymentState.deploying;

	// We only report a module as running if the container is also ready to service requests.
	// We also implement the Readiness check as part of the container to ensure ready means
	// that the module is up and running and not only that the JVM has been created and the
	// Spring module is still starting up
	case "Running":
		// we assume we only have one container
		return runningPhaseDeploymentStateResolver.resolve(containerStatus);
	case "Failed":
		return DeploymentState.failed;

	case "Unknown":
		return DeploymentState.unknown;

	default:
		return DeploymentState.unknown;
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:29,代码来源:KubernetesAppInstanceStatus.java

示例8: getState

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@Override
public DeploymentState getState() {
	if (task == null) {
		if (app.getLastTaskFailure() == null) {
			return DeploymentState.unknown;
		}
		else {
			return DeploymentState.failed;
		}
	}
	else {
		if (app.getInstances().intValue() > app.getTasksRunning().intValue()) {
			return DeploymentState.deploying;
		}
		else {
			Collection<HealthCheckResult> healthCheckResults = task.getHealthCheckResults();
			boolean alive = healthCheckResults != null && healthCheckResults.iterator().next().isAlive();
			if (!alive && app.getLastTaskFailure() != null) {
				return DeploymentState.failed;
			}
			return alive ? DeploymentState.deployed : DeploymentState.deploying;
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:25,代码来源:MarathonAppInstanceStatus.java

示例9: getState

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@Override
public DeploymentState getState() {
	if (instanceDetail == null) {
		return DeploymentState.failed;
	}
	switch (instanceDetail.getState()) {
		case "STARTING":
		case "DOWN":
			return DeploymentState.deploying;
		case "CRASHED":
			return DeploymentState.failed;
		// Seems the client incorrectly reports apps as FLAPPING when they are
		// obviously fine. Mapping as RUNNING for now
		case "FLAPPING":
		case "RUNNING":
			return DeploymentState.deployed;
		case "UNKNOWN":
			return DeploymentState.unknown;
		default:
			throw new IllegalStateException("Unsupported CF state: " + instanceDetail.getState());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:23,代码来源:CloudFoundryAppInstanceStatus.java

示例10: statusOfCrashedApplicationIsFailed

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void statusOfCrashedApplicationIsFailed() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder()
			.state("CRASHED")
			.index("1")
			.build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.failed));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:23,代码来源:CloudFoundryAppDeployerTests.java

示例11: statusOfDownApplicationIsDeploying

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void statusOfDownApplicationIsDeploying() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder()
			.state("DOWN")
			.index("1")
			.build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.deploying));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:23,代码来源:CloudFoundryAppDeployerTests.java

示例12: statusOfFlappingApplicationIsDeployed

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void statusOfFlappingApplicationIsDeployed() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder()
			.state("FLAPPING")
			.index("1")
			.build())
		.build()));

	AppStatus status = deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.deployed));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:23,代码来源:CloudFoundryAppDeployerTests.java

示例13: statusOfRunningApplicationIsDeployed

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void statusOfRunningApplicationIsDeployed() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder()
			.state("RUNNING")
			.index("1")
			.build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.deployed));
	assertThat(status.getInstances().get("test-application-0").toString(), equalTo("CloudFoundryAppInstanceStatus[test-application-0 : deployed]"));
	assertThat(status.getInstances().get("test-application-0").getAttributes(), equalTo(Collections.singletonMap("guid","test-application:0")));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:25,代码来源:CloudFoundryAppDeployerTests.java

示例14: statusOfStartingApplicationIsDeploying

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void statusOfStartingApplicationIsDeploying() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder()
			.state("STARTING")
			.index("1")
			.build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.deploying));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:23,代码来源:CloudFoundryAppDeployerTests.java

示例15: statusOfUnknownApplicationIsUnknown

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void statusOfUnknownApplicationIsUnknown() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder()
			.state("UNKNOWN")
			.index("1")
			.build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.unknown));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-cloudfoundry,代码行数:23,代码来源:CloudFoundryAppDeployerTests.java


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