use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters in project ovirt-engine by oVirt.
the class CreateGlusterVolumeSnapshotCommand method pauseAndCreateSnapshotForGeoRepSessions.
private boolean pauseAndCreateSnapshotForGeoRepSessions() {
if (georepSessions != null && georepSessions.size() > 0) {
for (GlusterGeoRepSession session : georepSessions) {
final GlusterVolumeEntity slaveVolume = glusterVolumeDao.getById(session.getSlaveVolumeId());
if (slaveVolume == null) {
// Continue to other geo-rep sessions and pause them for snapshot purpose
continue;
}
VDS slaveUpServer = glusterUtil.getRandomUpServer(slaveVolume.getClusterId());
if (slaveUpServer == null) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, "No up server found in slave cluster of geo-rep session");
setSucceeded(false);
return false;
}
// Pause the geo-rep session if required
if (!(session.getStatus() == GeoRepSessionStatus.CREATED || session.getStatus() == GeoRepSessionStatus.PAUSED || session.getStatus() == GeoRepSessionStatus.STOPPED)) {
ActionReturnValue sessionPauseRetVal = null;
try (EngineLock lock = acquireEngineLock(slaveVolume.getId(), LockingGroup.GLUSTER_SNAPSHOT)) {
sessionPauseRetVal = runInternalAction(ActionType.PauseGlusterVolumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(), session.getId()));
}
if (sessionPauseRetVal != null && !sessionPauseRetVal.getSucceeded()) {
handleVdsErrors(AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE_FAILED, sessionPauseRetVal.getExecuteFailedMessages());
setSucceeded(false);
return false;
}
session.setStatus(GeoRepSessionStatus.PAUSED);
enginePausedSessions.add(session);
}
// Create snapshot for slave volume
VDSReturnValue snapCreationRetVal = runVdsCommand(VDSCommandType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotVDSParameters(slaveUpServer.getId(), session.getSlaveVolumeName(), snapshot.getSnapshotName(), snapshot.getDescription(), force));
if (!snapCreationRetVal.getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, snapCreationRetVal.getVdsError().getMessage());
setSucceeded(false);
return false;
} else {
// Persist the snapshot details
GlusterVolumeSnapshotEntity slaveVolumeSnapshot = (GlusterVolumeSnapshotEntity) snapCreationRetVal.getReturnValue();
slaveVolumeSnapshot.setClusterId(slaveVolume.getClusterId());
slaveVolumeSnapshot.setVolumeId(slaveVolume.getId());
slaveVolumeSnapshot.setDescription(snapshot.getDescription());
slaveVolumeSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
glusterVolumeSnapshotDao.save(slaveVolumeSnapshot);
// check if the snapshot soft limit reached now for the volume and alert
glusterUtil.alertVolumeSnapshotLimitsReached(slaveVolume);
}
}
}
return true;
}
use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters in project ovirt-engine by oVirt.
the class GlusterStorageSyncCommand method performNextOperation.
@Override
public boolean performNextOperation(int completedChildCount) {
if (getParameters().getNextStep() == null) {
return false;
}
switch(getParameters().getNextStep()) {
case GEO_REP:
GlusterVolumeGeoRepSessionParameters parameters = new GlusterVolumeGeoRepSessionParameters(getSession().getMasterVolumeId(), getSession().getId());
parameters.setEndProcedure(EndProcedure.COMMAND_MANAGED);
parameters.setParentCommand(getActionType());
parameters.setParentParameters(getParameters());
getParameters().setNextStep(DRStep.REMOVE_TMP_SNAPSHOTS);
runInternalActionWithTasksContext(ActionType.GlusterStorageGeoRepSyncInternal, parameters);
persistCommandIfNeeded();
break;
case REMOVE_TMP_SNAPSHOTS:
removeDRSnapshots();
getParameters().setNextStep(null);
persistCommandIfNeeded();
break;
}
return true;
}
use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters in project ovirt-engine by oVirt.
the class GlusterStorageGeoRepSyncCallback method evaluateGeoRepSessionStatus.
private void evaluateGeoRepSessionStatus(CommandBase<?> rootCommand) {
GlusterVolumeGeoRepSessionParameters parameters = (GlusterVolumeGeoRepSessionParameters) rootCommand.getParameters();
GlusterGeoRepSession session = geoRepDao.getById(parameters.getGeoRepSessionId());
if (session == null) {
rootCommand.setCommandStatus(CommandStatus.FAILED);
return;
}
session.setSessionDetails((ArrayList<GlusterGeoRepSessionDetails>) geoRepDao.getGeoRepSessionDetails(session.getId()));
switch(session.getStatus()) {
case ACTIVE:
// check if checkpoint is completed
if (session.isCheckPointCompleted()) {
// stop the geo-rep session
stopGeoRepSessionCommand(rootCommand, session);
rootCommand.setCommandStatus(CommandStatus.SUCCEEDED);
}
break;
case FAULTY:
rootCommand.setCommandStatus(CommandStatus.FAILED);
default:
break;
}
}
use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters in project ovirt-engine by oVirt.
the class GlusterStorageGeoRepSyncInternalCommand method executeCommand.
@Override
protected void executeCommand() {
if (getSession().getStatus() != GeoRepSessionStatus.ACTIVE) {
// Start geo-replication
Future<ActionReturnValue> geoRepCmd = commandCoordinatorUtil.executeAsyncCommand(ActionType.StartGlusterVolumeGeoRep, new GlusterVolumeGeoRepSessionParameters(getSession().getMasterVolumeId(), getSession().getId()), cloneContext());
ActionReturnValue result;
try {
result = geoRepCmd.get();
if (!result.getSucceeded()) {
propagateFailure(result);
return;
}
} catch (InterruptedException | ExecutionException e) {
log.error("Exception", e);
return;
}
}
// checkpoint the replication session
GlusterVolumeGeoRepSessionConfigParameters configParams = new GlusterVolumeGeoRepSessionConfigParameters(getSession().getMasterVolumeId(), getSession().getId(), GlusterConstants.GEOREP_CHECKPOINT_OPTION, GlusterConstants.GEOREP_CHECKPOINT_VALUE);
ActionReturnValue result = runInternalAction(ActionType.SetGeoRepConfig, configParams);
if (!result.getSucceeded()) {
propagateFailure(result);
return;
}
setSucceeded(true);
}
use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters in project ovirt-engine by oVirt.
the class VolumeGeoRepListModel method onCreateSession.
private void onCreateSession() {
final GlusterVolumeGeoRepCreateModel createModel = (GlusterVolumeGeoRepCreateModel) getWindow();
if (!createModel.validate()) {
return;
}
createModel.startProgress();
final Guid masterVolumeId = getEntity().getId();
final String remoteVolumeName = createModel.getSlaveVolumes().getSelectedItem().getName();
final String remoteHostName = createModel.getSlaveHosts().getSelectedItem().getFirst();
String remoteUserName = createModel.getSlaveUserName().getEntity();
String remoteUserGroup = createModel.getSlaveUserGroupName().getEntity();
final Guid remoteHostId = createModel.getSlaveHosts().getSelectedItem().getSecond();
Frontend.getInstance().runAction(ActionType.CreateGlusterVolumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(masterVolumeId, remoteVolumeName, remoteHostId, remoteUserName, remoteUserGroup, !createModel.getShowEligibleVolumes().getEntity()), result -> {
createModel.stopProgress();
if (result.getReturnValue().getSucceeded()) {
closeWindow();
if (createModel.getStartSession().getEntity()) {
// $NON-NLS-1$//$NON-NLS-2$
initializeGeoRepActionConfirmation(constants.geoReplicationStartTitle(), HelpTag.volume_geo_rep_start_confirmation, "volume_geo_rep_start_confirmation", constants.geoRepForceHelp(), messages.geoRepForceTitle(constants.startGeoRep()), "onStartGeoRepSession", getEntity().getName(), remoteVolumeName, remoteHostName, null);
final GlusterVolumeGeoRepActionConfirmationModel cModel = (GlusterVolumeGeoRepActionConfirmationModel) getWindow();
cModel.startProgress();
Frontend.getInstance().runAction(ActionType.StartGlusterVolumeGeoRep, new GlusterVolumeGeoRepSessionParameters(masterVolumeId, remoteVolumeName, remoteHostId), result1 -> {
cModel.stopProgress();
if (!result1.getReturnValue().getSucceeded()) {
cModel.setMessage(result1.getReturnValue().getFault().getMessage());
} else {
closeWindow();
}
}, VolumeGeoRepListModel.this, false);
}
}
}, this, true);
}
Aggregations