Search in sources :

Example 91 with GlusterBrickEntity

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

the class GetGlusterBrickByIdQueryTest method setupExpectedBrick.

private void setupExpectedBrick() {
    expected = new GlusterBrickEntity();
    expected.setId(Guid.newGuid());
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)

Example 92 with GlusterBrickEntity

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

the class StartRemoveGlusterVolumeBricksCommandTest method getBricks.

private List<GlusterBrickEntity> getBricks(Guid volumeId, int max) {
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    for (Integer i = 0; i < max; i++) {
        GlusterBrickEntity brick1 = new GlusterBrickEntity();
        brick1.setVolumeId(volumeId);
        brick1.setServerName("server1");
        brick1.setStatus(GlusterStatus.UP);
        brick1.setBrickDirectory("/tmp/s" + i.toString());
        bricks.add(brick1);
    }
    return bricks;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList)

Example 93 with GlusterBrickEntity

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

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

Example 95 with GlusterBrickEntity

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

the class GlusterVolumesHealInfoReturn method getUnSyncedEntries.

@SuppressWarnings("unchecked")
private void getUnSyncedEntries(Map<String, Object> map) {
    Object[] healInfos = (Object[]) map.get(BRICKS);
    for (Object healInfoObj : healInfos) {
        Map<String, String> healInfo = (Map<String, String>) healInfoObj;
        String status = (String) healInfo.get(STATUS);
        Integer entries = null;
        if (BRICK_STATUS_CONNECTED.equals(status)) {
            String hostUuid = (String) healInfo.get(HOST_UUID);
            GlusterServer glusterServer = dbUtils.getServerByUuid(Guid.createGuidFromString(hostUuid));
            String brickName = (String) healInfo.get(NAME);
            String[] brickParts = brickName.split(":", -1);
            if (brickParts.length != 2) {
                log.warn("Invalid brick representation [{}] in volume volume {}", brickName);
                continue;
            }
            if (glusterServer == null) {
                log.warn("Could not fetch heal info for brick '{}' - server uuid '{}' not found", brickName, hostUuid);
                continue;
            }
            GlusterBrickEntity brick = dbUtils.getGlusterBrickByServerUuidAndBrickDir(glusterServer.getId(), brickParts[1]);
            entries = Integer.valueOf((String) healInfo.get(NO_OF_ENTRIES));
            unSyncedEntries.put(brick.getId(), entries);
        }
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) Map(java.util.Map) HashMap(java.util.HashMap)

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