Search in sources :

Example 6 with OnTimerMethodAnnotation

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);
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterStorageSyncCommandParameters(org.ovirt.engine.core.common.action.GlusterStorageSyncCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 7 with OnTimerMethodAnnotation

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);
            }
        }
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) HashMap(java.util.HashMap) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Callable(java.util.concurrent.Callable) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 8 with OnTimerMethodAnnotation

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()));
    }
}
Also used : GlusterVolumeSnapshotSchedule(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule) CreateGlusterVolumeSnapshotParameters(org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) HashMap(java.util.HashMap) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) Guid(org.ovirt.engine.core.compat.Guid) Date(java.util.Date) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Aggregations

OnTimerMethodAnnotation (org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)8 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)5 HashMap (java.util.HashMap)4 Guid (org.ovirt.engine.core.compat.Guid)4 Callable (java.util.concurrent.Callable)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 GlusterStorageSyncCommandParameters (org.ovirt.engine.core.common.action.GlusterStorageSyncCommandParameters)1 CreateGlusterVolumeSnapshotParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters)1 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)1 VdsSpmIdMap (org.ovirt.engine.core.common.businessentities.VdsSpmIdMap)1