You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by bf...@apache.org on 2010/12/14 22:41:21 UTC

svn commit: r1049294 - in /oodt/trunk: ./ resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/ resource/src/main/java/org/apache/oodt/cas/resource/scheduler/

Author: bfoster
Date: Tue Dec 14 21:41:21 2010
New Revision: 1049294

URL: http://svn.apache.org/viewvc?rev=1049294&view=rev
Log:

- add requeue(JobSpec) to Scheduler interface to allow for JobSpecs to be pulled from queue then added back without treating the JobSpec as a new JobSpec, but a returning JobSpec

----------------------

OODT-79

Modified:
    oodt/trunk/CHANGES.txt
    oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobQueue.java
    oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java
    oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java

Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1049294&r1=1049293&r2=1049294&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Tue Dec 14 21:41:21 2010
@@ -4,6 +4,9 @@ Apache OODT Change Log
 Release 0.2 (Current Development)
 --------------------------------------------
 
+* OODT-79 LRUScheduler removes a job from the JobQueue, but adds it back if can't schedule it, which (in the 
+  JobStack impl) causes JobRepo to create duplicate copies of the same JobSpec with different JobIds (bfoster)
+
 * OODT-77 Make resource manager Queue aware (bfoster)
 
 * OODT-80 Create Cached JobRepository for cas-resource (bfoster)

Modified: oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobQueue.java
URL: http://svn.apache.org/viewvc/oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobQueue.java?rev=1049294&r1=1049293&r2=1049294&view=diff
==============================================================================
--- oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobQueue.java (original)
+++ oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobQueue.java Tue Dec 14 21:41:21 2010
@@ -47,7 +47,17 @@ public interface JobQueue {
    *           If there is any error queueing the {@link JobSpec}.
    */
   public String addJob(JobSpec spec) throws JobQueueException;
-
+  
+  /**
+   * Re-adds a {@link JobSpec} to the back of the queue.
+   * 
+   * @param spec
+   *          The {@link JobSpec} to re-add.
+   * @throws JobQueueException
+   *           If there is any error requeueing the {@link JobSpec}.
+   */
+  public String requeueJob(JobSpec spec) throws JobQueueException;
+  
   /**
    * Gets an ordered {@link List} of queued {@link JobSpec}s.
    * 

Modified: oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java
URL: http://svn.apache.org/viewvc/oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java?rev=1049294&r1=1049293&r2=1049294&view=diff
==============================================================================
--- oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java (original)
+++ oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java Tue Dec 14 21:41:21 2010
@@ -82,6 +82,23 @@ public class JobStack implements JobQueu
 
   /*
    * (non-Javadoc)
+   * @see gov.nasa.jpl.oodt.cas.resource.jobqueue.JobQueue#requeueJob(gov.nasa.jpl.oodt.cas.resource.structs.JobSpec)
+   */
+  public String requeueJob(JobSpec spec) throws JobQueueException {
+	  try {
+	      queue.add(spec);
+	      spec.getJob().setStatus(JobStatus.QUEUED);
+	      safeUpdateJob(spec);
+	      return spec.getJob().getId();
+	  }catch (Exception e) {
+		  throw new JobQueueException("Failed to re-queue job '"
+                    + (spec != null ? spec.getJob().getId() : "null") + "' : "
+                    + e.getMessage(), e);
+	  }
+  }
+  
+  /*
+   * (non-Javadoc)
    * 
    * @see org.apache.oodt.cas.resource.jobqueue.JobQueue#getQueuedJobs()
    */

Modified: oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java
URL: http://svn.apache.org/viewvc/oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java?rev=1049294&r1=1049293&r2=1049294&view=diff
==============================================================================
--- oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java (original)
+++ oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/LRUScheduler.java Tue Dec 14 21:41:21 2010
@@ -112,7 +112,7 @@ public class LRUScheduler implements Sch
                             + e.getMessage());
                     // place the job spec back on the queue
                     try {
-                        myJobQueue.addJob(exec);
+                        myJobQueue.requeueJob(exec);
                     } catch (Exception ignore) {
                     }
                 }
@@ -153,7 +153,7 @@ public class LRUScheduler implements Sch
                         // queue the job back up
                         LOG.log(Level.INFO, "Requeueing job: ["
                                 + spec.getJob().getId() + "]");
-                        myJobQueue.addJob(spec);
+                        myJobQueue.requeueJob(spec);
 
                         // make sure to decrement the load
                         myMonitor.reduceLoad(node, load);
@@ -169,7 +169,7 @@ public class LRUScheduler implements Sch
         } else {
             // could not find resource, push onto JobQueue
             try {
-                myJobQueue.addJob(spec);
+                myJobQueue.requeueJob(spec);
             } catch (Exception ignore) {
             }
         }