Search in sources :

Example 1 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterVolumeUtils method countDownBricks.

public static int countDownBricks(GlusterVolumeEntity volume) {
    int downCount = 0;
    int upCount = 0;
    for (GlusterBrickEntity brick : volume.getBricks()) {
        if (brick.getStatus() == GlusterStatus.UP) {
            upCount++;
        } else {
            downCount++;
        }
        if (upCount > 0 && downCount > 0) {
            return downCount;
        }
    }
    return downCount;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)

Example 2 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterStorageModel method volumeSelectedItemChanged.

private void volumeSelectedItemChanged() {
    GlusterVolumeEntity volume = getGlusterVolumes().getSelectedItem();
    Boolean useLinkGlusterVolume = getLinkGlusterVolume().getEntity();
    // $NON-NLS-1$
    String mountOptions = "";
    if (volume == null || !useLinkGlusterVolume) {
        return;
    }
    Set<String> addressSet = new LinkedHashSet<>();
    for (GlusterBrickEntity brick : volume.getBricks()) {
        addressSet.add(brick.getNetworkId() != null && !brick.getNetworkAddress().isEmpty() ? brick.getNetworkAddress() : brick.getServerName());
    }
    List<String> addressList = new ArrayList<>();
    addressList.addAll(addressSet);
    if (addressList.size() >= 1) {
        // the first server is already used to mount volume
        addressList.remove(0);
    }
    if (addressList.size() > 0) {
        mountOptions = StorageConstants.GLUSTER_BACKUP_SERVERS_MNT_OPTION + "=" + // $NON-NLS-1$ //$NON-NLS-2$
        String.join(":", addressList);
    }
    getMountOptions().setEntity(mountOptions);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList)

Example 3 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class VolumeBrickStatusColumn method getTooltip.

@Override
public SafeHtml getTooltip(GlusterVolumeEntity object) {
    // $NON-NLS-1$
    String SPACE = " ";
    // Nothing to render if no volume is provided:
    if (object == null) {
        return null;
    }
    int upBricks = 0;
    int downBricks = 0;
    for (GlusterBrickEntity brick : object.getBricks()) {
        if (brick.isOnline()) {
            upBricks++;
        } else {
            downBricks++;
        }
    }
    StringBuilder sb = new StringBuilder();
    sb.append(upBricks).append(SPACE).append(constants.up()).append(SPACE).append(downBricks).append(SPACE).append(constants.down());
    return SafeHtmlUtils.fromString(sb.toString());
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)

Example 4 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterCommandBase method validateDuplicateBricks.

protected boolean validateDuplicateBricks(List<GlusterBrickEntity> newBricks) {
    Set<String> bricks = new HashSet<>();
    for (GlusterBrickEntity brick : newBricks) {
        if (bricks.contains(brick.getQualifiedName())) {
            addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_DUPLICATE_BRICKS);
            addValidationMessageVariable("brick", brick.getQualifiedName());
            return false;
        }
        bricks.add(brick.getQualifiedName());
        GlusterBrickEntity existingBrick = glusterBrickDao.getBrickByServerIdAndDirectory(brick.getServerId(), brick.getBrickDirectory());
        if (existingBrick != null) {
            addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_BRICK_ALREADY_EXISTS_IN_VOLUME);
            addValidationMessageVariable("brick", brick.getQualifiedName());
            addValidationMessageVariable("volumeName", glusterVolumeDao.getById(existingBrick.getVolumeId()).getName());
            return false;
        }
    }
    return true;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) HashSet(java.util.HashSet)

Example 5 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterHostValidator method checkUnsyncedEntries.

public Map<Guid, List<String>> checkUnsyncedEntries(Iterable<Guid> hostIds) {
    Map<Guid, List<String>> result = new HashMap<>();
    for (Guid serverId : hostIds) {
        List<GlusterBrickEntity> bricks = brickDao.getGlusterVolumeBricksByServerId(serverId);
        List<String> bricksWithUnsyncedEntries = bricks.stream().filter(brick -> brick.getStatus() == GlusterStatus.UP && brick.getUnSyncedEntries() != null && brick.getUnSyncedEntries() > 0).map(brick -> brick.getQualifiedName()).collect(Collectors.toList());
        if (!bricksWithUnsyncedEntries.isEmpty()) {
            result.put(serverId, bricksWithUnsyncedEntries);
        }
    }
    return result;
}
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) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid)

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