Search in sources :

Example 1 with OnTimerMethodAnnotation

use of org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation in project ovirt-engine by oVirt.

the class IrsProxy method hostsStorageConnectionsAndPoolMetadataRefresh.

@OnTimerMethodAnnotation("hostsStorageConnectionsAndPoolMetadataRefresh")
public void hostsStorageConnectionsAndPoolMetadataRefresh() {
    Map<Guid, Guid> reportsToHandle = procceedReportsThreatmenet();
    if (reportsToHandle.isEmpty()) {
        return;
    }
    List<Callable<Void>> connectStorageTasks = new ArrayList<>();
    final List<Callable<Void>> refreshStoragePoolTasks = new ArrayList<>();
    final StoragePool storagePool = storagePoolDao.get(storagePoolId);
    final Guid masterDomainId = storageDomainDao.getMasterStorageDomainIdForPool(storagePoolId);
    final List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
    Map<String, Pair<String, String>> acquiredLocks = new HashMap<>();
    try {
        for (Map.Entry<Guid, Guid> entry : reportsToHandle.entrySet()) {
            Guid vdsId = entry.getKey();
            Guid currentReportId = entry.getValue();
            vdsHandeledReportsOnUnseenDomains.put(vdsId, currentReportId);
            Map<String, Pair<String, String>> lockMap = Collections.singletonMap(vdsId.toString(), new Pair<>(LockingGroup.VDS_POOL_AND_STORAGE_CONNECTIONS.toString(), EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED.toString()));
            EngineLock engineLock = new EngineLock(lockMap, null);
            if (!lockManager.acquireLock(engineLock).getFirst()) {
                log.info("Failed to acquire lock to refresh storage connection and pool metadata for host '{}', skipping it", vdsId);
                continue;
            }
            final VDS vds = vdsDao.get(entry.getKey());
            if (vds.getStatus() != VDSStatus.Up) {
                log.info("Skipping storage connection and pool metadata information for host '{}' as it's no longer in status UP", vdsId);
                lockManager.releaseLock(engineLock);
                continue;
            }
            acquiredLocks.putAll(lockMap);
            connectStorageTasks.add(() -> {
                getEventListener().connectHostToDomainsInActiveOrUnknownStatus(vds);
                return null;
            });
            refreshStoragePoolTasks.add(() -> {
                storagePoolDomainHelper.refreshHostPoolMetadata(vds, storagePool, masterDomainId, storagePoolIsoMap);
                return null;
            });
        }
        final Set<String> handledHosts = acquiredLocks.keySet();
        log.info("Running storage connections refresh for hosts '{}'", handledHosts);
        ThreadPoolUtil.invokeAll(connectStorageTasks);
        log.info("Submitting to the event queue pool refresh for hosts '{}'", handledHosts);
        getEventQueue().submitEventSync(new Event(storagePoolId, null, null, EventType.POOLREFRESH, ""), () -> {
            log.info("Running storage pool metadata refresh for hosts '{}'", handledHosts);
            ThreadPoolUtil.invokeAll(refreshStoragePoolTasks);
            return new EventResult(true, EventType.POOLREFRESH);
        });
    } finally {
        if (!acquiredLocks.isEmpty()) {
            lockManager.releaseLock(new EngineLock(acquiredLocks, null));
        }
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) Callable(java.util.concurrent.Callable) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) Event(org.ovirt.engine.core.common.eventqueue.Event) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Pair(org.ovirt.engine.core.common.utils.Pair) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 2 with OnTimerMethodAnnotation

use of org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation in project ovirt-engine by oVirt.

the class GlusterHookSyncJob method refreshHooks.

@OnTimerMethodAnnotation("refreshHooks")
public void refreshHooks() {
    log.debug("Refreshing hooks list");
    List<Cluster> clusters = clusterDao.getAll();
    for (Cluster cluster : clusters) {
        refreshHooksInCluster(cluster, false);
    }
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 3 with OnTimerMethodAnnotation

use of org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation in project ovirt-engine by oVirt.

the class GlusterSyncJob method refreshSelfHealInfo.

/**
 * Refreshes self heal info from GlusterFS. This method is scheduled less frequently as it uses the 'volume
 * heal info' command, that adds significant overhead on Gluster processes, and hence should not be invoked too
 * frequently.
 */
@OnTimerMethodAnnotation("refreshSelfHealInfo")
public void refreshSelfHealInfo() {
    log.debug("Refreshing Gluster Self Heal Data");
    for (Cluster cluster : clusterDao.getAll()) {
        if (supportsGlusterSelfHealMonitoring(cluster)) {
            try {
                refreshSelfHealData(cluster);
            } catch (Exception e) {
                log.error("Error while refreshing Gluster self heal data of cluster '{}': {}", cluster.getName(), e.getMessage());
                log.debug("Exception", e);
            }
        }
    }
    log.debug("Refreshing Gluster Self Heal data is completed");
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 4 with OnTimerMethodAnnotation

use of org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation in project ovirt-engine by oVirt.

the class GlusterSyncJob method refreshLightWeightData.

/**
 * Refreshes details of all volume across all clusters being managed in the engine. It can end up doing the
 * following in engine DB to make sure that the volume details in engine DB are in sync with GlusterFS:<br>
 * <li>Insert volumes</li><li>Delete volumes</li><li>Update properties of volume e.g. status, volume type</li><li>
 * Add / remove bricks to / from volumes</li><li>Set / Unset volume options</li><br>
 * These are all fetched using the 'volume info' command on gluster CLI, which is relatively lightweight, and hence
 * this method is scheduled more frequently as compared to the other method <code>refreshHeavyWeightData</code>,
 * which uses 'volume status' to fetch and update status of volume bricks.
 */
@OnTimerMethodAnnotation("refreshLightWeightData")
public void refreshLightWeightData() {
    log.debug("Refreshing Gluster Data [lightweight]");
    List<Cluster> clusters = clusterDao.getAll();
    for (Cluster cluster : clusters) {
        if (cluster.supportsGlusterService()) {
            try {
                refreshClusterData(cluster);
            } catch (Exception e) {
                log.error("Error while refreshing Gluster lightweight data of cluster '{}': {}", cluster.getName(), e.getMessage());
                log.debug("Exception", e);
            }
        }
    }
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 5 with OnTimerMethodAnnotation

use of org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation in project ovirt-engine by oVirt.

the class GlusterTasksSyncJob method updateGlusterAsyncTasks.

@OnTimerMethodAnnotation("gluster_async_task_poll_event")
public void updateGlusterAsyncTasks() {
    log.debug("Refreshing gluster tasks list");
    List<Cluster> clusters = clusterDao.getAll();
    Map<Guid, Set<Guid>> tasksFromClustersMap = new HashMap<>();
    for (Cluster cluster : clusters) {
        if (!cluster.supportsGlusterService()) {
            continue;
        }
        try {
            Map<Guid, GlusterAsyncTask> runningTasks = provider.getTaskListForCluster(cluster.getId());
            if (runningTasks != null) {
                updateTasksInCluster(cluster, runningTasks);
                tasksFromClustersMap.put(cluster.getId(), runningTasks.keySet());
            }
        } catch (EngineException e) {
            log.error("Error updating tasks from CLI", e);
        }
    }
    cleanUpOrphanTasks(tasksFromClustersMap);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) EngineException(org.ovirt.engine.core.common.errors.EngineException) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid) 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