use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails in project ovirt-engine by oVirt.
the class GetGlusterVolumeAdvancedDetailsQuery method getServiceInfo.
/**
* To get the service info, the UI will not pass the volume name, in that case engine will fetch the volume name in
* the database.
*
* NFS volume name should be passed to get nfs service details, similarly REPLICATE/DISTRIBUTED_REPLICATE volume
* name should be passed as an argument to get the SHD details.
*
* So to get volume name from database engine will do the following steps.<br>
* 1. First fetch NFS + REPLICATE/DISTRIBUTED_REPLICATE volume name<br>
* 2. If not found then fetch the nfs volume name and then fetch REPLICATE/DISTRIBUTED_REPLICATE volume name<br>
* 3. The VDS query will be called twice, one with nfs volume name and another with replicate volume name, finally
* combine the service details.
*/
private GlusterVolumeAdvancedDetails getServiceInfo() {
// Get Nfs + Replicated/Distributed Replicate volume.
GlusterVolumeEntity nfsReplicateVolume = getNfsReplicateVolume(clusterId);
if (nfsReplicateVolume != null) {
return fetchAdvancedDetails(nfsReplicateVolume.getName());
}
// Get Nfs enabled volume
GlusterVolumeEntity nfsVolume = getNfsVolume(clusterId);
// Get Replicated volume
GlusterVolumeEntity replicateVolume = getReplicateVolume(clusterId);
// If there is no volume present in the cluster, then return empty Volume Advanced Details
if (nfsVolume == null && replicateVolume == null) {
log.error("To get service details, no Nfs or Replicated volumes found in the cluster.");
return new GlusterVolumeAdvancedDetails();
}
GlusterVolumeAdvancedDetails nfsServiceInfo = null;
GlusterVolumeAdvancedDetails shdServiceInfo = null;
if (nfsVolume != null) {
nfsServiceInfo = fetchAdvancedDetails(nfsVolume.getName());
}
if (replicateVolume != null) {
shdServiceInfo = fetchAdvancedDetails(replicateVolume.getName());
}
if (nfsServiceInfo == null && shdServiceInfo != null) {
return shdServiceInfo;
} else if (nfsServiceInfo != null && shdServiceInfo != null) {
// combine the Nfs + Shd status
nfsServiceInfo.getServiceInfo().addAll(shdServiceInfo.getServiceInfo());
}
return nfsServiceInfo;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails in project ovirt-engine by oVirt.
the class BackendGlusterBrickResource method getStatisticsResource.
@Override
public StatisticsResource getStatisticsResource() {
EntityIdResolver<Guid> resolver = new QueryIdResolver<Guid>(QueryType.GetGlusterBrickById, IdQueryParameters.class) {
@Override
public GlusterBrickEntity lookupEntity(Guid id) throws BackendFailureException {
GlusterBrickEntity brickEntity = getEntity(GlusterBrickEntity.class, QueryType.GetGlusterBrickById, new IdQueryParameters(id), null, true);
GlusterVolumeEntity volumeEntity = getEntity(GlusterVolumeEntity.class, QueryType.GetGlusterVolumeById, new IdQueryParameters(brickEntity.getVolumeId()), null, true);
GlusterVolumeAdvancedDetails detailsEntity = getEntity(GlusterVolumeAdvancedDetails.class, QueryType.GetGlusterVolumeAdvancedDetails, new GlusterVolumeAdvancedDetailsParameters(volumeEntity.getClusterId(), volumeEntity.getId(), brickEntity.getId(), true), null, true);
brickEntity.setBrickDetails(detailsEntity.getBrickDetails().get(0));
return brickEntity;
}
};
BrickStatisticalQuery query = new BrickStatisticalQuery(resolver, newModel(id));
return inject(new BackendStatisticsResource<>(GlusterBrickEntity.class, guid, query));
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails in project ovirt-engine by oVirt.
the class BackendGlusterBricksResource method populateAdvancedDetails.
protected GlusterBrick populateAdvancedDetails(GlusterBrick model, GlusterBrickEntity entity) {
GlusterVolumeEntity volumeEntity = getEntity(GlusterVolumeEntity.class, QueryType.GetGlusterVolumeById, new IdQueryParameters(entity.getVolumeId()), null, true);
GlusterVolumeAdvancedDetails detailsEntity = getEntity(GlusterVolumeAdvancedDetails.class, QueryType.GetGlusterVolumeAdvancedDetails, new GlusterVolumeAdvancedDetailsParameters(volumeEntity.getClusterId(), volumeEntity.getId(), entity.getId(), true), null, true);
model = getMapper(GlusterVolumeAdvancedDetails.class, GlusterBrick.class).map(detailsEntity, model);
return model;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails 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.GlusterVolumeAdvancedDetails 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