Search in sources :

Example 1 with BrickDetails

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

the class GlusterVolumeStatusReturn method prepareBrickDetails.

private List<BrickDetails> prepareBrickDetails(GlusterVolumeEntity volume, Object[] bricksList) {
    List<BrickDetails> brickDetailsList = new ArrayList<>();
    for (Object brickObj : bricksList) {
        BrickDetails brickDetails = new BrickDetails();
        Map<String, Object> brick = (Map<String, Object>) brickObj;
        brickDetails.setBrickProperties(getBrickProperties(volume, brick));
        // Fetch Clients Details
        if (brick.containsKey(CLIENTS_STATUS)) {
            brickDetails.setClients(prepareClientInfo((Object[]) brick.get(CLIENTS_STATUS)));
        }
        // Fetch Memory Details
        if (brick.containsKey(MEMORY_MALL_INFO) || brick.containsKey(MEMORY_MEM_POOL)) {
            MemoryStatus memoryStatus = new MemoryStatus();
            memoryStatus.setMallInfo(prepareMallInfo((Map<String, Object>) brick.get(MEMORY_MALL_INFO)));
            memoryStatus.setMemPools(prepareMemPool((Object[]) brick.get(MEMORY_MEM_POOL)));
            brickDetails.setMemoryStatus(memoryStatus);
        }
        brickDetailsList.add(brickDetails);
    }
    return brickDetailsList;
}
Also used : MemoryStatus(org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 2 with BrickDetails

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

the class GlusterBrickDetailMapper method map.

@Mapping(from = GlusterVolumeAdvancedDetails.class, to = GlusterBrick.class)
public static GlusterBrick map(GlusterVolumeAdvancedDetails fromEntity, GlusterBrick toModel) {
    GlusterBrick model = (toModel == null) ? new GlusterBrick() : toModel;
    if (fromEntity.getBrickDetails() == null) {
        return model;
    }
    // Since the getDetails call is for a single brick the list size will always be 1 - so get the first element
    BrickDetails detail = (fromEntity.getBrickDetails().size() > 0) ? fromEntity.getBrickDetails().get(0) : null;
    if (detail == null) {
        return model;
    }
    model = mapBrickProperties(detail, model);
    if (detail.getClients() != null) {
        model.setGlusterClients(new GlusterClients());
        for (GlusterClientInfo clientEntity : detail.getClients()) {
            model.getGlusterClients().getGlusterClients().add(map(clientEntity));
        }
    }
    if (detail.getMemoryStatus() != null && detail.getMemoryStatus().getMemPools() != null) {
        model.setMemoryPools(new GlusterMemoryPools());
        for (Mempool pool : detail.getMemoryStatus().getMemPools()) {
            model.getMemoryPools().getGlusterMemoryPools().add(map(pool));
        }
    }
    return model;
}
Also used : GlusterMemoryPools(org.ovirt.engine.api.model.GlusterMemoryPools) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) GlusterClientInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterClientInfo) Mempool(org.ovirt.engine.core.common.businessentities.gluster.Mempool) GlusterClients(org.ovirt.engine.api.model.GlusterClients) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 3 with BrickDetails

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

the class GlusterSyncJob method refreshVolumeDetails.

