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());
}
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;
}
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;
}
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;
}
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);
}
}
}
Aggregations