use of org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService in project ovirt-engine by oVirt.
the class GlusterServiceSyncJob method addOrUpdateClusterServices.
private void addOrUpdateClusterServices(Cluster cluster, Map<ServiceType, GlusterServiceStatus> fetchedClusterServiceStatusMap) {
Map<ServiceType, GlusterClusterService> existingClusterServiceMap = getClusterServiceMap(cluster);
for (Entry<ServiceType, GlusterServiceStatus> entry : fetchedClusterServiceStatusMap.entrySet()) {
ServiceType type = entry.getKey();
GlusterServiceStatus status = entry.getValue();
GlusterClusterService existingClusterService = existingClusterServiceMap.get(type);
if (existingClusterService == null) {
existingClusterServiceMap.put(type, addClusterServiceToDb(cluster, type, status));
} else if (existingClusterService.getStatus() != status) {
updateClusterServiceStatus(existingClusterService, status);
}
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService in project ovirt-engine by oVirt.
the class GlusterServiceSyncJob method addClusterServiceToDb.
@SuppressWarnings("serial")
private GlusterClusterService addClusterServiceToDb(Cluster cluster, final ServiceType serviceType, final GlusterServiceStatus status) {
GlusterClusterService clusterService = new GlusterClusterService();
clusterService.setClusterId(cluster.getId());
clusterService.setServiceType(serviceType);
clusterService.setStatus(status);
clusterServiceDao.save(clusterService);
log.info("Service type '{}' not mapped to cluster '{}'. Mapped it now.", serviceType, cluster.getName());
Map<String, String> customValues = new HashMap<>();
customValues.put(GlusterConstants.SERVICE_TYPE, serviceType.name());
customValues.put(GlusterConstants.NEW_STATUS, status.getStatusMsg());
logUtil.logAuditMessage(clusterService.getClusterId(), clusterDao.get(clusterService.getClusterId()).getName(), null, null, AuditLogType.GLUSTER_CLUSTER_SERVICE_STATUS_ADDED, customValues);
return clusterService;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService in project ovirt-engine by oVirt.
the class GlusterClusterServiceDaoTest method testUpdate.
@Test
public void testUpdate() {
GlusterClusterService service = dao.getByClusterIdAndServiceType(CLUSTER_ID, ServiceType.GLUSTER);
assertNotNull(service);
assertEquals(GlusterServiceStatus.RUNNING, service.getStatus());
service.setStatus(GlusterServiceStatus.STOPPED);
dao.update(service);
service = dao.getByClusterIdAndServiceType(CLUSTER_ID, ServiceType.GLUSTER);
assertNotNull(service);
assertEquals(GlusterServiceStatus.STOPPED, service.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService in project ovirt-engine by oVirt.
the class GlusterClusterServiceDaoTest method testSave.
@Test
public void testSave() {
List<GlusterClusterService> services = dao.getByClusterId(NEW_CLUSTER_ID);
assertNotNull(services);
assertEquals(0, services.size());
insertTestService(NEW_CLUSTER_ID, ServiceType.SMB, GlusterServiceStatus.MIXED);
services = dao.getByClusterId(NEW_CLUSTER_ID);
assertNotNull(services);
assertEquals(1, services.size());
GlusterClusterService service = services.get(0);
assertEquals(ServiceType.SMB, service.getServiceType());
assertEquals(GlusterServiceStatus.MIXED, service.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService in project ovirt-engine by oVirt.
the class GlusterClusterServiceDaoTest method testGetByClusterId.
@Test
public void testGetByClusterId() {
List<GlusterClusterService> services = dao.getByClusterId(CLUSTER_ID);
assertNotNull(services);
assertEquals(2, services.size());
for (GlusterClusterService service : services) {
switch(service.getServiceType()) {
case GLUSTER:
assertEquals(GlusterServiceStatus.RUNNING, service.getStatus());
break;
case GLUSTER_SWIFT:
assertEquals(GlusterServiceStatus.STOPPED, service.getStatus());
break;
default:
fail("Unexpected service type: " + service.getServiceType());
}
}
}
Aggregations