incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1205267 - in /incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs: JobManager.java Jobs.java
Date Wed, 23 Nov 2011 02:33:56 GMT
Author: kwright
Date: Wed Nov 23 02:33:55 2011
New Revision: 1205267

URL: http://svn.apache.org/viewvc?rev=1205267&view=rev
Log:
First batch of changes to allow docpriority modifications during pause, activewait, resume,
and return to active.  These changes are incomplete in that we're missing support for the
actual transitions, so pause is busted with this commit.

Modified:
    incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
    incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java

Modified: incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java?rev=1205267&r1=1205266&r2=1205267&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
(original)
+++ incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
Wed Nov 23 02:33:55 2011
@@ -4566,21 +4566,7 @@ public class JobManager implements IJobM
           break;
         case Jobs.STATUS_ACTIVEWAIT:
           unwaitList.add(jobID);
-          if (connectionMgr.checkConnectorExists(connectionName))
-          {
-            if (outputMgr.checkConnectorExists(outputName))
-              newJobState = jobs.STATUS_ACTIVE;
-            else
-              newJobState = jobs.STATUS_ACTIVE_NOOUTPUT;
-          }
-          else
-          {
-            if (outputMgr.checkConnectorExists(outputName))
-              newJobState = jobs.STATUS_ACTIVE_UNINSTALLED;
-            else
-              newJobState = jobs.STATUS_ACTIVE_NEITHER;
-          }
-          jobs.unwaitJob(jobID,newJobState,windowEnd);
+          jobs.unwaitJob(jobID,Jobs.STATUS_RESUMING,windowEnd);
           jobQueue.clearFailTimes(jobID);
           if (Logging.jobs.isDebugEnabled())
           {
@@ -4589,21 +4575,7 @@ public class JobManager implements IJobM
           break;
         case Jobs.STATUS_ACTIVEWAITSEEDING:
           unwaitList.add(jobID);
-          if (connectionMgr.checkConnectorExists(connectionName))
-          {
-            if (outputMgr.checkConnectorExists(outputName))
-              newJobState = jobs.STATUS_ACTIVESEEDING;
-            else
-              newJobState = jobs.STATUS_ACTIVESEEDING_NOOUTPUT;
-          }
-          else
-          {
-            if (outputMgr.checkConnectorExists(outputName))
-              newJobState = jobs.STATUS_ACTIVESEEDING_UNINSTALLED;
-            else
-              newJobState = jobs.STATUS_ACTIVESEEDING_NEITHER;
-          }
-          jobs.unwaitJob(jobID,newJobState,windowEnd);
+          jobs.unwaitJob(jobID,Jobs.STATUS_RESUMINGSEEDING,windowEnd);
           jobQueue.clearFailTimes(jobID);
           if (Logging.jobs.isDebugEnabled())
           {
@@ -4626,6 +4598,22 @@ public class JobManager implements IJobM
             Logging.jobs.debug("Un-waited (but still paused) job "+jobID);
           }
           break;
+        case Jobs.STATUS_PAUSINGWAITING:
+          unwaitList.add(jobID);
+          jobs.unwaitJob(jobID,jobs.STATUS_PAUSING,windowEnd);
+          if (Logging.jobs.isDebugEnabled())
+          {
+            Logging.jobs.debug("Un-waited (but still paused) job "+jobID);
+          }
+          break;
+        case Jobs.STATUS_PAUSINGWAITINGSEEDING:
+          unwaitList.add(jobID);
+          jobs.unwaitJob(jobID,jobs.STATUS_PAUSINGSEEDING,windowEnd);
+          if (Logging.jobs.isDebugEnabled())
+          {
+            Logging.jobs.debug("Un-waited (but still paused) job "+jobID);
+          }
+          break;
         default:
           break;
         }
@@ -4647,6 +4635,40 @@ public class JobManager implements IJobM
       database.endTransaction();
     }
   }
