Search in sources :

Example 1 with StorageDomainDR

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

the class GlusterGeoRepSyncJob method removeDeletedSessions.

private void removeDeletedSessions(Cluster cluster, final Map<String, GlusterGeoRepSession> sessionsMap, GlusterVolumeEntity volume) {
    List<GlusterGeoRepSession> sessionsInDb;
    if (volume != null) {
        // syncing for a specific volume, so retrieve only that volume's sessions
        sessionsInDb = geoRepDao.getGeoRepSessions(volume.getId());
    } else {
        sessionsInDb = geoRepDao.getGeoRepSessionsInCluster(cluster.getId());
    }
    if (CollectionUtils.isEmpty(sessionsInDb)) {
        return;
    }
    List<GlusterGeoRepSession> sessionsToDelete = new ArrayList<>();
    for (GlusterGeoRepSession grepSession : sessionsInDb) {
        if (sessionsMap.get(grepSession.getSessionKey()) == null) {
            sessionsToDelete.add(grepSession);
        }
    }
    for (final GlusterGeoRepSession session : sessionsToDelete) {
        log.info("geo-rep session '{}' detected removed for volume '{}'", session.getSessionKey(), session.getMasterVolumeName());
        // check if geo-rep session is reference by a DR schedule
        List<StorageDomainDR> storageDRs = storageDomainDRDao.getWithGeoRepSession(session.getId());
        for (StorageDomainDR storageDR : storageDRs) {
            // delete and log deletion of storage DR - the schedule needs to be deleted as well
            log.info("Geo-rep session '{}'- for volume '{}' that has been deleted from CLI " + "has associated DR sync schedules which will be removed", session.getSessionKey(), session.getMasterVolumeName());
            if (storageDR.getJobId() != null) {
                schedulerUtil.deleteJob(storageDR.getJobId());
            }
            storageDomainDRDao.remove(storageDR.getStorageDomainId(), storageDR.getGeoRepSessionId());
            StorageDomainStatic storageDomain = storageDomainStaticDao.get(storageDR.getStorageDomainId());
            Map<String, String> customValues = new HashMap<>();
            customValues.put("storageDomainName", storageDomain.getName());
            customValues.put("geoRepSessionKey", session.getSessionKey());
            logGeoRepMessage(AuditLogType.STORAGE_DOMAIN_DR_DELETED, cluster, customValues);
        }
        geoRepDao.remove(session.getId());
        logGeoRepMessage(AuditLogType.GLUSTER_GEOREP_SESSION_DELETED_FROM_CLI, cluster, session);
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomainDR(org.ovirt.engine.core.common.businessentities.StorageDomainDR) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 2 with StorageDomainDR

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

the class ScheduleGlusterStorageSyncCommand method executeCommand.

@Override
protected void executeCommand() {
    StorageDomainDR storageDomainDR = storageDomainDRDao.get(getParameters().getStorageDomainId(), getParameters().getGeoRepSessionId());
    if (storageDomainDR == null) {
        storageDomainDR = new StorageDomainDR();
        storageDomainDR.setStorageDomainId(getParameters().getStorageDomainId());
        storageDomainDR.setGeoRepSessionId(getParameters().getGeoRepSessionId());
    } else if (storageDomainDR.getJobId() != null) {
        // delete existing job
        schedulerUtil.deleteJob(storageDomainDR.getJobId());
    }
    if (getParameters().getSchedule().getFrequency() != StorageSyncSchedule.Frequency.NONE) {
        String jobId = schedulerUtil.scheduleACronJob(new GlusterStorageDomainDRSyncJob(), "syncData", new Class[] { String.class, String.class }, new Object[] { getParameters().getStorageDomainId().toString(), getParameters().getGeoRepSessionId().toString() }, getParameters().getSchedule().toCronExpression());
        storageDomainDR.setScheduleCronExpression(getParameters().getSchedule().toCronExpression());
        storageDomainDR.setJobId(jobId);
        storageDomainDRDao.saveOrUpdate(storageDomainDR);
    } else {
        // FREQUENCY = NONE - no sync scheduled, so delete this
        storageDomainDRDao.remove(storageDomainDR.getStorageDomainId(), storageDomainDR.getGeoRepSessionId());
    }
    setSucceeded(true);
}
Also used : StorageDomainDR(org.ovirt.engine.core.common.businessentities.StorageDomainDR)

Example 3 with StorageDomainDR

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

the class SubTabStorageDRView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    AbstractTextColumn<StorageDomainDR> sessionColumn = new AbstractTextColumn<StorageDomainDR>() {

        @Override
        public String getValue(StorageDomainDR storageDomainDR) {
            GlusterGeoRepSession session = getDetailModel().getGeoRepSessionsMap().get(storageDomainDR.getGeoRepSessionId());
            if (session == null) {
                return storageDomainDR.getGeoRepSessionId().toString();
            } else {
                return messages.geoRepRemoteSessionName(session.getSlaveHostName(), session.getSlaveVolumeName());
            }
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(sessionColumn, constants.geoRepSlaveVolume(), "300px");
    AbstractTextColumn<StorageDomainDR> scheduleColumn = new AbstractTextColumn<StorageDomainDR>() {

        @Override
        public String getValue(StorageDomainDR storageDomainDR) {
            StorageSyncSchedule schedule = new StorageSyncSchedule(storageDomainDR.getScheduleCronExpression());
            return schedule.toString();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(scheduleColumn, constants.scheduleLabel(), "300px");
}
Also used : StorageSyncSchedule(org.ovirt.engine.core.common.businessentities.gluster.StorageSyncSchedule) StorageDomainDR(org.ovirt.engine.core.common.businessentities.StorageDomainDR) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 4 with StorageDomainDR

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

the class StorageDomainDRDaoTest method testRemoveAndSave.

@Test
public void testRemoveAndSave() {
    dao.remove(FixturesTool.POSIX_STORAGE_DOMAIN_ID, FixturesTool.GLUSTER_GEOREP_SESSION_ID2);
    StorageDomainDR result = dao.get(FixturesTool.POSIX_STORAGE_DOMAIN_ID, FixturesTool.GLUSTER_GEOREP_SESSION_ID2);
    assertEquals(null, result);
    dao.save(storageDomainDR);
    result = dao.get(FixturesTool.POSIX_STORAGE_DOMAIN_ID, FixturesTool.GLUSTER_GEOREP_SESSION_ID2);
    assertEquals(storageDomainDR, result);
}
Also used : StorageDomainDR(org.ovirt.engine.core.common.businessentities.StorageDomainDR) Test(org.junit.Test)

Example 5 with StorageDomainDR

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

the class StorageDomainDRDaoTest method testUpdate.

@Test
public void testUpdate() {
    storageDomainDR.setJobId("qrtzjob2");
    dao.update(storageDomainDR);
    StorageDomainDR result = dao.get(FixturesTool.POSIX_STORAGE_DOMAIN_ID, FixturesTool.GLUSTER_GEOREP_SESSION_ID2);
    assertEquals(storageDomainDR, result);
}
Also used : StorageDomainDR(org.ovirt.engine.core.common.businessentities.StorageDomainDR) Test(org.junit.Test)

Aggregations

StorageDomainDR (org.ovirt.engine.core.common.businessentities.StorageDomainDR)10 Test (org.junit.Test)4 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 StorageSyncSchedule (org.ovirt.engine.core.common.businessentities.gluster.StorageSyncSchedule)3 List (java.util.List)2 Map (java.util.Map)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 ActionType (org.ovirt.engine.core.common.action.ActionType)2 StorageSyncScheduleParameters (org.ovirt.engine.core.common.action.StorageSyncScheduleParameters)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 QueryType (org.ovirt.engine.core.common.queries.QueryType)2 Guid (org.ovirt.engine.core.compat.Guid)2 Frontend (org.ovirt.engine.ui.frontend.Frontend)2 Linq (org.ovirt.engine.ui.uicommonweb.Linq)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)2