Author: kwright
Date: Fri Nov 22 19:07:01 2013
New Revision: 1544643
URL: http://svn.apache.org/r1544643
Log:
Break agents initialization/deinitialization out so we have loggers available
all the time.
Modified:
manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IAgent.java
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/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=1544643&r1=1544642&r2=1544643&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
Fri Nov 22 19:07:01 2013
@@ -31,6 +31,20 @@ public interface IAgent
{
public static final String _rcsid = "@(#)$Id: IAgent.java 988245 2010-08-23
18:39:35Z kwright $";
+ /** Initialize agent environment.
+ * This is called before any of the other operations are called, and is meant
to insure that
+ * the environment is properly initialized.
+ */
+ public void initialize()
+ throws ManifoldCFException;
+
+ /** Tear down agent environment.
+ * This is called after all the other operations are completed, and is meant
to allow
+ * environment resources to be freed.
+ */
+ public void cleanUp()
+ throws ManifoldCFException;
+
/** Install agent. This usually installs the agent's database tables etc.
*/
public void install()
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=1544643&r1=1544642&r2=1544643&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
Fri Nov 22 19:07:01 2013
@@ -153,12 +153,11 @@ public class ManifoldCF extends org.apac
{
// Start this agent
IAgent agent = AgentFactory.make(threadContext,className);
+ agent.initialize();
try
{
// There is a potential race condition where the agent has been
started but hasn't yet appeared in runningHash.
// But having runningHash be the synchronizer for this activity
will prevent any problems.
- // There is ANOTHER potential race condition, however, that can
occur if the process is shut down just before startAgents() is called.
- // We avoid that problem by means of a flag, which prevents
startAgents() from doing anything once stopAgents() has been called.
agent.startAgent();
// Successful!
runningHash.put(className,agent);
@@ -166,6 +165,7 @@ public class ManifoldCF extends org.apac
catch (ManifoldCFException e)
{
problem = e;
+ agent.cleanUp();
}
}
}
@@ -191,6 +191,7 @@ public class ManifoldCF extends org.apac
// Stop it
agent.stopAgent();
iter.remove();
+ agent.cleanUp();
}
}
// Done.
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=1544643&r1=1544642&r2=1544643&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
Fri Nov 22 19:07:01 2013
@@ -39,6 +39,28 @@ public class CrawlerAgent implements IAg
this.threadContext = threadContext;
}
+ /** Initialize agent environment.
+ * This is called before any of the other operations are called, and is meant
to insure that
+ * the environment is properly initialized.
+ */
+ public void initialize()
+ throws ManifoldCFException
+ {
+
org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize(threadContext);
+
org.apache.manifoldcf.crawler.system.ManifoldCF.localInitialize(threadContext);
+ }
+
+ /** Tear down agent environment.
+ * This is called after all the other operations are completed, and is meant
to allow
+ * environment resources to be freed.
+ */
+ public void cleanUp()
+ throws ManifoldCFException
+ {
+
org.apache.manifoldcf.crawler.system.ManifoldCF.localCleanup(threadContext);
+
org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup(threadContext);
+ }
+
/** Install agent. This usually installs the agent's database tables etc.
*/
@Override
@@ -91,8 +113,6 @@ public class CrawlerAgent implements IAg
public void startAgent()
throws ManifoldCFException
{
-
org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize(threadContext);
-
org.apache.manifoldcf.crawler.system.ManifoldCF.localInitialize(threadContext);
ManifoldCF.startSystem(threadContext);
}
@@ -103,8 +123,6 @@ public class CrawlerAgent implements IAg
throws ManifoldCFException
{
ManifoldCF.stopSystem(threadContext);
-
org.apache.manifoldcf.crawler.system.ManifoldCF.localCleanup(threadContext);
-
org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup(threadContext);
}
/** Request permission from agent to delete an output connection.