use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class SdxDiagnosticsCollectionHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxDiagnosticsWaitRequest> event) {
SdxDiagnosticsWaitRequest request = event.getData();
Long sdxId = request.getResourceId();
String userId = request.getUserId();
Map<String, Object> properties = request.getProperties();
Selectable response;
try {
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
diagnosticsFlowService.waitForDiagnosticsCollection(sdxId, pollingConfig, request.getFlowIdentifier());
response = new SdxDiagnosticsSuccessEvent(sdxId, userId, properties);
LOGGER.debug("SDX diagnostics collection event finished");
} catch (UserBreakException userBreakException) {
LOGGER.error("Polling exited before timeout for SDX (diagnostic collection): {}. Cause: ", sdxId, userBreakException);
response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Poller stopped for SDX (diagnostic collection): {}", sdxId, pollerStoppedException);
response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, new PollerStoppedException("Datalake diagnostic collection timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Polling failed for stack (diagnostic collection): {}", sdxId, exception);
response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in diagnostic collection wait phase", anotherException);
response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, anotherException);
}
return response;
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class DatalakeChangeImageWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<DatalakeChangeImageWaitRequest> event) {
DatalakeChangeImageWaitRequest request = event.getData();
Long sdxId = request.getResourceId();
String userId = request.getUserId();
Selectable response;
try {
LOGGER.info("Start polling change image process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "Change image");
String imageId = upgradeService.getImageId(sdxId);
String expectedImageId = request.getUpgradeOption().getUpgrade().getImageId();
if (Objects.equals(imageId, expectedImageId)) {
LOGGER.info("Image changed in cloudbreak side for SDX {}, actual image: {}", sdxId, imageId);
response = new DatalakeVmReplaceEvent(sdxId, userId);
} else {
String message = String.format("Image not changed in cloudbreak side, expected image: %s, actual image: %s", expectedImageId, imageId);
LOGGER.info(message);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, new IllegalStateException(message));
}
} catch (UserBreakException userBreakException) {
LOGGER.error("Change image polling exited before timeout. Cause: ", userBreakException);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Change image poller stopped for cluster: {}", sdxId);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("Change image poller timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Change image polling failed for cluster: {}", sdxId);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
}
return response;
}
use of com.dyngr.exception.PollerException 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.PollerException 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.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class StackDeletionHandlerTest method acceptTestPollerStackOtherError.
@Test
void acceptTestPollerStackOtherError() {
long id = 2L;
StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new PollerException("stack deletion error")).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());
}
Aggregations