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;
});
}
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));
}
}
}
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);
}
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);
}
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;
}
Aggregations