Search in sources :

Example 1 with ChangePrimaryGatewayService

use of com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayService in project cloudbreak by hortonworks.

the class ChangePrimaryGatewayActions method orchestrationAction.

@Bean(name = "CHANGE_PRIMARY_GATEWAY_METADATA_STATE")
public Action<?, ?> orchestrationAction() {
    return new AbstractChangePrimaryGatewayAction<>(ChangePrimaryGatewaySelectionSuccess.class) {

        @Inject
        private ChangePrimaryGatewayService changePrimaryGatewayService;

        @Override
        protected void doExecute(ChangePrimaryGatewayContext context, ChangePrimaryGatewaySelectionSuccess payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Changing the primary gateway metadata");
            try {
                changePrimaryGatewayService.changePrimaryGatewayMetadata(stack, payload.getFormerPrimaryGatewayInstanceId(), payload.getNewPrimaryGatewayInstanceId());
                sendEvent(context, CHANGE_PRIMARY_GATEWAY_METADATA_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
            } catch (Exception e) {
                LOGGER.error("Failed to update the primary gateway metadata", e);
                sendEvent(context, CHANGE_PRIMARY_GATEWAY_METADATA_FAILED_EVENT.selector(), new ChangePrimaryGatewayFailureEvent(stack.getId(), "Updating metadata", Set.of(), Map.of(), e));
            }
        }
    };
}
Also used : ChangePrimaryGatewayService(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayService) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) ChangePrimaryGatewayFailureEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayFailureEvent) ChangePrimaryGatewaySelectionSuccess(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.selection.ChangePrimaryGatewaySelectionSuccess) ChangePrimaryGatewayContext(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayContext) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)1 ChangePrimaryGatewayContext (com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayContext)1 ChangePrimaryGatewayService (com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayService)1 ChangePrimaryGatewayFailureEvent (com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayFailureEvent)1 ChangePrimaryGatewaySelectionSuccess (com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.selection.ChangePrimaryGatewaySelectionSuccess)1 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1