use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServer in project ovirt-engine by oVirt.
the class GlusterVolumesHealInfoReturn method getUnSyncedEntries.
@SuppressWarnings("unchecked")
private void getUnSyncedEntries(Map<String, Object> map) {
Object[] healInfos = (Object[]) map.get(BRICKS);
for (Object healInfoObj : healInfos) {
Map<String, String> healInfo = (Map<String, String>) healInfoObj;
String status = (String) healInfo.get(STATUS);
Integer entries = null;
if (BRICK_STATUS_CONNECTED.equals(status)) {
String hostUuid = (String) healInfo.get(HOST_UUID);
GlusterServer glusterServer = dbUtils.getServerByUuid(Guid.createGuidFromString(hostUuid));
String brickName = (String) healInfo.get(NAME);
String[] brickParts = brickName.split(":", -1);
if (brickParts.length != 2) {
log.warn("Invalid brick representation [{}] in volume volume {}", brickName);
continue;
}
if (glusterServer == null) {
log.warn("Could not fetch heal info for brick '{}' - server uuid '{}' not found", brickName, hostUuid);
continue;
}
GlusterBrickEntity brick = dbUtils.getGlusterBrickByServerUuidAndBrickDir(glusterServer.getId(), brickParts[1]);
entries = Integer.valueOf((String) healInfo.get(NO_OF_ENTRIES));
unSyncedEntries.put(brick.getId(), entries);
}
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServer in project ovirt-engine by oVirt.
the class GlusterVolumesListReturn method getBrick.
private GlusterBrickEntity getBrick(Guid clusterId, Guid volumeId, Map<String, Object> brickInfoMap, int brickOrder) {
String brickName = (String) brickInfoMap.get(NAME);
String[] brickParts = brickName.split(":", -1);
if (brickParts.length != 2) {
throw new RuntimeException("Invalid brick representation [" + brickName + "]");
}
String hostUuid = (String) brickInfoMap.get(HOST_UUID);
String brickDir = brickParts[1];
String hostAddress = brickParts[0];
boolean isArbiter = brickInfoMap.containsKey(IS_ARBITER) ? Boolean.valueOf(brickInfoMap.get(IS_ARBITER).toString()) : Boolean.FALSE;
GlusterServer glusterServer = dbUtils.getServerByUuid(Guid.createGuidFromString(hostUuid));
if (glusterServer == null) {
log.warn("Could not add brick '{}' to volume '{}' - server uuid '{}' not found in cluster '{}'", brickName, volumeId, hostUuid, clusterId);
return null;
}
VdsStatic server = DbFacade.getInstance().getVdsStaticDao().get(glusterServer.getId());
String networkAddress = null;
Guid networkId = null;
if (!server.getHostName().equals(hostAddress)) {
networkAddress = hostAddress;
Network network = getGlusterNetworkId(server, networkAddress);
if (network != null) {
networkId = network.getId();
} else {
log.warn("Could not associate brick '{}' of volume '{}' with correct network as no gluster network found in cluster '{}'", brickName, volumeId, clusterId);
}
}
return getBrickEntity(clusterId, volumeId, brickOrder, server, brickDir, networkAddress, networkId, isArbiter);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServer 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.GlusterServer in project ovirt-engine by oVirt.
the class GlusterServerDaoTest method testUpdateGlusterServerUuid.
@Test
public void testUpdateGlusterServerUuid() {
GlusterServer entityToUpdate = new GlusterServer(FixturesTool.GLUSTER_BRICK_SERVER1, FixturesTool.GLUSTER_SERVER_UUID_NEW);
dao.update(entityToUpdate);
GlusterServer entity = dao.getByServerId(FixturesTool.GLUSTER_BRICK_SERVER1);
assertNotNull(entity);
assertEquals(FixturesTool.GLUSTER_SERVER_UUID_NEW, entity.getGlusterServerUuid());
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServer in project ovirt-engine by oVirt.
the class GlusterServerDaoTest method testRemoveByGlusterServerUuid.
@Test
public void testRemoveByGlusterServerUuid() {
dao.removeByGlusterServerUuid(FixturesTool.GLUSTER_SERVER_UUID1);
GlusterServer entity = dao.getByGlusterServerUuid(FixturesTool.GLUSTER_SERVER_UUID1);
assertNull(entity);
}
Aggregations