use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class RestoreGlusterVolumeSnapshotCommand method resumeGeoRepSessions.
private boolean resumeGeoRepSessions(List<GlusterGeoRepSession> geoRepSessions) {
for (GlusterGeoRepSession session : geoRepSessions) {
GlusterVolumeEntity slaveVolume = glusterVolumeDao.getById(session.getSlaveVolumeId());
if (slaveVolume == null) {
// continue with other sessions and try to pause
continue;
}
try (EngineLock lock = acquireGeoRepSessionLock(session.getId())) {
ActionReturnValue retVal = runInternalAction(ActionType.ResumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(), session.getId()));
if (!retVal.getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_GEO_REP_RESUME_FAILED, retVal.getExecuteFailedMessages().toString());
setSucceeded(false);
return false;
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class RestoreGlusterVolumeSnapshotCommand method restoreVolumeToSnapshot.
private boolean restoreVolumeToSnapshot(Guid upServerId, GlusterVolumeEntity volume, String snapshotName) {
if (volume != null) {
VDSReturnValue retVal = runVdsCommand(VDSCommandType.RestoreGlusterVolumeSnapshot, new GlusterVolumeSnapshotActionVDSParameters(upServerId, volume.getName(), snapshotName));
if (!retVal.getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED, retVal.getVdsError().getMessage());
setSucceeded(false);
return false;
} else {
glusterVolumeSnapshotDao.removeByName(volume.getId(), snapshotName);
// Sync the new bricks of the volume immediately
VDS upServer = glusterUtil.getRandomUpServer(volume.getClusterId());
VDSReturnValue volDetailsRetVal = runVdsCommand(VDSCommandType.GetGlusterVolumeInfo, new GlusterVolumeInfoVDSParameters(upServer.getId(), volume.getClusterId(), volume.getName()));
GlusterVolumeEntity fetchedVolume = ((Map<Guid, GlusterVolumeEntity>) volDetailsRetVal.getReturnValue()).get(volume.getId());
List<GlusterBrickEntity> fetchedBricks = fetchedVolume.getBricks();
if (fetchedBricks != null) {
glusterBrickDao.removeAllInBatch(volume.getBricks());
for (GlusterBrickEntity fetchdBrick : fetchedVolume.getBricks()) {
if (fetchdBrick.getServerId() != null) {
fetchdBrick.setStatus(GlusterStatus.UP);
glusterBrickDao.save(fetchdBrick);
} else {
log.warn("Invalid server details for brick " + fetchdBrick.getName() + ". Not adding now.");
}
}
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class ScheduleGlusterVolumeSnapshotCommandBase method validate.
@Override
protected boolean validate() {
if (!super.validate()) {
return false;
}
GlusterVolumeEntity volume = getGlusterVolume();
if (volume != null && volume.getStatus() == GlusterStatus.DOWN) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN);
}
if (!glusterUtil.isVolumeThinlyProvisioned(volume)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_NOT_THINLY_PROVISIONED);
}
// Validate the scheduling dates (start and end by dates)
Date convertedStartDate = glusterUtil.convertDate(schedule.getStartDate(), schedule.getTimeZone());
Date convertedEndByDate = glusterUtil.convertDate(schedule.getEndByDate(), schedule.getTimeZone());
if (schedule.getRecurrence() != null && schedule.getRecurrence() != GlusterVolumeSnapshotScheduleRecurrence.UNKNOWN && schedule.getEndByDate() != null && convertedStartDate != null && convertedEndByDate.compareTo(convertedStartDate) <= 0) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_END_BY_DATE_BEFORE_START_DATE);
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity 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.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class StopRebalanceGlusterVolumeCommandTest method getvolumeWithoutRebalanceTask.
private Object getvolumeWithoutRebalanceTask(Guid volumeId) {
GlusterVolumeEntity volume = getVolumeWithRebalanceTask(volumeId);
volume.getAsyncTask().setType(null);
return volume;
}
Aggregations