Search in sources :

Example 1 with EventResult

use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.

the class IrsProxy method updateDomainInProblem.

private void updateDomainInProblem(final Guid vdsId, final String vdsName, final Map<Guid, DomainMonitoringResult> domainsInProblem, final Set<Guid> domainsInMaintenance) {
    getEventQueue().submitEventSync(new Event(storagePoolId, null, vdsId, EventType.DOMAINMONITORING, ""), () -> {
        EventResult result = new EventResult(true, EventType.DOMAINMONITORING);
        updateProblematicVdsData(vdsId, vdsName, domainsInProblem);
        updateMaintenanceVdsData(vdsId, vdsName, domainsInMaintenance);
        return result;
    });
}
Also used : EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) Event(org.ovirt.engine.core.common.eventqueue.Event)

Example 2 with EventResult

use of org.ovirt.engine.core.common.eventqueue.EventResult 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 3 with EventResult

use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.

the class VdsEventListener method storageDomainNotOperational.

@Override
public EventResult storageDomainNotOperational(Guid storageDomainId, Guid storagePoolId) {
    StorageDomainPoolParametersBase parameters = new StorageDomainPoolParametersBase(storageDomainId, storagePoolId);
    parameters.setIsInternal(true);
    parameters.setInactive(true);
    boolean isSucceeded = backend.runInternalAction(ActionType.DeactivateStorageDomain, parameters, ExecutionHandler.createInternalJobContext()).getSucceeded();
    return new EventResult(isSucceeded, EventType.DOMAINNOTOPERATIONAL);
}
Also used : EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase)

Example 4 with EventResult

use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.

the class VdsEventListener method masterDomainNotOperational.

@Override
public EventResult masterDomainNotOperational(Guid storageDomainId, Guid storagePoolId, boolean isReconstructToInactiveDomains, boolean canReconstructToCurrentMaster) {
    ActionParametersBase parameters = new ReconstructMasterParameters(storagePoolId, storageDomainId, true, isReconstructToInactiveDomains, canReconstructToCurrentMaster);
    boolean isSucceeded = backend.runInternalAction(ActionType.ReconstructMasterDomain, parameters, ExecutionHandler.createInternalJobContext()).getSucceeded();
    return new EventResult(isSucceeded, EventType.RECONSTRUCT);
}
Also used : EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ReconstructMasterParameters(org.ovirt.engine.core.common.action.ReconstructMasterParameters)

Example 5 with EventResult

use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.

the class EventQueueMonitor method submitTaskInternal.

private FutureTask<EventResult> submitTaskInternal(Event event, Callable<EventResult> callable) {
    FutureTask<EventResult> task = null;
    Guid storagePoolId = event.getStoragePoolId();
    ReentrantLock lock = getPoolLock(storagePoolId);
    lock.lock();
    try {
        Event currentEvent = poolCurrentEventMap.get(storagePoolId);
        if (currentEvent != null) {
            switch(currentEvent.getEventType()) {
                case RECOVERY:
                    if (event.getEventType() == EventType.VDSCONNECTTOPOOL || event.getEventType() == EventType.VDSCLEARCACHE || event.getEventType() == EventType.DOMAINFAILOVER) {
                        task = addTaskToQueue(event, callable, storagePoolId, isEventShouldBeFirst(event));
                    } else {
                        log.debug("Current event was skipped because of recovery is running now for pool '{}', event '{}'", storagePoolId, event);
                    }
                    break;
                case RECONSTRUCT:
                    if (event.getEventType() == EventType.VDSCONNECTTOPOOL || event.getEventType() == EventType.RECOVERY || event.getEventType() == EventType.DOMAINFAILOVER || event.getEventType() == EventType.VDSCLEARCACHE) {
                        task = addTaskToQueue(event, callable, storagePoolId, isEventShouldBeFirst(event));
                    } else {
                        log.debug("Current event was skipped because of reconstruct is running now for pool '{}', event '{}'", storagePoolId, event);
                    }
                    break;
                default:
                    task = addTaskToQueue(event, callable, storagePoolId, isEventShouldBeFirst(event));
                    break;
            }
        } else {
            task = addTaskToQueue(event, callable, storagePoolId, false);
            poolCurrentEventMap.put(storagePoolId, event);
            ThreadPoolUtil.execute(new InternalEventQueueThread(storagePoolId, lock, poolsEventsMap, poolCurrentEventMap));
        }
    } finally {
        lock.unlock();
    }
    return task;
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) Event(org.ovirt.engine.core.common.eventqueue.Event) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)11 Event (org.ovirt.engine.core.common.eventqueue.Event)6 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)4 ArrayList (java.util.ArrayList)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Guid (org.ovirt.engine.core.compat.Guid)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 VdsSpmIdMap (org.ovirt.engine.core.common.businessentities.VdsSpmIdMap)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1