Author: kwright
Date: Mon Nov 25 18:01:51 2013
New Revision: 1545355
URL: http://svn.apache.org/r1545355
Log:
Separate cluster init from global cleanup
Modified:
manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IAgent.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Carrydown.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/EventManager.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/HopCount.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/IntrinsicLink.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java
Modified:
manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IAgent.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IAgent.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IAgent.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IAgent.java
Mon Nov 25 18:01:51 2013
@@ -60,6 +60,12 @@ public interface IAgent
public void deinstall(IThreadContext threadContext)
throws ManifoldCFException;
+ /** Called ONLY when no other active services of this kind are running.
Meant to be
+ * used after the cluster has been down for an indeterminate period of time.
+ */
+ public void clusterInit(IThreadContext threadContext)
+ throws ManifoldCFException;
+
/** Cleanup after ALL agents processes.
* Call this method to clean up dangling persistent state when a cluster is
just starting
* to come up. This method CANNOT be called when there are any active agents
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java
Mon Nov 25 18:01:51 2013
@@ -143,11 +143,18 @@ public interface IJobManager
*/
public void cleanupProcessData(String processID)
throws ManifoldCFException;
-
+
+ /** Reset the job queue for all process IDs.
+ * If a node was shut down in the middle of doing something, sufficient
information should
+ * be around in the database to allow the node's activities to be cleaned up.
+ */
+ public void cleanupProcessData()
+ throws ManifoldCFException;
+
/** Prepare to start the entire cluster.
* If there are no other nodes alive, then at the time the first node comes
up, we need to
- * reset the job queue for ALL processes that had been running before. This
method can
- * be called in lieu of prepareForStart().
+ * reset the job queue for ALL processes that had been running before. This
method must
+ * be called in addition to cleanupProcessData().
*/
public void prepareForClusterStart()
throws ManifoldCFException;
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Carrydown.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Carrydown.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Carrydown.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Carrydown.java
Mon Nov 25 18:01:51 2013
@@ -229,9 +229,9 @@ public class Carrydown extends org.apach
performUpdate(map,"WHERE "+query,list,null);
}
- /** Reset, at startup time, entire cluster
+ /** Clean up after all process IDs.
*/
- public void restartCluster()
+ public void restart()
throws ManifoldCFException
{
// Delete "new" rows
@@ -248,6 +248,14 @@ public class Carrydown extends org.apach
new UnitaryClause(newField,statusToString(ISNEW_EXISTING))});
performUpdate(map,"WHERE "+query,list,null);
}
+
+ /** Reset, at startup time, entire cluster
+ */
+ public void restartCluster()
+ throws ManifoldCFException
+ {
+ // Does nothing
+ }
/** Add carrydown data for a given parent/child pair.
*
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/EventManager.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/EventManager.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/EventManager.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/EventManager.java
Mon Nov 25 18:01:51 2013
@@ -130,12 +130,20 @@ public class EventManager extends org.ap
performDelete("WHERE "+query,null,null);
}
+ /** Clean up after all processIDs.
+ */
+ public void restart()
+ throws ManifoldCFException
+ {
+ performDelete("",null,null);
+ }
+
/** Restart cluster.
*/
public void restartCluster()
throws ManifoldCFException
{
- performDelete("",null,null);
+ // Does nothing
}
/** Atomically create an event - and return false if the event already
exists */
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/HopCount.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/HopCount.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/HopCount.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/HopCount.java
Mon Nov 25 18:01:51 2013
@@ -310,6 +310,14 @@ public class HopCount extends org.apache
intrinsicLinkManager.restart(processID);
}
+ /** Clean up after all process IDs.
+ */
+ public void restart()
+ throws ManifoldCFException
+ {
+ intrinsicLinkManager.restart();
+ }
+
/** Restart entire cluster.
*/
public void restartCluster()
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/IntrinsicLink.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/IntrinsicLink.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/IntrinsicLink.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/IntrinsicLink.java
Mon Nov 25 18:01:51 2013
@@ -204,9 +204,9 @@ public class IntrinsicLink extends org.a
performUpdate(map,"WHERE "+query,list,null);
}
- /** Restart entire cluster.
+ /** Clean up after all process IDs
*/
- public void restartCluster()
+ public void restart()
throws ManifoldCFException
{
HashMap map = new HashMap();
@@ -219,6 +219,12 @@ public class IntrinsicLink extends org.a
performUpdate(map,"WHERE "+query,list,null);
}
+ public void restartCluster()
+ throws ManifoldCFException
+ {
+ // Does nothing
+ }
+
/** Record a references from source to targets. These references will be
marked as either "new" or "existing".
*@return the target document ID's that are considered "new".
*/
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
Mon Nov 25 18:01:51 2013
@@ -677,12 +677,71 @@ public class JobManager implements IJobM
}
}
}
-
+
+ /** Reset the job queue for all process IDs.
+ * If a node was shut down in the middle of doing something, sufficient
information should
+ * be around in the database to allow the node's activities to be cleaned up.
+ */
+ @Override
+ public void cleanupProcessData()
+ throws ManifoldCFException
+ {
+ Logging.jobs.debug("Cleaning up all process data");
+ while (true)
+ {
+ long sleepAmt = 0L;
+ database.beginTransaction();
+ try
+ {
+ // Clean up events
+ eventManager.restart();
+ // Clean up job queue
+ jobQueue.restart();
+ // Clean up jobs
+ jobs.restart();
+ // Clean up hopcount stuff
+ hopCount.restart();
+ // Clean up carrydown stuff
+ carryDown.restart();
+ TrackerClass.notePrecommit();
+ database.performCommit();
+ TrackerClass.noteCommit();
+ Logging.jobs.debug("Cleanup complete");
+ break;
+ }
+ catch (ManifoldCFException e)
+ {
+ database.signalRollback();
+ TrackerClass.noteRollback();
+ if (e.getErrorCode() == e.DATABASE_TRANSACTION_ABORT)
+ {
+ if (Logging.perf.isDebugEnabled())
+ Logging.perf.debug("Aborted transaction resetting for restart:
"+e.getMessage());
+ sleepAmt = getRandomAmount();
+ continue;
+ }
+ throw e;
+ }
+ catch (Error e)
+ {
+ database.signalRollback();
+ TrackerClass.noteRollback();
+ throw e;
+ }
+ finally
+ {
+ database.endTransaction();
+ sleepFor(sleepAmt);
+ }
+ }
+ }
+
/** Prepare to start the entire cluster.
* If there are no other nodes alive, then at the time the first node comes
up, we need to
- * reset the job queue for ALL processes that had been running before. This
method can
- * be called in lieu of prepareForStart().
+ * reset the job queue for ALL processes that had been running before. This
method must
+ * be called in addition to cleanupProcessData().
*/
+ @Override
public void prepareForClusterStart()
throws ManifoldCFException
{
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java
Mon Nov 25 18:01:51 2013
@@ -419,9 +419,9 @@ public class JobQueue extends org.apache
TrackerClass.noteGlobalChange("Restart");
}
- /** Restart for entire cluster.
+ /** Cleanup after all processIDs.
*/
- public void restartCluster()
+ public void restart()
throws ManifoldCFException
{
// Map ACTIVE back to PENDING.
@@ -472,15 +472,6 @@ public class JobQueue extends org.apache
new UnitaryClause(isSeedField,seedstatusToString(SEEDSTATUS_NEWSEED))});
performUpdate(map,"WHERE "+query,list,null);
- // Clear out all failtime fields (since we obviously haven't been retrying
whilst we were not
- // running)
- map.clear();
- map.put(failTimeField,null);
- list.clear();
- query = buildConjunctionClause(list,new ClauseDescription[]{
- new NullCheckClause(failTimeField,false)});
- performUpdate(map,"WHERE "+query,list,null);
-
// Reindex the jobqueue table, since we've probably made lots of bad
tuples doing the above operations.
reindexTable();
unconditionallyAnalyzeTables();
@@ -488,6 +479,21 @@ public class JobQueue extends org.apache
TrackerClass.noteGlobalChange("Restart cluster");
}
+ /** Restart for entire cluster.
+ */
+ public void restartCluster()
+ throws ManifoldCFException
+ {
+ // Clear out all failtime fields (since we obviously haven't been retrying
whilst we were not
+ // running)
+ HashMap map = new HashMap();
+ map.put(failTimeField,null);
+ ArrayList list = new ArrayList();
+ String query = buildConjunctionClause(list,new ClauseDescription[]{
+ new NullCheckClause(failTimeField,false)});
+ performUpdate(map,"WHERE "+query,list,null);
+ }
+
/** Flip all records for a job that have status HOPCOUNTREMOVED back to
PENDING.
* NOTE: We need to actually schedule these!!! so the following can't really
work. ???
*/
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
Mon Nov 25 18:01:51 2013
@@ -1061,9 +1061,9 @@ public class Jobs extends org.apache.man
}
- /** This method is called on a restart of the entire cluster.
+ /** Clean up after all process IDs.
*/
- public void restartCluster()
+ public void restart()
throws ManifoldCFException
{
StringSet invKey = new StringSet(getJobStatusKey());
@@ -1210,6 +1210,12 @@ public class Jobs extends org.apache.man
}
+ public void restartCluster()
+ throws ManifoldCFException
+ {
+ // Does nothing
+ }
+
/** Signal to a job that its underlying output connector has gone away.
*@param jobID is the identifier of the job.
*@param oldStatusValue is the current status value for the job.
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java?rev=1545355&r1=1545354&r2=1545355&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java
(original)
+++
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java
Mon Nov 25 18:01:51 2013
@@ -125,6 +125,17 @@ public class CrawlerAgent implements IAg
ManifoldCF.deinstallSystemTables(threadContext);
}
+ /** Called ONLY when no other active services of this kind are running.
Meant to be
+ * used after the cluster has been down for an indeterminate period of time.
+ */
+ @Override
+ public void clusterInit(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ IJobManager jobManager = JobManagerFactory.make(threadContext);
+ jobManager.prepareForClusterStart();
+ }
+
/** Cleanup after ALL agents processes.
* Call this method to clean up dangling persistent state when a cluster is
just starting
* to come up. This method CANNOT be called when there are any active agents
@@ -135,7 +146,7 @@ public class CrawlerAgent implements IAg
throws ManifoldCFException
{
IJobManager jobManager = JobManagerFactory.make(threadContext);
- jobManager.prepareForClusterStart();
+ jobManager.cleanupProcessData();
}
/** Cleanup after agents process.
@@ -150,7 +161,6 @@ public class CrawlerAgent implements IAg
throws ManifoldCFException
{
IJobManager jobManager = JobManagerFactory.make(threadContext);
- // This replaces prepareForStart(), and is always called before system
starts
jobManager.cleanupProcessData(processID);
}