Search in sources :

Example 6 with Event

use of org.ovirt.engine.core.common.eventqueue.Event 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)

Example 7 with Event

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

the class IrsProxy method queueDomainMaintenanceCheck.

public void queueDomainMaintenanceCheck(final StorageDomain domain, final StoragePool pool) {
    getEventQueue().submitEventAsync(new Event(storagePoolId, domain.getId(), null, EventType.DOMAINFAILOVER, ""), () -> {
        Collection<Guid> vdsConnectedToPool = getVdsConnectedToPool(storagePoolId);
        Set<Guid> vdsDomInMaintenance = _domainsInMaintenance.get(domain.getId());
        if (vdsConnectedToPool.isEmpty() || (vdsDomInMaintenance != null && vdsDomInMaintenance.containsAll(vdsConnectedToPool))) {
            log.info("Moving domain '{}' to maintenance", domain.getId());
            storagePoolIsoMapDao.updateStatus(domain.getStoragePoolIsoMapData().getId(), StorageDomainStatus.Maintenance);
            AuditLogable logable = new AuditLogableImpl();
            logable.setStorageDomainId(domain.getId());
            logable.setStorageDomainName(domain.getName());
            logable.setStoragePoolId(pool.getId());
            logable.setStoragePoolName(pool.getName());
            auditLogDirector.log(logable, AuditLogType.STORAGE_DOMAIN_MOVED_TO_MAINTENANCE);
        }
        return null;
    });
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) Event(org.ovirt.engine.core.common.eventqueue.Event) Guid(org.ovirt.engine.core.compat.Guid) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 8 with Event

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

the class IrsProxy method reconstructMasterDomainNotInSync.

/**
 * Reconstructs the master domain when the old domain is not in sync.
 *
 * @param storagePoolId
 *            The storage pool id.
 * @param masterDomain
 *            The master domain.
 * @param exceptionMessage
 *            The message of the exception to throw.
 * @param logMessage
 *            The log message to write in the log.
 */
private void reconstructMasterDomainNotInSync(final Guid storagePoolId, final StorageDomainStatic masterDomain, final String exceptionMessage, final String logMessage) {
    getEventQueue().submitEventSync(new Event(this.storagePoolId, masterDomain.getId(), null, EventType.RECONSTRUCT, "Reconstruct caused by failure to execute spm command"), () -> {
        log.warn(logMessage);
        AuditLogable logable = new AuditLogableImpl();
        logable.setVdsId(currentVdsId);
        logable.setVdsName(vdsStaticDao.get(currentVdsId).getName());
        logable.setStorageDomainId(masterDomain.getId());
        logable.setStorageDomainName(masterDomain.getName());
        auditLogDirector.log(logable, AuditLogType.SYSTEM_MASTER_DOMAIN_NOT_IN_SYNC);
        return getEventListener().masterDomainNotOperational(masterDomain.getId(), storagePoolId, false, true);
    });
    throw new IRSNoMasterDomainException(exceptionMessage);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) Event(org.ovirt.engine.core.common.eventqueue.Event) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 9 with Event

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

the class IrsProxy method addDomainData.

public void addDomainData(final Guid domainId) {
    getEventQueue().submitEventAsync(new Event(storagePoolId, domainId, null, EventType.DOMAINFAILOVER, ""), () -> {
        EventResult result = null;
        if (domainsInProblem.containsKey(domainId)) {
            log.info("starting processDomainRecovery for domain '{}'.", getDomainIdTuple(domainId));
            result = processDomainRecovery(domainId);
        }
        timersMap.remove(domainId);
        return result;
    });
}
Also used : EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) Event(org.ovirt.engine.core.common.eventqueue.Event)

Example 10 with Event

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

the class RecoveryStoragePoolCommand method executeCommand.

@Override
protected void executeCommand() {
    StorageDomain newMasterDomain = loadTargetedMasterDomain();
    if (storageHelperDirector.getItem(newMasterDomain.getStorageType()).connectStorageToDomainByVdsId(newMasterDomain, getVds().getId())) {
        getEventQueue().submitEventSync(new Event(getParameters().getStoragePoolId(), getParameters().getNewMasterDomainId(), null, EventType.RECOVERY, ""), () -> {
            getParameters().setStorageDomainId(getMasterDomainIdFromDb());
            StoragePoolIsoMap domainPoolMap = new StoragePoolIsoMap(getParameters().getNewMasterDomainId(), getParameters().getStoragePoolId(), StorageDomainStatus.Active);
            storagePoolIsoMapDao.save(domainPoolMap);
            getParameters().setVdsId(getVds().getId());
            ActionReturnValue returnVal = runInternalAction(ActionType.ReconstructMasterDomain, getParameters(), cloneContextAndDetachFromParent());
            boolean reconstructVerbExecuted = (returnVal.getActionReturnValue() != null) ? (Boolean) returnVal.getActionReturnValue() : false;
            storagePoolDao.updateStatus(getStoragePool().getId(), StoragePoolStatus.NonResponsive);
            if (!reconstructVerbExecuted) {
                storagePoolIsoMapDao.remove(domainPoolMap.getId());
            }
            if (returnVal.getSucceeded()) {
                updateStorageDomainFormatIfNeeded(loadTargetedMasterDomain());
            }
            setSucceeded(returnVal.getSucceeded());
            return new EventResult(reconstructVerbExecuted, EventType.RECONSTRUCT);
        });
    } else {
        getReturnValue().setFault(new EngineFault(new EngineException(EngineError.StorageServerConnectionError, "Failed to connect storage"), EngineError.StorageServerConnectionError));
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) EngineException(org.ovirt.engine.core.common.errors.EngineException) Event(org.ovirt.engine.core.common.eventqueue.Event)

Aggregations

Event (org.ovirt.engine.core.common.eventqueue.Event)11 EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)6 Guid (org.ovirt.engine.core.compat.Guid)6 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 ArrayList (java.util.ArrayList)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)2 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 AfterDeactivateSingleAsyncOperationFactory (org.ovirt.engine.core.bll.storage.pool.AfterDeactivateSingleAsyncOperationFactory)1 DisconnectStoragePoolAsyncOperationFactory (org.ovirt.engine.core.bll.storage.pool.DisconnectStoragePoolAsyncOperationFactory)1 RefreshPoolSingleAsyncOperationFactory (org.ovirt.engine.core.bll.storage.pool.RefreshPoolSingleAsyncOperationFactory)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 SetNonOperationalVdsParameters (org.ovirt.engine.core.common.action.SetNonOperationalVdsParameters)1 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)1