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);
}
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);
}
}
}
}
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;
}
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;
}
Aggregations