Search in sources :

Example 1 with GlusterStatus

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

the class BrickStatusColumn method getTooltip.

@Override
public SafeHtml getTooltip(GlusterBrickEntity brick) {
    GlusterStatus status = brick.getStatus();
    String tooltip = null;
    switch(status) {
        case DOWN:
            tooltip = constants.down();
            break;
        case UP:
            tooltip = constants.up();
            break;
        case UNKNOWN:
            tooltip = constants.unknown();
            break;
        default:
            tooltip = constants.down();
    }
    if (brick.getStatus() != GlusterStatus.DOWN && brick.getUnSyncedEntries() != null && brick.getUnSyncedEntries() > 0) {
        tooltip = messages.brickStatusWithUnSyncedEntriesPresent(tooltip, brick.getUnSyncedEntries());
    }
    return SafeHtmlUtils.fromSafeConstant(tooltip);
}
Also used : GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)

Example 2 with GlusterStatus

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

the class GlusterBrickEventSubscriber method processEvent.

@Override
public void processEvent(GlusterEvent event) {
    if (event == null) {
        log.debug("No event to process!");
        return;
    }
    GlusterServer glusterServer = glusterServerDao.getByGlusterServerUuid(Guid.createGuidFromString(event.getNodeId()));
    if (glusterServer == null) {
        log.debug("Could not determine gluster server from event '{}'", event);
        return;
    }
    VdsStatic host = vdsStaticDao.get(glusterServer.getId());
    if (host == null) {
        log.debug("No host corresponding to gluster server in '{}'", event);
        return;
    }
    GlusterVolumeEntity vol = glusterVolumeDao.getByName(host.getClusterId(), (String) event.getMessage().get("volume"));
    if (vol == null) {
        return;
    }
    if (event.getEvent().equalsIgnoreCase(EVENT_BRICK_DISCONNECTED) || event.getEvent().equalsIgnoreCase(EVENT_BRICK_CONNECTED)) {
        // get brick
        GlusterStatus status = event.getEvent().equalsIgnoreCase(EVENT_BRICK_DISCONNECTED) ? GlusterStatus.DOWN : GlusterStatus.UP;
        String path = (String) event.getMessage().get(BRICK);
        String peer = (String) event.getMessage().get(PEER);
        List<VdsStatic> vdsList = vdsStaticDao.getAllForCluster(host.getClusterId());
        VdsStatic vds = vdsList.stream().filter(v -> v.getName().equals(peer) || interfaceDao.getAllInterfacesForVds(v.getId()).stream().anyMatch(iface -> iface.getIpv4Address().equals(peer))).findFirst().orElse(null);
        GlusterBrickEntity brick = vds != null ? glusterBrickDao.getBrickByServerIdAndDirectory(vds.getId(), path) : null;
        if (brick != null) {
            glusterBrickDao.updateBrickStatus(brick.getId(), status);
            logBrickStatusChange(vol, status, brick);
        } else {
            // call sync to force updation
            log.debug("Forcing sync as brick event '{}' received that could not be resolved to brick", event);
            backend.runInternalAction(ActionType.RefreshGlusterVolumeDetails, new GlusterVolumeParameters(vol.getId()));
        }
    }
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) GlusterVolumeParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters)

Example 3 with GlusterStatus

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

the class GlusterVolumeUtils method getVolumeStatus.

public static VolumeStatus getVolumeStatus(GlusterVolumeEntity volume) {
    GlusterStatus status = volume.getStatus();
    int count = 0;
    int brickCount = volume.getBricks().size();
    switch(status) {
        case DOWN:
            return VolumeStatus.DOWN;
        case UP:
            count = countDownBricks(volume);
            if (count == 0) {
                return VolumeStatus.UP;
            } else if (count < brickCount) {
                return VolumeStatus.SOME_BRICKS_DOWN;
            } else {
                return VolumeStatus.ALL_BRICKS_DOWN;
            }
        default:
            return VolumeStatus.DOWN;
    }
}
Also used : GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)

Example 4 with GlusterStatus

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

the class GlusterVolumeEngineDao method processVolumeStatus.

private InventoryStatus processVolumeStatus(InventoryStatus summary, String status, int bricksNotUp) {
    summary.addCount();
    GlusterStatus volumeStatus = GlusterStatus.valueOf(status);
    if (GlusterStatus.UP == volumeStatus && bricksNotUp > 0) {
        summary.addStatus(GlusterStatus.WARNING.name().toLowerCase());
    } else {
        summary.addStatus(volumeStatus.name().toLowerCase());
    }
    return summary;
}
Also used : GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)

Example 5 with GlusterStatus

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

the class BrickStatusCell method render.

@Override
public void render(Context context, GlusterBrickEntity brick, SafeHtmlBuilder sb, String id) {
    // Nothing to render if no brick is provided:
    if (brick == null) {
        return;
    }
    // Find the image corresponding to the status of the brick:
    GlusterStatus status = brick.getStatus();
    ImageResource statusImage = null;
    switch(status) {
        case DOWN:
            statusImage = resources.downImage();
            break;
        case UP:
            statusImage = resources.upImage();
            break;
        case UNKNOWN:
            statusImage = resources.questionMarkImage();
            break;
        default:
            statusImage = resources.downImage();
    }
    // Generate the HTML for the image:
    SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML());
    if (brick.getUnSyncedEntries() != null && brick.getUnSyncedEntries() > 0) {
        SafeHtml alertImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.alertImage()).getHTML());
        sb.append(templates.statusWithAlertTemplate(statusImageHtml, alertImageHtml, id, status.toString()));
    } else {
        sb.append(templates.statusTemplate(statusImageHtml, id, status.toString()));
    }
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)

Aggregations

GlusterStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)5 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 GlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters)1 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)1 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)1 GlusterServer (org.ovirt.engine.core.common.businessentities.gluster.GlusterServer)1 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)1