use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class SdxRepairWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxRepairWaitRequest> event) {
SdxRepairWaitRequest sdxRepairWaitRequest = event.getData();
Long sdxId = sdxRepairWaitRequest.getResourceId();
String userId = sdxRepairWaitRequest.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack repair process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
repairService.waitCloudbreakClusterRepair(sdxId, pollingConfig);
response = new SdxRepairSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Repair polling exited before timeout. Cause: ", userBreakException);
response = new SdxRepairFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Repair poller stopped for stack: {}", sdxId);
response = new SdxRepairFailedEvent(sdxId, userId, new PollerStoppedException("Datalake repair timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Repair polling failed for stack: {}", sdxId);
response = new SdxRepairFailedEvent(sdxId, userId, exception);
}
return response;
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class RdsStopHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<RdsWaitingToStopRequest> event) {
RdsWaitingToStopRequest 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_STOP_IN_PROGRESS, "External database stop in progress", sdxCluster);
LOGGER.debug("stop polling database stop for sdx: {}", sdxId);
databaseService.stop(sdxCluster);
} else {
LOGGER.debug("skipping stop of database for sdx: {}", sdxId);
}
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_STOPPED, "External database stopped", sdxCluster);
});
response = new RdsStopSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
response = new SdxStopFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
response = new SdxStopFailedEvent(sdxId, userId, new PollerStoppedException("Database stop timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
response = new SdxStopFailedEvent(sdxId, userId, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx database stop wait phase", anotherException);
response = new SdxStopFailedEvent(sdxId, userId, anotherException);
}
return response;
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class SdxStopWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxStopWaitRequest> event) {
SdxStopWaitRequest waitRequest = event.getData();
Long sdxId = waitRequest.getResourceId();
String userId = waitRequest.getUserId();
Selectable response;
try {
LOGGER.debug("Stop polling stack stopping process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
sdxStopService.waitCloudbreakCluster(sdxId, pollingConfig);
response = new SdxStopSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Stop polling exited before timeout. Cause: ", userBreakException);
response = new SdxStopFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Stop poller stopped for stack: {}", sdxId);
response = new SdxStopFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stop timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Stop polling failed for stack: {}", sdxId);
response = new SdxStopFailedEvent(sdxId, userId, exception);
}
return response;
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class StackCreationHandlerTest method acceptTestPollerStackOtherError.
@Test
void acceptTestPollerStackOtherError() {
long stackId = 2L;
StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
doThrow(new PollerException("stack error")).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(PollerException.class, ((SdxCreateFailedEvent) event.getData()).getException().getClass());
}
use of com.dyngr.exception.PollerException in project cloudbreak by hortonworks.
the class SdxCertRenewWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxCertRenewalWaitEvent> event) {
SdxEvent sdxEvent = event.getData();
Long sdxId = sdxEvent.getResourceId();
String userId = sdxEvent.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack cert renewal process.");
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
certRenewalService.waitForCloudbreakClusterCertRenewal(sdxId, pollingConfig);
response = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_FINISHED_EVENT.event(), sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Cert renewal polling exited before timeout. Cause: ", userBreakException);
response = new SdxCertRenewalFailedEvent(sdxId, userId, userBreakException.getMessage());
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Cert renewal poller stopped.");
response = new SdxCertRenewalFailedEvent(sdxId, userId, "Datalake cert renewal timed out after " + durationInMinutes + " minutes");
} catch (PollerException exception) {
LOGGER.error("Cert renewal polling failed. Cause: ", exception);
response = new SdxCertRenewalFailedEvent(sdxId, userId, exception.getMessage());
}
return response;
}
Aggregations