Search in sources :

Example 1 with EnvDeleteFailedEvent

use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.

the class IdBrokerMappingsDeleteHandlerTest method verifyEnvDeleteFailedEvent.

private void verifyEnvDeleteFailedEvent(Exception exceptionExpected) {
    BaseNamedFlowEvent event = eventArgumentCaptor.getValue();
    assertThat(event).isInstanceOf(EnvDeleteFailedEvent.class);
    EnvDeleteFailedEvent envDeleteFailedEvent = (EnvDeleteFailedEvent) event;
    assertThat(envDeleteFailedEvent.getResourceName()).isEqualTo(ENVIRONMENT_NAME);
    assertThat(envDeleteFailedEvent.getResourceCrn()).isEqualTo(ENVIRONMENT_CRN);
    assertThat(envDeleteFailedEvent.getResourceId()).isEqualTo(ENVIRONMENT_ID);
    assertThat(envDeleteFailedEvent.selector()).isEqualTo(FAILED_ENV_DELETE_EVENT.selector());
    assertThat(envDeleteFailedEvent.getException()).isSameAs(exceptionExpected);
    assertThat(headersArgumentCaptor.getValue()).isSameAs(headers);
}
Also used : BaseNamedFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent) EnvDeleteFailedEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent)

Example 2 with EnvDeleteFailedEvent

use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.

the class S3GuardTableDeleteHandlerTest method verifyEnvDeleteFailedEvent.

private void verifyEnvDeleteFailedEvent(Exception exceptionExpected) {
    BaseNamedFlowEvent event = eventArgumentCaptor.getValue();
    assertThat(event).isInstanceOf(EnvDeleteFailedEvent.class);
    EnvDeleteFailedEvent envDeleteFailedEvent = (EnvDeleteFailedEvent) event;
    assertThat(envDeleteFailedEvent.getResourceName()).isEqualTo(ENVIRONMENT_NAME);
    assertThat(envDeleteFailedEvent.getResourceCrn()).isEqualTo(ENVIRONMENT_CRN);
    assertThat(envDeleteFailedEvent.getResourceId()).isEqualTo(ENVIRONMENT_ID);
    assertThat(envDeleteFailedEvent.selector()).isEqualTo(FAILED_ENV_DELETE_EVENT.selector());
    assertThat(envDeleteFailedEvent.getException()).isSameAs(exceptionExpected);
    assertThat(headersArgumentCaptor.getValue()).isSameAs(headers);
}
Also used : BaseNamedFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent) EnvDeleteFailedEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent)

Example 3 with EnvDeleteFailedEvent

use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.

the class FreeIpaDeletionHandler method accept.

@Override
public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) {
    EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData();
    EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto();
    Environment environment = environmentService.findEnvironmentById(environmentDto.getId()).orElse(null);
    try {
        if (shouldRemoveFreeIpa(environment)) {
            if (Objects.nonNull(environment.getParentEnvironment())) {
                detachChildEnvironmentFromFreeIpa(environment);
            } else {
                deleteFreeIpa(environment, environmentDeletionDto.isForceDelete());
            }
        }
        eventSender().sendEvent(getNextStepObject(environmentDeletionDto), environmentDtoEvent.getHeaders());
    } catch (Exception e) {
        EnvDeleteFailedEvent failedEvent = EnvDeleteFailedEvent.builder().withEnvironmentID(environmentDto.getId()).withException(e).withResourceCrn(environmentDto.getResourceCrn()).withResourceName(environmentDto.getName()).build();
        eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
    }
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Environment(com.sequenceiq.environment.environment.domain.Environment) EnvDeleteFailedEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) NotFoundException(javax.ws.rs.NotFoundException) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)

Example 4 with EnvDeleteFailedEvent

use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.

the class HandlerExceptionProcessor method handle.

public void handle(HandlerFailureConjoiner conjoiner, Logger loggerFromCaller, EventSender eventSender, String selector) {
    if (conjoiner.getEnvironmentDeletionDto().isForceDelete()) {
        loggerFromCaller.warn("The {} was not successful but the environment deletion was requested as force delete so " + "continue the deletion flow", selector);
        eventSender.sendEvent(conjoiner.getEnvDeleteEvent(), conjoiner.getEnvironmentDtoEvent().getHeaders());
    } else {
        EnvDeleteFailedEvent failedEvent = EnvDeleteFailedEvent.builder().withEnvironmentID(conjoiner.getEnvironmentDto().getId()).withException(conjoiner.getException()).withResourceCrn(conjoiner.getEnvironmentDto().getResourceCrn()).withResourceName(conjoiner.getEnvironmentDto().getName()).build();
        eventSender.sendEvent(failedEvent, conjoiner.getEnvironmentDtoEvent().getHeaders());
    }
}
Also used : EnvDeleteFailedEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent)

Example 5 with EnvDeleteFailedEvent

use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.

the class PublicKeyDeleteHandlerTest method verifyEnvDeleteFailedEvent.

private void verifyEnvDeleteFailedEvent(Exception exceptionExpected) {
    BaseNamedFlowEvent event = baseNamedFlowEvent.getValue();
    assertThat(event).isInstanceOf(EnvDeleteFailedEvent.class);
    EnvDeleteFailedEvent envDeleteFailedEvent = (EnvDeleteFailedEvent) event;
    assertThat(envDeleteFailedEvent.getResourceName()).isEqualTo(ENVIRONMENT_NAME);
    assertThat(envDeleteFailedEvent.getResourceCrn()).isEqualTo(ENVIRONMENT_CRN);
    assertThat(envDeleteFailedEvent.getResourceId()).isEqualTo(ENVIRONMENT_ID);
    assertThat(envDeleteFailedEvent.selector()).isEqualTo(FAILED_ENV_DELETE_EVENT.selector());
    assertThat(envDeleteFailedEvent.getException()).isSameAs(exceptionExpected);
    assertThat(headersArgumentCaptor.getValue()).isSameAs(headers);
}
Also used : BaseNamedFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent) EnvDeleteFailedEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent)

Aggregations

EnvDeleteFailedEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent)5 BaseNamedFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent)3 Environment (com.sequenceiq.environment.environment.domain.Environment)1 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)1 NotFoundException (javax.ws.rs.NotFoundException)1