use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.restore.DatabaseRestoreFailedEvent in project cloudbreak by hortonworks.
the class DatabaseRestoreActions method databaseRestoreFailedAction.
@Bean(name = "DATABASE_RESTORE_FAILED_STATE")
public Action<?, ?> databaseRestoreFailedAction() {
return new AbstractBackupRestoreActions<>(DatabaseRestoreFailedEvent.class) {
@Override
protected BackupRestoreContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatabaseRestoreFailedEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return BackupRestoreContext.from(flowParameters, payload, null, null, true);
}
@Override
protected void doExecute(BackupRestoreContext context, DatabaseRestoreFailedEvent payload, Map<Object, Object> variables) {
backupRestoreStatusService.handleDatabaseRestoreFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
sendEvent(context, DATABASE_RESTORE_FAIL_HANDLED_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.restore.DatabaseRestoreFailedEvent in project cloudbreak by hortonworks.
the class DatabaseRestoreHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<DatabaseRestoreRequest> event) {
DatabaseRestoreRequest request = event.getData();
Selectable result;
Long stackId = request.getResourceId();
LOGGER.debug("Restoring database on stack {}, backup id {}", stackId, request.getBackupId());
try {
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
Cluster cluster = stack.getCluster();
InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, cluster.hasGateway());
Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
ExitCriteriaModel exitModel = ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, cluster.getId());
String rangerAdminGroup = rangerVirtualGroupService.getRangerVirtualGroup(stack);
SaltConfig saltConfig = saltConfigGenerator.createSaltConfig(request.getBackupLocation(), request.getBackupId(), rangerAdminGroup, true, stack);
hostOrchestrator.restoreDatabase(gatewayConfig, gatewayFQDN, stackUtil.collectReachableNodes(stack), saltConfig, exitModel);
result = new DatabaseRestoreSuccess(stackId);
} catch (Exception e) {
LOGGER.error("Database restore event failed", e);
result = new DatabaseRestoreFailedEvent(stackId, e, DetailedStackStatus.DATABASE_RESTORE_FAILED);
}
return result;
}
Aggregations