use of org.ovirt.engine.core.common.config.Config in project ovirt-engine by oVirt.
the class IrsProxy method proceedStoragePoolStats.
@SuppressWarnings("unchecked")
private void proceedStoragePoolStats(StoragePool storagePool) {
// ugly patch because vdsm doesnt check if host is spm on spm
// operations
VDSReturnValue result = null;
Guid curVdsId = currentVdsId;
if (curVdsId != null) {
result = resourceManager.runVdsCommand(VDSCommandType.SpmStatus, new SpmStatusVDSCommandParameters(curVdsId, storagePoolId));
}
if (result == null || !result.getSucceeded() || (result.getSucceeded() && ((SpmStatusResult) result.getReturnValue()).getSpmStatus() != SpmStatus.SPM)) {
// update pool status to problematic until fence will happen
if (storagePool.getStatus() != StoragePoolStatus.NonResponsive && storagePool.getStatus() != StoragePoolStatus.NotOperational) {
if (result != null && result.getVdsError() != null) {
updateStoragePoolStatus(storagePoolId, StoragePoolStatus.NonResponsive, AuditLogType.SYSTEM_CHANGE_STORAGE_POOL_STATUS_PROBLEMATIC_WITH_ERROR, result.getVdsError().getCode());
} else {
updateStoragePoolStatus(storagePoolId, StoragePoolStatus.NonResponsive, AuditLogType.SYSTEM_CHANGE_STORAGE_POOL_STATUS_PROBLEMATIC, EngineError.ENGINE);
}
}
// then cause failover with attempts
if (result != null && !(result.getExceptionObject() instanceof VDSNetworkException)) {
HashMap<Guid, AsyncTaskStatus> tasksList = (HashMap<Guid, AsyncTaskStatus>) resourceManager.runVdsCommand(VDSCommandType.HSMGetAllTasksStatuses, new VdsIdVDSCommandParametersBase(curVdsId)).getReturnValue();
boolean allTasksFinished = true;
if (tasksList != null) {
for (AsyncTaskStatus taskStatus : tasksList.values()) {
if (AsyncTaskStatusEnum.finished != taskStatus.getStatus()) {
allTasksFinished = false;
break;
}
}
}
if ((tasksList == null) || allTasksFinished) {
nullifyInternalProxies();
} else {
if (_errorAttempts < Config.<Integer>getValue(ConfigValues.SPMFailOverAttempts)) {
_errorAttempts++;
log.warn("failed getting spm status for pool '{}' ({}), attempt number: {}", storagePoolId, storagePool.getName(), _errorAttempts);
} else {
nullifyInternalProxies();
_errorAttempts = 0;
}
}
}
} else if (result.getSucceeded() && ((SpmStatusResult) result.getReturnValue()).getSpmStatus() == SpmStatus.SPM && (storagePool.getStatus() == StoragePoolStatus.NonResponsive || storagePool.getStatus() == StoragePoolStatus.Contend)) {
// if recovered from network exception set back to up
storagePoolDao.updateStatus(storagePool.getId(), StoragePoolStatus.Up);
storagePool.setStatus(StoragePoolStatus.Up);
getEventListener().storagePoolStatusChanged(storagePool.getId(), storagePool.getStatus());
}
List<StorageDomain> domainsInDb = storageDomainDao.getAllForStoragePool(storagePoolId);
GetStoragePoolInfoVDSCommandParameters tempVar = new GetStoragePoolInfoVDSCommandParameters(storagePoolId);
tempVar.setIgnoreFailoverLimit(true);
VDSReturnValue storagePoolInfoResult = resourceManager.runVdsCommand(VDSCommandType.GetStoragePoolInfo, tempVar);
if (storagePoolInfoResult.getSucceeded()) {
KeyValuePairCompat<StoragePool, List<StorageDomain>> data = (KeyValuePairCompat<StoragePool, List<StorageDomain>>) storagePoolInfoResult.getReturnValue();
int masterVersion = data.getKey().getMasterDomainVersion();
HashSet<Guid> domainsInVds = new HashSet<>();
List<StorageDomain> storageDomainsToSync = data.getValue().stream().peek(storageDomain -> domainsInVds.add(storageDomain.getId())).filter(storageDomain -> proceedStorageDomain(storageDomain, masterVersion, storagePool)).collect(Collectors.toList());
if (!storageDomainsToSync.isEmpty()) {
getEventListener().syncStorageDomainsLuns(getCurrentVdsId(), storageDomainsToSync.stream().map(StorageDomain::getId).collect(Collectors.toList()));
}
for (final StorageDomain domainInDb : domainsInDb) {
if (domainInDb.getStorageDomainType() != StorageDomainType.Master && domainInDb.getStatus() != StorageDomainStatus.Locked && !domainInDb.getStorageType().isCinderDomain() && !domainsInVds.contains(domainInDb.getId())) {
// domain not attached to pool anymore
storagePoolIsoMapDao.remove(new StoragePoolIsoMapId(domainInDb.getId(), storagePoolId));
}
}
}
domainsInMaintenanceCheck(domainsInDb, storagePool);
}
use of org.ovirt.engine.core.common.config.Config in project ovirt-engine by oVirt.
the class DataCenterCompatibilityChecker method checkCompatibility.
private void checkCompatibility() {
try {
Optional<Version> retVal = Config.<HashSet<Version>>getValue(ConfigValues.SupportedClusterLevels).stream().max(Comparator.naturalOrder());
if (retVal.isPresent()) {
Version version = retVal.get();
storagePoolDao.getAll().stream().filter(storagePool -> version.compareTo(storagePool.getCompatibilityVersion()) > 0).forEach(storagePool -> logAlert(version, storagePool));
}
} catch (Throwable t) {
log.error("Failed to check certification validity: {}", ExceptionUtils.getRootCauseMessage(t));
log.debug("Exception", t);
}
}
use of org.ovirt.engine.core.common.config.Config in project ovirt-engine by oVirt.
the class VmPoolMonitor method prestartVms.
/**
* Prestarts the given amount of VMs in the given VM Pool.
*/
private void prestartVms(VmPool vmPool, int numOfVmsToPrestart) {
int failedAttempts = 0;
int prestartedVms = 0;
int maxFailedAttempts = Config.<Integer>getValue(ConfigValues.VmPoolMonitorMaxAttempts);
Map<String, Set<Guid>> failureReasons = new HashMap<>();
Iterator<Guid> iterator = vmPoolHandler.selectNonPrestartedVms(vmPool.getVmPoolId(), (vmId, messages) -> collectVmPrestartFailureReasons(vmId, failureReasons, messages)).iterator();
while (failedAttempts < maxFailedAttempts && prestartedVms < numOfVmsToPrestart && iterator.hasNext()) {
Guid vmId = iterator.next();
if (prestartVm(vmId, !vmPool.isStateful(), vmPool.getName())) {
prestartedVms++;
failedAttempts = 0;
} else {
failedAttempts++;
}
}
logResultOfPrestartVms(prestartedVms, numOfVmsToPrestart, vmPool.getVmPoolId(), failureReasons);
if (prestartedVms == 0) {
log.info("No VMs available for prestarting");
}
}
use of org.ovirt.engine.core.common.config.Config in project ovirt-engine by oVirt.
the class FixedDelayJobListener method jobWasExecuted.
/**
* reschedule the job with a new trigger. The new trigger will fire within a
* fixed time from the method execution.
*
* @see org.quartz.JobListener#jobWasExecuted(JobExecutionContext,
* JobExecutionException)
*/
@Override
public void jobWasExecuted(JobExecutionContext context, JobExecutionException exception) {
// Get the details of the job:
JobDetail jobdetail = context.getJobDetail();
JobDataMap data = jobdetail.getJobDataMap();
// job and if not just exit:
if (!data.containsKey(SchedulerUtilBaseImpl.FIXED_DELAY_VALUE)) {
return;
}
// This Job might already have an unused trigger in place, use it
List<? extends Trigger> triggersOfJob = null;
try {
triggersOfJob = context.getScheduler().getTriggersOfJob(context.getJobDetail().getKey());
} catch (SchedulerException e) {
// ignore
}
if (triggersOfJob != null && triggersOfJob.stream().filter(t -> t instanceof SimpleTrigger).anyMatch(t -> ((SimpleTrigger) t).getTimesTriggered() == 0)) {
logger.debug("Not scheduling {} again as there is still an unfired trigger.", context.getJobDetail().getKey());
return;
} else {
logger.debug("Rescheduling {} as there is no unfired trigger.", context.getJobDetail().getKey());
}
// generate the new trigger time
String configValueName = data.getString(SchedulerUtilBaseImpl.CONFIGURABLE_DELAY_KEY_NAME);
long delay;
if (StringUtils.isEmpty(configValueName)) {
delay = data.getLongValue(SchedulerUtilBaseImpl.FIXED_DELAY_VALUE);
} else {
ConfigValues configDelay = ConfigValues.valueOf(configValueName);
delay = Config.<Integer>getValue(configDelay).longValue();
}
TimeUnit delayUnit = (TimeUnit) data.getWrappedMap().get(SchedulerUtilBaseImpl.FIXED_DELAY_TIME_UNIT);
Date runTime = SchedulerUtilQuartzImpl.getFutureDate(delay, delayUnit);
// generate the new trigger
Trigger oldTrigger = context.getTrigger();
TriggerKey oldTriggerKey = oldTrigger.getKey();
Trigger newTrigger = newTrigger().withIdentity(oldTriggerKey).startAt(runTime).build();
// schedule the new trigger
sched.rescheduleAJob(oldTriggerKey.getName(), oldTriggerKey.getGroup(), newTrigger);
// SchedulerUtilQuartzImpl.getInstance().rescheduleAJob(oldTriggerName,
// oldTriggerGroup, newTrigger);
}
Aggregations