use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class GlusterGeoRepSyncJob method updateDiscoveredSessions.
private void updateDiscoveredSessions(Cluster cluster, Map<String, GlusterGeoRepSession> sessionsMap, GlusterVolumeEntity volume) {
removeDeletedSessions(cluster, sessionsMap, volume);
// for each geo-rep session, find session in database and update details.
for (GlusterGeoRepSession session : sessionsMap.values()) {
GlusterVolumeEntity masterVolume = getVolume(cluster, session.getMasterVolumeName());
if (masterVolume == null) {
log.info("Could not find corresponding volume for geo-rep session '{}' and volume '{}' - status will not be updated.", session.getSessionKey(), session.getMasterVolumeName());
} else {
session.setMasterVolumeId(masterVolume.getId());
// update consolidated status
updateGeoRepStatus(masterVolume, session);
}
// check if session exists in database
GlusterGeoRepSession sessionInDb = geoRepDao.getGeoRepSession(session.getSessionKey());
if (sessionInDb == null) {
// save the session in database first.
log.debug("detected new geo-rep session '{}' for volume '{}'", session.getSessionKey(), session.getMasterVolumeName());
if (Guid.isNullOrEmpty(session.getId())) {
session.setId(Guid.newGuid());
}
if (session.getSlaveNodeUuid() == null && session.getSlaveVolumeId() == null) {
updateSlaveNodeAndVolumeId(session);
}
geoRepDao.save(session);
logGeoRepMessage(AuditLogType.GLUSTER_GEOREP_SESSION_DETECTED_FROM_CLI, cluster, session);
} else {
// if retrieved session does not have the slave uuid's set
if (session.getSlaveNodeUuid() == null && session.getSlaveVolumeId() == null) {
// set it from the one in db
session.setSlaveNodeUuid(sessionInDb.getSlaveNodeUuid());
session.setSlaveVolumeId(sessionInDb.getSlaveVolumeId());
}
// if even the updated session has no slave ids, try setting it by querying db
if (session.getSlaveNodeUuid() == null && session.getSlaveVolumeId() == null) {
updateSlaveNodeAndVolumeId(session);
}
session.setId(sessionInDb.getId());
geoRepDao.updateSession(session);
}
updateSessionDetailsInDB(session);
updateDiscoveredSessionConfig(cluster, session);
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class GlusterHostValidator method checkGlusterQuorum.
public List<String> checkGlusterQuorum(Cluster cluster, Iterable<Guid> selectedHostIdsForMaintenance) {
List<String> volumesWithoutQuorum = new ArrayList<>();
if (cluster.supportsGlusterService()) {
List<GlusterBrickEntity> bricksGoingToMaintenance = new ArrayList<>();
for (Guid serverId : selectedHostIdsForMaintenance) {
bricksGoingToMaintenance.addAll(brickDao.getGlusterVolumeBricksByServerId(serverId));
}
List<GlusterVolumeEntity> volumesInCluster = volumeDao.getByClusterId(cluster.getId());
volumesWithoutQuorum = volumesInCluster.stream().filter(volume -> volume.getStatus() == GlusterStatus.UP && volume.getVolumeType().isReplicatedType() && !isQuorumMet(volume, bricksGoingToMaintenance)).map(v -> v.getName()).collect(Collectors.toList());
}
return volumesWithoutQuorum;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class AddBricksToGlusterVolumeCommand method executeCommand.
@Override
protected void executeCommand() {
final List<GlusterBrickEntity> bricksList = getParameters().getBricks();
GlusterVolumeEntity volumeBeforeBrickAdd = getGlusterVolume();
// Add bricks in a single transaction
TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
addGlusterVolumeBricks(bricksList, getParameters().getReplicaCount(), getParameters().getStripeCount(), getParameters().isForce());
return null;
});
if (getGlusterVolume().getIsGeoRepMaster() || getGlusterVolume().getIsGeoRepSlave()) {
Set<Guid> newServerIds = findNewServers(bricksList, volumeBeforeBrickAdd);
if (!newServerIds.isEmpty()) {
postAddBrickHandleGeoRepCase(bricksList, newServerIds);
}
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class AddBricksToGlusterVolumeCommand method getSlaveNodesSet.
private Set<Guid> getSlaveNodesSet(GlusterGeoRepSession currentSession) {
Set<Guid> slaveNodesSet = new HashSet<>();
GlusterVolumeEntity sessionSlaveVolume = glusterVolumeDao.getById(currentSession.getSlaveVolumeId());
for (GlusterBrickEntity currentSlaveBrick : sessionSlaveVolume.getBricks()) {
slaveNodesSet.add(currentSlaveBrick.getServerId());
}
return slaveNodesSet;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class CommitRemoveGlusterVolumeBricksCommand method executeCommand.
@Override
protected void executeCommand() {
GlusterVolumeEntity volume = getGlusterVolume();
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.CommitRemoveGlusterVolumeBricks, new GlusterVolumeRemoveBricksVDSParameters(getUpServer().getId(), volume.getName(), getParameters().getBricks()));
setSucceeded(returnValue.getSucceeded());
if (!getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT_FAILED, returnValue.getVdsError().getMessage());
return;
}
addCustomValue(GlusterConstants.NO_OF_BRICKS, String.valueOf(getParameters().getBricks().size()));
endStepJobCommitted();
glusterDBUtils.removeBricksFromVolumeInDb(volume, getParameters().getBricks(), getParameters().getReplicaCount());
glusterVolumeDao.updateVolumeTask(volume.getId(), null);
releaseVolumeLock();
getReturnValue().setActionReturnValue(returnValue.getReturnValue());
}
Aggregations