Search in sources :

Example 31 with JobExecutionException

use of org.quartz.JobExecutionException in project opennms by OpenNMS.

the class ImportJob method execute.

/** {@inheritDoc} */
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    try {
        String url = context.getJobDetail().getJobDataMap().getString(URL);
        Assert.notNull(url);
        String rescanExisting = context.getJobDetail().getJobDataMap().getString(RESCAN_EXISTING);
        getProvisioner().doImport(url, rescanExisting == null ? Boolean.TRUE.toString() : rescanExisting);
    } catch (Throwable t) {
        throw new JobExecutionException(t);
    }
}
Also used : JobExecutionException(org.quartz.JobExecutionException)

Example 32 with JobExecutionException

use of org.quartz.JobExecutionException in project cdap by caskdata.

the class LogPrintingJob method execute.

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    try {
        LOG.info("Received Trigger at {}", context.getScheduledFireTime().toString());
        JobDataMap triggerMap = context.getTrigger().getJobDataMap();
        JobDataMap map = context.getMergedJobDataMap();
        String[] keys = map.getKeys();
        TriggerKey triggerKey = context.getTrigger().getKey();
        if (triggerKey.getName().equalsIgnoreCase("g2")) {
            Preconditions.checkArgument(triggerMap.getString(KEY).equals(VALUE));
        } else {
            Preconditions.checkArgument(!triggerMap.containsKey(KEY));
        }
        Preconditions.checkArgument(keys != null);
        Preconditions.checkArgument(keys.length > 0);
        LOG.info("Number of parameters {}", keys.length);
        for (String key : keys) {
            LOG.info("Parameter key: {}, value: {}", key, map.get(key));
        }
    } catch (Throwable e) {
        throw Throwables.propagate(e);
    }
    throw new JobExecutionException("exception");
}
Also used : TriggerKey(org.quartz.TriggerKey) JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException)

Example 33 with JobExecutionException

use of org.quartz.JobExecutionException in project ddf by codice.

the class CommandJob method doExecute.

public void doExecute(JobExecutionContext context) throws JobExecutionException {
    String commandInput;
    try {
        commandInput = checkInput(context);
    } catch (CommandException e) {
        LOGGER.debug("unable to get command from job execution context", e);
        return;
    }
    SessionFactory sessionFactory = getSessionFactory();
    if (sessionFactory == null) {
        LOGGER.debug("unable to create session factory: command=[{}]", commandInput);
        return;
    }
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    Session session = null;
    try (PrintStream output = getPrintStream(byteArrayOutputStream)) {
        session = sessionFactory.create(null, output, output);
        if (session == null) {
            LOGGER.debug("unable to create session: command=[{}]", commandInput);
            return;
        }
        if (commandInput != null) {
            try {
                LOGGER.trace("Executing command [{}]", commandInput);
                session.execute(commandInput);
                LOGGER.trace("Execution Output: {}", byteArrayOutputStream.toString(StandardCharsets.UTF_8.name()));
            } catch (CommandNotFoundException e) {
                LOGGER.info("Command could not be found. Make sure the command's library has been loaded and try again: {}", e.getLocalizedMessage());
                LOGGER.debug("Command not found.", e);
            } catch (Exception e) {
                LOGGER.info("Error with execution. ", e);
            }
        }
    } catch (UnsupportedEncodingException e) {
        LOGGER.info("Unable to produce output", e);
    } finally {
        if (session != null) {
            session.close();
        }
        try {
            byteArrayOutputStream.close();
        } catch (IOException e) {
            LOGGER.debug("Could not close output stream", e);
        }
    }
}
Also used : SessionFactory(org.apache.karaf.shell.api.console.SessionFactory) PrintStream(java.io.PrintStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) CommandNotFoundException(org.apache.felix.gogo.runtime.CommandNotFoundException) IOException(java.io.IOException) JobExecutionException(org.quartz.JobExecutionException) CommandNotFoundException(org.apache.felix.gogo.runtime.CommandNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Session(org.apache.karaf.shell.api.console.Session)

Aggregations

JobExecutionException (org.quartz.JobExecutionException)33 SchedulerException (org.quartz.SchedulerException)9 EmailException (org.apache.commons.mail.EmailException)6 JobDataMap (org.quartz.JobDataMap)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 SchedulerContext (org.quartz.SchedulerContext)4 TimeSeriesResponse (com.linkedin.thirdeye.client.timeseries.TimeSeriesResponse)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ExecutionException (java.util.concurrent.ExecutionException)3 CamelContext (org.apache.camel.CamelContext)3 Route (org.apache.camel.Route)3 HtmlEmail (org.apache.commons.mail.HtmlEmail)3 ThirdEyeAnomalyConfiguration (com.linkedin.thirdeye.anomaly.ThirdEyeAnomalyConfiguration)2 MetricDimensionReport (com.linkedin.thirdeye.anomaly.alert.template.pojo.MetricDimensionReport)2 DataReportHelper (com.linkedin.thirdeye.anomaly.alert.util.DataReportHelper)2 DimensionKey (com.linkedin.thirdeye.api.DimensionKey)2 MetricTimeSeries (com.linkedin.thirdeye.api.MetricTimeSeries)2 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)2 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)2