Search in sources :

Example 1 with GlusterVolumeGeoRepSessionParameters

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;
}
Also used : CreateGlusterVolumeSnapshotVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 2 with GlusterVolumeGeoRepSessionParameters

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;
}
Also used : GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters)

Example 3 with GlusterVolumeGeoRepSessionParameters

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;
    }
}
Also used : GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterGeoRepSessionDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionDetails)

Example 4 with GlusterVolumeGeoRepSessionParameters

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);
}
Also used : GlusterVolumeGeoRepSessionConfigParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionConfigParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) ExecutionException(java.util.concurrent.ExecutionException)

Example 5 with GlusterVolumeGeoRepSessionParameters

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);
}
Also used : GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

GlusterVolumeGeoRepSessionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters)11 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)8 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)6 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)5 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)4 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 CreateGlusterVolumeSnapshotVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters)2 Guid (org.ovirt.engine.core.compat.Guid)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 GlusterVolumeGeoRepSessionConfigParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionConfigParameters)1 SetUpMountBrokerParameters (org.ovirt.engine.core.common.action.gluster.SetUpMountBrokerParameters)1 SetUpPasswordLessSSHParameters (org.ovirt.engine.core.common.action.gluster.SetUpPasswordLessSSHParameters)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 GlusterGeoRepSessionDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionDetails)1 GlusterVolumeGeoRepSessionVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters)1