Search in sources :

Example 21 with GlusterServerService

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

the class GlusterServerServiceDaoTest method testGetByClusterId.

@Test
public void testGetByClusterId() {
    List<GlusterServerService> services = dao.getByClusterId(CLUSTER_ID);
    assertNotNull(services);
    assertEquals(2, services.size());
    for (GlusterServerService service : services) {
        Guid serverId = service.getServerId();
        if (FixturesTool.GLUSTER_BRICK_SERVER1.equals(serverId)) {
            verifyServiceOnServer1(service);
        } else if (FixturesTool.VDS_GLUSTER_SERVER2.equals(serverId)) {
            verifyServiceOnServer2(service);
        } else {
            fail("Unexpected server id: " + service.getServerId());
        }
    }
}
Also used : GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 22 with GlusterServerService

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

the class GlusterServiceSyncJob method refreshServerServices.

/**
 * Refreshes statuses of services on given server, and returns a map of service name to it's status
 *
 * @param server
 *            The server whose services statuses are to be refreshed
 * @return map of service name to it's status
 */
@SuppressWarnings({ "unchecked", "serial" })
private Map<String, GlusterServiceStatus> refreshServerServices(final VDS server) {
    Map<String, GlusterServiceStatus> serviceStatusMap = new HashMap<>();
    if (server.getStatus() != VDSStatus.Up) {
        // Update the status of all the services of stopped server in single transaction
        TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> updateGlusterServicesStatusForStoppedServer(server));
    } else {
        acquireLock(server.getId());
        try {
            Map<Guid, GlusterServerService> existingServicesMap = getExistingServicesMap(server);
            List<GlusterServerService> servicesToUpdate = new ArrayList<>();
            VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterServicesList, new GlusterServicesListVDSParameters(server.getId(), getServiceNameMap().keySet()));
            if (!returnValue.getSucceeded()) {
                log.error("Couldn't fetch services statuses from server '{}', error: {}! " + "Updating statuses of all services on this server to UNKNOWN.", server.getHostName(), returnValue.getVdsError().getMessage());
                logUtil.logServerMessage(server, AuditLogType.GLUSTER_SERVICES_LIST_FAILED);
                return updateStatusToUnknown(existingServicesMap.values());
            }
            for (final GlusterServerService fetchedService : (List<GlusterServerService>) returnValue.getReturnValue()) {
                serviceStatusMap.put(fetchedService.getServiceName(), fetchedService.getStatus());
                GlusterServerService existingService = existingServicesMap.get(fetchedService.getServiceId());
                if (existingService == null) {
                    insertServerService(server, fetchedService);
                } else {
                    final GlusterServiceStatus oldStatus = existingService.getStatus();
                    final GlusterServiceStatus newStatus = fetchedService.getStatus();
                    if (oldStatus != newStatus) {
                        log.info("Status of service '{}' on server '{}' changed from '{}' to '{}'. Updating in engine now.", fetchedService.getServiceName(), server.getHostName(), oldStatus.name(), newStatus.name());
                        Map<String, String> customValues = new HashMap<>();
                        customValues.put(GlusterConstants.SERVICE_NAME, fetchedService.getServiceName());
                        customValues.put(GlusterConstants.OLD_STATUS, oldStatus.getStatusMsg());
                        customValues.put(GlusterConstants.NEW_STATUS, newStatus.getStatusMsg());
                        logUtil.logAuditMessage(server.getClusterId(), server.getClusterName(), null, server, AuditLogType.GLUSTER_SERVER_SERVICE_STATUS_CHANGED, customValues);
                        existingService.setStatus(fetchedService.getStatus());
                        servicesToUpdate.add(existingService);
                    }
                }
            }
            if (servicesToUpdate.size() > 0) {
                serverServiceDao.updateAll(servicesToUpdate);
            }
        } finally {
            releaseLock(server.getId());
        }
    }
    return serviceStatusMap;
}
Also used : HashMap(java.util.HashMap) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) ArrayList(java.util.ArrayList) List(java.util.List) GlusterServicesListVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterServicesListVDSParameters)

Example 23 with GlusterServerService

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

the class GlusterServiceSyncJob method updateGlusterServicesStatusForStoppedServer.

private Map<String, GlusterServiceStatus> updateGlusterServicesStatusForStoppedServer(VDS server) {
    Map<String, GlusterServiceStatus> retMap = new HashMap<>();
    List<GlusterServerService> serviceList = serverServiceDao.getByServerId(server.getId());
    for (GlusterServerService service : serviceList) {
        retMap.put(service.getServiceName(), GlusterServiceStatus.UNKNOWN);
        service.setStatus(GlusterServiceStatus.UNKNOWN);
        serverServiceDao.update(service);
    }
    return retMap;
}
Also used : GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) HashMap(java.util.HashMap) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService)

Aggregations

GlusterServerService (org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService)23 Guid (org.ovirt.engine.core.compat.Guid)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 Test (org.junit.Test)4 GlusterServiceStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus)4 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)4 List (java.util.List)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 GlusterService (org.ovirt.engine.core.common.businessentities.gluster.GlusterService)2 ServiceType (org.ovirt.engine.core.common.businessentities.gluster.ServiceType)2 GlusterServiceVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterServiceVDSParameters)2 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)2 Context (com.google.gwt.cell.client.Cell.Context)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 Column (com.google.gwt.user.cellview.client.Column)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1