Search in sources :

Example 1 with MemoryStatus

use of org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus 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 MemoryStatus

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

the class GetGlusterVolumeAdvancedDetailsQueryTest method getMemoryStatus.

private MemoryStatus getMemoryStatus() {
    MemoryStatus memoryStatus = new MemoryStatus();
    memoryStatus.setMallInfo(getMallInfo());
    memoryStatus.setMemPools(getMemPools());
    return memoryStatus;
}
Also used : MemoryStatus(org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus)

Example 3 with MemoryStatus

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

the class GlusterBrickDetailMapperTest method getMemoryStatus.

private MemoryStatus getMemoryStatus(int listSize) {
    MemoryStatus memStatus = new MemoryStatus();
    memStatus.setMallInfo(new MallInfo());
    memStatus.getMallInfo().setArena(RandomUtils.instance().nextInt());
    memStatus.getMallInfo().setUordblks(RandomUtils.instance().nextInt());
    ArrayList<Mempool> memPoolsList = new ArrayList<>();
    for (int i = 0; i < listSize; i++) {
        Mempool pool = new Mempool();
        pool.setAllocCount(RandomUtils.instance().nextInt());
        pool.setHotCount(0);
        pool.setName(RandomUtils.instance().nextString(5));
        memPoolsList.add(pool);
    }
    memStatus.setMemPools(memPoolsList);
    return memStatus;
}
Also used : MallInfo(org.ovirt.engine.core.common.businessentities.gluster.MallInfo) MemoryStatus(org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus) ArrayList(java.util.ArrayList) Mempool(org.ovirt.engine.core.common.businessentities.gluster.Mempool)

Example 4 with MemoryStatus

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

the class GlusterTestHelper method getBrickEntity.

protected GlusterBrickEntity getBrickEntity(int index, boolean hasDetails) {
    GlusterBrickEntity entity = mock(GlusterBrickEntity.class);
    when(entity.getId()).thenReturn(GUIDS[index]);
    when(entity.getServerId()).thenReturn(serverId);
    when(entity.getBrickDirectory()).thenReturn(GlusterTestHelper.brickDir);
    when(entity.getQualifiedName()).thenReturn(GlusterTestHelper.brickName);
    when(entity.getVolumeId()).thenReturn(volumeId);
    if (hasDetails) {
        BrickDetails brickDetails = mock(BrickDetails.class);
        BrickProperties brickProps = mock(BrickProperties.class);
        MemoryStatus memStatus = mock(MemoryStatus.class);
        MallInfo mallInfo = mock(MallInfo.class);
        when(mallInfo.getArena()).thenReturn(888);
        when(brickProps.getMntOptions()).thenReturn(GlusterTestHelper.BRICK_MNT_OPT);
        when(brickProps.getPort()).thenReturn(GlusterTestHelper.BRICK_PORT);
        when(brickDetails.getMemoryStatus()).thenReturn(memStatus);
        when(memStatus.getMallInfo()).thenReturn(mallInfo);
        when(brickDetails.getBrickProperties()).thenReturn(brickProps);
        when(entity.getBrickDetails()).thenReturn(brickDetails);
    }
    return entity;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) MallInfo(org.ovirt.engine.core.common.businessentities.gluster.MallInfo) MemoryStatus(org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Aggregations

MemoryStatus (org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus)4 ArrayList (java.util.ArrayList)2 BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)2 MallInfo (org.ovirt.engine.core.common.businessentities.gluster.MallInfo)2 Map (java.util.Map)1 BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)1 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)1 Mempool (org.ovirt.engine.core.common.businessentities.gluster.Mempool)1