Revision: 15604
Author: [email protected]
Date: Thu Dec 2 07:40:04 2010
Log: Update Issue 2131
Fixing timer recovery exception
http://code.google.com/p/mobicents/source/detail?r=15604
Modified:
/trunk/servers/cluster/timers/src/main/java/org/mobicents/timers/FaultTolerantScheduler.java
=======================================
---
/trunk/servers/cluster/timers/src/main/java/org/mobicents/timers/FaultTolerantScheduler.java
Thu Nov 18 09:02:41 2010
+++
/trunk/servers/cluster/timers/src/main/java/org/mobicents/timers/FaultTolerantScheduler.java
Thu Dec 2 07:40:04 2010
@@ -198,12 +198,15 @@
// logic
+ public void schedule(TimerTask task) {
+ schedule(task, true);
+ }
/**
* Schedules the specified task.
*
* @param task
*/
- public void schedule(TimerTask task) {
+ public void schedule(TimerTask task, boolean checkIfAlreadyPresent) {
final TimerTaskData taskData = task.getData();
final Serializable taskID = taskData.getTaskID();
@@ -217,7 +220,7 @@
final TimerTaskCacheData timerTaskCacheData = new
TimerTaskCacheData(taskID, baseFqn, cluster);
if (timerTaskCacheData.create()) {
timerTaskCacheData.setTaskData(taskData);
- } else {
+ } else if(checkIfAlreadyPresent) {
throw new IllegalStateException("timer task " + taskID + "
already scheduled");
}
@@ -339,7 +342,9 @@
logger.debug("Recovering task with id
"+taskData.getTaskID());
}
task.beforeRecover();
- schedule(task);
+ // on recovery the task will already be in the cache so we don't check
for it
+ // or an IllegalStateException will be thrown
+ schedule(task, false);
}
public void shutdownNow() {