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