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