+  
+  /*
+            if (connectionMgr.checkConnectorExists(connectionName))
+          {
+            if (outputMgr.checkConnectorExists(outputName))
+              newJobState = jobs.STATUS_ACTIVE;
+            else
+              newJobState = jobs.STATUS_ACTIVE_NOOUTPUT;
+          }
+          else
+          {
+            if (outputMgr.checkConnectorExists(outputName))
+              newJobState = jobs.STATUS_ACTIVE_UNINSTALLED;
+            else
+              newJobState = jobs.STATUS_ACTIVE_NEITHER;
+          }
+  
+  
+            if (connectionMgr.checkConnectorExists(connectionName))
+          {
+            if (outputMgr.checkConnectorExists(outputName))
+              newJobState = jobs.STATUS_ACTIVESEEDING;
+            else
+              newJobState = jobs.STATUS_ACTIVESEEDING_NOOUTPUT;
+          }
+          else
+          {
+            if (outputMgr.checkConnectorExists(outputName))
+              newJobState = jobs.STATUS_ACTIVESEEDING_UNINSTALLED;
+            else
+              newJobState = jobs.STATUS_ACTIVESEEDING_NEITHER;
+          }
+
+*/
 
   /** Put active or paused jobs in wait state, if they've exceeded their window.
   *@param currentTime is the current time in milliseconds since epoch.
@@ -4704,7 +4726,7 @@ public class JobManager implements IJobM
         case Jobs.STATUS_ACTIVE_UNINSTALLED:
         case Jobs.STATUS_ACTIVE_NOOUTPUT:
         case Jobs.STATUS_ACTIVE_NEITHER:
-          jobs.waitJob(jobID,Jobs.STATUS_ACTIVEWAIT);
+          jobs.waitJob(jobID,Jobs.STATUS_ACTIVEWAITING);
           if (Logging.jobs.isDebugEnabled())
           {
             Logging.jobs.debug("Job "+jobID+" now in 'wait' state due to window end");
@@ -4714,7 +4736,7 @@ public class JobManager implements IJobM
         case Jobs.STATUS_ACTIVESEEDING_UNINSTALLED:
         case Jobs.STATUS_ACTIVESEEDING_NOOUTPUT:
         case Jobs.STATUS_ACTIVESEEDING_NEITHER:
-          jobs.waitJob(jobID,Jobs.STATUS_ACTIVEWAITSEEDING);
+          jobs.waitJob(jobID,Jobs.STATUS_ACTIVEWAITINGSEEDING);
           if (Logging.jobs.isDebugEnabled())
           {
             Logging.jobs.debug("Job "+jobID+" now in 'wait' state due to window end");
@@ -4734,6 +4756,20 @@ public class JobManager implements IJobM
             Logging.jobs.debug("Job "+jobID+" now in 'wait paused' state due to window end");
           }
           break;
+        case Jobs.STATUS_PAUSING:
+          jobs.waitJob(jobID,Jobs.STATUS_PAUSINGWAITING);
+          if (Logging.jobs.isDebugEnabled())
+          {
+            Logging.jobs.debug("Job "+jobID+" now in 'wait paused' state due to window end");
+          }
+          break;
+        case Jobs.STATUS_PAUSINGSEEDING:
+          jobs.waitJob(jobID,Jobs.STATUS_PAUSINGWAITINGSEEDING);
+          if (Logging.jobs.isDebugEnabled())
+          {
+            Logging.jobs.debug("Job "+jobID+" now in 'wait paused' state due to window end");
+          }
+          break;
         default:
           break;
         }

Modified: incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java?rev=1205267&r1=1205266&r2=1205267&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
(original)
+++ incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
Wed Nov 23 02:33:55 2011
@@ -81,8 +81,8 @@ public class Jobs extends org.apache.man
   public static final int STATUS_ACTIVEWAITSEEDING = 6;        // Same as active wait, but
seeding process is currently active also.
   public static final int STATUS_PAUSING = 7;                            // In the process
of pausing a job; will enter STATUS_PAUSED when done.
   public static final int STATUS_PAUSINGSEEDING = 8;                 // In the process of
pausing a job, but seeding also; will enter STATUS_PAUSEDSEEDING when done.
-  public static final int STATUS_PAUSINGWAIT = 9;                    // In the process of
pausing a job; will enter STATUS_PAUSEDWAIT when done.
-  public static final int STATUS_PAUSINGWAITSEEDING = 10;        // In the process of pausing
a job, but seeding also; will enter STATUS_PAUSEDWAITSEEDING when done.
+  public static final int STATUS_PAUSINGWAITING = 9;                // In the process of
pausing a job; will enter STATUS_PAUSEDWAIT when done.
+  public static final int STATUS_PAUSINGWAITINGSEEDING = 10;        // In the process of
pausing a job, but seeding also; will enter STATUS_PAUSEDWAITSEEDING when done.
   public static final int STATUS_PAUSED = 11;                             // Paused, but
within a valid window
   public static final int STATUS_PAUSEDSEEDING = 12;              // Same as paused, but
seeding process is currently active also.
   public static final int STATUS_PAUSEDWAIT = 13;                        // Paused, and outside
of window expiration
@@ -213,8 +213,8 @@ public class Jobs extends org.apache.man
     statusMap.put("h",new Integer(STATUS_ACTIVEWAITINGSEEDING));
     statusMap.put("F",new Integer(STATUS_PAUSING));
     statusMap.put("f",new Integer(STATUS_PAUSINGSEEDING));
-    statusMap.put("G",new Integer(STATUS_PAUSINGWAIT));
-    statusMap.put("g",new Integer(STATUS_PAUSINGWAITSEEDING));
+    statusMap.put("G",new Integer(STATUS_PAUSINGWAITING));
+    statusMap.put("g",new Integer(STATUS_PAUSINGWAITINGSEEDING));
     statusMap.put("I",new Integer(STATUS_RESUMING));
     statusMap.put("i",new Integer(STATUS_RESUMINGSEEDING));
 
@@ -830,6 +830,26 @@ public class Jobs extends org.apache.man
       performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
       query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_PAUSINGSEEDING))});
+      map.put(statusField,statusToString(STATUS_PAUSING));
+      performUpdate(map,"WHERE "+query,list,invKey);
+      list.clear();
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVEWAITINGSEEDING))});
+      map.put(statusField,statusToString(STATUS_ACTIVEWAITING));
+      performUpdate(map,"WHERE "+query,list,invKey);
+      list.clear();
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_PAUSINGWAITINGSEEDING))});
+      map.put(statusField,statusToString(STATUS_PAUSINGWAITING));
+      performUpdate(map,"WHERE "+query,list,invKey);
+      list.clear();
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_RESUMINGSEEDING))});
+      map.put(statusField,statusToString(STATUS_RESUMING));
+      performUpdate(map,"WHERE "+query,list,invKey);
+      list.clear();
+      query = buildConjunctionClause(list,new ClauseDescription[]{
         new UnitaryClause(statusField,statusToString(STATUS_ABORTINGSEEDING))});
       map.put(statusField,statusToString(STATUS_ABORTING));
       performUpdate(map,"WHERE "+query,list,invKey);
@@ -1115,7 +1135,8 @@ public class Jobs extends org.apache.man
     String statusValue = (String)row.getValue(statusField);
     int status = stringToStatus(statusValue);
     // Any active state in the lifecycle will do: seeding, active, active_seeding
-    return (status == STATUS_ACTIVE || status == STATUS_ACTIVESEEDING || status == STATUS_STARTINGUP);
+    return (status == STATUS_ACTIVE || status == STATUS_ACTIVESEEDING ||
+      status == STATUS_STARTINGUP);
   }
 
   /** Reset delete startup worker thread status.
@@ -1200,6 +1221,26 @@ public class Jobs extends org.apache.man
       performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
       query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_PAUSINGSEEDING))});
+      map.put(statusField,statusToString(STATUS_PAUSING));
+      performUpdate(map,"WHERE "+query,list,invKey);
+      list.clear();
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVEWAITINGSEEDING))});
+      map.put(statusField,statusToString(STATUS_ACTIVEWAITING));
+      performUpdate(map,"WHERE "+query,list,invKey);
+      list.clear();
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_PAUSINGWAITINGSEEDING))});
+      map.put(statusField,statusToString(STATUS_PAUSINGWAITING));
+      performUpdate(map,"WHERE "+query,list,invKey);
+      list.clear();
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_RESUMINGSEEDING))});
+      map.put(statusField,statusToString(STATUS_RESUMING));
+      performUpdate(map,"WHERE "+query,list,invKey);
+      list.clear();
+      query = buildConjunctionClause(list,new ClauseDescription[]{
         new UnitaryClause(statusField,statusToString(STATUS_ABORTINGSEEDING))});
       map.put(statusField,statusToString(STATUS_ABORTING));
       performUpdate(map,"WHERE "+query,list,invKey);
@@ -1448,7 +1489,8 @@ public class Jobs extends org.apache.man
 
       HashMap map = new HashMap();
       map.put(statusField,statusToString(newStatus));
-      if (newStatus == STATUS_ACTIVE || newStatus == STATUS_ACTIVE_UNINSTALLED || newStatus
== STATUS_ACTIVE_NOOUTPUT || newStatus == STATUS_ACTIVE_NEITHER)
+      if (newStatus == STATUS_ACTIVE || newStatus == STATUS_ACTIVE_UNINSTALLED ||
+        newStatus == STATUS_ACTIVE_NOOUTPUT || newStatus == STATUS_ACTIVE_NEITHER)
       {
         map.put(startTimeField,new Long(startTime));
       }
@@ -1496,6 +1538,15 @@ public class Jobs extends org.apache.man
       case STATUS_ACTIVESEEDING:
         newStatus = STATUS_ACTIVE;
         break;
+      case STATUS_PAUSINGSEEDING:
+        newStatus = STATUS_PAUSING;
+        break;
+      case STATUS_ACTIVEWAITINGSEEDING:
+        newStatus = STATUS_ACTIVEWAITING;
+        break;
+      case STATUS_PAUSINGWAITINGSEEDING:
+        newStatus = STATUS_PAUSINGWAITING;
+        break;
       case STATUS_ACTIVESEEDING_UNINSTALLED:
         newStatus = STATUS_ACTIVE_UNINSTALLED;
         break;
@@ -1615,6 +1666,9 @@ public class Jobs extends org.apache.man
       case STATUS_ACTIVE_NOOUTPUT:
       case STATUS_ACTIVE_NEITHER:
       case STATUS_ACTIVEWAIT:
+      case STATUS_PAUSING:
+      case STATUS_ACTIVEWAITING:
+      case STATUS_PAUSINGWAITING:
       case STATUS_PAUSED:
       case STATUS_PAUSEDWAIT:
       case STATUS_ABORTINGFORRESTART:
@@ -1625,6 +1679,9 @@ public class Jobs extends org.apache.man
       case STATUS_ACTIVESEEDING_NOOUTPUT:
       case STATUS_ACTIVESEEDING_NEITHER:
       case STATUS_ACTIVEWAITSEEDING:
+      case STATUS_PAUSINGSEEDING:
+      case STATUS_ACTIVEWAITINGSEEDING:
+      case STATUS_PAUSINGWAITINGSEEDING:
       case STATUS_PAUSEDSEEDING:
       case STATUS_PAUSEDWAITSEEDING:
       case STATUS_ABORTINGFORRESTARTSEEDING:
@@ -1689,6 +1746,9 @@ public class Jobs extends org.apache.man
       case STATUS_ACTIVE_NOOUTPUT:
       case STATUS_ACTIVE_NEITHER:
       case STATUS_ACTIVEWAIT:
+      case STATUS_PAUSING:
+      case STATUS_ACTIVEWAITING:
+      case STATUS_PAUSINGWAITING:
       case STATUS_PAUSED:
       case STATUS_PAUSEDWAIT:
         newStatus = STATUS_ABORTINGFORRESTART;
@@ -1698,6 +1758,9 @@ public class Jobs extends org.apache.man
       case STATUS_ACTIVESEEDING_NOOUTPUT:
       case STATUS_ACTIVESEEDING_NEITHER:
       case STATUS_ACTIVEWAITSEEDING:
+      case STATUS_PAUSINGSEEDING:
+      case STATUS_ACTIVEWAITINGSEEDING:
+      case STATUS_PAUSINGWAITINGSEEDING:
       case STATUS_PAUSEDSEEDING:
       case STATUS_PAUSEDWAITSEEDING:
         newStatus = STATUS_ABORTINGFORRESTARTSEEDING;
@@ -1752,7 +1815,10 @@ public class Jobs extends org.apache.man
       case STATUS_ACTIVE_UNINSTALLED:
       case STATUS_ACTIVE_NOOUTPUT:
       case STATUS_ACTIVE_NEITHER:
-        newStatus = STATUS_PAUSED;
+        newStatus = STATUS_PAUSING;
+        break;
+      case STATUS_ACTIVEWAITING:
+        newStatus = STATUS_PAUSINGWAITING;
         break;
       case STATUS_ACTIVEWAIT:
         newStatus = STATUS_PAUSEDWAIT;
@@ -1761,7 +1827,10 @@ public class Jobs extends org.apache.man
       case STATUS_ACTIVESEEDING_UNINSTALLED:
       case STATUS_ACTIVESEEDING_NOOUTPUT:
       case STATUS_ACTIVESEEDING_NEITHER:
-        newStatus = STATUS_PAUSEDSEEDING;
+        newStatus = STATUS_PAUSINGSEEDING;
+        break;
+      case STATUS_ACTIVEWAITINGSEEDING:
+        newStatus = STATUS_PAUSINGWAITINGSEEDING;
         break;
       case STATUS_ACTIVEWAITSEEDING:
         newStatus = STATUS_PAUSEDWAITSEEDING;
@@ -1815,6 +1884,47 @@ public class Jobs extends org.apache.man
       switch (status)
       {
       case STATUS_PAUSED:
+        newStatus = STATUS_RESUMING;
+        break;
+      case STATUS_PAUSEDWAIT:
+        newStatus = STATUS_ACTIVEWAIT;
+        break;
+      case STATUS_PAUSEDSEEDING:
+        newStatus = STATUS_RESUMINGSEEDING;
+        break;
+      case STATUS_PAUSEDWAITSEEDING:
+        newStatus = STATUS_ACTIVEWAITSEEDING;
+        break;
+      default:
+        throw new ManifoldCFException("Job "+jobID+" is not paused");
+      }
+      // Pause the job
+      HashMap map = new HashMap();
+      map.put(statusField,statusToString(newStatus));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
+    }
+    catch (ManifoldCFException e)
+    {
+      signalRollback();
+      throw e;
+    }
+    catch (Error e)
+    {
+      signalRollback();
+      throw e;
+    }
+    finally
+    {
+      endTransaction();
+    }
+  }
+
+  /* We will need in some method to transition from RESUMING and RESUMINGSEEDING to an active
method.  The code for that,
+  in part, is as follows:
+
+      switch (status)
+      {
+      case STATUS_RESUMING:
         if (connectionMgr.checkConnectorExists(connectionName))
         {
           if (outputMgr.checkConnectorExists(outputName))
@@ -1830,10 +1940,7 @@ public class Jobs extends org.apache.man
             newStatus = STATUS_ACTIVE_NEITHER;
         }
         break;
-      case STATUS_PAUSEDWAIT:
-        newStatus = STATUS_ACTIVEWAIT;
-        break;
-      case STATUS_PAUSEDSEEDING:
+      case STATUS_RESUMINGSEEDING:
         if (connectionMgr.checkConnectorExists(connectionName))
         {
           if (outputMgr.checkConnectorExists(outputName))
@@ -1849,33 +1956,12 @@ public class Jobs extends org.apache.man
             newStatus = STATUS_ACTIVESEEDING_NEITHER;
         }
         break;
-      case STATUS_PAUSEDWAITSEEDING:
-        newStatus = STATUS_ACTIVEWAITSEEDING;
-        break;
       default:
         throw new ManifoldCFException("Job "+jobID+" is not paused");
       }
-      // Pause the job
-      HashMap map = new HashMap();
-      map.put(statusField,statusToString(newStatus));
-      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
-    }
-    catch (ManifoldCFException e)
-    {
-      signalRollback();
-      throw e;
-    }
-    catch (Error e)
-    {
-      signalRollback();
-      throw e;
-    }
-    finally
-    {
-      endTransaction();
-    }
-  }
 
+  */
+  
   /** Update a job's status, and its reseed time.
   *@param jobID is the job id.
   *@param status is the desired status.
@@ -2208,9 +2294,9 @@ public class Jobs extends org.apache.man
       return "F";
     case STATUS_PAUSINGSEEDING:
       return "f";
-    case STATUS_PAUSINGWAIT:
+    case STATUS_PAUSINGWAITING:
       return "G";
-    case STATUS_PAUSINGWAITSEEDING:
+    case STATUS_PAUSINGWAITINGSEEDING:
       return "g";
     case STATUS_RESUMING:
       return "I";



Mime
View raw message