Search in sources :

Example 46 with GlusterGeoRepSession

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession in project ovirt-engine by oVirt.

the class CreateGlusterVolumeSnapshotCommand method validate.

@Override
protected boolean validate() {
    if (!super.validate()) {
        return false;
    }
    GlusterVolumeEntity volume = getGlusterVolume();
    if (volume.getStatus() == GlusterStatus.DOWN) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN);
    }
    if (volume.getAsyncTask() != null && (volume.getAsyncTask().getType() == GlusterTaskType.REBALANCE || volume.getAsyncTask().getType() == GlusterTaskType.REMOVE_BRICK) && volume.getAsyncTask().getStatus() == JobExecutionStatus.STARTED) {
        addValidationMessageVariable("asyncTask", volume.getAsyncTask().getType().name().toLowerCase());
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_VOLUME_ASYNC_OPERATION_IN_PROGRESS);
    }
    if (!glusterUtil.isVolumeThinlyProvisioned(volume)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED);
    }
    if (glusterVolumeSnapshotDao.getByName(getGlusterVolumeId(), snapshot.getSnapshotName()) != null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_SNAPSHOT_ALREADY_EXISTS);
    }
    List<GlusterBrickEntity> bricks = volume.getBricks();
    for (GlusterBrickEntity brick : bricks) {
        if (!brick.isOnline()) {
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_ONE_OR_MORE_BRICKS_ARE_DOWN);
        }
    }
    for (GlusterGeoRepSession session : georepSessions) {
        if (session.getSlaveNodeUuid() == null || session.getSlaveVolumeId() == null) {
            // the volume
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_REMOTE_CLUSTER_NOT_MAINTAINED_BY_ENGINE);
        }
    }
    return true;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 47 with GlusterGeoRepSession

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession 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)

Example 48 with GlusterGeoRepSession

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession in project ovirt-engine by oVirt.

the class GlusterGeoRepSyncJob method refreshGeoRepSessionStatusForSessions.

private void refreshGeoRepSessionStatusForSessions(final Cluster cluster, List<GlusterGeoRepSession> geoRepSessions) {
    if (CollectionUtils.isEmpty(geoRepSessions)) {
        return;
    }
    List<Callable<GlusterGeoRepSession>> geoRepSessionCalls = new ArrayList<>();
    for (final GlusterGeoRepSession geoRepSession : geoRepSessions) {
        geoRepSessionCalls.add(() -> {
            geoRepSession.setSessionDetails((ArrayList) getSessionDetailFromCLI(cluster, geoRepSession));
            return geoRepSession;
        });
    }
    List<GlusterGeoRepSession> updatedSessions = ThreadPoolUtil.invokeAll(geoRepSessionCalls);
    for (GlusterGeoRepSession updatedSession : updatedSessions) {
        if (updatedSession.getSessionDetails() == null) {
            log.info("Geo-replication session details not updated for session '{}' as there was error returning data from VDS", updatedSession.getSessionKey());
            continue;
        }
        try (EngineLock lock = acquireGeoRepSessionLock(updatedSession.getId())) {
            GlusterVolumeEntity masterVolume = volumeDao.getById(updatedSession.getMasterVolumeId());
            updateGeoRepStatus(masterVolume, updatedSession);
            geoRepDao.updateSession(updatedSession);
            updateSessionDetailsInDB(updatedSession);
        } catch (Exception e) {
            log.error("Error updating session details '{}' : '{}'", updatedSession.getSessionKey(), e.getMessage());
            log.debug("Exception", e);
        }
    }
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) Callable(java.util.concurrent.Callable) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 49 with GlusterGeoRepSession

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession in project ovirt-engine by oVirt.

the class GlusterGeoRepSyncJob method getSessionsFromCLI.

private Map<String, GlusterGeoRepSession> getSessionsFromCLI(Cluster cluster, GlusterVolumeEntity volume) {
    VDS upServer = glusterUtil.getRandomUpServer(cluster.getId());
    if (upServer == null) {
        log.debug("No UP server found in cluster '{}' for geo-rep monitoring", cluster.getName());
        return null;
    }
    String volName = volume != null ? volume.getName() : null;
    // get details of geo-rep sessions in cluster
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeGeoRepSessionList, new GlusterVolumeGeoRepSessionVDSParameters(upServer.getId(), volName));
    if (returnValue.getSucceeded()) {
        List<GlusterGeoRepSession> sessions = (List<GlusterGeoRepSession>) returnValue.getReturnValue();
        HashMap<String, GlusterGeoRepSession> sessionsMap = new HashMap<>();
        if (sessions == null) {
            return sessionsMap;
        }
        for (GlusterGeoRepSession session : sessions) {
            sessionsMap.put(session.getSessionKey(), session);
        }
        return sessionsMap;
    } else {
        log.error("VDS error {}", returnValue.getVdsError().getMessage());
        log.debug("VDS error", returnValue.getVdsError());
        return null;
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) HashMap(java.util.HashMap) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeGeoRepSessionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters) ArrayList(java.util.ArrayList) List(java.util.List) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)49 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)12 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)9 GlusterVolumeGeoRepSessionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters)8 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 VDS (org.ovirt.engine.core.common.businessentities.VDS)6 Guid (org.ovirt.engine.core.compat.Guid)6 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)5 GlusterVolumeGeoRepSessionVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters)5 GlusterGeoRepSessionDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionDetails)3 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)3 HashMap (java.util.HashMap)2 Callable (java.util.concurrent.Callable)2 StorageDomainDR (org.ovirt.engine.core.common.businessentities.StorageDomainDR)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 CreateGlusterVolumeSnapshotVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters)2