Search in sources :

Example 1 with ShardingContext

use of com.dangdang.ddframe.job.api.ShardingContext in project elastic-job by dangdangdotcom.

the class AbstractElasticJobExecutor method process.

private void process(final ShardingContexts shardingContexts, final int item, final JobExecutionEvent startEvent) {
    if (shardingContexts.isAllowSendJobEvent()) {
        jobFacade.postJobExecutionEvent(startEvent);
    }
    log.trace("Job '{}' executing, item is: '{}'.", jobName, item);
    JobExecutionEvent completeEvent = null;
    try {
        process(new ShardingContext(shardingContexts, item));
        completeEvent = startEvent.executionSuccess();
        log.trace("Job '{}' executed, item is: '{}'.", jobName, item);
    // CHECKSTYLE:OFF
    } catch (final Throwable cause) {
        // CHECKSTYLE:ON
        completeEvent = startEvent.executionFailure(cause);
        itemErrorMessages.put(item, ExceptionUtil.transform(cause));
        jobExceptionHandler.handleException(jobName, cause);
    } finally {
        if (shardingContexts.isAllowSendJobEvent()) {
            jobFacade.postJobExecutionEvent(completeEvent);
        }
    }
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) ShardingContext(com.dangdang.ddframe.job.api.ShardingContext)

Aggregations

ShardingContext (com.dangdang.ddframe.job.api.ShardingContext)1 JobExecutionEvent (com.dangdang.ddframe.job.event.type.JobExecutionEvent)1