Search in sources :

Example 11 with GlusterServer

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);
        }
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with GlusterServer

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);
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) Network(org.ovirt.engine.core.common.businessentities.network.Network) Guid(org.ovirt.engine.core.compat.Guid)

Example 13 with GlusterServer

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()));
        }
    }
}
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 14 with GlusterServer

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());
}
Also used : GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) Test(org.junit.Test)

Example 15 with GlusterServer

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);
}
Also used : GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) Test(org.junit.Test)

Aggregations

GlusterServer (org.ovirt.engine.core.common.businessentities.gluster.GlusterServer)19 Test (org.junit.Test)8 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)3 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)2 Guid (org.ovirt.engine.core.compat.Guid)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters)1 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)1 GlusterGeoRepSessionDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionDetails)1 GlusterStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)1 GlusterVolumeTaskStatusForHost (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusForHost)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)1 GlusterDBUtils (org.ovirt.engine.core.dao.gluster.GlusterDBUtils)1