use of com.vip.saturn.job.exception.JobException in project Saturn by vipshop.
the class SaturnWorker method initTrigger.
private void initTrigger(Trigger trigger) {
if (trigger == null) {
return;
}
if (!(trigger instanceof OperableTrigger)) {
throw new JobException("the trigger should be the instance of OperableTrigger");
}
this.triggerObj = (OperableTrigger) trigger;
Date ft = this.triggerObj.computeFirstFireTime(null);
if (ft == null) {
LogUtils.warn(log, LogEvents.ExecutorEvent.COMMON, "Based on configured schedule, the given trigger {} will never fire.", trigger.getKey(), job.getJobName());
}
}
use of com.vip.saturn.job.exception.JobException in project Saturn by vipshop.
the class JobNodeStorage method executeInLeader.
/**
* 在主节点执行操作.
*
* @param latchNode 分布式锁使用的作业节点名称
* @param callback 执行操作的回调
*/
public void executeInLeader(final String latchNode, final LeaderExecutionCallback callback) {
try (LeaderLatch latch = new LeaderLatch(getClient(), JobNodePath.getNodeFullPath(jobConfiguration.getJobName(), latchNode))) {
latch.start();
latch.await();
callback.execute();
// CHECKSTYLE:OFF
} catch (final Exception e) {
LogUtils.error(log, jobName, e.getMessage(), e);
// CHECKSTYLE:ON
if (e instanceof InterruptedException) {
// NOSONAR
Thread.currentThread().interrupt();
} else {
throw new JobException(e);
}
}
}
use of com.vip.saturn.job.exception.JobException in project Saturn by vipshop.
the class AbstractElasticJob method init.
protected void init() {
Class<? extends Trigger> triggerClass = configService.getJobType().getTriggerClass();
Trigger trigger = null;
try {
trigger = triggerClass.newInstance();
trigger.init(this);
} catch (Exception e) {
LogUtils.error(log, jobName, "Trigger init failed", e);
throw new JobException(e);
}
scheduler = new SaturnScheduler(this, trigger);
scheduler.start();
getExecutorService();
}
use of com.vip.saturn.job.exception.JobException in project Saturn by vipshop.
the class JobExecutionMultipleShardingContext method createJobExecutionSingleShardingContext.
/**
* 根据分片项获取单分片作业运行时上下文.
*
* @param item 分片项
* @return 单分片作业运行时上下文
*/
public JobExecutionSingleShardingContext createJobExecutionSingleShardingContext(final int item) {
JobExecutionSingleShardingContext result = new JobExecutionSingleShardingContext();
try {
BeanUtils.copyProperties(result, this);
} catch (final IllegalAccessException | InvocationTargetException ex) {
throw new JobException(ex);
}
result.setShardingItem(item);
result.setShardingItemParameter(shardingItemParameters.get(item));
result.setOffset(offsets.get(item));
return result;
}
use of com.vip.saturn.job.exception.JobException in project Saturn by vipshop.
the class JobScheduler method createJob.
private void createJob() {
try {
job = JobTypeManager.get(currentConf.getJobType()).getHandlerClass().newInstance();
} catch (Exception e) {
LogUtils.error(log, jobName, "unexpected error", e);
throw new JobException(e);
}
job.setJobScheduler(this);
job.setConfigService(configService);
job.setShardingService(shardingService);
job.setExecutionContextService(executionContextService);
job.setExecutionService(executionService);
job.setFailoverService(failoverService);
job.setServerService(serverService);
job.setExecutorName(executorName);
job.setReportService(reportService);
job.setJobName(jobName);
job.setNamespace(coordinatorRegistryCenter.getNamespace());
job.setSaturnExecutorService(saturnExecutorService);
job.init();
}
Aggregations