Search in sources :

Example 16 with GlusterVolumeEntity

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

the class GlusterGeoRepSyncJob method updateDiscoveredSessions.

private void updateDiscoveredSessions(Cluster cluster, Map<String, GlusterGeoRepSession> sessionsMap, GlusterVolumeEntity volume) {
    removeDeletedSessions(cluster, sessionsMap, volume);
    // for each geo-rep session, find session in database and update details.
    for (GlusterGeoRepSession session : sessionsMap.values()) {
        GlusterVolumeEntity masterVolume = getVolume(cluster, session.getMasterVolumeName());
        if (masterVolume == null) {
            log.info("Could not find corresponding volume for geo-rep session '{}' and volume '{}' - status will not be updated.", session.getSessionKey(), session.getMasterVolumeName());
        } else {
            session.setMasterVolumeId(masterVolume.getId());
            // update consolidated status
            updateGeoRepStatus(masterVolume, session);
        }
        // check if session exists in database
        GlusterGeoRepSession sessionInDb = geoRepDao.getGeoRepSession(session.getSessionKey());
        if (sessionInDb == null) {
            // save the session in database first.
            log.debug("detected new geo-rep session '{}' for volume '{}'", session.getSessionKey(), session.getMasterVolumeName());
            if (Guid.isNullOrEmpty(session.getId())) {
                session.setId(Guid.newGuid());
            }
            if (session.getSlaveNodeUuid() == null && session.getSlaveVolumeId() == null) {
                updateSlaveNodeAndVolumeId(session);
            }
            geoRepDao.save(session);
            logGeoRepMessage(AuditLogType.GLUSTER_GEOREP_SESSION_DETECTED_FROM_CLI, cluster, session);
        } else {
            // if retrieved session does not have the slave uuid's set
            if (session.getSlaveNodeUuid() == null && session.getSlaveVolumeId() == null) {
                // set it from the one in db
                session.setSlaveNodeUuid(sessionInDb.getSlaveNodeUuid());
                session.setSlaveVolumeId(sessionInDb.getSlaveVolumeId());
            }
            // if even the updated session has no slave ids, try setting it by querying db
            if (session.getSlaveNodeUuid() == null && session.getSlaveVolumeId() == null) {
                updateSlaveNodeAndVolumeId(session);
            }
            session.setId(sessionInDb.getId());
            geoRepDao.updateSession(session);
        }
        updateSessionDetailsInDB(session);
        updateDiscoveredSessionConfig(cluster, session);
    }
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 17 with GlusterVolumeEntity

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

the class GlusterHostValidator method checkGlusterQuorum.

public List<String> checkGlusterQuorum(Cluster cluster, Iterable<Guid> selectedHostIdsForMaintenance) {
    List<String> volumesWithoutQuorum = new ArrayList<>();
    if (cluster.supportsGlusterService()) {
        List<GlusterBrickEntity> bricksGoingToMaintenance = new ArrayList<>();
        for (Guid serverId : selectedHostIdsForMaintenance) {
            bricksGoingToMaintenance.addAll(brickDao.getGlusterVolumeBricksByServerId(serverId));
        }
        List<GlusterVolumeEntity> volumesInCluster = volumeDao.getByClusterId(cluster.getId());
        volumesWithoutQuorum = volumesInCluster.stream().filter(volume -> volume.getStatus() == GlusterStatus.UP && volume.getVolumeType().isReplicatedType() && !isQuorumMet(volume, bricksGoingToMaintenance)).map(v -> v.getName()).collect(Collectors.toList());
    }
    return volumesWithoutQuorum;
}
Also used : GlusterBrickDao(org.ovirt.engine.core.dao.gluster.GlusterBrickDao) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Inject(javax.inject.Inject) GlusterConstants(org.ovirt.engine.core.common.constants.gluster.GlusterConstants) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Map(java.util.Map) GlusterVolumeDao(org.ovirt.engine.core.dao.gluster.GlusterVolumeDao) Validate(org.apache.commons.lang.Validate) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 18 with GlusterVolumeEntity

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

the class AddBricksToGlusterVolumeCommand method executeCommand.

@Override
protected void executeCommand() {
    final List<GlusterBrickEntity> bricksList = getParameters().getBricks();
    GlusterVolumeEntity volumeBeforeBrickAdd = getGlusterVolume();
    // Add bricks in a single transaction
    TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
        addGlusterVolumeBricks(bricksList, getParameters().getReplicaCount(), getParameters().getStripeCount(), getParameters().isForce());
        return null;
    });
    if (getGlusterVolume().getIsGeoRepMaster() || getGlusterVolume().getIsGeoRepSlave()) {
        Set<Guid> newServerIds = findNewServers(bricksList, volumeBeforeBrickAdd);
        if (!newServerIds.isEmpty()) {
            postAddBrickHandleGeoRepCase(bricksList, newServerIds);
        }
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Guid(org.ovirt.engine.core.compat.Guid)

Example 19 with GlusterVolumeEntity

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

the class AddBricksToGlusterVolumeCommand method getSlaveNodesSet.

private Set<Guid> getSlaveNodesSet(GlusterGeoRepSession currentSession) {
    Set<Guid> slaveNodesSet = new HashSet<>();
    GlusterVolumeEntity sessionSlaveVolume = glusterVolumeDao.getById(currentSession.getSlaveVolumeId());
    for (GlusterBrickEntity currentSlaveBrick : sessionSlaveVolume.getBricks()) {
        slaveNodesSet.add(currentSlaveBrick.getServerId());
    }
    return slaveNodesSet;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet)

Example 20 with GlusterVolumeEntity

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

the class CommitRemoveGlusterVolumeBricksCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterVolumeEntity volume = getGlusterVolume();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.CommitRemoveGlusterVolumeBricks, new GlusterVolumeRemoveBricksVDSParameters(getUpServer().getId(), volume.getName(), getParameters().getBricks()));
    setSucceeded(returnValue.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
    addCustomValue(GlusterConstants.NO_OF_BRICKS, String.valueOf(getParameters().getBricks().size()));
    endStepJobCommitted();
    glusterDBUtils.removeBricksFromVolumeInDb(volume, getParameters().getBricks(), getParameters().getReplicaCount());
    glusterVolumeDao.updateVolumeTask(volume.getId(), null);
    releaseVolumeLock();
    getReturnValue().setActionReturnValue(returnValue.getReturnValue());
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeRemoveBricksVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeRemoveBricksVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)220 ArrayList (java.util.ArrayList)57 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)49 Test (org.junit.Test)47 Guid (org.ovirt.engine.core.compat.Guid)30 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)30 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)26 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)20 VDS (org.ovirt.engine.core.common.businessentities.VDS)19 HashMap (java.util.HashMap)16 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)16 List (java.util.List)15 Map (java.util.Map)15 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)15 ActionType (org.ovirt.engine.core.common.action.ActionType)13 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)13 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)13 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)13 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)12 GlusterTaskType (org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType)12