[DSL] Unique job key for createTimer in DSL rule (#972)

Fixes #943

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2019-08-13 21:12:23 +02:00 committed by Christoph Weitkamp
parent a17d63ad64
commit aebcc6cd9a

View File

@ -44,6 +44,8 @@ import org.slf4j.LoggerFactory;
*/
public class ScriptExecution {
private static int timerCounter = 0;
/**
* Calls a script which must be located in the configurations/scripts folder.
*
@ -120,7 +122,7 @@ public class ScriptExecution {
private static Timer makeTimer(AbstractInstant instant, String closure, JobDataMap dataMap) {
Logger logger = LoggerFactory.getLogger(ScriptExecution.class);
JobKey jobKey = new JobKey(instant.toString() + ": " + closure.toString());
JobKey jobKey = new JobKey(getTimerId() + " " + instant.toString() + ": " + closure.toString());
Trigger trigger = newTrigger().startAt(instant.toDate()).build();
Timer timer = new TimerImpl(jobKey, trigger.getKey(), dataMap, instant);
try {
@ -137,4 +139,8 @@ public class ScriptExecution {
return null;
}
}
private static synchronized String getTimerId() {
return String.format("Timer %d", ++timerCounter);
}
}