Search in sources :

Example 6 with GlusterBrickEntity

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;
}
Also used : GlusterBrickDao(org.ovirt.engine.core.dao.gluster.GlusterBrickDao) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Inject(javax.inject.Inject) GlusterConstants(org.ovirt.engine.core.common.constants.gluster.GlusterConstants) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Map(java.util.Map) GlusterVolumeDao(org.ovirt.engine.core.dao.gluster.GlusterVolumeDao) Validate(org.apache.commons.lang.Validate) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 7 with GlusterBrickEntity

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)

Example 8 with GlusterBrickEntity

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);
        }
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Guid(org.ovirt.engine.core.compat.Guid)

Example 9 with GlusterBrickEntity

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet)

Example 10 with GlusterBrickEntity

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) VDS(org.ovirt.engine.core.common.businessentities.VDS) HashSet(java.util.HashSet)

Aggregations

GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)132 ArrayList (java.util.ArrayList)63 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)43 Test (org.junit.Test)28 Guid (org.ovirt.engine.core.compat.Guid)19 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)14 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 List (java.util.List)10 HashMap (java.util.HashMap)9 Map (java.util.Map)9 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)9 BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)9 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)7 BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)7 GlusterVolumeAdvancedDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)7 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)7 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)7 Iterator (java.util.Iterator)5