Search in sources :

Example 6 with ConfigValues

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));
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) WebApplicationException(javax.ws.rs.WebApplicationException) GetSystemOptionParameters(org.ovirt.engine.core.common.queries.GetSystemOptionParameters) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues)

Example 7 with ConfigValues

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);
}
Also used : ConfigValues(org.ovirt.engine.core.common.config.ConfigValues)

Example 8 with ConfigValues

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);
}
Also used : JobExecutionContext(org.quartz.JobExecutionContext) StringUtils(org.apache.commons.lang.StringUtils) Logger(org.slf4j.Logger) Date(java.util.Date) JobListener(org.quartz.JobListener) LoggerFactory(org.slf4j.LoggerFactory) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) TimeUnit(java.util.concurrent.TimeUnit) JobExecutionException(org.quartz.JobExecutionException) List(java.util.List) SchedulerException(org.quartz.SchedulerException) JobDataMap(org.quartz.JobDataMap) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) TriggerKey(org.quartz.TriggerKey) Config(org.ovirt.engine.core.common.config.Config) JobDetail(org.quartz.JobDetail) JobDataMap(org.quartz.JobDataMap) SchedulerException(org.quartz.SchedulerException) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Date(java.util.Date) TriggerKey(org.quartz.TriggerKey) JobDetail(org.quartz.JobDetail) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) TimeUnit(java.util.concurrent.TimeUnit) SimpleTrigger(org.quartz.SimpleTrigger)

Aggregations

ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)8 GetConfigurationValueParameters (org.ovirt.engine.core.common.queries.GetConfigurationValueParameters)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 TimeUnit (java.util.concurrent.TimeUnit)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 StringUtils (org.apache.commons.lang.StringUtils)1 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)1 Config (org.ovirt.engine.core.common.config.Config)1 GetSystemOptionParameters (org.ovirt.engine.core.common.queries.GetSystemOptionParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 KeyValuePairCompat (org.ovirt.engine.core.compat.KeyValuePairCompat)1 JobDataMap (org.quartz.JobDataMap)1 JobDetail (org.quartz.JobDetail)1 JobExecutionContext (org.quartz.JobExecutionContext)1 JobExecutionException (org.quartz.JobExecutionException)1 JobListener (org.quartz.JobListener)1 SchedulerException (org.quartz.SchedulerException)1