Search in sources :

Example 1 with GeoRepSessionStatus

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

the class VolumeGeoRepListModel method updateActionAvailability.

private void updateActionAvailability(GlusterVolumeEntity volumeEntity) {
    boolean allowNewGeoRepSessionCommand = true;
    boolean allowStartSessionCommand = false;
    boolean allowStopSessionCommand = false;
    boolean allowResumeSessionCommand = false;
    boolean allowPauseSessionCommand = false;
    boolean allowSessionOptionsCommand = false;
    boolean allowRemoveSessionCommand = false;
    boolean allowSessionDetailsCommand = false;
    if (volumeEntity == null) {
        return;
    }
    if (getSelectedItems() != null && getSelectedItems().size() == 1) {
        GlusterGeoRepSession selectedSession = getSelectedItem();
        GeoRepSessionStatus sessionStatus = selectedSession.getStatus();
        allowStartSessionCommand = sessionStatus == GeoRepSessionStatus.CREATED || sessionStatus == GeoRepSessionStatus.STOPPED;
        allowStopSessionCommand = !allowStartSessionCommand;
        allowResumeSessionCommand = sessionStatus == GeoRepSessionStatus.PAUSED;
        allowPauseSessionCommand = sessionStatus == GeoRepSessionStatus.ACTIVE || sessionStatus == GeoRepSessionStatus.INITIALIZING;
        allowSessionOptionsCommand = true;
        allowNewGeoRepSessionCommand = volumeEntity.getStatus() == GlusterStatus.UP;
        allowRemoveSessionCommand = sessionStatus == GeoRepSessionStatus.STOPPED || sessionStatus == GeoRepSessionStatus.CREATED;
        allowSessionDetailsCommand = true;
    }
    getNewSessionCommand().setIsExecutionAllowed(allowNewGeoRepSessionCommand);
    getRemoveSessionCommand().setIsExecutionAllowed(allowRemoveSessionCommand);
    getStartSessionCommand().setIsExecutionAllowed(allowStartSessionCommand);
    getStopSessionCommand().setIsExecutionAllowed(allowStopSessionCommand);
    getPauseSessionCommand().setIsExecutionAllowed(allowPauseSessionCommand);
    getResumeSessionCommand().setIsExecutionAllowed(allowResumeSessionCommand);
    getSessionOptionsCommand().setIsExecutionAllowed(allowSessionOptionsCommand);
    getViewSessionDetailsCommand().setIsExecutionAllowed(allowSessionDetailsCommand);
    getRefreshSessionsCommand().setIsAvailable(true);
}
Also used : GeoRepSessionStatus(org.ovirt.engine.core.common.businessentities.gluster.GeoRepSessionStatus) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 2 with GeoRepSessionStatus

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

the class GlusterGeoRepSyncJob method updateGeoRepStatus.

/**
 * This method updates the status depending on health of individual nodes
 */
private void updateGeoRepStatus(GlusterVolumeEntity volume, GlusterGeoRepSession session) {
    List<HashSet<GeoRepSessionStatus>> list = new ArrayList<>();
    // grouped node status
    int replicaCount = volume.getReplicaCount() == 0 ? 1 : volume.getReplicaCount();
    for (int i = 0; i < volume.getBricks().size(); i = i + replicaCount) {
        HashSet<GeoRepSessionStatus> subVolumeStatusSet = new HashSet<>();
        int j = 0;
        while (j < replicaCount) {
            Guid brickId = volume.getBricks().get(i + j).getId();
            subVolumeStatusSet.add(getStatusForBrickFromSession(session, brickId));
            j++;
        }
        list.add(subVolumeStatusSet);
    }
    session.setStatus(GeoRepSessionStatus.ACTIVE);
    // iterate through grouped status to set consolidated status
    for (HashSet<GeoRepSessionStatus> subVolumeStatusValues : list) {
        if (subVolumeStatusValues.contains(GeoRepSessionStatus.ACTIVE)) {
            // healthy
            continue;
        } else if (subVolumeStatusValues.contains(GeoRepSessionStatus.FAULTY)) {
            session.setStatus(GeoRepSessionStatus.FAULTY);
            // if any one of the sub-volume is faulty, the overall session status if faulty
            return;
        }
        // override status in case of these values
        if (ArrayUtils.contains(overridableStatuses, session.getStatus())) {
            if (subVolumeStatusValues.size() == 1) {
                session.setStatus((GeoRepSessionStatus) subVolumeStatusValues.toArray()[0]);
            } else {
                // if status values in sub-volume are not the same, what do we do?
                // this should not happen, so we'll log it for now
                log.info("Multiple status values found in volume '{}'", session.getMasterVolumeName());
            }
        }
    }
}
Also used : GeoRepSessionStatus(org.ovirt.engine.core.common.businessentities.gluster.GeoRepSessionStatus) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet)

Aggregations

GeoRepSessionStatus (org.ovirt.engine.core.common.businessentities.gluster.GeoRepSessionStatus)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)1 Guid (org.ovirt.engine.core.compat.Guid)1