Search in sources :

Example 1 with Event

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

the class IrsBrokerCommand method startReconstruct.

private void startReconstruct() {
    StorageDomainStatic masterDomain = null;
    List<StorageDomainStatic> storageDomainStaticList = DbFacade.getInstance().getStorageDomainStaticDao().getAllForStoragePool(getParameters().getStoragePoolId());
    for (StorageDomainStatic storageDomainStatic : storageDomainStaticList) {
        if (storageDomainStatic.getStorageDomainType() == StorageDomainType.Master) {
            masterDomain = storageDomainStatic;
            break;
        }
    }
    if (masterDomain != null) {
        final Guid masterDomainId = masterDomain.getId();
        eventQueue.submitEventAsync(new Event(getParameters().getStoragePoolId(), masterDomainId, null, EventType.RECONSTRUCT, "IrsBrokerCommand.startReconstruct()"), () -> eventListener.masterDomainNotOperational(masterDomainId, getParameters().getStoragePoolId(), true, getVDSReturnValue().getVdsError() != null && getVDSReturnValue().getVdsError().getCode() == EngineError.StoragePoolWrongMaster));
    } else {
        log.error("IrsBroker::IRSNoMasterDomainException:: Could not find master domain for pool '{}'", getParameters().getStoragePoolId());
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) Event(org.ovirt.engine.core.common.eventqueue.Event) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with Event

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

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

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

the class ActivateStorageDomainCommand method refreshAllVdssInPool.

private void refreshAllVdssInPool() {
    final List<Guid> vdsIdsToSetNonOperational = new ArrayList<>();
    getEventQueue().submitEventSync(new Event(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), null, EventType.POOLREFRESH, ""), () -> {
        runSynchronizeOperation(new RefreshPoolSingleAsyncOperationFactory(), vdsIdsToSetNonOperational);
        return null;
    });
    for (Guid vdsId : vdsIdsToSetNonOperational) {
        Map<String, String> customLogValues = Collections.singletonMap("StorageDomainNames", getStorageDomainName());
        SetNonOperationalVdsParameters tempVar = new SetNonOperationalVdsParameters(vdsId, STORAGE_DOMAIN_UNREACHABLE, customLogValues);
        tempVar.setStorageDomainId(getStorageDomain().getId());
        tempVar.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
        runInternalAction(ActionType.SetNonOperationalVds, tempVar, ExecutionHandler.createInternalJobContext(getContext()));
    }
}
Also used : SetNonOperationalVdsParameters(org.ovirt.engine.core.common.action.SetNonOperationalVdsParameters) ArrayList(java.util.ArrayList) Event(org.ovirt.engine.core.common.eventqueue.Event) RefreshPoolSingleAsyncOperationFactory(org.ovirt.engine.core.bll.storage.pool.RefreshPoolSingleAsyncOperationFactory) Guid(org.ovirt.engine.core.compat.Guid)

Example 5 with Event

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

the class DeactivateStorageDomainCommand method executeCommand.

