manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1546717 - in /manifoldcf/branches/CONNECTORS-781/framework: agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java
Date Sat, 30 Nov 2013 11:00:06 GMT
Author: kwright
Date: Sat Nov 30 11:00:06 2013
New Revision: 1546717

URL: http://svn.apache.org/r1546717
Log:
Get rid of unnecessary bells and whistles.

Modified:
    manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.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/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java?rev=1546717&r1=1546716&r2=1546717&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java
(original)
+++ manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java
Sat Nov 30 11:00:06 2013
@@ -321,7 +321,6 @@ public class ManifoldCF extends org.apac
     ILockManager lockManager = LockManagerFactory.make(threadContext);
     // Get agent manager
     IAgentManager manager = AgentManagerFactory.make(threadContext);
-    ManifoldCFException problem = null;
     synchronized (runningHash)
     {
       String[] classes = manager.getAllAgents();
@@ -349,8 +348,9 @@ public class ManifoldCF extends org.apac
           }
           catch (ManifoldCFException e)
           {
-            problem = e;
-            agent.cleanUp(threadContext);
+            if (e.getErrorCode() != ManifoldCFException.INTERRUPTED)
+              agent.cleanUp(threadContext);
+            throw e;
           }
         }
         currentAgentClasses.add(className);
@@ -365,25 +365,15 @@ public class ManifoldCF extends org.apac
         {
           // Shut down this one agent.
           IAgent agent = runningHash.get(runningAgentClass);
-          try
-          {
-            // Stop it
-            agent.stopAgent(threadContext);
-            lockManager.endServiceActivity(getAgentsClassServiceType(runningAgentClass),
processID);
-            runningAgentsIterator.remove();
-            agent.cleanUp(threadContext);
-          }
-          catch (ManifoldCFException e)
-          {
-            problem = e;
-          }
+          // Stop it
+          agent.stopAgent(threadContext);
+          lockManager.endServiceActivity(getAgentsClassServiceType(runningAgentClass), processID);
+          runningAgentsIterator.remove();
+          agent.cleanUp(threadContext);
         }
       }
     }
 
-    if (problem != null)
-      throw problem;
-    
     synchronized (runningHash)
     {
       // For every class we're supposed to be running, find registered but no-longer-active
instances and clean

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=1546717&r1=1546716&r2=1546717&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
Sat Nov 30 11:00:06 2013
@@ -31,7 +31,6 @@ public class CrawlerAgent implements IAg
 
   // Thread objects.
   // These get filled in as threads are created.
-  protected InitializationThread initializationThread = null;
   protected JobStartThread jobStartThread = null;
   protected StufferThread stufferThread = null;
   protected FinisherThread finisherThread = null;
@@ -149,8 +148,10 @@ public class CrawlerAgent implements IAg
     IJobManager jobManager = JobManagerFactory.make(threadContext);
     jobManager.cleanupProcessData();
     // What kind of reprioritization should be done here?
-    // There may be a dangling reprioritization, or even worse, someone may have blown
-    // away the lockmanager info.  So we need to do a complete reprioritization.
+    // Answer: since we basically keep everything in the database now, the only kind of reprioritization
we need
+    // to take care of are dangling ones that won't get done because the process that was
doing them went
+    // away.  BUT: somebody may have blown away lock info, in which case we won't know anything
at all.
+    // So we do everything in that case.
     ManifoldCF.resetAllDocumentPriorities(threadContext,System.currentTimeMillis(),currentProcessID);
   }
   
@@ -374,110 +375,53 @@ public class CrawlerAgent implements IAg
     seedingThread = new SeedingThread(new SeedingResetManager(processID),processID);
     idleCleanupThread = new IdleCleanupThread(processID);
 
