use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class SdxDiagnosticsCollectionHandlerTest method testAcceptWithPollerException.
@Test
void testAcceptWithPollerException() {
Event<SdxDiagnosticsWaitRequest> event = initEvent();
PollerException exception = new PollerException();
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));
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class SdxWaitTaskService method waitFor.
/**
* Will start a wait task on an SDX cluster.
* For the frequency of checks and the total amount of time allowed for the task, please check {@linkplain PollingConfig} in the waitTask
*
* This wait service uses {@linkplain com.dyngr.Polling} as the underlying polling mechanism, meaning:
* - if the polling succeeds, the method returns
* - if there is a timeout, or the wait task wants to indicate a negative result, then an exception is thrown of type {@linkplain PollerException}
* - optionally you can set to stop on any encountered exceptions, check {@linkplain PollingConfig.stopPollingIfExceptionOccured} for that
*
* @param sdxWaitTask A wait task with polling parameters as well as the algorithm for polling itself
* @param <V> The type of parameter returned by the underlying poller package's AttemptMaker interface, hidden from outside world
* @throws SdxWaitException is thrown if a {@linkplain PollerException} is reached
*/
public <V> void waitFor(SdxWaitTask<V> sdxWaitTask) {
try {
LOGGER.debug("Starting an sdx wait task: {}", sdxWaitTask);
PollingConfig pollingConfig = sdxWaitTask.getPollingConfig();
Polling.waitPeriodly(pollingConfig.getSleepTime(), pollingConfig.getSleepTimeUnit()).stopIfException(pollingConfig.getStopPollingIfExceptionOccurred()).stopAfterDelay(pollingConfig.getDuration(), pollingConfig.getDurationTimeUnit()).run(sdxWaitTask);
} catch (PollerException e) {
LOGGER.warn("Polling of {} reached an exception: ", sdxWaitTask.getPollingMessage(), e);
throw new SdxWaitException(String.format("Polling of %s reached an error state.", sdxWaitTask.getPollingMessage()), e);
}
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class RdsStartHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<RdsWaitingToStartRequest> event) {
RdsWaitingToStartRequest rdsWaitRequest = event.getData();
Long sdxId = rdsWaitRequest.getResourceId();
String userId = rdsWaitRequest.getUserId();
Selectable response;
try {
sdxClusterRepository.findById(sdxId).ifPresent(sdxCluster -> {
if (databasePauseSupportService.isDatabasePauseSupported(sdxCluster)) {
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_START_IN_PROGRESS, "External database start in progress", sdxCluster);
LOGGER.debug("start polling database start for sdx: {}", sdxId);
databaseService.start(sdxCluster);
} else {
LOGGER.debug("skipping start of database for sdx: {}", sdxId);
}
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_STARTED, "External database started", sdxCluster);
});
response = new RdsStartSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
response = new SdxStartFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
response = new SdxStartFailedEvent(sdxId, userId, new PollerStoppedException("Database start timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
response = new SdxStartFailedEvent(sdxId, userId, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx database start wait phase", anotherException);
response = new SdxStartFailedEvent(sdxId, userId, anotherException);
}
return response;
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class SdxStartWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxStartWaitRequest> event) {
SdxStartWaitRequest waitRequest = event.getData();
Long sdxId = waitRequest.getResourceId();
String userId = waitRequest.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack start process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
sdxStartService.waitCloudbreakCluster(sdxId, pollingConfig);
response = new SdxStartSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Start polling exited before timeout. Cause: ", userBreakException);
response = new SdxStartFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Start poller stopped for stack: {}", sdxId);
response = new SdxStartFailedEvent(sdxId, userId, new PollerStoppedException("Datalake start timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Start polling failed for stack: {}", sdxId);
response = new SdxStartFailedEvent(sdxId, userId, exception);
}
return response;
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class UpgradeCcmStackHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<UpgradeCcmStackRequest> event) {
UpgradeCcmStackRequest request = event.getData();
SdxCluster sdxCluster = sdxService.getById(request.getResourceId());
Long sdxId = request.getResourceId();
String userId = request.getUserId();
Selectable response;
try {
LOGGER.debug("Initiating CCM upgrade and start polling for SDX: {}", sdxCluster.getName());
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
ccmUpgradeService.initAndWaitForStackUpgrade(sdxCluster, pollingConfig);
response = new UpgradeCcmSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Upgrade CCM poller exited before timeout. Cause: ", userBreakException);
response = new UpgradeCcmFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Upgrade CCM poller stopped for stack: {}", sdxId);
response = new UpgradeCcmFailedEvent(sdxId, userId, new PollerStoppedException("Upgrade CCM timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Upgrade CCM polling failed for stack: {}", sdxId);
response = new UpgradeCcmFailedEvent(sdxId, userId, exception);
}
return response;
}
Aggregations