Search in sources :

Example 1 with GlusterServerInfo

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

the class GlusterSyncJob method fetchServers.

private List<GlusterServerInfo> fetchServers(Cluster cluster, VDS upServer, List<VDS> existingServers) {
    // Create a copy of the existing servers as the fetchServer method can potentially remove elements from it
    List<VDS> tempServers = new ArrayList<>(existingServers);
    List<GlusterServerInfo> fetchedServers = fetchServers(upServer, tempServers);
    if (fetchedServers == null) {
        log.error("gluster peer status command failed on all servers of the cluster '{}'." + "Can't refresh it's data at this point.", cluster.getName());
        return null;
    }
    if (fetchedServers.size() == 1 && existingServers.size() > 2) {
        log.info("Gluster servers list fetched from server '{}' has only one server", upServer.getName());
        // It's possible that the server we are using to get list of servers itself has been removed from the
        // cluster, and hence is returning a single server (itself)
        GlusterServerInfo server = fetchedServers.iterator().next();
        if (isSameServer(upServer, server)) {
            // Find a different UP server, and get servers list from it
            tempServers.remove(upServer);
            upServer = getNewUpServer(tempServers, upServer);
            if (upServer == null) {
                log.warn("The only UP server in cluster '{}' seems to have been removed from it using gluster CLI. " + "Can't refresh it's data at this point.", cluster.getName());
                return null;
            }
            fetchedServers = fetchServers(upServer, tempServers);
            if (fetchedServers == null) {
                log.warn("The only UP server in cluster '{}' (or the only one on which gluster peer status " + "command is working) seems to have been removed from it using gluster CLI. " + "Can't refresh it's data at this point.", cluster.getName());
                return null;
            }
        }
    }
    return fetchedServers;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) GlusterServerInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo)

Example 2 with GlusterServerInfo

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

the class InitGlusterCommandHelper method getGlusterPeers.

@SuppressWarnings("unchecked")
private List<GlusterServerInfo> getGlusterPeers(VDS upServer) {
    List<GlusterServerInfo> glusterServers = new ArrayList<>();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterServersList, new VdsIdVDSCommandParametersBase(upServer.getId()));
    if (!returnValue.getSucceeded()) {
        AuditLogable logable = GlusterEventFactory.createEvent(upServer, returnValue);
        auditLogDirector.log(logable, AuditLogType.GLUSTER_SERVERS_LIST_FAILED);
    } else {
        glusterServers = (List<GlusterServerInfo>) returnValue.getReturnValue();
    }
    return glusterServers;
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ArrayList(java.util.ArrayList) GlusterServerInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 3 with GlusterServerInfo

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

the class GlusterSyncJobTest method getFetchedServersList.

private List<GlusterServerInfo> getFetchedServersList() {
    List<GlusterServerInfo> servers = new ArrayList<>();
    servers.add(new GlusterServerInfo(SERVER_ID_1, SERVER_NAME_1, PeerStatus.CONNECTED));
    servers.add(new GlusterServerInfo(SERVER_ID_2, SERVER_NAME_2, PeerStatus.CONNECTED));
    return servers;
}
Also used : ArrayList(java.util.ArrayList) GlusterServerInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo)

Example 4 with GlusterServerInfo

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

the class GetAddedGlusterServersQueryTest method setupExpectedGlusterServersInfo.

private void setupExpectedGlusterServersInfo() {
    expectedServers = new ArrayList<>();
    GlusterServerInfo server = new GlusterServerInfo();
    server.setUuid(server_id3);
    server.setHostnameOrIp(TEST_SERVER3);
    server.setStatus(PeerStatus.CONNECTED);
    expectedServers.add(server);
}
Also used : GlusterServerInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo)

Example 5 with GlusterServerInfo

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

the class GlusterServersListReturn method prepareServerInfo.

private GlusterServerInfo prepareServerInfo(Map<String, Object> map) {
    GlusterServerInfo entity = new GlusterServerInfo();
    entity.setHostnameOrIp(map.get(HOST_NAME).toString());
    entity.setUuid(new Guid(map.get(UUID).toString()));
    String status = map.get(PEER_STATUS).toString();
    entity.setStatus(PeerStatus.valueOf(status));
    return entity;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) GlusterServerInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo)

Aggregations

GlusterServerInfo (org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo)9 ArrayList (java.util.ArrayList)4 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 VdsIdVDSCommandParametersBase (org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase)3 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)3 HashMap (java.util.HashMap)2 Guid (org.ovirt.engine.core.compat.Guid)2 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)2 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 Validate (org.apache.commons.lang.Validate)1 BackendInternal (org.ovirt.engine.core.bll.interfaces.BackendInternal)1 GlusterEventFactory (org.ovirt.engine.core.bll.utils.GlusterEventFactory)1 GlusterUtil (org.ovirt.engine.core.bll.utils.GlusterUtil)1 AuditLogType (org.ovirt.engine.core.common.AuditLogType)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1