org.springframework.cloud.deployer.spi.app.AppStatus Java Examples

The following examples show how to use org.springframework.cloud.deployer.spi.app.AppStatus. 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: MarathonAppDeployer.java    From spring-cloud-deployer-mesos with Apache License 2.0 6 votes vote down vote up
private AppStatus buildAppStatus(String id, App app) {
	logger.debug("Deployment " + id + " has " + app.getTasksRunning() + "/" + app.getInstances() + " tasks running");
	AppStatus.Builder result = AppStatus.of(id);
	int requestedInstances = app.getInstances();
	int actualInstances = 0;
	if (app.getTasks() != null) {
		for (Task task : app.getTasks()) {
			result.with(MarathonAppInstanceStatus.up(app, task));
			actualInstances++;
		}
	}
	for (int i = actualInstances; i < requestedInstances; i++) {
		result.with(MarathonAppInstanceStatus.down(app));
	}
	return result.build();
}
 
Example #2
Source File: CloudFoundryManifestApplicationDeployer.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
private AppStatus createAppStatus(ApplicationDetail applicationDetail, String deploymentId) {
	logger.trace("Gathering instances for " + applicationDetail);
	logger.trace("InstanceDetails: " + applicationDetail.getInstanceDetails());

	AppStatus.Builder builder = AppStatus.of(deploymentId);

	int i = 0;
	for (InstanceDetail instanceDetail : applicationDetail.getInstanceDetails()) {
		builder.with(new CloudFoundryAppInstanceStatus(applicationDetail, instanceDetail, i++));
	}
	for (; i < applicationDetail.getInstances(); i++) {
		builder.with(new CloudFoundryAppInstanceStatus(applicationDetail, null, i));
	}

	return builder.build();
}
 
Example #3
Source File: LocalAppDeployerIntegrationTests.java    From spring-cloud-deployer-local with Apache License 2.0 6 votes vote down vote up
@Test
// was triggered by GH-50 and subsequently GH-55
public void testNoStdoutStderrOnInheritLoggingAndNoNPEOnGetAttributes() {
	Map<String, String> properties = new HashMap<>();
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.singletonMap(LocalDeployerProperties.INHERIT_LOGGING, "true"));

	AppDeployer deployer = appDeployer();
	String deploymentId = deployer.deploy(request);
	AppStatus appStatus = deployer.status(deploymentId);
	assertTrue(appStatus.getInstances().size() > 0);
	for (Entry<String, AppInstanceStatus> instanceStatusEntry : appStatus.getInstances().entrySet()) {
		Map<String, String> attributes = instanceStatusEntry.getValue().getAttributes();
		assertFalse(attributes.containsKey("stdout"));
		assertFalse(attributes.containsKey("stderr"));
	}
	deployer.undeploy(deploymentId);
}
 
Example #4
Source File: Status.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
@JsonIgnore
public String getPlatformStatusPrettyPrint() {
	List<AppStatus> appStatusList = getAppStatusList();
	StringBuffer statusMsg = new StringBuffer();

	for (AppStatus appStatus : appStatusList) {
		statusMsg.append("[" + appStatus.getDeploymentId() + "]");
		if (appStatus.getInstances().isEmpty()) {
			statusMsg.append(", State = [" + appStatus.getState() + "]\n");
		}
		else {
			statusMsg.append(", State = [");
			for (AppInstanceStatus appInstanceStatus : appStatus.getInstances().values()) {
				statusMsg.append(appInstanceStatus.getId() + "=" + appInstanceStatus.getState() + "\n");
			}
			statusMsg.setLength(statusMsg.length() - 1);
			statusMsg.append("]\n");
		}
	}
	return statusMsg.toString();
}
 
Example #5
Source File: SkipperStreamDeployer.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
private DeploymentState getStreamDeploymentState(String streamName) {
	DeploymentState state = null;
	try {
		Info info = this.skipperClient.status(streamName);
		if (info.getStatus().getPlatformStatus() == null) {
			return getDeploymentStateFromStatusInfo(info);
		}
		List<AppStatus> appStatusList = deserializeAppStatus(info.getStatus().getPlatformStatus());
		Set<DeploymentState> deploymentStateList = appStatusList.stream().map(AppStatus::getState)
				.collect(Collectors.toSet());
		state = StreamDeployerUtil.aggregateState(deploymentStateList);
	}
	catch (ReleaseNotFoundException e) {
		// a defined stream but unknown to skipper is considered to be in an undeployed state
		if (streamDefinitionExists(streamName)) {
			state = DeploymentState.undeployed;
		}
	}
	return state;
}
 
