use of org.ovirt.engine.core.common.config.ConfigValues in project ovirt-engine by oVirt.
the class BackendSystemOptionResource method get.
@Override
public SystemOption get() {
ConfigValues config;
try {
config = ConfigValues.valueOf(id);
} catch (IllegalArgumentException ex) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
GetSystemOptionParameters parameters = new GetSystemOptionParameters(config);
String version = ParametersHelper.getParameter(httpHeaders, uriInfo, VERSION);
if (version != null && !version.isEmpty()) {
parameters.setOptionVersion(version);
}
QueryReturnValue result = runQuery(QueryType.GetSystemOption, parameters);
if (result.getReturnValue() == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
return LinkHelper.addLinks(SystemOptionsMapper.map(result.getReturnValue(), id));
}
use of org.ovirt.engine.core.common.config.ConfigValues in project ovirt-engine by oVirt.
the class FenceConfigHelper method getFenceConfigurationValue.
public static String getFenceConfigurationValue(String key, String version) {
init();
String returnValue = null;
String customReturnValue = null;
ConfigValues value = ConfigValues.valueOf(key);
ConfigValues customValue = ConfigValues.valueOf(getCustomKey(key));
returnValue = Config.getValue(value, version);
customReturnValue = Config.getValue(customValue, ConfigCommon.defaultConfigurationVersion);
return merge(key, returnValue, customReturnValue);
}
use of org.ovirt.engine.core.common.config.ConfigValues 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