@SuppressWarnings("unchecked") private ApplicationStats doGetApplicationStats(UUID appId, CloudApplication.AppState appState) { List<InstanceStats> instanceList = new ArrayList<InstanceStats>(); if (appState.equals(CloudApplication.AppState.STARTED)) { Map<String, Object> respMap = getInstanceInfoForApp(appId, "stats"); if (!CollectionUtils.isEmpty(respMap)) { for (String instanceId : respMap.keySet()) { InstanceStats instanceStats = new InstanceStats(instanceId, (Map<String, Object>) respMap.get(instanceId)); instanceList.add(instanceStats); } } } return new ApplicationStats(instanceList); }
@SuppressWarnings("unchecked") private ApplicationStats doGetApplicationStats(UUID appId, CloudApplication.AppState appState) { List<InstanceStats> instanceList = new ArrayList<InstanceStats>(); if (appState.equals(CloudApplication.AppState.STARTED)) { Map<String, Object> respMap = getInstanceInfoForApp(appId, "stats"); for (String instanceId : respMap.keySet()) { InstanceStats instanceStats = new InstanceStats(instanceId, (Map<String, Object>) respMap.get(instanceId)); instanceList.add(instanceStats); } } return new ApplicationStats(instanceList); }
private boolean isStarted(CloudControllerClient client, String appName) { try { CloudApplication app = client.getApplication(appName); return app.getState() .equals(AppState.STARTED); } catch (CloudOperationException e) { if (e.getStatusCode() .equals(HttpStatus.INTERNAL_SERVER_ERROR)) { logger.warn(e.getMessage(), e); return false; } throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { // Get the next cloud application from the context CloudApplication app = StepsUtil.getApp(execution.getContext()); // Get the existing application from the context CloudApplication existingApp = StepsUtil.getExistingApp(execution.getContext()); try { if (existingApp != null && !existingApp.getState() .equals(AppState.STOPPED)) { getStepLogger().info(Messages.STOPPING_APP, app.getName()); // Get a cloud foundry client CloudControllerClient client = execution.getControllerClient(); // Stop the application client.stopApplication(app.getName()); getStepLogger().debug(Messages.APP_STOPPED, app.getName()); } else { getStepLogger().debug("Application \"{0}\" already stopped", app.getName()); } return StepPhase.DONE; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_STOPPING_APP, app.getName()); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_STOPPING_APP, app.getName()); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { // Get the next cloud application from the context CloudApplication app = StepsUtil.getApp(execution.getContext()); // Get the existing application from the context CloudApplication existingApp = StepsUtil.getExistingApp(execution.getContext()); try { if (existingApp != null && !existingApp.getState() .equals(AppState.STOPPED)) { getStepLogger().info(Messages.STOPPING_APP, app.getName()); // Get a cloud foundry client CloudControllerClient client = execution.getControllerClient(); // Stop the application client.stopApplication(app.getName()); getStepLogger().debug(Messages.APP_STOPPED, app.getName()); } else { getStepLogger().debug("Application \"{0}\" already stopped", app.getName()); } return StepPhase.DONE; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_STOPPING_APP, app.getName()); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_STOPPING_APP, app.getName()); throw e; } }
private boolean isStarted(CloudControllerClient client, String appName) { try { CloudApplication app = client.getApplication(appName); return app.getState() .equals(AppState.STARTED); } catch (CloudOperationException e) { if (e.getStatusCode() .equals(HttpStatus.INTERNAL_SERVER_ERROR)) { logger.warn(e.getMessage(), e); return false; } throw e; } }
private boolean isStopped(CloudApplication app) { return app.getRunningInstances() == 0 && getRequestedState(app).equals(org.cloudfoundry.client.lib.domain.CloudApplication.AppState.STOPPED); }
private boolean isStarted(CloudApplication app) { return app.getRunningInstances() == app.getInstances() && app.getInstances() != 0 && getRequestedState(app).equals(org.cloudfoundry.client.lib.domain.CloudApplication.AppState.STARTED); }
@Override public InstancesInfo getApplicationInstances(CloudApplication app) { if (app.getState().equals(CloudApplication.AppState.STARTED)) { return doGetApplicationInstances(app.getMeta().getGuid()); } return null; }
private boolean isApplicationReady(CloudApplication application) { /* * RestTemplate restTemplate = new RestTemplate(); String response = * restTemplate.getForObject(application.getUris().get(0), * String.class); if * (response.contains("B29 ROUTER: 404 - FILE NOT FOUND")) { return * false; } */ return AppState.STARTED.equals(application.getState()); }
@Override public InstancesInfo getApplicationInstances(CloudApplication app) { if (app.getState() .equals(CloudApplication.AppState.STARTED)) { return doGetApplicationInstances(app.getMeta() .getGuid()); } return null; }