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");
}
use of org.quartz.JobExecutionException in project xwiki-platform by xwiki.
the class WatchListJob method executeJob.
/**
* Method called from the scheduler.
*
* @param jobContext Context of the request
* @throws JobExecutionException if the job execution fails.
*/
@Override
public void executeJob(JobExecutionContext jobContext) throws JobExecutionException {
try {
// Don't go further if the application is disabled
if (!isWatchListEnabled()) {
return;
}
init(jobContext);
if (this.watchListJobObject == null) {
return;
}
Collection<String> subscribers = getSubscribers();
// Stop here if nobody is interested.
if (!hasSubscribers()) {
return;
}
// Determine what happened since the last execution for everybody.
Date previousFireTime = getPreviousFireTime();
WatchListEventMatcher eventMatcher = Utils.getComponent(WatchListEventMatcher.class);
List<WatchListEvent> events = eventMatcher.getEventsSince(previousFireTime);
setPreviousFireTime();
// Stop here if nothing happened in the meantime.
if (events.size() == 0) {
return;
}
// Notify all the interested subscribers of the events that occurred.
// When processing the events, a subscriber will only be notified of events that interest him.
Map<String, Object> notificationData = new HashMap<>();
notificationData.put(DefaultWatchListNotifier.PREVIOUS_FIRE_TIME_VARIABLE, previousFireTime);
String mailTemplate = this.watchListJobObject.getStringValue(WatchListJobClassDocumentInitializer.TEMPLATE_FIELD);
notificationData.put(WatchListEventMimeMessageFactory.TEMPLATE_PARAMETER, mailTemplate);
// Send the notification for processing.
this.watchlist.getNotifier().sendNotification(subscribers, events, notificationData);
} catch (Exception e) {
// We're in a job, we don't throw exceptions
LOGGER.error("Exception while running job", e);
}
}
use of org.quartz.JobExecutionException in project syncope by apache.
the class AbstractPushResultHandler method handle.
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public boolean handle(final String anyKey) {
Any<?> any = null;
try {
any = getAny(anyKey);
doHandle(any);
return true;
} catch (IgnoreProvisionException e) {
ProvisioningReport result = new ProvisioningReport();
result.setOperation(ResourceOperation.NONE);
result.setAnyType(any == null ? null : any.getType().getKey());
result.setStatus(ProvisioningReport.Status.IGNORE);
result.setKey(anyKey);
profile.getResults().add(result);
LOG.warn("Ignoring during push", e);
return true;
} catch (JobExecutionException e) {
LOG.error("Push failed", e);
return false;
}
}
use of org.quartz.JobExecutionException in project syncope by apache.
the class DefaultRealmPullResultHandler method handle.
@Override
public boolean handle(final SyncDelta delta) {
try {
OrgUnit orgUnit = profile.getTask().getResource().getOrgUnit();
if (orgUnit == null) {
throw new JobExecutionException("No orgUnit found on " + profile.getTask().getResource() + " for " + delta.getObject().getObjectClass());
}
doHandle(delta, orgUnit);
executor.reportHandled(delta.getObjectClass(), delta.getObject().getName());
LOG.debug("Successfully handled {}", delta);
if (profile.getTask().getPullMode() != PullMode.INCREMENTAL) {
return true;
}
boolean shouldContinue;
synchronized (this) {
shouldContinue = latestResult == Result.SUCCESS;
this.latestResult = null;
}
if (shouldContinue) {
executor.setLatestSyncToken(delta.getObjectClass(), delta.getToken());
}
return shouldContinue;
} catch (IgnoreProvisionException e) {
ProvisioningReport ignoreResult = new ProvisioningReport();
ignoreResult.setOperation(ResourceOperation.NONE);
ignoreResult.setStatus(ProvisioningReport.Status.IGNORE);
ignoreResult.setAnyType(REALM_TYPE);
ignoreResult.setKey(null);
ignoreResult.setName(delta.getObject().getName().getNameValue());
profile.getResults().add(ignoreResult);
LOG.warn("Ignoring during pull", e);
executor.setLatestSyncToken(delta.getObjectClass(), delta.getToken());
executor.reportHandled(delta.getObjectClass(), delta.getObject().getName());
return true;
} catch (JobExecutionException e) {
LOG.error("Pull failed", e);
return false;
}
}
use of org.quartz.JobExecutionException in project syncope by apache.
the class DefaultRealmPullResultHandler method create.
private void create(final RealmTO realmTO, final SyncDelta delta, final String operation, final ProvisioningReport result) throws JobExecutionException {
Object output;
Result resultStatus;
try {
Realm realm = realmDAO.save(binder.create(profile.getTask().getDestinatioRealm(), realmTO));
PropagationByResource propByRes = new PropagationByResource();
for (String resource : realm.getResourceKeys()) {
propByRes.add(ResourceOperation.CREATE, resource);
}
List<PropagationTaskTO> tasks = propagationManager.createTasks(realm, propByRes, null);
taskExecutor.execute(tasks, false);
RealmTO actual = binder.getRealmTO(realm, true);
result.setKey(actual.getKey());
result.setName(profile.getTask().getDestinatioRealm().getFullPath() + "/" + actual.getName());
output = actual;
resultStatus = Result.SUCCESS;
for (PullActions action : profile.getActions()) {
action.after(profile, delta, actual, result);
}
LOG.debug("Realm {} successfully created", actual.getKey());
} catch (PropagationException e) {
// A propagation failure doesn't imply a pull failure.
// The propagation exception status will be reported into the propagation task execution.
LOG.error("Could not propagate Realm {}", delta.getUid().getUidValue(), e);
output = e;
resultStatus = Result.FAILURE;
} catch (Exception e) {
throwIgnoreProvisionException(delta, e);
result.setStatus(ProvisioningReport.Status.FAILURE);
result.setMessage(ExceptionUtils.getRootCauseMessage(e));
LOG.error("Could not create Realm {} ", delta.getUid().getUidValue(), e);
output = e;
resultStatus = Result.FAILURE;
}
finalize(operation, resultStatus, null, output, delta);
}
Aggregations