use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class DiagnosticsCollectionActions method diagnosticsCleanupAction.
@Bean(name = "DIAGNOSTICS_CLEANUP_STATE")
public Action<?, ?> diagnosticsCleanupAction() {
return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionEvent.class) {
@Override
protected void doExecute(CommonContext context, DiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into DIAGNOSTICS_CLEANUP_STATE. resourceCrn: '{}'", resourceCrn);
DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(payload.getResourceCrn()).withSelector(DiagnosticsCollectionHandlerSelectors.CLEANUP_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class CreateBindUserActions method createBindUserFinishedAction.
@Bean("CREATE_BIND_USER_FINISHED_STATE")
public Action<?, ?> createBindUserFinishedAction() {
return new AbstractBindUserCreateAction<>(CreateBindUserEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(CommonContext context, CreateBindUserEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Bind user creation successfully finished with payload: {}", payload);
SuccessDetails successDetails = new SuccessDetails(payload.getEnvironmentCrn());
successDetails.getAdditionalDetails().put("suffix", List.of(payload.getSuffix()));
operationService.completeOperation(payload.getAccountId(), payload.getOperationId(), Set.of(successDetails), Set.of());
LOGGER.debug("Finalizing user creation finished");
sendEvent(context, CreateBindUserFlowEvent.CREATE_BIND_USER_FINISHED_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class CreateBindUserActions method createLdapBindUserAction.
@Bean("CREATE_LDAP_BIND_USER_STATE")
public Action<?, ?> createLdapBindUserAction() {
return new AbstractBindUserCreateAction<>(CreateBindUserEvent.class) {
@Override
protected void doExecute(CommonContext context, CreateBindUserEvent payload, Map<Object, Object> variables) {
LOGGER.info("Sending request to create LDAP bind user for {}", payload.getSuffix());
sendEvent(context, new CreateLdapBindUserEvent(payload));
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class CreateBindUserActions method createKerberosBindUserAction.
@Bean("CREATE_KERBEROS_BIND_USER_STATE")
public Action<?, ?> createKerberosBindUserAction() {
return new AbstractBindUserCreateAction<>(CreateBindUserEvent.class) {
@Override
protected void doExecute(CommonContext context, CreateBindUserEvent payload, Map<Object, Object> variables) {
LOGGER.info("Sending request to create Kerberos bind user for {}", payload.getSuffix());
sendEvent(context, new CreateKerberosBindUserEvent(payload));
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvironmentStatusUpdateServiceTest method testUpdateEnvironmentStatusAndNotify.
@Test
public void testUpdateEnvironmentStatusAndNotify() {
CommonContext commonContext = new CommonContext(new FlowParameters("flowId", "userCrn", null));
EnvironmentDto environmentDto = EnvironmentDto.builder().withId(1L).withEnvironmentStatus(EnvironmentStatus.STOP_DATAHUB_FAILED).build();
Environment environment = new Environment();
when(environmentService.findEnvironmentById(environmentDto.getResourceId())).thenReturn(Optional.of(environment));
when(environmentService.save(environment)).thenReturn(environment);
when(environmentService.getEnvironmentDto(environment)).thenReturn(environmentDto);
EnvironmentDto actual = underTest.updateEnvironmentStatusAndNotify(commonContext, environmentDto, EnvironmentStatus.STOP_DATAHUB_FAILED, ResourceEvent.ENVIRONMENT_VALIDATION_FAILED, EnvStartState.ENV_START_FINISHED_STATE);
Assertions.assertEquals(EnvironmentStatus.STOP_DATAHUB_FAILED, actual.getStatus());
verify(eventSenderService).sendEventAndNotification(environmentDto, "userCrn", ResourceEvent.ENVIRONMENT_VALIDATION_FAILED);
}
Aggregations