Search in sources :

Example 6 with BrickProperties

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

the class GlusterBrickDaoTest method testAddAllBrickProperties.

@Test
public void testAddAllBrickProperties() {
    Guid brickId1 = FixturesTool.GLUSTER_BRICK_UUID1;
    Guid brickId2 = FixturesTool.GLUSTER_BRICK_UUID2;
    GlusterBrickEntity brick1 = dao.getById(brickId1);
    GlusterBrickEntity brick2 = dao.getById(brickId2);
    brick1.setBrickDetails(new BrickDetails());
    BrickProperties brickProperties1 = new BrickProperties();
    brickProperties1.setBrickId(brickId1);
    brickProperties1.setFreeSize(Long.valueOf("75000"));
    brickProperties1.setTotalSize(Long.valueOf("250000"));
    brick1.getBrickDetails().setBrickProperties(brickProperties1);
    brick2.setBrickDetails(new BrickDetails());
    BrickProperties brickProperties2 = new BrickProperties();
    brickProperties2.setBrickId(brickId2);
    brickProperties2.setFreeSize(Long.valueOf("175000"));
    brickProperties2.setTotalSize(Long.valueOf("275000"));
    brick2.getBrickDetails().setBrickProperties(brickProperties2);
    List<GlusterBrickEntity> bricksToAdd = new ArrayList<>();
    bricksToAdd.add(brick1);
    bricksToAdd.add(brick2);
    dao.addBrickProperties(bricksToAdd);
    brick1 = dao.getById(brickId1);
    assertNotNull(brick1);
    assertNotNull(brick1.getBrickProperties());
    assertEquals(250000, brick1.getBrickProperties().getTotalSize(), 0.0);
    assertEquals(75000, brick1.getBrickProperties().getFreeSize(), 0.0);
    brick2 = dao.getById(brickId2);
    assertNotNull(brick2);
    assertNotNull(brick2.getBrickProperties());
    assertEquals(275000, brick2.getBrickProperties().getTotalSize(), 0.0);
    assertEquals(175000, brick2.getBrickProperties().getFreeSize(), 0.0);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties) Test(org.junit.Test)

Example 7 with BrickProperties

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

the class GlusterBrickDetailMapperTest method getBrickDetails.

private List<BrickDetails> getBrickDetails(int size, int clientListSize, int memPoolSize) {
    ArrayList<BrickDetails> list = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        BrickDetails details = new BrickDetails();
        BrickProperties props = new BrickProperties();
        props.setBlockSize(14556);
        props.setPid(88888);
        props.setMntOptions("rw");
        details.setBrickProperties(props);
        details.setClients(getClientList(clientListSize));
        details.setMemoryStatus(getMemoryStatus(memPoolSize));
        list.add(details);
    }
    return list;
}
Also used : BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) ArrayList(java.util.ArrayList) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Example 8 with BrickProperties

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

Example 9 with BrickProperties

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

the class GlusterTestHelper method getVolumeAdvancedDetailsEntity.

protected GlusterVolumeAdvancedDetails getVolumeAdvancedDetailsEntity() {
    GlusterVolumeAdvancedDetails entity = mock(GlusterVolumeAdvancedDetails.class);
    BrickDetails brickDetails = mock(BrickDetails.class);
    BrickProperties brickProps = mock(BrickProperties.class);
    when(brickProps.getMntOptions()).thenReturn(BRICK_MNT_OPT);
    when(brickProps.getPort()).thenReturn(BRICK_PORT);
    when(brickDetails.getBrickProperties()).thenReturn(brickProps);
    List<BrickDetails> brickDetailsList = Collections.singletonList(brickDetails);
    when(entity.getBrickDetails()).thenReturn(brickDetailsList);
    return entity;
}
Also used : GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Example 10 with BrickProperties

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

the class GlusterVolumeStatusReturn method getBrickProperties.

private BrickProperties getBrickProperties(GlusterVolumeEntity volume, Map<String, Object> brick) {
    BrickProperties brickProperties = new BrickProperties();
    GlusterBrickEntity brickEntity = getBrickEntity(volume, brick);
    if (brickEntity != null) {
        brickProperties.setBrickId(brickEntity.getId());
    } else {
        log.warn("Could not update brick '{}' as not found in db", brick.get(BRICK));
    }
    if (brick.containsKey(STATUS)) {
        String brickStatus = (String) brick.get(STATUS);
        if (brickStatus.toUpperCase().equals(ONLINE)) {
            brickProperties.setStatus(GlusterStatus.UP);
            boolean portPresent = false;
            if (brick.containsKey(PORT) && StringUtils.isNumeric((String) brick.get(PORT))) {
                brickProperties.setPort(Integer.parseInt((String) brick.get(PORT)));
                portPresent = true;
            }
            if (brick.containsKey(RDMA_PORT) && StringUtils.isNumeric((String) brick.get(RDMA_PORT))) {
                brickProperties.setRdmaPort(Integer.parseInt((String) brick.get(RDMA_PORT)));
                portPresent = true;
            }
            if (!portPresent) {
                // if there's no port registered, then the brick status is down.
                brickProperties.setStatus(GlusterStatus.DOWN);
            }
            if (brick.containsKey(PID) && StringUtils.isNumeric((String) brick.get(PID))) {
                brickProperties.setPid(Integer.parseInt((String) brick.get(PID)));
            }
        } else {
            brickProperties.setStatus(GlusterStatus.DOWN);
        }
    }
    // Fetch the volume status detail
    if (brick.containsKey(DETAIL_SIZE_TOTAL)) {
        brickProperties.setTotalSize(Double.parseDouble((String) brick.get(DETAIL_SIZE_TOTAL)));
    }
    if (brick.containsKey(DETAIL_SIZE_FREE)) {
        brickProperties.setFreeSize(Double.parseDouble((String) brick.get(DETAIL_SIZE_FREE)));
    }
    if (brick.containsKey(DETAIL_DEVICE)) {
        brickProperties.setDevice((String) brick.get(DETAIL_DEVICE));
    }
    if (brick.containsKey(DETAIL_BLOCK_SIZE)) {
        brickProperties.setBlockSize(Integer.parseInt((String) brick.get(DETAIL_BLOCK_SIZE)));
    }
    if (brick.containsKey(DETAIL_MNT_OPTIONS)) {
        brickProperties.setMntOptions((String) brick.get(DETAIL_MNT_OPTIONS));
    }
    if (brick.containsKey(DETAIL_FS_NAME)) {
        brickProperties.setFsName((String) brick.get(DETAIL_FS_NAME));
    }
    return brickProperties;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Aggregations

BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)14 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)9 BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)7 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 Guid (org.ovirt.engine.core.compat.Guid)4 GlusterVolumeAdvancedDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)3 GlusterVolumeSizeInfo (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSizeInfo)1 MallInfo (org.ovirt.engine.core.common.businessentities.gluster.MallInfo)1 MemoryStatus (org.ovirt.engine.core.common.businessentities.gluster.MemoryStatus)1 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)1 BrickCapacityCell (org.ovirt.engine.ui.webadmin.widget.table.column.BrickCapacityCell)1 BrickHealInfoColumn (org.ovirt.engine.ui.webadmin.widget.table.column.BrickHealInfoColumn)1 BrickStatusColumn (org.ovirt.engine.ui.webadmin.widget.table.column.BrickStatusColumn)1