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());
}
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());
}
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());
}
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());
}
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;
}
Aggregations