-    initializationThread = new InitializationThread();
-    // Start the initialization thread.  This does the initialization work and starts all
the other threads when that's done.  It then exits.
-    initializationThread.start();
-    Logging.root.info("Pull-agent started");
-  }
-
-  protected class InitializationThread extends Thread
-  {
+    // Start all the threads
+    jobStartThread.start();
+    startupThread.start();
+    startDeleteThread.start();
+    finisherThread.start();
+    notificationThread.start();
+    jobDeleteThread.start();
+    stufferThread.start();
+    expireStufferThread.start();
+    setPriorityThread.start();
+    historyCleanupThread.start();
 
-    public InitializationThread()
+    i = 0;
+    while (i < numWorkerThreads)
     {
-      super();
-      setName("Initialization thread");
-      setDaemon(true);
+      workerThreads[i].start();
+      i++;
     }
 
-    public void run()
+    i = 0;
+    while (i < numExpireThreads)
     {
-      int i;
-
-      try
-      {
-        IThreadContext threadContext = ThreadContextFactory.make();
-
-        // First, get a job manager
-        IJobManager jobManager = JobManagerFactory.make(threadContext);
-        IBinManager binManager = BinManagerFactory.make(threadContext);
-        IRepositoryConnectionManager mgr = RepositoryConnectionManagerFactory.make(threadContext);
-        ReprioritizationTracker rt = new ReprioritizationTracker(threadContext);
-
-        /* No longer needed, because IAgents specifically initializes/cleans up.
-        
-        Logging.threads.debug("Agents process starting initialization...");
-
-        // Call the database to get it ready
-        jobManager.prepareForStart();
-        
-        Logging.threads.debug("Agents process reprioritizing documents...");
-        // This needs to be moved to cleanup method(s)
-        ManifoldCF.resetAllDocumentPriorities(threadContext,System.currentTimeMillis(),processID);
-        Logging.threads.debug("Agents process initialization complete!");
-        */
-        
-        // Start all the threads
-        jobStartThread.start();
-        startupThread.start();
-        startDeleteThread.start();
-        finisherThread.start();
-        notificationThread.start();
-        jobDeleteThread.start();
-        stufferThread.start();
-        expireStufferThread.start();
-        setPriorityThread.start();
-        historyCleanupThread.start();
-
-        i = 0;
-        while (i < numWorkerThreads)
-        {
-          workerThreads[i].start();
-          i++;
-        }
+      expireThreads[i].start();
+      i++;
+    }
 
-        i = 0;
-        while (i < numExpireThreads)
-        {
-          expireThreads[i].start();
-          i++;
-        }
+    cleanupStufferThread.start();
+    i = 0;
+    while (i < numCleanupThreads)
+    {
+      cleanupThreads[i].start();
+      i++;
+    }
 
-        cleanupStufferThread.start();
-        i = 0;
-        while (i < numCleanupThreads)
-        {
-          cleanupThreads[i].start();
-          i++;
-        }
+    deleteStufferThread.start();
+    i = 0;
+    while (i < numDeleteThreads)
+    {
+      deleteThreads[i].start();
+      i++;
+    }
 
-        deleteStufferThread.start();
-        i = 0;
-        while (i < numDeleteThreads)
-        {
-          deleteThreads[i].start();
-          i++;
-        }
+    jobResetThread.start();
+    seedingThread.start();
+    idleCleanupThread.start();
 
-        jobResetThread.start();
-        seedingThread.start();
-        idleCleanupThread.start();
-        // exit!
-      }
-      catch (Throwable e)
-      {
-        // Severe error on initialization
-        if (e instanceof ManifoldCFException)
-        {
-          // Deal with interrupted exception gracefully, because it means somebody is trying
to shut us down before we got started.
-          if (((ManifoldCFException)e).getErrorCode() == ManifoldCFException.INTERRUPTED)
-            return;
-        }
-        System.err.println("agents process could not start - shutting down");
-        Logging.threads.fatal("Startup initialization error tossed: "+e.getMessage(),e);
-        System.exit(-300);
-      }
-    }
+    Logging.root.info("Pull-agent started");
   }
 
   /** Stop the system.
@@ -486,7 +430,7 @@ public class CrawlerAgent implements IAg
     throws ManifoldCFException
   {
     Logging.root.info("Shutting down pull-agent...");
-    while (initializationThread != null || jobDeleteThread != null || startupThread != null
|| startDeleteThread != null ||
+    while (jobDeleteThread != null || startupThread != null || startDeleteThread != null
||
       jobStartThread != null || stufferThread != null ||
       finisherThread != null || notificationThread != null || workerThreads != null || expireStufferThread
!= null || expireThreads != null ||
       deleteStufferThread != null || deleteThreads != null ||
@@ -496,10 +440,6 @@ public class CrawlerAgent implements IAg
       // Send an interrupt to all threads that are still there.
       // In theory, this only needs to be done once.  In practice, I have seen cases where
the thread loses track of the fact that it has been
       // interrupted (which may be a JVM bug - who knows?), but in any case there's no harm
in doing it again.
-      if (initializationThread != null)
-      {
-        initializationThread.interrupt();
-      }
       if (historyCleanupThread != null)
       {
         historyCleanupThread.interrupt();
@@ -611,11 +551,6 @@ public class CrawlerAgent implements IAg
       }
 
       // Check to see which died.
-      if (initializationThread != null)
-      {
-        if (!initializationThread.isAlive())
-          initializationThread = null;
-      }
       if (historyCleanupThread != null)
       {
         if (!historyCleanupThread.isAlive())



Mime
View raw message