use of com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.selection.ChangePrimaryGatewaySelectionSuccess 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));
}
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.selection.ChangePrimaryGatewaySelectionSuccess in project cloudbreak by hortonworks.
the class SelectionHandler method accept.
@Override
public void accept(Event<ChangePrimaryGatewaySelectionRequest> changePrimaryGatewaySelectionRequestEvent) {
ChangePrimaryGatewaySelectionRequest request = changePrimaryGatewaySelectionRequestEvent.getData();
Selectable result;
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
Optional<String> formerPrimaryGatewayInstanceId = changePrimaryGatewayService.getPrimaryGatewayInstanceId(stack);
String newPrimaryGatewayInstanceId = changePrimaryGatewayService.selectNewPrimaryGatewayInstanceId(stack, request.getRepairInstanceIds());
result = new ChangePrimaryGatewaySelectionSuccess(request.getResourceId(), formerPrimaryGatewayInstanceId, newPrimaryGatewayInstanceId);
} catch (Exception e) {
LOGGER.error("Failed to select the new primary gateway", e);
result = new ChangePrimaryGatewayFailureEvent(request.getResourceId(), "Selecting primary gateway", Set.of(), Map.of(), e);
}
eventBus.notify(result.selector(), new Event<>(changePrimaryGatewaySelectionRequestEvent.getHeaders(), result));
}
Aggregations