use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class StartExternalDatabaseHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<StartExternalDatabaseRequest> event) {
LOGGER.debug("In StartExternalDatabaseHandler.doAccept");
StartExternalDatabaseRequest request = event.getData();
Stack stack = stackService.getById(request.getResourceId());
DatabaseAvailabilityType externalDatabase = ObjectUtils.defaultIfNull(stack.getExternalDatabaseCreationType(), DatabaseAvailabilityType.NONE);
LOGGER.debug("External database: {} for stack {}", externalDatabase.name(), stack.getName());
LOGGER.debug("Getting environment CRN for stack {}", stack.getName());
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
Selectable result;
try {
if (StackType.WORKLOAD != stack.getType()) {
LOGGER.debug("External database start in Cloudbreak service is required for WORKLOAD stacks only.");
result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
} else if (externalDatabase.isEmbedded()) {
LOGGER.info("External database for stack {} is not requested. Start is not possible.", stack.getName());
result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
} else if (!externalDatabaseConfig.isExternalDatabasePauseSupportedFor(CloudPlatform.valueOf(environment.getCloudPlatform()))) {
LOGGER.debug("External database pause is not supported for '{}' cloud platform.", environment.getCloudPlatform());
result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
} else {
LOGGER.debug("Updating stack {} status from {} to {}", stack.getName(), stack.getStatus().name(), DetailedStackStatus.EXTERNAL_DATABASE_START_IN_PROGRESS.name());
stackUpdaterService.updateStatus(stack.getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_IN_PROGRESS, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_COMMANCED, "External database start in progress");
startService.startDatabase(stack.getCluster(), externalDatabase, environment);
LOGGER.debug("Updating stack {} status from {} to {}", stack.getName(), stack.getStatus().name(), DetailedStackStatus.EXTERNAL_DATABASE_START_FINISHED.name());
stackUpdaterService.updateStatus(stack.getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_FINISHED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_FINISHED, "External database start finished");
result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), stack.getCluster().getDatabaseServerCrn());
}
} catch (UserBreakException e) {
LOGGER.error("Database 'start' polling exited before timeout. Cause: ", e);
result = startFailedEvent(stack, e);
} catch (PollerStoppedException e) {
LOGGER.error(String.format("Database 'start' poller stopped for stack: %s", stack.getName()), e);
result = startFailedEvent(stack, e);
} catch (PollerException e) {
LOGGER.error(String.format("Database 'start' polling failed for stack: %s", stack.getName()), e);
result = startFailedEvent(stack, e);
}
return result;
}
use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class RdsDeletionHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<RdsDeletionWaitRequest> event) {
RdsDeletionWaitRequest rdsWaitRequest = event.getData();
Long sdxId = rdsWaitRequest.getResourceId();
String userId = rdsWaitRequest.getUserId();
Selectable response;
try {
sdxClusterRepository.findById(sdxId).ifPresent(sdxCluster -> {
if (sdxCluster.hasExternalDatabase() && StringUtils.isNotEmpty(sdxCluster.getDatabaseCrn())) {
LOGGER.debug("start polling database termination for sdx: {}", sdxId);
databaseService.terminate(sdxCluster, rdsWaitRequest.isForced());
} else {
LOGGER.debug("skipping deletion of database for sdx: {}", sdxId);
}
setDeletedStatus(sdxCluster);
});
response = new RdsDeletionSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
response = new SdxDeletionFailedEvent(sdxId, userId, userBreakException, rdsWaitRequest.isForced());
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
response = new SdxDeletionFailedEvent(sdxId, userId, new PollerStoppedException("Database deletion timed out after " + durationInMinutes + " minutes"), rdsWaitRequest.isForced());
} catch (PollerException exception) {
LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
response = new SdxDeletionFailedEvent(sdxId, userId, exception, rdsWaitRequest.isForced());
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx database deletion wait phase", anotherException);
response = new SdxDeletionFailedEvent(sdxId, userId, anotherException, rdsWaitRequest.isForced());
}
return response;
}
use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class StackDeletionHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<StackDeletionWaitRequest> event) {
StackDeletionWaitRequest stackDeletionWaitRequest = event.getData();
Long sdxId = stackDeletionWaitRequest.getResourceId();
String userId = stackDeletionWaitRequest.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack deletion process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
provisionerService.waitCloudbreakClusterDeletion(sdxId, pollingConfig);
response = new StackDeletionSuccessEvent(sdxId, userId, stackDeletionWaitRequest.isForced());
} catch (UserBreakException userBreakException) {
LOGGER.error("Deletion polling exited before timeout. Cause: ", userBreakException);
response = new SdxDeletionFailedEvent(sdxId, userId, userBreakException, stackDeletionWaitRequest.isForced());
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Deletion poller stopped for stack: {}", sdxId);
response = new SdxDeletionFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stack deletion timed out after " + durationInMinutes + " minutes"), stackDeletionWaitRequest.isForced());
} catch (PollerException exception) {
LOGGER.error("Deletion polling failed for stack: {}", sdxId);
response = new SdxDeletionFailedEvent(sdxId, userId, exception, stackDeletionWaitRequest.isForced());
}
return response;
}
use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class RdsWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<RdsWaitRequest> event) {
RdsWaitRequest rdsWaitRequest = event.getData();
Long sdxId = rdsWaitRequest.getResourceId();
String userId = rdsWaitRequest.getUserId();
try {
DetailedEnvironmentResponse env = environmentService.waitNetworkAndGetEnvironment(sdxId);
Optional<SdxCluster> sdxCluster = sdxClusterRepository.findById(sdxId);
if (sdxCluster.isPresent()) {
if (sdxCluster.get().hasExternalDatabase()) {
validForDatabaseCreation(sdxId, env);
LOGGER.debug("start polling database for sdx: {}", sdxId);
databaseService.create(sdxCluster.get(), env);
setRdsCreatedStatus(sdxCluster.get());
return new RdsWaitSuccessEvent(sdxId, userId);
} else {
LOGGER.debug("skipping creation of database for sdx: {}", sdxId);
return new RdsWaitSuccessEvent(sdxId, userId);
}
} else {
throw notFound("SDX cluster", sdxId).get();
}
} catch (UserBreakException userBreakException) {
LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
return new SdxCreateFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
return new SdxCreateFailedEvent(sdxId, userId, new PollerStoppedException("Database creation timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
return new SdxCreateFailedEvent(sdxId, userId, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx database creation wait phase", anotherException);
return new SdxCreateFailedEvent(sdxId, userId, anotherException);
}
}
use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.
the class DatalakeVmReplaceWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<DatalakeVmReplaceWaitRequest> event) {
DatalakeVmReplaceWaitRequest request = event.getData();
Long sdxId = request.getResourceId();
String userId = request.getUserId();
Selectable response;
try {
LOGGER.info("Start polling cluster VM replacement process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "VM replace");
response = new DatalakeUpgradeSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("VM replace polling exited before timeout. Cause: ", userBreakException);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("VM replace poller stopped for cluster: {}", sdxId);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("VM replace timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("VM replace polling failed for cluster: {}", sdxId);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened during VM replacement wait phase", anotherException);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, anotherException);
}
return response;
}
Aggregations