Java Code Examples for org.springframework.cloud.deployer.spi.app.DeploymentState#unknown()

The following examples show how to use org.springframework.cloud.deployer.spi.app.DeploymentState#unknown() . 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: KubernetesAppInstanceStatus.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
	}
}
 
Example 2
Source File: MarathonAppInstanceStatus.java    From spring-cloud-deployer-mesos with Apache License 2.0 6 votes vote down vote up
@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;
		}
	}
}
 
Example 3
Source File: CloudFoundryAppInstanceStatus.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@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());
	}
}
 
Example 4
Source File: ReleaseCommands.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
/**
 * Aggregate the set of app states into a single state for a stream.
 *
 * @param states set of states for apps of a stream
 * @return the stream state based on app states
 */
public static DeploymentState aggregateState(List<DeploymentState> states) {
	if (states.size() == 1) {
		DeploymentState state = states.iterator().next();
		logger.debug("aggregateState: Deployment State Set Size = 1.  Deployment State " + state);
		// a stream which is known to the stream definition repository
		// but unknown to deployers is undeployed
		if (state == DeploymentState.unknown) {
			logger.debug("aggregateState: Returning " + DeploymentState.undeployed);
			return DeploymentState.undeployed;
		}
		else {
			logger.debug("aggregateState: Returning " + state);
			return state;
		}
	}
	if (states.isEmpty() || states.contains(DeploymentState.error)) {
		logger.debug("aggregateState: Returning " + DeploymentState.error);
		return DeploymentState.error;
	}
	if (states.contains(DeploymentState.failed)) {
		logger.debug("aggregateState: Returning " + DeploymentState.failed);
		return DeploymentState.failed;
	}
	if (states.contains(DeploymentState.deploying)) {
		logger.debug("aggregateState: Returning " + DeploymentState.deploying);
		return DeploymentState.deploying;
	}

	if (allAppsDeployed(states)) {
		return DeploymentState.deployed;
	}

	logger.debug("aggregateState: Returning " + DeploymentState.partial);
	return DeploymentState.partial;
}
 
Example 5
Source File: YarnAppDeployer.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
public InstanceStatus(String id, boolean deployed, Map<String, String> attributes) {
	this.id = id;
	this.state = deployed ? DeploymentState.deployed : DeploymentState.unknown;
	if (attributes != null) {
		this.attributes.putAll(attributes);
	}
}
 
Example 6
Source File: StreamDeployerUtil.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Aggregate the set of app states into a single state for a stream.
 *
 * @param states set of states for apps of a stream
 * @return the stream state based on app states
 */
public static DeploymentState aggregateState(Set<DeploymentState> states) {
	if (states.size() == 1) {
		DeploymentState state = states.iterator().next();
		logger.debug("aggregateState: Deployment State Set Size = 1.  Deployment State " + state);
		// a stream which is known to the stream definition streamDefinitionRepository
		// but unknown to deployers is undeployed
		if (state == null || state == DeploymentState.unknown) {
			logger.debug("aggregateState: Returning " + DeploymentState.undeployed);
			return DeploymentState.undeployed;
		}
		else {
			logger.debug("aggregateState: Returning " + state);
			return state;
		}
	}
	DeploymentState result = DeploymentState.partial;
	if (states.isEmpty() || states.contains(DeploymentState.error)) {
		logger.debug("aggregateState: Returning " + DeploymentState.error);
		result = DeploymentState.error;
	}
	else if (states.contains(DeploymentState.deployed) && states.contains(DeploymentState.failed)) {
		logger.debug("aggregateState: Returning " + DeploymentState.partial);
		result = DeploymentState.partial;
	}
	else if (states.contains(DeploymentState.failed)) {
		logger.debug("aggregateState: Returning " + DeploymentState.failed);
		result = DeploymentState.failed;
	}
	else if (states.contains(DeploymentState.deploying)) {
		logger.debug("aggregateState: Returning " + DeploymentState.deploying);
		result = DeploymentState.deploying;
	}

	logger.debug("aggregateState: Returning " + DeploymentState.partial);
	return result;
}
 
Example 7
Source File: SkipperStreamDeployer.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private DeploymentState getDeploymentStateFromStatusInfo(Info info) {
	DeploymentState result = DeploymentState.unknown;
	switch (info.getStatus().getStatusCode()) {
	case FAILED:
		result = DeploymentState.failed;
		break;
	case DELETED:
		result = DeploymentState.undeployed;
		break;
	case DEPLOYED:
		result = DeploymentState.deployed;
	}
	return result;
}
 
Example 8
Source File: KubernetesAppInstanceStatus.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 4 votes vote down vote up
@Override
public DeploymentState getState() {
	return pod != null && containerStatus != null ? mapState() : DeploymentState.unknown;
}
 
Example 9
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void assertApplicationDoesNotExist(String deploymentId, AppStatus status) {
	DeploymentState state = status.getState();
	if (state != DeploymentState.unknown && state != DeploymentState.error) {
		throw new IllegalStateException(String.format("App %s is already deployed with state %s", deploymentId, state));
	}
}
 
Example 10
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void assertApplicationExists(String deploymentId, AppStatus status) {
	DeploymentState state = status.getState();
	if (state == DeploymentState.unknown) {
		throw new IllegalStateException(String.format("App %s is not in a deployed state", deploymentId));
	}
}