Search in sources :

Example 1 with GlusterVolumeAdvancedDetails

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;
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)

Example 2 with GlusterVolumeAdvancedDetails

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));
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) GlusterVolumeAdvancedDetailsParameters(org.ovirt.engine.core.common.queries.gluster.GlusterVolumeAdvancedDetailsParameters) BrickStatisticalQuery(org.ovirt.engine.api.restapi.resource.BrickStatisticalQuery) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with GlusterVolumeAdvancedDetails

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;
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) GlusterVolumeAdvancedDetailsParameters(org.ovirt.engine.core.common.queries.gluster.GlusterVolumeAdvancedDetailsParameters)

Example 4 with GlusterVolumeAdvancedDetails

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);
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) Guid(org.ovirt.engine.core.compat.Guid) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Example 5 with GlusterVolumeAdvancedDetails

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeSizeInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSizeInfo) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) ArrayList(java.util.ArrayList) BrickProperties(org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)

Aggregations

GlusterVolumeAdvancedDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)18 Test (org.junit.Test)6 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)6 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)5 GlusterBrickAdvancedDetails (org.ovirt.engine.api.model.GlusterBrickAdvancedDetails)4 BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)4 Guid (org.ovirt.engine.core.compat.Guid)4 ArrayList (java.util.ArrayList)3 BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)3 GlusterVolumeSizeInfo (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSizeInfo)3 List (java.util.List)2 AbstractQueryTest (org.ovirt.engine.core.bll.AbstractQueryTest)2 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)2 GlusterTaskType (org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType)2 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)2 JobExecutionStatus (org.ovirt.engine.core.common.job.JobExecutionStatus)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 GlusterVolumeAdvancedDetailsParameters (org.ovirt.engine.core.common.queries.gluster.GlusterVolumeAdvancedDetailsParameters)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1