Example #6
Source File: SkipperStreamDeployer.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Override
public AppStatus getAppStatus(String appDeploymentId) {
	// iteration through a real platform statuses one by one
	// is too expensive instead we rely on what skipper
	// already knows about it.
	return this.skipperClient.list(null)
		.stream()
		.flatMap(r -> {
			Info info = r.getInfo();
			if (info != null) {
				Status status = info.getStatus();
				if (status != null) {
					return status.getAppStatusList().stream();
				}
			}
			return Stream.empty();
		})
		.filter(as -> ObjectUtils.nullSafeEquals(appDeploymentId, as.getDeploymentId()))
		.findFirst()
		.orElseThrow(() -> new NoSuchAppException(appDeploymentId));
}
 
Example #7
Source File: StreamControllerTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
public void testDuplicateDeploy() throws Exception {
	repository.save(new StreamDefinition("myStream", "time | log"));

	mockMvc.perform(post("/streams/deployments/myStream")
			.accept(MediaType.APPLICATION_JSON)).andDo(print())
			.andExpect(status().isCreated());

	ArgumentCaptor<UploadRequest> uploadRequestCaptor = ArgumentCaptor.forClass(UploadRequest.class);
	verify(skipperClient, times(1)).upload(uploadRequestCaptor.capture());

	Package pkg = SkipperPackageUtils.loadPackageFromBytes(uploadRequestCaptor);
	assertNotNull(findChildPackageByName(pkg, "log"));
	assertNotNull(findChildPackageByName(pkg, "time"));

	streamStatusInfo.getStatus().setPlatformStatusAsAppStatusList(Arrays.asList(
			AppStatus.of("myStream.time-v1").generalState(DeploymentState.deploying).build(),
			AppStatus.of("myStream.log-v1").generalState(DeploymentState.deployed).build()));

	// Attempt to deploy already deployed stream
	mockMvc.perform(post("/streams/deployments/myStream")
			.accept(MediaType.APPLICATION_JSON)).andDo(print())
			.andExpect(status().isConflict());
}
 
Example #8
Source File: CloudFoundryManifestApplicationDeployer.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
public AppStatus status(Release release) {
	logger.info("Checking application status for the release: " + release.getName());
	ApplicationManifest applicationManifest = CloudFoundryApplicationManifestUtils.updateApplicationName(release);
	String applicationName = applicationManifest.getName();
	AppStatus appStatus = null;
	try {
		appStatus = getStatus(applicationName, release.getPlatformName())
				.doOnSuccess(v -> logger.info("Successfully computed status [{}] for {}", v,
						applicationName))
				.doOnError(e -> logger.error(
						String.format("Failed to compute status for %s", applicationName)))
				.block();
	}
	catch (Exception timeoutDueToBlock) {
		logger.error("Caught exception while querying for status of {}", applicationName, timeoutDueToBlock);
		appStatus = createErrorAppStatus(applicationName);
	}
	return appStatus;
}
 
Example #9
Source File: LocalAppDeployerIntegrationTests.java    From spring-cloud-deployer-local with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailureToCallShutdownOnUndeploy() {
	Map<String, String> properties = new HashMap<>();
	// disable shutdown endpoint
	properties.put("endpoints.shutdown.enabled", "false");
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Deploying {}...", request.getDefinition().getName());

	String deploymentId = appDeployer().deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(deployed))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));
}
 
Example #10
Source File: RuntimeAppsController.java    From spring-cloud-dashboard with Apache License 2.0 6 votes vote down vote up
@RequestMapping
public PagedResources<AppStatusResource> list(PagedResourcesAssembler<AppStatus> assembler) {
	List<AppStatus> values = new ArrayList<>();

	for (ApplicationDefinition applicationDefinition : this.applicationDefinitionRepository.findAll()) {
		String key = forApplicationDefinition(applicationDefinition);
		String id = this.deploymentIdRepository.findOne(key);
		if (id != null) {
			values.add(appDeployer.status(id));
		}
	}

	Collections.sort(values, new Comparator<AppStatus>() {
		@Override
		public int compare(AppStatus o1, AppStatus o2) {
			return o1.getDeploymentId().compareTo(o2.getDeploymentId());
		}
	});
	return assembler.toResource(new PageImpl<>(values), statusAssembler);
}
 
Example #11
Source File: LocalAppDeployerEnvironmentIntegrationTests.java    From spring-cloud-deployer-local with Apache License 2.0 6 votes vote down vote up
@Test
// was triggered by GH-50 and subsequently GH-55
public void testNoStdoutStderrOnInheritLoggingAndNoNPEOnGetAttributes() {
	Map<String, String> properties = new HashMap<>();
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.singletonMap(LocalDeployerProperties.INHERIT_LOGGING, "true"));

	AppDeployer deployer = appDeployer();
	String deploymentId = deployer.deploy(request);
	AppStatus appStatus = deployer.status(deploymentId);
	assertTrue(appStatus.getInstances().size() > 0);
	for (Entry<String, AppInstanceStatus> instanceStatusEntry : appStatus.getInstances().entrySet()) {
		Map<String, String> attributes = instanceStatusEntry.getValue().getAttributes();
		assertFalse(attributes.containsKey("stdout"));
		assertFalse(attributes.containsKey("stderr"));
	}
	deployer.undeploy(deploymentId);
}
 
Example #12
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #13
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #14
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@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")));
}
 
Example #15
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #16
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #17
Source File: YarnAppDeployer.java    From spring-cloud-deployer-yarn with Apache License 2.0 6 votes vote down vote up
@Override
public AppStatus status(String id) {
	logger.info("Checking status of {}", id);
	DeploymentKey key = new DeploymentKey(id);
	Builder builder = AppStatus.of(id);
	for (Entry<String, StreamClustersInfoReportData> entry : yarnCloudAppService.getClustersStates(key.applicationId).entrySet()) {
		if (ObjectUtils.nullSafeEquals(entry.getKey(), key.getClusterId())) {
			ClustersInfoReportData data = entry.getValue();
			List<String> members = entry.getValue().getMembers();
			for (int i = 0 ; i < data.getProjectionAny(); i++) {
				Map<String, String> attributes = new HashMap<>();
				if (i < members.size()) {
					attributes.put("container", members.get(i));
					attributes.put("guid", members.get(i));
				}
				InstanceStatus instanceStatus = new InstanceStatus(key.getClusterId() + "-" + i, i < data.getCount(), attributes);
				builder.with(instanceStatus);
			}
			break;
		}
	}
	return builder.build();
}
 
Example #18
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #19
Source File: AbstractAppDeployerIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that an app which takes a long time to deploy is correctly reported as deploying.
 * Test that such an app can be undeployed.
 */
@Test
public void testDeployingStateCalculationAndCancel() {
	Map<String, String> properties = new HashMap<>();
	properties.put("initDelay", "" + 1000 * 60 * 60); // 1hr
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties);

	log.info("Deploying {}...", request.getDefinition().getName());

	String deploymentId = appDeployer().deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(deploying))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));

}
 
Example #20
Source File: LocalAppDeployerEnvironmentIntegrationTests.java    From spring-cloud-deployer-local with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailureToCallShutdownOnUndeploy() {
	Map<String, String> properties = new HashMap<>();
	// disable shutdown endpoint
	properties.put("endpoints.shutdown.enabled", "false");
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Deploying {}...", request.getDefinition().getName());

	String deploymentId = appDeployer().deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(deployed))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));
}
 
Example #21
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
private AppStatus createAppStatus(ApplicationDetail applicationDetail, String deploymentId) {
	logger.trace("Gathering instances for " + applicationDetail);
	logger.trace("InstanceDetails: " + applicationDetail.getInstanceDetails());

	AppStatus.Builder builder = AppStatus.of(deploymentId);

	int i = 0;
	for (InstanceDetail instanceDetail : applicationDetail.getInstanceDetails()) {
		builder.with(new CloudFoundryAppInstanceStatus(applicationDetail, instanceDetail, i++));
	}
	for (; i < applicationDetail.getInstances(); i++) {
		builder.with(new CloudFoundryAppInstanceStatus(applicationDetail, null, i));
	}

	return builder.build();
}
 
Example #22
Source File: HealthCheckStep.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
public boolean isHealthy(Release replacingRelease) {
	AppDeployerData replacingAppDeployerData = this.appDeployerDataRepository
			.findByReleaseNameAndReleaseVersionRequired(
					replacingRelease.getName(), replacingRelease.getVersion());
	Map<String, String> appNamesAndDeploymentIds = (replacingAppDeployerData!= null) ?
			replacingAppDeployerData.getDeploymentDataAsMap() : Collections.EMPTY_MAP;
	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;
}
 
Example #23
Source File: RuntimeAppInstanceController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/{instanceId}")
public AppInstanceStatusResource display(@PathVariable String appId, @PathVariable String instanceId) {
	AppStatus status = streamDeployer.getAppStatus(appId);
	if (status.getState().equals(DeploymentState.unknown)) {
		throw new NoSuchAppException(appId);
	}
	AppInstanceStatus appInstanceStatus = status.getInstances().get(instanceId);
	if (appInstanceStatus == null) {
		throw new NoSuchAppInstanceException(instanceId);
	}
	return new RuntimeAppInstanceController.InstanceAssembler(status).toModel(appInstanceStatus);
}
 
Example #24
Source File: RuntimeAppInstanceController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@RequestMapping
public PagedModel<AppInstanceStatusResource> list(Pageable pageable, @PathVariable String appId,
		PagedResourcesAssembler<AppInstanceStatus> assembler) {
	AppStatus status = streamDeployer.getAppStatus(appId);
	if (status.getState().equals(DeploymentState.unknown)) {
		throw new NoSuchAppException(appId);
	}
	List<AppInstanceStatus> appInstanceStatuses = new ArrayList<>(status.getInstances().values());
	Collections.sort(appInstanceStatuses, RuntimeAppInstanceController.INSTANCE_SORTER);
	return assembler.toModel(new PageImpl<>(appInstanceStatuses, pageable,
			appInstanceStatuses.size()), new RuntimeAppInstanceController.InstanceAssembler(status));
}
 
Example #25
Source File: RuntimeStreamsController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * @param streamNames comma separated list of streams to retrieve the statuses for
 */
@RequestMapping(value = "/{streamNames}", method = RequestMethod.GET)
public PagedModel<StreamStatusResource> streamStatus(@PathVariable("streamNames") String[] streamNames, Pageable pageable,
		PagedResourcesAssembler<Pair<String, List<AppStatus>>> assembler) {
	return assembler.toModel(new PageImpl<>(getStreamStatusList(getPagedStreamNames(pageable, Arrays.asList(streamNames))),
			pageable, streamNames.length), statusAssembler);
}
 
Example #26
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Override
public AppStatus status(String id) {
	try {
		return getStatus(id)
			.doOnSuccess(v -> logger.info("Successfully computed status [{}] for {}", 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, timeoutDueToBlock);
		return createErrorAppStatus(id);
	}
}
 
Example #27
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private Mono<AppStatus> getStatus(String deploymentId) {
	return requestGetApplication(deploymentId)
		.map(applicationDetail -> createAppStatus(applicationDetail, deploymentId))
		.onErrorResume(IllegalArgumentException.class, t -> {
			logger.debug("Application for {} does not exist.", deploymentId);
			return Mono.just(createEmptyAppStatus(deploymentId));
		})
		.transform(statusRetry(deploymentId))
		.onErrorReturn(createErrorAppStatus(deploymentId));
}
 
Example #28
Source File: SkipperStreamDeployer.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private List<AppStatus> skipperStatus(String streamName) {
	List<AppStatus> appStatuses = new ArrayList<>();
	try {
		Info info = this.skipperClient.status(streamName);
		appStatuses.addAll(info.getStatus().getAppStatusList());
	}
	catch (Exception e) {
		// ignore as we query status for all the streams.
	}
	return appStatuses;
}
 
Example #29
Source File: DeleteStep.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
public Release delete(Release release, AppDeployerData existingAppDeployerData,
		List<String> applicationNamesToDelete) {
	AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName())
			.getAppDeployer();

	Map<String, String> appNamesAndDeploymentIds = (existingAppDeployerData!= null) ?
			existingAppDeployerData.getDeploymentDataAsMap() : Collections.EMPTY_MAP;

	for (Map.Entry<String, String> appNameAndDeploymentId : appNamesAndDeploymentIds.entrySet()) {
		if (applicationNamesToDelete.contains(appNameAndDeploymentId.getKey())) {
			AppStatus appStatus = appDeployer.status(appNameAndDeploymentId.getValue());
			if (appStatus.getState().equals(DeploymentState.deployed)) {
				appDeployer.undeploy(appNameAndDeploymentId.getValue());
			}
			else {
				logger.warn("For Release name {}, did not undeploy existing app {} as its status is not "
						+ "'deployed'.", release.getName(), appNameAndDeploymentId.getKey());
			}
		}
	}

	Status deletedStatus = new Status();
	deletedStatus.setStatusCode(StatusCode.DELETED);
	release.getInfo().setStatus(deletedStatus);
	release.getInfo().setDescription("Delete complete");
	this.releaseRepository.save(release);
	return release;
}
 
Example #30
Source File: SkipperStreamDeployer.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private List<AppStatus> getStreamsStatuses(List<String> streamNames) {
	Map<String, Info> statuses = this.skipperClient.statuses(streamNames.toArray(new String[0]));
	List<AppStatus> appStatusList = new ArrayList<>();
	statuses.entrySet().stream().forEach(e -> {
		appStatusList.addAll(e.getValue().getStatus().getAppStatusList());
	});
	return appStatusList;
}