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;
}
}
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);
}
}
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);
}
}
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;
}
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());
}
Aggregations