Search in sources :

Example 1 with GlusterClusterService

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);
        }
    }
}
Also used : GlusterClusterService(org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService) GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType)

Example 2 with GlusterClusterService

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;
}
Also used : GlusterClusterService(org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService) HashMap(java.util.HashMap)

Example 3 with GlusterClusterService

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());
}
Also used : GlusterClusterService(org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService) Test(org.junit.Test)

Example 4 with GlusterClusterService

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());
}
Also used : GlusterClusterService(org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService) Test(org.junit.Test)

Example 5 with GlusterClusterService

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());
        }
    }
}
Also used : GlusterClusterService(org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService) Test(org.junit.Test)

Aggregations

GlusterClusterService (org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService)9 Test (org.junit.Test)4 HashMap (java.util.HashMap)2 ServiceType (org.ovirt.engine.core.common.businessentities.gluster.ServiceType)2 GlusterServiceStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus)1