public void refreshVolumeDetails(VDS upServer, GlusterVolumeEntity volume) {
    List<GlusterBrickEntity> bricksToUpdate = new ArrayList<>();
    List<GlusterBrickEntity> brickPropertiesToUpdate = new ArrayList<>();
    List<GlusterBrickEntity> brickPropertiesToAdd = new ArrayList<>();
    GlusterVolumeAdvancedDetails volumeAdvancedDetails = getVolumeAdvancedDetails(upServer, volume.getClusterId(), volume.getName());
    if (volumeAdvancedDetails == null) {
        log.error("Error while refreshing brick statuses for volume '{}'. Failed to get volume advanced details ", volume.getName());
        return;
    }
    if (volumeAdvancedDetails.getCapacityInfo() != null) {
        if (volume.getAdvancedDetails().getCapacityInfo() == null) {
            volumeDao.addVolumeCapacityInfo(volumeAdvancedDetails.getCapacityInfo());
        } else {
            volumeDao.updateVolumeCapacityInfo(volumeAdvancedDetails.getCapacityInfo());
        }
    }
    Map<Guid, BrickProperties> brickPropertiesMap = getBrickPropertiesMap(volumeAdvancedDetails);
    for (GlusterBrickEntity brick : volume.getBricks()) {
        BrickProperties brickProperties = brickPropertiesMap.get(brick.getId());
        if (brickProperties != null) {
            if (brickProperties.getStatus() != brick.getStatus()) {
                logBrickStatusChange(volume, brick, brickProperties.getStatus());
                brick.setStatus(brickProperties.getStatus());
                bricksToUpdate.add(brick);
            }
            if (brick.getBrickProperties() == null) {
                BrickDetails brickDetails = new BrickDetails();
                brickDetails.setBrickProperties(brickProperties);
                brick.setBrickDetails(brickDetails);
                brickPropertiesToAdd.add(brick);
            } else if (brickProperties.getTotalSize() != brick.getBrickProperties().getTotalSize() || brickProperties.getFreeSize() != brick.getBrickProperties().getFreeSize()) {
                brick.getBrickDetails().setBrickProperties(brickProperties);
                brickPropertiesToUpdate.add(brick);
            }
        }
    }
    if (!brickPropertiesToAdd.isEmpty()) {
        brickDao.addBrickProperties(brickPropertiesToAdd);
    }
    if (!brickPropertiesToUpdate.isEmpty()) {
        brickDao.updateBrickProperties(brickPropertiesToUpdate);
    }
    if (!bricksToUpdate.isEmpty()) {
        brickDao.updateBrickStatuses(bricksToUpdate);
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) Guid(org.ovirt.engine.core.compat.Guid) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Example 4 with BrickDetails

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

the class BrickStatisticalQuery method getStatistics.

@Override
public List<Statistic> getStatistics(GlusterBrickEntity entity) {
    BrickDetails brickDetails = entity.getBrickDetails();
    MallInfo mallInfo = brickDetails.getMemoryStatus().getMallInfo();
    return asList(setDatum(clone(MEM_TOTAL_SIZE), brickDetails.getBrickProperties().getTotalSize() * Mb), setDatum(clone(MEM_FREE_SIZE), brickDetails.getBrickProperties().getFreeSize() * Mb), setDatum(clone(MEM_BLOCK_SIZE), brickDetails.getBrickProperties().getBlockSize() * Mb), setDatum(clone(MEM_MALL_ARENA), mallInfo.getArena()), setDatum(clone(MEM_MALL_ORDBLKS), mallInfo.getOrdblks()), setDatum(clone(MEM_MALL_SMBLKS), mallInfo.getSmblks()), setDatum(clone(MEM_MALL_HBLKS), mallInfo.getHblks()), setDatum(clone(MEM_MALL_HBLKSHD), mallInfo.getHblkhd()), setDatum(clone(MEM_MALL_USMBLKS), mallInfo.getUsmblks()), setDatum(clone(MEM_MALL_FSMBLKS), mallInfo.getFsmblks()), setDatum(clone(MEM_MALL_UORDBLKS), mallInfo.getUordblks()), setDatum(clone(MEM_MALL_FORDBLKS), mallInfo.getFordblks()), setDatum(clone(MEM_MALL_KEEPCOST), mallInfo.getKeepcost()));
}
Also used : MallInfo(org.ovirt.engine.core.common.businessentities.gluster.MallInfo) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)

Example 5 with BrickDetails

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

the class GlusterSyncJobTest method getVolumeAdvancedDetails.

private GlusterVolumeAdvancedDetails getVolumeAdvancedDetails(GlusterVolumeEntity volume) {
    GlusterVolumeAdvancedDetails volDetails = new GlusterVolumeAdvancedDetails();
    GlusterVolumeSizeInfo capacityInfo = new GlusterVolumeSizeInfo();
    capacityInfo.setVolumeId(volume.getId());
    capacityInfo.setTotalSize(600000L);
    capacityInfo.setFreeSize(200000L);
    capacityInfo.setUsedSize(400000L);
    volDetails.setCapacityInfo(capacityInfo);
    List<BrickDetails> brickDetailsList = new ArrayList<>();
    for (GlusterBrickEntity brick : volume.getBricks()) {
        BrickDetails brickDetails = new BrickDetails();
        BrickProperties properties = new BrickProperties();
        properties.setBrickId(brick.getId());
        brickDetails.setBrickProperties(properties);
        properties.setStatus(brick.getStatus());
        if (volume == existingReplVol) {
            if (brick.getServerId().equals(SERVER_ID_1) && (brick.getBrickDirectory().equals(REPL_BRICK_R1D1) || brick.getBrickDirectory().equals(REPL_BRICK_R2D1))) {
                properties.setStatus(GlusterStatus.DOWN);
                bricksWithChangedStatus.add(brick);
            }
        }
        brickDetailsList.add(brickDetails);
    }
    volDetails.setBrickDetails(brickDetailsList);
    return volDetails;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeSizeInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSizeInfo) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) ArrayList(java.util.ArrayList) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Aggregations

BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)12 BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)7 ArrayList (java.util.ArrayList)6 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)5 GlusterVolumeAdvancedDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)4 Map (java.util.Map)2 GlusterClientInfo (org.ovirt.engine.core.common.businessentities.gluster.GlusterClientInfo)2 MallInfo (org.ovirt.engine.core.common.businessentities.gluster.MallInfo)2 MemoryStatus (org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus)2 Mempool (org.ovirt.engine.core.common.businessentities.gluster.Mempool)2 Guid (org.ovirt.engine.core.compat.Guid)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Test (org.junit.Test)1 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)1 GlusterClients (org.ovirt.engine.api.model.GlusterClients)1 GlusterMemoryPools (org.ovirt.engine.api.model.GlusterMemoryPools)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1