@Override
protected void executeCommand() {
    if (isCinderStorageDomain()) {
        deactivateCinderStorageDomain();
        return;
    }
    final StoragePoolIsoMap map = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(getParameters().getStorageDomainId(), getParameters().getStoragePoolId()));
    map.setStatus(StorageDomainStatus.Unknown);
    changeStorageDomainStatusInTransaction(map, getParameters().isInactive() ? StorageDomainStatus.Locked : StorageDomainStatus.PreparingForMaintenance);
    final StorageDomain newMaster;
    if (getStorageDomain().getStorageDomainType() == StorageDomainType.Master) {
        newMaster = electNewMaster();
        isLastMaster = proceedStorageDomainTreatmentByDomainType(newMaster, true);
    } else {
        newMaster = null;
        isLastMaster = false;
    }
    final Guid newMasterId = newMaster != null ? newMaster.getId() : Guid.Empty;
    if (isLastMaster) {
        executeInNewTransaction(() -> {
            getCompensationContext().snapshotEntityStatus(getStoragePool());
            getStoragePool().setStatus(StoragePoolStatus.Maintenance);
            storagePoolDao.updateStatus(getStoragePool().getId(), getStoragePool().getStatus());
            getCompensationContext().stateChanged();
            return null;
        });
        StoragePoolStatusHandler.poolStatusChanged(getStoragePool().getId(), getStoragePool().getStatus());
        getStorageDomain().getStorageDynamicData().setAvailableDiskSize(null);
        getStorageDomain().getStorageDynamicData().setUsedDiskSize(null);
    }
    if (!getParameters().isInactive()) {
        runVdsCommand(VDSCommandType.DeactivateStorageDomain, new DeactivateStorageDomainVDSCommandParameters(getStoragePool().getId(), getStorageDomain().getId(), newMasterId, getStoragePool().getMasterDomainVersion()));
    }
    freeLock();
    VDS spm = null;
    if (getStoragePool().getSpmVdsId() != null) {
        spm = vdsDao.get(getStoragePool().getSpmVdsId());
    }
    if (isLastMaster) {
        if (spm != null) {
            final VDSReturnValue stopSpmReturnValue = runVdsCommand(VDSCommandType.SpmStopOnIrs, new SpmStopOnIrsVDSCommandParameters(getStoragePool().getId()));
            if (!stopSpmReturnValue.getSucceeded()) {
                // no need to continue because DisconnectStoragePool will
                // fail if host is SPM
                log.error("Aborting execution due to failure to stop SPM");
                setSucceeded(false);
                return;
            }
            runVdsCommand(VDSCommandType.DisconnectStoragePool, new DisconnectStoragePoolVDSCommandParameters(spm.getId(), getStoragePool().getId(), spm.getVdsSpmId()));
        }
        runSynchronizeOperation(new DisconnectStoragePoolAsyncOperationFactory());
    }
    if (!getParameters().isInactive()) {
        getEventQueue().submitEventSync(new Event(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), null, EventType.POOLREFRESH, ""), () -> {
            runSynchronizeOperation(new AfterDeactivateSingleAsyncOperationFactory(), isLastMaster, newMasterId);
            return null;
        });
        if (spm != null) {
            getStorageHelper(getStorageDomain()).disconnectStorageFromDomainByVdsId(getStorageDomain(), spm.getId());
        }
    }
    executeInNewTransaction(() -> {
        if (getParameters().isInactive()) {
            map.setStatus(StorageDomainStatus.Inactive);
        } else if (isLastMaster) {
            map.setStatus(StorageDomainStatus.Maintenance);
        } else {
            log.info("Domain '{}' will remain in '{}' status until deactivated on all hosts", getStorageDomain().getId(), map.getStatus());
        }
        storagePoolIsoMapDao.updateStatus(map.getId(), map.getStatus());
        if (newMaster != null) {
            StoragePoolIsoMap mapOfNewMaster = newMaster.getStoragePoolIsoMapData();
            mapOfNewMaster.setStatus(StorageDomainStatus.Active);
            storagePoolIsoMapDao.updateStatus(mapOfNewMaster.getId(), mapOfNewMaster.getStatus());
        }
        return null;
    });
    if (!getParameters().isSkipChecks()) {
        notifyAsyncTasks();
    }
    setSucceeded(true);
}
Also used : DeactivateStorageDomainVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DeactivateStorageDomainVDSCommandParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) SpmStopOnIrsVDSCommandParameters(org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) StoragePoolIsoMapId(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId) DisconnectStoragePoolAsyncOperationFactory(org.ovirt.engine.core.bll.storage.pool.DisconnectStoragePoolAsyncOperationFactory) Event(org.ovirt.engine.core.common.eventqueue.Event) Guid(org.ovirt.engine.core.compat.Guid) DisconnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters) AfterDeactivateSingleAsyncOperationFactory(org.ovirt.engine.core.bll.storage.pool.AfterDeactivateSingleAsyncOperationFactory) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

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