use of org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation in project ovirt-engine by oVirt.
the class GlusterStorageDomainDRSyncJob method syncData.
@OnTimerMethodAnnotation("syncData")
public void syncData(String storageDomainId, String geoRepSessionId) {
try {
// Get storage domain and georep session
StorageDomain storageDomain = storageDomainDao.get(new Guid(storageDomainId));
if (storageDomain == null) {
log.error("No storage domain found for id '{}'", storageDomainId);
return;
}
GlusterGeoRepSession session = geoRepDao.getById(new Guid(geoRepSessionId));
if (session == null) {
log.error("No geo-replication session found for id '{}'", geoRepSessionId);
return;
}
backend.runInternalAction(ActionType.GlusterStorageSync, new GlusterStorageSyncCommandParameters(storageDomain.getId(), session.getId()), ExecutionHandler.createInternalJobContext());
} catch (Exception e) {
log.error("Error running dr sync", e);
}
}
use of org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation 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.utils.timer.OnTimerMethodAnnotation in project ovirt-engine by oVirt.
the class GlusterSnapshotScheduleJob method onTimer.
@OnTimerMethodAnnotation("onTimer")
public void onTimer(String serverId, String volumeId, String snapshotNamePrefix, String description, boolean force) {
final GlusterVolumeEntity volume = glusterVolumeDao.getById(new Guid(volumeId));
if (volume == null) {
log.error("Error while creating volume snapshot. Volume is null.");
return;
}
final GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity();
snapshot.setClusterId(volume.getClusterId());
snapshot.setVolumeId(volume.getId());
snapshot.setSnapshotName(snapshotNamePrefix);
snapshot.setDescription(description);
ActionReturnValue returnValue = backend.runInternalAction(ActionType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotParameters(snapshot, force));
if (!returnValue.getSucceeded()) {
log.error("Error while creating snapshot for volume '{}': {}", volume.getName(), returnValue.getExecuteFailedMessages().toString());
Map<String, String> customValues = new HashMap<>();
customValues.put(GlusterConstants.VOLUME_SNAPSHOT_NAME, snapshot.getSnapshotName());
customValues.put(GlusterConstants.VOLUME_NAME, volume.getName());
logUtil.logAuditMessage(volume.getClusterId(), volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, customValues);
}
// Check if next schedule available, and if not delete the scheduling details from DB
GlusterVolumeSnapshotSchedule schedule = glusterVolumeSnapshotScheduleDao.getByVolumeId(volume.getId());
Date endDate = glusterUtil.convertDate(schedule.getEndByDate(), schedule.getTimeZone());
if (endDate != null && endDate.before(new Date())) {
glusterVolumeSnapshotScheduleDao.removeByVolumeId(volume.getId());
logUtil.logAuditMessage(volume.getClusterId(), volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_SCHEDULE_DELETED, Collections.singletonMap(GlusterConstants.VOLUME_NAME, volume.getName()));
}
}
Aggregations