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);
}
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()));
}
}
}
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;
}
}
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;
}
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()));
}
}
Aggregations