use of com.dyngr.exception.UserBreakException 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.UserBreakException 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.UserBreakException 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.UserBreakException in project cloudbreak by hortonworks.
the class SdxUpgradeService method waitCloudbreakFlow.
public void waitCloudbreakFlow(Long id, PollingConfig pollingConfig, String pollingMessage) {
SdxCluster sdxCluster = sdxService.getById(id);
cloudbreakPoller.pollUpdateUntilAvailable(pollingMessage, sdxCluster, pollingConfig);
if (cloudbreakFlowResultProvider.isValidationFailed(sdxCluster)) {
throw new UserBreakException(new UpgradeValidationFailedException("Upgrade validation failed."));
}
}
use of com.dyngr.exception.UserBreakException 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());
}
Aggregations