Search in sources :

Example 6 with GlusterServiceStatus

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

the class GlusterServiceSyncJob method updateClusterServiceStatus.

@SuppressWarnings("serial")
private void updateClusterServiceStatus(final GlusterClusterService clusterService, final GlusterServiceStatus newStatus) {
    final GlusterServiceStatus oldStatus = clusterService.getStatus();
    clusterService.setStatus(newStatus);
    clusterServiceDao.update(clusterService);
    log.info("Status of service type '{}' changed on cluster '{}' from '{}' to '{}'.", clusterService.getServiceType().name(), clusterService.getClusterId(), oldStatus, newStatus);
    Map<String, String> customValues = new HashMap<>();
    customValues.put(GlusterConstants.SERVICE_TYPE, clusterService.getServiceType().name());
    customValues.put(GlusterConstants.OLD_STATUS, oldStatus.getStatusMsg());
    customValues.put(GlusterConstants.NEW_STATUS, newStatus.getStatusMsg());
    logUtil.logAuditMessage(clusterService.getClusterId(), clusterDao.get(clusterService.getClusterId()).getName(), null, null, AuditLogType.GLUSTER_CLUSTER_SERVICE_STATUS_CHANGED, customValues);
}
Also used : GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) HashMap(java.util.HashMap)

Example 7 with GlusterServiceStatus

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

the class GlusterServiceSyncJob method refreshGlusterServices.

@OnTimerMethodAnnotation("refreshGlusterServices")
public void refreshGlusterServices() {
    if (getServiceNameMap().isEmpty()) {
        // Lazy loading. Keeping this out of the constructor/getInstance
        // helps in writing the JUnit test as well.
        populateServiceMap();
    }
    List<Cluster> clusters = clusterDao.getAll();
    for (Cluster cluster : clusters) {
        if (supportsGlusterServicesFeature(cluster)) {
            try {
                List<VDS> serversList = glusterUtil.getAllUpServers(cluster.getId());
                // If there are no servers in the cluster, set the status as unknown
                if (serversList.isEmpty()) {
                    Map<ServiceType, GlusterServiceStatus> statusMap = new HashMap<>();
                    for (ServiceType type : getClusterServiceMap(cluster).keySet()) {
                        statusMap.put(type, GlusterServiceStatus.UNKNOWN);
                    }
                    addOrUpdateClusterServices(cluster, statusMap);
                } else {
                    List<Callable<Map<String, GlusterServiceStatus>>> taskList = createTaskList(serversList);
                    if (taskList != null && taskList.size() > 0) {
                        refreshClusterServices(cluster, ThreadPoolUtil.invokeAll(taskList));
                    }
                }
            } catch (Exception e) {
                log.error("Error while refreshing service statuses of cluster '{}': {}", cluster.getName(), e.getMessage());
                log.debug("Exception", e);
            }
        }
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) HashMap(java.util.HashMap) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Callable(java.util.concurrent.Callable) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 8 with GlusterServiceStatus

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus 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)

Example 9 with GlusterServiceStatus

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

the class GlusterServiceSyncJob method mergeServiceStatusMaps.

private Map<String, GlusterServiceStatus> mergeServiceStatusMaps(List<Map<String, GlusterServiceStatus>> serviceStatusMaps) {
    Map<String, GlusterServiceStatus> mergedServiceStatusMap = new HashMap<>();
    for (Map<String, GlusterServiceStatus> serviceStatusMap : serviceStatusMaps) {
        for (Entry<String, GlusterServiceStatus> entry : serviceStatusMap.entrySet()) {
            String serviceName = entry.getKey();
            GlusterServiceStatus status = entry.getValue();
            GlusterServiceStatus alreadyFoundStatus = mergedServiceStatusMap.get(serviceName);
            if (alreadyFoundStatus == null) {
                mergedServiceStatusMap.put(serviceName, status);
            } else if (alreadyFoundStatus != status && alreadyFoundStatus != GlusterServiceStatus.MIXED) {
                GlusterServiceStatus finalStatus = getFinalStatus(status, alreadyFoundStatus);
                mergedServiceStatusMap.put(serviceName, finalStatus);
            }
        }
    }
    return mergedServiceStatusMap;
}
Also used : GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) HashMap(java.util.HashMap)

Aggregations

GlusterServiceStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus)9 HashMap (java.util.HashMap)7 GlusterServerService (org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService)4 ServiceType (org.ovirt.engine.core.common.businessentities.gluster.ServiceType)4 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 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 GlusterClusterService (org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 GlusterServicesListVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterServicesListVDSParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1 OnTimerMethodAnnotation (org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)1 EntityModelCheckBoxEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)1 EntityModelRadioButtonEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)1 EnumRenderer (org.ovirt.engine.ui.common.widget.renderer.EnumRenderer)1