Search in sources :

Example 11 with GlusterVolumeGeoRepSessionParameters

use of org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters in project ovirt-engine by oVirt.

the class CreateGlusterVolumeSnapshotCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterVolumeEntity volume = getGlusterVolume();
    // Pause geo-rep sessions and create snapshot for slave volumes
    Boolean tranRetVal = TransactionSupport.executeInNewTransaction(() -> pauseAndCreateSnapshotForGeoRepSessions());
    if (!tranRetVal) {
        return;
    }
    // Create snapshot for the master volume
    VDSReturnValue retVal = runVdsCommand(VDSCommandType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotVDSParameters(upServer.getId(), volume.getName(), snapshot.getSnapshotName(), snapshot.getDescription(), force));
    setSucceeded(retVal.getSucceeded());
    if (!retVal.getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, retVal.getVdsError().getMessage());
    } else {
        GlusterVolumeSnapshotEntity createdSnapshot = (GlusterVolumeSnapshotEntity) retVal.getReturnValue();
        createdSnapshot.setClusterId(snapshot.getClusterId());
        createdSnapshot.setVolumeId(snapshot.getVolumeId());
        createdSnapshot.setDescription(snapshot.getDescription());
        createdSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
        glusterVolumeSnapshotDao.save(createdSnapshot);
        addCustomValue(GlusterConstants.VOLUME_SNAPSHOT_NAME, createdSnapshot.getSnapshotName());
        // check if the snapshot soft limit reached now for the volume and alert
        glusterUtil.alertVolumeSnapshotLimitsReached(getGlusterVolume());
    }
    // Resume the snapshot paused sessions by engine
    for (GlusterGeoRepSession session : enginePausedSessions) {
        if (session.getStatus() == GeoRepSessionStatus.PAUSED) {
            try (EngineLock lock = acquireGeoRepSessionLock(session.getId())) {
                ActionReturnValue sessionResumeRetVal = runInternalAction(ActionType.ResumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(volume.getId(), session.getId()));
                if (!sessionResumeRetVal.getSucceeded()) {
                    handleVdsErrors(AuditLogType.GLUSTER_VOLUME_GEO_REP_RESUME_FAILED, sessionResumeRetVal.getExecuteFailedMessages());
                    setSucceeded(false);
                    return;
                }
            }
        }
    }
}
Also used : CreateGlusterVolumeSnapshotVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) 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)

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