• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DeploymentState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getStreamDeploymentState

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
private DeploymentState getStreamDeploymentState(String streamName) {
	DeploymentState state = null;
	try {
		Info info = this.skipperClient.status(streamName);
		List<AppStatus> appStatusList = deserializeAppStatus(info.getStatus().getPlatformStatus());
		Set<DeploymentState> deploymentStateList = appStatusList.stream().map(appStatus -> appStatus.getState())
				.collect(Collectors.toSet());
		DeploymentState aggregateState = StreamDefinitionController.aggregateState(deploymentStateList);
		state = aggregateState;
	}
	catch (ReleaseNotFoundException e) {
		// a defined stream but unknown to skipper is considered to be in undeployed state
		if (streamDefinitionExists(streamName)) {
			state = DeploymentState.undeployed;
		}
	}
	return state;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:19,代码来源:SkipperStreamDeployer.java


示例17: undeployStream

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@Override
public void undeployStream(String streamName) {
	StreamDefinition streamDefinition = this.streamDefinitionRepository.findOne(streamName);
	for (StreamAppDefinition appDefinition : streamDefinition.getAppDefinitions()) {
		String key = DeploymentKey.forStreamAppDefinition(appDefinition);
		String id = this.deploymentIdRepository.findOne(key);
		// if id is null, assume nothing is deployed
		if (id != null) {
			AppStatus status = this.appDeployer.status(id);
			if (!EnumSet.of(DeploymentState.unknown, DeploymentState.undeployed).contains(status.getState())) {
				this.appDeployer.undeploy(id);
			}
			this.deploymentIdRepository.delete(key);
		}
	}
	this.streamDeploymentRepository.delete(streamDefinition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:18,代码来源:AppDeployerStreamDeployer.java


示例18: calculateStreamState

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@Override
public DeploymentState calculateStreamState(String streamName) {
	Set<DeploymentState> appStates = EnumSet.noneOf(DeploymentState.class);
	StreamDefinition stream = this.streamDefinitionRepository.findOne(streamName);
	for (StreamAppDefinition appDefinition : stream.getAppDefinitions()) {
		String key = DeploymentKey.forStreamAppDefinition(appDefinition);
		String id = this.deploymentIdRepository.findOne(key);
		if (id != null) {
			AppStatus status = this.appDeployer.status(id);
			appStates.add(status.getState());
		}
		else {
			appStates.add(DeploymentState.undeployed);
		}
	}
	return StreamDefinitionController.aggregateState(appStates);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:18,代码来源:AppDeployerStreamDeployer.java


示例19: state

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
@Override
public Map<StreamDefinition, DeploymentState> state(List<StreamDefinition> streamDefinitions) {
	Map<StreamDefinition, List<String>> deploymentIdsPerStream = streamDefinitions.stream()
			.collect(Collectors.toMap(Function.identity(),
					sd -> sd.getAppDefinitions().stream().map(
							sad -> deploymentIdRepository.findOne(DeploymentKey.forStreamAppDefinition(sad)))
							.collect(Collectors.toList())));

	// Map from app deployment id to state
	Map<String, DeploymentState> statePerApp = gatherDeploymentStates(deploymentIdsPerStream.values().stream()
			.flatMap(Collection::stream).filter(Objects::nonNull).toArray(String[]::new));

	// Map from SCDF Stream to aggregate state
	return deploymentIdsPerStream.entrySet().stream()
			.map(kv -> new AbstractMap.SimpleImmutableEntry<>(kv.getKey(),
					StreamDefinitionController.aggregateState(kv.getValue().stream()
							.map(deploymentId -> statePerApp.getOrDefault(deploymentId, DeploymentState.unknown))
							.collect(Collectors.toSet()))))
			.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:21,代码来源:AppDeployerStreamDeployer.java


示例20: info

import org.springframework.cloud.deployer.spi.app.DeploymentState; //导入依赖的package包/类
/**
 * Request deployment of an existing stream definition.
 * @param name the name of an existing stream definition (required)
 */
@RequestMapping(value = "/{name}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.CREATED)
public StreamDeploymentResource info(@PathVariable("name") String name) {
	StreamDefinition streamDefinition = this.repository.findOne(name);
	if (streamDefinition == null) {
		throw new NoSuchStreamDefinitionException(name);
	}
	StreamDeployment streamDeployment = this.streamService.info(name);
	Map<StreamDefinition, DeploymentState> streamDeploymentStates =
			this.streamService.state(Arrays.asList(streamDefinition));
	DeploymentState deploymentState = streamDeploymentStates.get(streamDefinition);
	String status = "";
	if (deploymentState != null) {
		final DeploymentStateResource deploymentStateResource = ControllerUtils.mapState(deploymentState);
		status = deploymentStateResource.getKey();
	}
	return new Assembler(streamDefinition.getDslText(), status).toResource(streamDeployment);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:23,代码来源:StreamDeploymentController.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Await类代码示例发布时间:2022-05-22
下一篇:
Java VersionConflictEngineException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap