org.cloudfoundry.operations.applications.ScaleApplicationRequest Java Examples

The following examples show how to use org.cloudfoundry.operations.applications.ScaleApplicationRequest. 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: ScaleAppInstancesPolicyExecutorTask.java    From cf-butler with Apache License 2.0 6 votes vote down vote up
protected Mono<HistoricalRecord> scaleApplication(ApplicationPolicy policy, AppDetail detail) {
	return DefaultCloudFoundryOperations.builder()
            .from(opsClient)
            .organization(detail.getOrganization())
            .space(detail.getSpace())
            .build()
.applications()
	.scale(
			ScaleApplicationRequest
				.builder()
					.name(detail.getAppName())
					.instances(policy.getOption("instances-to", Integer.class))
					.build())
	.then(Mono.just(HistoricalRecord
				.builder()
					.transactionDateTime(LocalDateTime.now())
					.actionTaken("scale-instances")
					.organization(detail.getOrganization())
					.space(detail.getSpace())
					.appId(detail.getAppId())
					.type("application")
					.name(detail.getAppName())
					.build()));
}
 
Example #2
Source File: CloudFoundryReleaseManager.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
@Override
public Release scale(Release release, ScaleRequest scaleRequest) {
	logger.info("Scaling the application instance using ", scaleRequest.toString());
	for (ScaleRequest.ScaleRequestItem scaleRequestItem: scaleRequest.getScale()) {
		ScaleApplicationRequest scaleApplicationRequest = ScaleApplicationRequest.builder()
				.name(scaleRequestItem.getName())
				.instances(scaleRequestItem.getCount())
				.stagingTimeout(CloudFoundryManifestApplicationDeployer.STAGING_TIMEOUT)
				.startupTimeout(CloudFoundryManifestApplicationDeployer.STARTUP_TIMEOUT)
				.build();
		this.platformCloudFoundryOperations.getCloudFoundryOperations(release.getPlatformName()).applications()
				.scale(scaleApplicationRequest)
				.timeout(Duration.ofSeconds(API_TIMEOUT.toMillis()))
				.doOnSuccess(v -> logger.info("Scaled the application with deploymentId = {}",
						scaleRequestItem.getName()))
				.doOnError(e -> logger.error("Error: {} scaling the app instance {}", e.getMessage(),
						scaleRequestItem.getName()))
				.subscribe();
	}
	return release;
}
 
Example #3
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@Override
public void scale(AppScaleRequest appScaleRequest) {
	logger.info("Scaling the application instance using ", appScaleRequest.toString());
	ScaleApplicationRequest scaleApplicationRequest = ScaleApplicationRequest.builder()
			.name(appScaleRequest.getDeploymentId())
			.instances(appScaleRequest.getCount())
			.memoryLimit(memory(appScaleRequest))
			.diskLimit(diskQuota(appScaleRequest))
			.stagingTimeout(this.deploymentProperties.getStagingTimeout())
			.startupTimeout(this.deploymentProperties.getStartupTimeout())
			.build();
	this.operations.applications().scale(scaleApplicationRequest)
			.timeout(Duration.ofSeconds(this.deploymentProperties.getApiTimeout()))
			.doOnSuccess(v -> logger.info("Scaled the application with deploymentId = {}",
					appScaleRequest.getDeploymentId()))
			.doOnError(e -> logger.error("Error: {} scaling the app instance {}", e.getMessage(),
					appScaleRequest.getDeploymentId()))
			.subscribe();
}
 
Example #4
Source File: CfScaleInstanceCountDelegate.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
public Mono<Void> scaleInstances(CloudFoundryOperations cfOperations,
                                 CfProperties cfProperties, int instanceCount) {

    Mono<Void> resp = cfOperations.applications().scale(
        ScaleApplicationRequest.builder()
            .instances(instanceCount)
            .build()
    ).doOnSubscribe((s) -> {
        LOGGER.lifecycle("Scaling app {} to instance count {}", cfProperties.name(), instanceCount);
    });

    return resp;

}
 
Example #5
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void givenRequestScaleApplication(String id, Integer count, int memoryLimit, int diskLimit, Mono<Void> response) {
	given(this.operations.applications()
			.scale(ScaleApplicationRequest.builder().name(id).instances(count).memoryLimit(memoryLimit).diskLimit(diskLimit)
					.startupTimeout(this.deploymentProperties.getStartupTimeout())
					.stagingTimeout(this.deploymentProperties.getStagingTimeout()).build())).willReturn(response);
}