You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/08/25 07:19:41 UTC
[GitHub] [shardingsphere-elasticjob] Technoboy- opened a new issue #1410: OneOffJob reschedule error
Technoboy- opened a new issue #1410:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1410
As OneOffJob do not need cron, If we update the job config, reschedule OneOffJob will throw below exception.
![image](https://user-images.githubusercontent.com/6297296/91144267-5cae1300-e6e6-11ea-9611-440fac776bce.png)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere-elasticjob] terrymanu closed issue #1410: OneOffJob reschedule error
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #1410:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1410
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere-elasticjob] Technoboy- commented on issue #1410: OneOffJob reschedule error
Posted by GitBox <gi...@apache.org>.
Technoboy- commented on issue #1410:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1410#issuecomment-679855580
I suggest to add a check logic for OneOffJobBootstrap#execute :
```
/**
* Execute job.
*/
public void execute() {
Preconditions.checkArgument(Strings.isNullOrEmpty(jobScheduler.getJobConfig().getCron()), "Cron should be empty for OneOffJob.");
jobScheduler.getJobScheduleController().executeJob();
}
```
and then fix RescheduleListenerManager like below :
```
class CronSettingAndJobEventChangedJobListener extends AbstractJobListener {
@Override
protected void dataChanged(final String path, final Type eventType, final String data) {
if (configNode.isConfigPath(path) && Type.NODE_CHANGED == eventType && !JobRegistry.getInstance().isShutdown(jobName)) {
JobConfiguration jobConfiguration = YamlEngine.unmarshal(data, JobConfigurationPOJO.class).toJobConfiguration();
if(StringUtils.isEmpty(jobConfiguration.getCron())){
JobRegistry.getInstance().getJobScheduleController(jobName).rescheduleJob();
} else{
JobRegistry.getInstance().getJobScheduleController(jobName).rescheduleJob(jobConfiguration.getCron());
}
}
}
}
```
Add JobScheduleController#rescheduleJob:
```
/**
* Reschedule OneOff job.
*/
public synchronized void rescheduleJob() {
try {
SimpleTrigger trigger = (SimpleTrigger) scheduler.getTrigger(TriggerKey.triggerKey(triggerIdentity));
if (!scheduler.isShutdown() && null != trigger) {
scheduler.rescheduleJob(TriggerKey.triggerKey(triggerIdentity), createOneOffTrigger());
}
} catch (final SchedulerException ex) {
throw new JobSystemException(ex);
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org