Jason,
Could you please install these files they include fixes for the problems we
talked about
Thanks
<<calcRuntimeForColdStoreObjects.txt>> <<improvedcalcRuntime.txt>>
<<sortQueueBasedOnRuntime.txt>>
Erik Kazandjian - Software Engineer
Siemens Atea IC D AS B5
++32 14 252962
e-mail : [EMAIL PROTECTED]
Index: TurbineSchedulerService.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/schedule/TurbineSchedulerService.java,v
retrieving revision 1.2
diff -u -r1.2 TurbineSchedulerService.java
--- TurbineSchedulerService.java 2001/08/02 05:31:12 1.2
+++ TurbineSchedulerService.java 2001/12/19 13:43:43
@@ -56,6 +56,7 @@
import java.util.List;
import java.util.Vector;
+import java.util.Iterator;
import org.apache.fulcrum.BaseService;
import org.apache.fulcrum.InitializationException;
import org.apache.torque.om.NumberKey;
@@ -117,6 +118,10 @@
if ( jobs != null && jobs.size() > 0 )
{
+ Iterator it =
+jobs.iterator();
+ while(it.hasNext())
+
+((JobEntry)it.next()).calcRunTime();
+
scheduleQueue.batchLoad(jobs);
restart();
}
@@ -159,6 +164,7 @@
/**
* Add a new job to the queue.
+ * Before we add the job it calculates the runtime to make sure the
+entry will be placed at the right order in the queue.
*
* @param je A JobEntry with the job to add.
* @exception Exception, a generic exception.
@@ -169,6 +175,8 @@
try
{
// Save to DB.
+ // first we calculate the runtime to
+make sure the entry will be placed at the right order
+ je.calcRunTime();
je.save();
}
catch(Exception e)
Index: JobEntry.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/schedule/JobEntry.java,v
retrieving revision 1.3
diff -u -r1.3 JobEntry.java
--- JobEntry.java 2001/09/20 22:57:55 1.3
+++ JobEntry.java 2001/12/19 13:46:39
@@ -227,21 +227,21 @@
switch( evaluateJobType() )
{
- case 0:
+ case SECOND:
// SECOND (every so many seconds...)
schedrun.add(Calendar.SECOND, getSecond());
runtime = schedrun.getTime().getTime();
break;
- case 1:
+ case MINUTE:
// MINUTE (every so many minutes...)
schedrun.add(Calendar.SECOND, getSecond());
schedrun.add(Calendar.MINUTE, getMinute());
runtime = schedrun.getTime().getTime();
break;
- case 2:
+ case WEEK_DAY:
// WEEKDAY (day of the week)
- schedrun.add(Calendar.SECOND, getSecond());
+ schedrun.set(Calendar.SECOND, getSecond());
schedrun.set(Calendar.MINUTE, getMinute());
schedrun.set(Calendar.HOUR_OF_DAY, getHour());
schedrun.set(Calendar.DAY_OF_WEEK, getWeekDay());
@@ -259,9 +259,9 @@
}
break;
- case 3:
+ case DAY_OF_MONTH:
// DAY_OF_MONTH (date of the month)
- schedrun.add(Calendar.SECOND, getSecond());
+ schedrun.set(Calendar.SECOND, getSecond());
schedrun.set(Calendar.MINUTE, getMinute());
schedrun.set(Calendar.HOUR_OF_DAY, getHour());
schedrun.set(Calendar.DAY_OF_MONTH, getDayOfMonth());
@@ -279,9 +279,9 @@
}
break;
- case 4:
+ case DAILY:
// DAILY (certain hour:minutes of the day)
- schedrun.add(Calendar.SECOND, getSecond());
+ schedrun.set(Calendar.SECOND, getSecond());
schedrun.set(Calendar.MINUTE, getMinute());
schedrun.set(Calendar.HOUR_OF_DAY, getHour());
Index: JobQueue.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/schedule/JobQueue.java,v
retrieving revision 1.2
diff -u -r1.2 JobQueue.java
--- JobQueue.java 2001/08/10 11:46:24 1.2
+++ JobQueue.java 2001/12/19 13:45:07
@@ -57,6 +57,7 @@
import java.util.List;
import java.util.Vector;
import java.util.Collections;
+import java.util.Comparator;
/**
* Queue for the scheduler.
@@ -206,9 +207,19 @@
/**
* Re-sort the existing queue. Consumers of this method should be
* <code>synchronized</code>.
+ * <code>JobEntry</code>s are ordered based on there
+<code>runtime</code>.
*/
private void sortQueue()
{
- Collections.sort(queue);
+ Comparator aComparator = new Comparator () {
+ public int
+compare(Object o1, Object o2) {
+ Long
+time1 = new Long (((JobEntry)o1).getNextRuntime());
+ Long
+time2 = new Long (((JobEntry)o2).getNextRuntime());
+
+ return
+(time1.compareTo(time2));
+ }
+ };
+
+ Collections.sort(queue,aComparator);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>