Search in sources :

Example 1 with SdxStopAllDatahubRequest

use of com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest in project cloudbreak by hortonworks.

the class SdxStopAllDatahubHandlerTest method testBadRequestException.

@Test
public void testBadRequestException() {
    BadRequestException badRequestException = new BadRequestException("");
    doThrow(badRequestException).when(sdxStopService).stopAllDatahub(anyLong());
    underTest.accept(new Event<>(new SdxStopAllDatahubRequest(1L, "USER_ID")));
    verify(eventBus).notify(anyString(), captor.capture());
    SdxStopFailedEvent sdxStopFailedEvent = captor.getValue().getData();
    assertEquals(SDX_ID, sdxStopFailedEvent.getResourceId());
    assertEquals(USER_ID, sdxStopFailedEvent.getUserId());
    assertEquals(badRequestException, sdxStopFailedEvent.getException());
}
Also used : SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) BadRequestException(javax.ws.rs.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 2 with SdxStopAllDatahubRequest

use of com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest in project cloudbreak by hortonworks.

the class SdxStopAllDatahubHandlerTest method testUserBreakException.

@Test
public void testUserBreakException() {
    UserBreakException userBreakException = new UserBreakException("");
    doThrow(userBreakException).when(sdxStopService).stopAllDatahub(anyLong());
    underTest.accept(new Event<>(new SdxStopAllDatahubRequest(1L, "USER_ID")));
    verify(eventBus).notify(anyString(), captor.capture());
    SdxStopFailedEvent sdxStopFailedEvent = captor.getValue().getData();
    assertEquals(SDX_ID, sdxStopFailedEvent.getResourceId());
    assertEquals(USER_ID, sdxStopFailedEvent.getUserId());
    assertEquals(userBreakException, sdxStopFailedEvent.getException());
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) Test(org.junit.jupiter.api.Test)

Example 3 with SdxStopAllDatahubRequest

use of com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest in project cloudbreak by hortonworks.

the class SdxStopAllDatahubHandlerTest method testPollerStoppedException.

@Test
public void testPollerStoppedException() {
    PollerStoppedException pollerStoppedException = new PollerStoppedException("");
    doThrow(pollerStoppedException).when(sdxStopService).stopAllDatahub(anyLong());
    underTest.accept(new Event<>(new SdxStopAllDatahubRequest(SDX_ID, USER_ID)));
    verify(eventBus).notify(anyString(), captor.capture());
    SdxStopFailedEvent sdxStopFailedEvent = captor.getValue().getData();
    assertEquals(SDX_ID, sdxStopFailedEvent.getResourceId());
    assertEquals(USER_ID, sdxStopFailedEvent.getUserId());
    assertEquals("Datalake stop timed out after 40 minutes", sdxStopFailedEvent.getException().getMessage());
}
Also used : SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Test(org.junit.jupiter.api.Test)

Example 4 with SdxStopAllDatahubRequest

use of com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest in project cloudbreak by hortonworks.

the class SdxStopAllDatahubHandlerTest method testPollerException.

@Test
public void testPollerException() {
    PollerException pollerException = new PollerException("");
    doThrow(pollerException).when(sdxStopService).stopAllDatahub(anyLong());
    underTest.accept(new Event<>(new SdxStopAllDatahubRequest(SDX_ID, USER_ID)));
    verify(eventBus).notify(anyString(), captor.capture());
    SdxStopFailedEvent sdxStopFailedEvent = captor.getValue().getData();
    assertEquals(SDX_ID, sdxStopFailedEvent.getResourceId());
    assertEquals(USER_ID, sdxStopFailedEvent.getUserId());
    assertEquals(pollerException, sdxStopFailedEvent.getException());
}
Also used : SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) PollerException(com.dyngr.exception.PollerException) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) Test(org.junit.jupiter.api.Test)

Example 5 with SdxStopAllDatahubRequest

use of com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest in project cloudbreak by hortonworks.

the class SdxStopAllDatahubHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxStopAllDatahubRequest> event) {
    SdxStopAllDatahubRequest stopAllDatahubRequest = event.getData();
    Long sdxId = stopAllDatahubRequest.getResourceId();
    String userId = stopAllDatahubRequest.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Polling is started for the operation of stopping all datahubs clusters for sdx with id: {}", sdxId);
        sdxStopService.stopAllDatahub(sdxId);
        response = new SdxEvent(SdxStopEvent.SDX_STOP_IN_PROGRESS_EVENT.event(), sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Polling exited before timeout. Cause ", userBreakException);
        response = new SdxStopFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Poller stopped for stack: " + sdxId, pollerStoppedException);
        response = new SdxStopFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stop timed out after " + DURATION_IN_MINUTES + " minutes", pollerStoppedException));
    } catch (PollerException exception) {
        LOGGER.error("Polling failed for stack: {}", sdxId);
        response = new SdxStopFailedEvent(sdxId, userId, exception);
    } catch (BadRequestException badRequest) {
        LOGGER.error("Datahub stop failed.", badRequest);
        response = new SdxStopFailedEvent(sdxId, userId, badRequest);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) BadRequestException(javax.ws.rs.BadRequestException) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Aggregations

SdxStopAllDatahubRequest (com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest)5 SdxStopFailedEvent (com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent)5 Test (org.junit.jupiter.api.Test)4 PollerException (com.dyngr.exception.PollerException)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)2 UserBreakException (com.dyngr.exception.UserBreakException)2 BadRequestException (javax.ws.rs.BadRequestException)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)1