Search in sources :

Example 16 with GlusterGeoRepSession

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

the class SetGeoRepConfigCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterGeoRepSession session = getGeoRepSession();
    String configKey = getParameters().getConfigKey();
    String configValue = getParameters().getConfigValue();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.SetGlusterVolumeGeoRepConfig, new GlusterVolumeGeoRepConfigVdsParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), configKey, configValue, session.getUserName()));
    boolean succeeded = returnValue.getSucceeded();
    if (succeeded && configKey.equals("use_meta_volume")) {
        // Not handling failures as there's no way to figure out if the error is that the option is already set.
        runVdsCommand(VDSCommandType.SetGlusterVolumeOption, new GlusterVolumeOptionVDSParameters(upServer.getId(), "all", new GlusterVolumeOptionEntity(getGeoRepSession().getMasterVolumeId(), "cluster.enable-shared-storage", "enable")));
    }
    setSucceeded(succeeded);
    if (getSucceeded()) {
        GlusterGeoRepSessionConfiguration geoRepSessionConfig = new GlusterGeoRepSessionConfiguration();
        geoRepSessionConfig.setValue(configValue);
        geoRepSessionConfig.setKey(configKey);
        geoRepSessionConfig.setId(session.getId());
        if (glusterGeoRepDao.getGeoRepSessionConfigByKey(session.getId(), configKey) == null) {
            glusterGeoRepDao.saveConfig(geoRepSessionConfig);
        } else {
            glusterGeoRepDao.updateConfig(geoRepSessionConfig);
        }
    } else {
        handleVdsError(AuditLogType.GLUSTER_GEOREP_CONFIG_SET_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
}
Also used : GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) GlusterVolumeOptionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeOptionVDSParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) GlusterVolumeGeoRepConfigVdsParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepConfigVdsParameters)

Example 17 with GlusterGeoRepSession

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

the class GeorepEventSubscriber method processEvent.

@Override
public void processEvent(GlusterEvent event) {
    if (event == null) {
        log.debug("No event to process!");
        return;
    }
    GlusterServer glusterServer = glusterServerDao.getByGlusterServerUuid(Guid.createGuidFromString(event.getNodeId()));
    if (glusterServer == null) {
        log.debug("Could not determine gluster server from event '{}'", event);
        return;
    }
    VdsStatic host = vdsStaticDao.get(glusterServer.getId());
    if (host == null) {
        log.debug("No host corresponding to gluster server in '{}'", event);
        return;
    }
    if (event.getEvent().equalsIgnoreCase(EVENT_GEOREP_CHECKPOINT_COMPLETED)) {
        GlusterVolumeEntity masterVol = glusterVolumeDao.getByName(host.getClusterId(), (String) event.getMessage().get(MASTER_VOLUME));
        if (masterVol == null) {
            log.debug("Could not determine master volume from event '{}'", event);
            return;
        }
        GlusterGeoRepSession session = geoRepDao.getGeoRepSession(masterVol.getId(), (String) event.getMessage().get(SLAVE_HOST), (String) event.getMessage().get(SLAVE_VOLUME));
        // hence forcing sync for now.
        if (session != null) {
            log.debug("received event for session '{}'", session.getSessionKey());
        }
        geoRepSyncJob.refreshGeoRepDataForVolume(masterVol);
    }
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 18 with GlusterGeoRepSession

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

the class PauseGlusterVolumeGeoRepSessionCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterGeoRepSession session = getGeoRepSession();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.PauseGlusterVolumeGeoRepSession, new GlusterVolumeGeoRepSessionVDSParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), session.getUserName(), getParameters().isForce()));
    setSucceeded(returnValue.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE_FAILED, returnValue.getVdsError().getMessage());
        return;
    } else {
        session.setStatus(GeoRepSessionStatus.PAUSED);
        glusterGeoRepDao.updateSession(session);
    }
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeGeoRepSessionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 19 with GlusterGeoRepSession

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

the class ResumeGeoRepSessionCommandTest method getGeoRepSession.

protected GlusterGeoRepSession getGeoRepSession(Guid gSessionId, GeoRepSessionStatus status, Guid masterVolumeID) {
    GlusterGeoRepSession session = super.getGeoRepSession(gSessionId, status);
    session.setMasterVolumeId(startedVolumeId);
    return session;
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 20 with GlusterGeoRepSession

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

the class CreateGlusterVolumeGeoRepSessionCommandTest method commandFailsSessionExists.

@Test
public void commandFailsSessionExists() {
    doReturn(volume).when(command).getSlaveVolume();
    doReturn(vds).when(command).getSlaveHost();
    doReturn(SUPPORTED_VERSION).when(cluster).getCompatibilityVersion();
    doReturn(Guid.newGuid()).when(vds).getId();
    doReturn(new GlusterGeoRepSession()).when(geoRepDao).getGeoRepSession(any(Guid.class), any(Guid.class), any(String.class));
    assertFalse(command.validate());
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

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