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