Search in sources :

Example 51 with JobExecutionException

use of org.quartz.JobExecutionException in project alfresco-repository by Alfresco.

the class UserUsageCollapseJob method execute.

public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap jobData = context.getJobDetail().getJobDataMap();
    UserUsageTrackingComponent usageComponent = (UserUsageTrackingComponent) jobData.get(KEY_COMPONENT);
    if (usageComponent == null) {
        throw new JobExecutionException("Missing job data: " + KEY_COMPONENT);
    }
    // perform the content usage calculations
    usageComponent.execute();
}
Also used : JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException)

Example 52 with JobExecutionException

use of org.quartz.JobExecutionException in project alfresco-repository by Alfresco.

the class DownloadsCleanupJob method execute.

/*
     * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
     */
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap jobData = context.getJobDetail().getJobDataMap();
    // extract the services and max age to use
    final DownloadService downloadService = (DownloadService) jobData.get(KEY_DOWNLOAD_SERVICE);
    final TenantAdminService tenantAdminService = (TenantAdminService) jobData.get(KEY_TENANT_ADMIN_SERVICE);
    final int maxAgeInMinutes = Integer.parseInt((String) jobData.get(KEY_MAX_AGE));
    final int batchSize = Integer.parseInt((String) jobData.get(BATCH_SIZE));
    final boolean cleanAllSysDownloadFolders = Boolean.parseBoolean((String) jobData.get(CLEAN_All_SYS_DOWNLOAD_FOLDERS));
    final DateTime before = new DateTime().minusMinutes(maxAgeInMinutes);
    AuthenticationUtil.runAs(new RunAsWork<Object>() {

        public Object doWork() throws Exception {
            downloadService.deleteDownloads(before.toDate(), batchSize, cleanAllSysDownloadFolders);
            return null;
        }
    }, AuthenticationUtil.getSystemUserName());
    if ((tenantAdminService != null) && tenantAdminService.isEnabled()) {
        List<Tenant> tenants = tenantAdminService.getAllTenants();
        for (Tenant tenant : tenants) {
            TenantUtil.runAsSystemTenant(new TenantRunAsWork<Object>() {

                public Object doWork() throws Exception {
                    downloadService.deleteDownloads(before.toDate(), batchSize, cleanAllSysDownloadFolders);
                    return null;
                }
            }, tenant.getTenantDomain());
        }
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) Tenant(org.alfresco.repo.tenant.Tenant) TenantAdminService(org.alfresco.repo.tenant.TenantAdminService) DownloadService(org.alfresco.service.cmr.download.DownloadService) DateTime(org.joda.time.DateTime) JobExecutionException(org.quartz.JobExecutionException)

Example 53 with JobExecutionException

use of org.quartz.JobExecutionException in project iaf by ibissource.

the class ServiceJob method execute.

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    try {
        log.info("executing" + getLogPrefix(context));
        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
        String serviceName = dataMap.getString(JAVALISTENER_KEY);
        Message message = new Message(dataMap.getString(MESSAGE_KEY));
        // send job
        IbisLocalSender localSender = new IbisLocalSender();
        localSender.setJavaListener(serviceName);
        localSender.setIsolated(false);
        localSender.setName("ServiceJob");
        localSender.configure();
        localSender.open();
        try {
            localSender.sendMessage(message, null);
        } finally {
            localSender.close();
        }
    } catch (Exception e) {
        log.error("JobExecutionException while running " + getLogPrefix(context), e);
        throw new JobExecutionException(e, false);
    }
    log.debug(getLogPrefix(context) + "completed");
}
Also used : JobDataMap(org.quartz.JobDataMap) IbisLocalSender(nl.nn.adapterframework.senders.IbisLocalSender) JobExecutionException(org.quartz.JobExecutionException) Message(nl.nn.adapterframework.stream.Message) JobExecutionException(org.quartz.JobExecutionException)

Example 54 with JobExecutionException

use of org.quartz.JobExecutionException in project jmxtrans by jmxtrans.

the class ServerJob method execute.

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap map = context.getMergedJobDataMap();
    Server server = (Server) map.get(Server.class.getName());
    log.debug("+++++ Started server job: {}", server);
    try {
        jmxUtils.processServer(server);
    } catch (Exception e) {
        throw new JobExecutionException(e);
    }
    log.debug("+++++ Finished server job: {}", server);
}
Also used : JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException) Server(com.googlecode.jmxtrans.model.Server) JobExecutionException(org.quartz.JobExecutionException)

Example 55 with JobExecutionException

use of org.quartz.JobExecutionException in project pinot by linkedin.

the class AlertTaskRunnerV2 method sendFailureEmail.

private void sendFailureEmail(Throwable t) throws JobExecutionException {
    HtmlEmail email = new HtmlEmail();
    String subject = String.format("[ThirdEye Anomaly Detector] FAILED ALERT ID=%d for config %s", alertConfig.getId(), alertConfig.getName());
    String textBody = String.format("%s%n%nException:%s", alertConfig.toString(), ExceptionUtils.getStackTrace(t));
    try {
        EmailHelper.sendEmailWithTextBody(email, thirdeyeConfig.getSmtpConfiguration(), subject, textBody, thirdeyeConfig.getFailureFromAddress(), thirdeyeConfig.getFailureToAddress());
    } catch (EmailException e) {
        throw new JobExecutionException(e);
    }
}
Also used : JobExecutionException(org.quartz.JobExecutionException) HtmlEmail(org.apache.commons.mail.HtmlEmail) EmailException(org.apache.commons.mail.EmailException)

Aggregations

JobExecutionException (org.quartz.JobExecutionException)123 JobDataMap (org.quartz.JobDataMap)35 ArrayList (java.util.ArrayList)18 Date (java.util.Date)16 IgnoreProvisionException (org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException)16 SchedulerException (org.quartz.SchedulerException)16 HashMap (java.util.HashMap)15 ProvisioningReport (org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport)15 Test (org.junit.Test)13 Result (org.apache.syncope.common.lib.types.AuditElements.Result)12 JobDetail (org.quartz.JobDetail)12 PullActions (org.apache.syncope.core.provisioning.api.pushpull.PullActions)11 SQLException (java.sql.SQLException)10 PropagationException (org.apache.syncope.core.provisioning.api.propagation.PropagationException)10 DelegatedAdministrationException (org.apache.syncope.core.spring.security.DelegatedAdministrationException)10 Map (java.util.Map)9 JobExecutionContext (org.quartz.JobExecutionContext)9 List (java.util.List)8 IOException (java.io.IOException)7 Realm (org.apache.syncope.core.persistence.api.entity.Realm)7