use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity 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.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterHostValidator method isQuorumMet.
private boolean isQuorumMet(GlusterVolumeEntity volume, List<GlusterBrickEntity> bricksGoingToMaintenance) {
int replicaCount = volume.getReplicaCount();
List<GlusterBrickEntity> bricks = volume.getBricks();
int subVolumes = bricks.size() / replicaCount;
String quorumType = volume.getOptionValue(GlusterConstants.OPTION_QUORUM_TYPE);
int quorumCount;
if (GlusterConstants.OPTION_QUORUM_TYPE_FIXED.equals(quorumType)) {
quorumCount = Integer.parseInt(volume.getOptionValue(GlusterConstants.OPTION_QUORUM_COUNT));
} else if (GlusterConstants.OPTION_QUORUM_TYPE_AUTO.equals(quorumType)) {
quorumCount = (int) Math.ceil((double) replicaCount / 2);
} else {
return true;
}
for (int index = 0; index < subVolumes; index++) {
List<GlusterBrickEntity> bricksInSubVolume = bricks.subList(index * replicaCount, (index * replicaCount) + replicaCount);
int bricksGoingDown = 0;
int remainingUpBricks = 0;
for (GlusterBrickEntity brick : bricksInSubVolume) {
if (GlusterStatus.UP.equals(brick.getStatus()) && bricksGoingToMaintenance.contains(brick)) {
bricksGoingDown++;
} else if (GlusterStatus.UP.equals(brick.getStatus())) {
remainingUpBricks++;
}
}
if (bricksGoingDown > 0) {
if (remainingUpBricks < quorumCount) {
return false;
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity 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.GlusterBrickEntity 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.GlusterBrickEntity in project ovirt-engine by oVirt.
the class CreateGlusterVolumeGeoRepSessionCommand method fetchRemoteServers.
private Set<VDS> fetchRemoteServers() {
Set<VDS> remoteServers = new HashSet<>();
List<GlusterBrickEntity> slaveBricks = slaveVolume.getBricks();
for (GlusterBrickEntity currentBrick : slaveBricks) {
remoteServers.add(vdsDao.get(currentBrick.getServerId()));
}
return remoteServers;
}
Aggregations