public synchronized int getInstanceCount() { if (application != null) { return application.getInstances(); } return 0; }
private boolean isStarted(CloudApplication app) { return app.getRunningInstances() == app.getInstances() && app.getInstances() != 0 && getRequestedState(app).equals(org.cloudfoundry.client.lib.domain.CloudApplication.AppState.STARTED); }
ApplicationDeploymentInfo deploymentInfo = new ApplicationDeploymentInfo(deploymentName); deploymentInfo.setInstances(cloudApplication.getInstances()); deploymentInfo.setStaging(cloudApplication.getStaging()); deploymentInfo.setMemory(cloudApplication.getMemory());
@Override protected StepPhase executeStep(ExecutionWrapper execution) { CloudApplication app = StepsUtil.getApp(execution.getContext()); CloudApplication existingApp = StepsUtil.getExistingApp(execution.getContext()); try { getStepLogger().debug(Messages.SCALING_APP, app.getName()); CloudControllerClient client = execution.getControllerClient(); String appName = app.getName(); Integer instances = (app.getInstances() != 0) ? app.getInstances() : null; if (instances != null && (existingApp == null || !instances.equals(existingApp.getInstances()))) { getStepLogger().info(Messages.SCALING_APP_0_TO_X_INSTANCES, appName, instances); client.updateApplicationInstances(appName, instances); } getStepLogger().debug(Messages.APP_SCALED, app.getName()); return StepPhase.DONE; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_SCALING_APP, app.getName()); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_SCALING_APP, app.getName()); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { CloudApplication app = StepsUtil.getApp(execution.getContext()); CloudApplication existingApp = StepsUtil.getExistingApp(execution.getContext()); try { getStepLogger().debug(Messages.SCALING_APP, app.getName()); CloudControllerClient client = execution.getControllerClient(); String appName = app.getName(); Integer instances = (app.getInstances() != 0) ? app.getInstances() : null; if (instances != null && (existingApp == null || !instances.equals(existingApp.getInstances()))) { getStepLogger().info(Messages.SCALING_APP_0_TO_X_INSTANCES, appName, instances); client.updateApplicationInstances(appName, instances); } getStepLogger().debug(Messages.APP_SCALED, app.getName()); return StepPhase.DONE; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_SCALING_APP, app.getName()); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_SCALING_APP, app.getName()); throw e; } }
private StartupStatus getStartupStatus(ExecutionWrapper execution, CloudControllerClient client, String appName) { CloudApplication app = client.getApplication(appName); List<InstanceInfo> instances = getApplicationInstances(client, app); // The default value here is provided for undeploy processes: boolean failOnCrashed = StepsUtil.getVariableOrDefault(execution.getContext(), Constants.PARAM_FAIL_ON_CRASHED, true); if (instances != null) { int expectedInstances = app.getInstances(); int runningInstances = getInstanceCount(instances, InstanceState.RUNNING); int flappingInstances = getInstanceCount(instances, InstanceState.FLAPPING); int crashedInstances = getInstanceCount(instances, InstanceState.CRASHED); int startingInstances = getInstanceCount(instances, InstanceState.STARTING); showInstancesStatus(execution, appName, instances, runningInstances, expectedInstances); if (runningInstances == expectedInstances) { return StartupStatus.STARTED; } if (startingInstances > 0) { return StartupStatus.STARTING; } if (flappingInstances > 0) { return StartupStatus.FLAPPING; } if (crashedInstances > 0 && failOnCrashed) { return StartupStatus.CRASHED; } } return StartupStatus.STARTING; }
private StartupStatus getStartupStatus(ExecutionWrapper execution, CloudControllerClient client, String appName) { CloudApplication app = client.getApplication(appName); List<InstanceInfo> instances = getApplicationInstances(client, app); // The default value here is provided for undeploy processes: boolean failOnCrashed = StepsUtil.getVariableOrDefault(execution.getContext(), Constants.PARAM_FAIL_ON_CRASHED, true); if (instances != null) { int expectedInstances = app.getInstances(); int runningInstances = getInstanceCount(instances, InstanceState.RUNNING); int flappingInstances = getInstanceCount(instances, InstanceState.FLAPPING); int crashedInstances = getInstanceCount(instances, InstanceState.CRASHED); int startingInstances = getInstanceCount(instances, InstanceState.STARTING); showInstancesStatus(execution, appName, instances, runningInstances, expectedInstances); if (runningInstances == expectedInstances) { return StartupStatus.STARTED; } if (startingInstances > 0) { return StartupStatus.STARTING; } if (flappingInstances > 0) { return StartupStatus.FLAPPING; } if (crashedInstances > 0 && failOnCrashed) { return StartupStatus.CRASHED; } } return StartupStatus.STARTING; }