use of com.dyngr.exception.PollerStoppedException in project cloudbreak by hortonworks.
the class DatalakeUpgradeWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<DatalakeUpgradeWaitRequest> event) {
DatalakeUpgradeWaitRequest request = event.getData();
Long sdxId = request.getResourceId();
String userId = request.getUserId();
Selectable response;
try {
LOGGER.info("Start polling cluster upgrade process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "Stack Upgrade");
response = new DatalakeImageChangeEvent(sdxId, userId, request.getImageId());
} catch (UserBreakException userBreakException) {
LOGGER.error("Upgrade polling exited before timeout. Cause: ", userBreakException);
if (userBreakException.getCause() instanceof UpgradeValidationFailedException) {
response = new DatalakeUpgradeValidationFailedEvent(sdxId, userId);
} else {
response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
}
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Upgrade poller stopped for cluster: {}", sdxId);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("Datalake upgrade timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Upgrade polling failed for cluster: {}", sdxId);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
}
return response;
}
use of com.dyngr.exception.PollerStoppedException 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.dyngr.exception.PollerStoppedException in project cloudbreak by hortonworks.
the class StackCreationHandlerTest method acceptTestPollerStackTimeout.
@Test
void acceptTestPollerStackTimeout() {
long stackId = 2L;
StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new PollerStoppedException("stack timeout")).when(provisionerService).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
stackCreationHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("SdxCreateFailedEvent", eventNotified);
Assertions.assertEquals(SdxCreateFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(stackId, ((SdxCreateFailedEvent) event.getData()).getResourceId());
Assertions.assertEquals(PollerStoppedException.class, ((SdxCreateFailedEvent) event.getData()).getException().getClass());
}
use of com.dyngr.exception.PollerStoppedException in project cloudbreak by hortonworks.
the class StackDeletionHandlerTest method acceptTestPollerStackTimeout.
@Test
void acceptTestPollerStackTimeout() {
long id = 2L;
StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new PollerStoppedException("stack deletion timeout")).when(provisionerService).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
stackDeletionHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("SdxDeletionFailedEvent", eventNotified);
Assertions.assertEquals(SdxDeletionFailedEvent.class, event.getData().getClass());
Assertions.assertEquals(id, ((SdxDeletionFailedEvent) event.getData()).getResourceId());
}
use of com.dyngr.exception.PollerStoppedException in project cloudbreak by hortonworks.
the class SdxDiagnosticsCollectionHandlerTest method testAcceptWithPollerStoppedException.
@Test
void testAcceptWithPollerStoppedException() {
Event<SdxDiagnosticsWaitRequest> event = initEvent();
PollerStoppedException exception = new PollerStoppedException();
doThrow(exception).when(diagnosticsFlowService).waitForDiagnosticsCollection(anyLong(), any(), any());
underTest.accept(event);
SdxDiagnosticsFailedEvent sdxDiagnosticsFailedEvent = new SdxDiagnosticsFailedEvent(1L, "userId", Map.of(), exception);
Mockito.verify(eventBus, Mockito.times(1)).notify(eq(sdxDiagnosticsFailedEvent.selector()), any(Event.class));
}
Aggregations