@Override public StepPhase executeAsyncStep(ExecutionWrapper execution) { CloudApplication app = getAppToRestart(execution.getContext()); try { restartApp(execution, app); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); onError(format(Messages.ERROR_STARTING_APP_1, app.getName()), e); throw e; } return StepPhase.POLL; }
@Override public String getMessage() { return decorateExceptionMessage(super.getMessage()); }
@Override public StepPhase executeAsyncStep(ExecutionWrapper execution) { CloudApplication app = getAppToRestart(execution.getContext()); try { restartApp(execution, app); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); onError(format(Messages.ERROR_STARTING_APP_1, app.getName()), e); throw e; } return StepPhase.POLL; }
public <T> T executeServiceOperation(CloudServiceExtended service, Supplier<T> serviceOperation, StepLogger stepLogger) { try { return serviceOperation.get(); } catch (CloudOperationException e) { if (!service.isOptional()) { if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { throw new CloudServiceBrokerException(e); } throw new CloudControllerException(e); } stepLogger.warn(e, Messages.COULD_NOT_EXECUTE_OPERATION_OVER_OPTIONAL_SERVICE, service.getName()); return null; } }
public <T> T executeServiceOperation(CloudServiceExtended service, Supplier<T> serviceOperation, StepLogger stepLogger) { try { return serviceOperation.get(); } catch (CloudOperationException e) { if (!service.isOptional()) { if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { throw new CloudServiceBrokerException(e); } throw new CloudControllerException(e); } stepLogger.warn(e, Messages.COULD_NOT_EXECUTE_OPERATION_OVER_OPTIONAL_SERVICE, service.getName()); return null; } }
private CloudOperationException evaluateCloudOperationException(CloudOperationException e, String serviceName) { if (e.getStatusCode() == HttpStatus.NOT_FOUND) { getStepLogger().warn(e, Messages.COULD_NOT_DELETE_SERVICE, serviceName); return null; } if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { return new CloudServiceBrokerException(e); } return new CloudControllerException(e); }
private CloudOperationException evaluateCloudOperationException(CloudOperationException e, String serviceName) { if (e.getStatusCode() == HttpStatus.NOT_FOUND) { getStepLogger().warn(e, Messages.COULD_NOT_DELETE_SERVICE, serviceName); return null; } if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { return new CloudServiceBrokerException(e); } return new CloudControllerException(e); }
private void processServiceCreationFailure(CloudServiceExtended service, CloudOperationException e) { if (!service.isOptional()) { if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { throw new CloudServiceBrokerException(e); } throw new CloudControllerException(e); } getStepLogger().warn(e, Messages.COULD_NOT_EXECUTE_OPERATION_OVER_OPTIONAL_SERVICE, service.getName()); }
private void processServiceCreationFailure(CloudServiceExtended service, CloudOperationException e) { if (!service.isOptional()) { if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { throw new CloudServiceBrokerException(e); } throw new CloudControllerException(e); } getStepLogger().warn(e, Messages.COULD_NOT_EXECUTE_OPERATION_OVER_OPTIONAL_SERVICE, service.getName()); }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { ModuleToDeploy moduleToDeploy = StepsUtil.getModuleToDeploy(execution.getContext()); try { List<CloudApplicationExtended> appsToDeploy = StepsUtil.getAppsToDeploy(execution.getContext()); CloudApplicationExtended appToDeploy = appsToDeploy.stream() .filter(app -> app.getModuleName() .equals(moduleToDeploy.getName())) .findFirst() .get(); StepsUtil.setApp(execution.getContext(), appToDeploy); return StepPhase.DONE; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_SETTING_APP, moduleToDeploy.getName()); throw e; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_SETTING_APP, moduleToDeploy.getName()); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { ModuleToDeploy moduleToDeploy = StepsUtil.getModuleToDeploy(execution.getContext()); try { List<CloudApplicationExtended> appsToDeploy = StepsUtil.getAppsToDeploy(execution.getContext()); CloudApplicationExtended appToDeploy = appsToDeploy.stream() .filter(app -> app.getModuleName() .equals(moduleToDeploy.getName())) .findFirst() .get(); StepsUtil.setApp(execution.getContext(), appToDeploy); return StepPhase.DONE; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_SETTING_APP, moduleToDeploy.getName()); throw e; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_SETTING_APP, moduleToDeploy.getName()); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper context) { CloudApplication app = StepsUtil.getApp(context.getContext()); try { return attemptToExecuteStep(context); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_DETERMINING_ACTIONS_TO_EXECUTE_ON_APP, app.getName()); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_DETERMINING_ACTIONS_TO_EXECUTE_ON_APP, app.getName()); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper context) { CloudApplication app = StepsUtil.getApp(context.getContext()); try { return attemptToExecuteStep(context); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_DETERMINING_ACTIONS_TO_EXECUTE_ON_APP, app.getName()); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_DETERMINING_ACTIONS_TO_EXECUTE_ON_APP, app.getName()); throw e; } }
@Override protected StepPhase executeAsyncStep(ExecutionWrapper execution) { CloudApplication app = StepsUtil.getApp(execution.getContext()); try { ApplicationStager applicationStager = ApplicationStagerFactory.createApplicationStager(configuration.getPlatformType()); return applicationStager.stageApp(execution.getContext(), execution.getControllerClient(), app, getStepLogger()); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_STAGING_APP_1, app.getName()); throw e; } }
@Override protected StepPhase executeAsyncStep(ExecutionWrapper execution) { CloudApplication app = StepsUtil.getApp(execution.getContext()); try { ApplicationStager applicationStager = ApplicationStagerFactory.createApplicationStager(configuration.getPlatformType()); return applicationStager.stageApp(execution.getContext(), execution.getControllerClient(), app, getStepLogger()); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_STAGING_APP_1, app.getName()); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { getStepLogger().debug(Messages.DETECTING_COMPONENTS_TO_UNDEPLOY); try { String mtaId = StepsUtil.getRequiredStringParameter(execution.getContext(), Constants.PARAM_MTA_ID); StepsUtil.setMtaModules(execution.getContext(), getMtaModules(execution.getContext())); StepsUtil.setServiceBrokersToCreate(execution.getContext(), Collections.emptyList()); StepsUtil.setPublishedEntries(execution.getContext(), Collections.emptyList()); StepsUtil.setAppsToDeploy(execution.getContext(), Collections.emptyList()); StepsUtil.setServiceUrlsToRegister(execution.getContext(), Collections.emptyList()); StepsUtil.setSubscriptionsToCreate(execution.getContext(), Collections.emptyList()); conflictPreventerSupplier.apply(operationDao) .acquireLock(mtaId, StepsUtil.getSpaceId(execution.getContext()), execution.getContext() .getProcessInstanceId()); getStepLogger().debug(Messages.COMPONENTS_TO_UNDEPLOY_DETECTED); return StepPhase.DONE; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_DETECTING_COMPONENTS_TO_UNDEPLOY); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_DETECTING_COMPONENTS_TO_UNDEPLOY); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { CloudApplicationExtended app = StepsUtil.getApp(execution.getContext()); List<CloudTask> tasksToExecute = app.getTasks(); try { return attemptToPrepareExecutionOfTasks(execution, tasksToExecute); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_PREPARING_TO_EXECUTE_TASKS_ON_APP, app.getName()); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_PREPARING_TO_EXECUTE_TASKS_ON_APP, app.getName()); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { CloudApplicationExtended app = StepsUtil.getApp(execution.getContext()); List<CloudTask> tasksToExecute = app.getTasks(); try { return attemptToPrepareExecutionOfTasks(execution, tasksToExecute); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_PREPARING_TO_EXECUTE_TASKS_ON_APP, app.getName()); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_PREPARING_TO_EXECUTE_TASKS_ON_APP, app.getName()); throw e; } }
@Override public AsyncExecutionState execute(ExecutionWrapper execution) { CloudApplication app = getAppToPoll(execution.getContext()); CloudControllerClient client = execution.getControllerClient(); try { execution.getStepLogger() .debug(Messages.CHECKING_APP_STATUS, app.getName()); StartupStatus status = getStartupStatus(execution, client, app.getName()); ProcessLoggerProvider processLoggerProvider = execution.getStepLogger().getProcessLoggerProvider(); StepsUtil.saveAppLogs(execution.getContext(), client, recentLogsRetriever, app, LOGGER, processLoggerProvider); return checkStartupStatus(execution, app, status); } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); onError(execution, format(Messages.ERROR_STARTING_APP_1, app.getName()), e); throw e; } catch (SLException e) { onError(execution, format(Messages.ERROR_STARTING_APP_1, app.getName()), e); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { getStepLogger().debug(Messages.DETECTING_COMPONENTS_TO_UNDEPLOY); try { String mtaId = StepsUtil.getRequiredStringParameter(execution.getContext(), Constants.PARAM_MTA_ID); StepsUtil.setMtaModules(execution.getContext(), getMtaModules(execution.getContext())); StepsUtil.setServiceBrokersToCreate(execution.getContext(), Collections.emptyList()); StepsUtil.setPublishedEntries(execution.getContext(), Collections.emptyList()); StepsUtil.setAppsToDeploy(execution.getContext(), Collections.emptyList()); StepsUtil.setServiceUrlsToRegister(execution.getContext(), Collections.emptyList()); StepsUtil.setSubscriptionsToCreate(execution.getContext(), Collections.emptyList()); conflictPreventerSupplier.apply(operationDao) .acquireLock(mtaId, StepsUtil.getSpaceId(execution.getContext()), execution.getContext() .getProcessInstanceId()); getStepLogger().debug(Messages.COMPONENTS_TO_UNDEPLOY_DETECTED); return StepPhase.DONE; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_DETECTING_COMPONENTS_TO_UNDEPLOY); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_DETECTING_COMPONENTS_TO_UNDEPLOY); throw e; } }