You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by sh...@apache.org on 2011/12/15 04:16:36 UTC
svn commit: r1214610 - in /incubator/lcf/branches/CONNECTORS-313/framework:
jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/
pull-agent/src/main/java/org/apache/manifoldcf/crawler/
Author: shinichiro
Date: Thu Dec 15 03:16:35 2011
New Revision: 1214610
URL: http://svn.apache.org/viewvc?rev=1214610&view=rev
Log:
replace misspelled RegsiterConnectors.java with RegisterConnectors.java
Added:
incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterConnectors.java
Removed:
incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegsiterConnectors.java
Modified:
incubator/lcf/branches/CONNECTORS-313/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java
incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterAll.java
Modified: incubator/lcf/branches/CONNECTORS-313/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-313/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java?rev=1214610&r1=1214609&r2=1214610&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-313/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java (original)
+++ incubator/lcf/branches/CONNECTORS-313/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java Thu Dec 15 03:16:35 2011
@@ -195,29 +195,29 @@ public class ManifoldCFJettyRunner
IThreadContext tc = ThreadContextFactory.make();
// Clear the shutdown signal
- RegsiterConnectors.clearShutdownSignal(tc);
+ RegisterConnectors.clearShutdownSignal(tc);
// Get the specified superuser name and password, in case this isn't Derby we're using
- String superuserName = ManifoldCF.getProperty(RegsiterConnectors.databaseSuperuserName);
+ String superuserName = ManifoldCF.getProperty(RegisterConnectors.databaseSuperuserName);
if (superuserName == null)
superuserName = "";
- String superuserPassword = ManifoldCF.getProperty(RegsiterConnectors.databaseSuperuserPassword);
+ String superuserPassword = ManifoldCF.getProperty(RegisterConnectors.databaseSuperuserPassword);
if (superuserPassword == null)
superuserPassword = "";
// Do the basic initialization of the database and its schema
- RegsiterConnectors.createDatabaseAndSchema(tc,superuserName,superuserPassword);
- RegsiterConnectors.registerAgents(tc);
+ RegisterConnectors.createDatabaseAndSchema(tc,superuserName,superuserPassword);
+ RegisterConnectors.registerAgents(tc);
// Read connectors configuration file (to figure out what we need to register)
- File connectorConfigFile = ManifoldCF.getFileProperty(RegsiterConnectors.connectorsConfigurationFile);
- Connectors c = RegsiterConnectors.readConnectorDeclarations(connectorConfigFile);
+ File connectorConfigFile = ManifoldCF.getFileProperty(RegisterConnectors.connectorsConfigurationFile);
+ Connectors c = RegisterConnectors.readConnectorDeclarations(connectorConfigFile);
// Unregister all connectors.
- RegsiterConnectors.unregisterAllConnectors(tc);
+ RegisterConnectors.unregisterAllConnectors(tc);
// Register connections specified by connectors.xml
- RegsiterConnectors.registerConnectors(tc,c);
+ RegisterConnectors.registerConnectors(tc,c);
System.err.println("Starting jetty...");
Modified: incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterAll.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterAll.java?rev=1214610&r1=1214609&r2=1214610&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterAll.java (original)
+++ incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterAll.java Thu Dec 15 03:16:35 2011
@@ -19,26 +19,26 @@ public class RegisterAll extends Transac
ManifoldCF.initializeEnvironment();
// Clear the shutdown signal
- RegsiterConnectors.clearShutdownSignal(tc);
+ RegisterConnectors.clearShutdownSignal(tc);
// Get the specified superuser name and password, in case this isn't Derby we're using
- String superuserName = ManifoldCF.getProperty(RegsiterConnectors.databaseSuperuserName);
+ String superuserName = ManifoldCF.getProperty(RegisterConnectors.databaseSuperuserName);
if (superuserName == null)
superuserName = "";
- String superuserPassword = ManifoldCF.getProperty(RegsiterConnectors.databaseSuperuserPassword);
+ String superuserPassword = ManifoldCF.getProperty(RegisterConnectors.databaseSuperuserPassword);
if (superuserPassword == null)
superuserPassword = "";
// Do the basic initialization of the database and its schema
- RegsiterConnectors.createDatabaseAndSchema(tc,superuserName,superuserPassword);
- RegsiterConnectors.registerAgents(tc);
+ RegisterConnectors.createDatabaseAndSchema(tc,superuserName,superuserPassword);
+ RegisterConnectors.registerAgents(tc);
// Read connectors configuration file (to figure out what we need to register)
- File connectorConfigFile = ManifoldCF.getFileProperty(RegsiterConnectors.connectorsConfigurationFile);
- Connectors c = RegsiterConnectors.readConnectorDeclarations(connectorConfigFile);
+ File connectorConfigFile = ManifoldCF.getFileProperty(RegisterConnectors.connectorsConfigurationFile);
+ Connectors c = RegisterConnectors.readConnectorDeclarations(connectorConfigFile);
// Register connections specified by connectors.xml
- RegsiterConnectors.registerConnectors(tc,c);
+ RegisterConnectors.registerConnectors(tc,c);
}
public static void main(String[] args)
Added: incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterConnectors.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterConnectors.java?rev=1214610&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterConnectors.java (added)
+++ incubator/lcf/branches/CONNECTORS-313/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/RegisterConnectors.java Thu Dec 15 03:16:35 2011
@@ -0,0 +1,324 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.manifoldcf.crawler;
+
+import java.io.*;
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.authorities.interfaces.*;
+import org.apache.manifoldcf.agents.system.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Register connectors.
+ *
+ */
+public class RegisterConnectors
+{
+
+ public static final String _rcsid = "@(#)$Id: RegisterConnectors.java 989983 2010-08-27 00:10:12Z kwright $";
+
+ public static final String agentShutdownSignal = org.apache.manifoldcf.agents.AgentRun.agentShutdownSignal;
+
+ // Configuration parameters
+ public static final String connectorsConfigurationFile = "org.apache.manifoldcf.connectorsconfigurationfile";
+ public static final String databaseSuperuserName = "org.apache.manifoldcf.dbsuperusername";
+ public static final String databaseSuperuserPassword = "org.apache.manifoldcf.dbsuperuserpassword";
+
+ // Connectors configuration file
+ public static final String NODE_OUTPUTCONNECTOR = "outputconnector";
+ public static final String NODE_AUTHORITYCONNECTOR = "authorityconnector";
+ public static final String NODE_REPOSITORYCONNECTOR = "repositoryconnector";
+ public static final String ATTRIBUTE_NAME = "name";
+ public static final String ATTRIBUTE_CLASS = "class";
+
+
+ public RegisterConnectors()
+ {
+ }
+
+ /** Clear the agents shutdown signal */
+ public static void clearShutdownSignal(IThreadContext tc)
+ throws ManifoldCFException
+ {
+ // Clear the agents shutdown signal.
+ ILockManager lockManager = LockManagerFactory.make(tc);
+ lockManager.clearGlobalFlag(agentShutdownSignal);
+ }
+
+ /** Create the database and the schema */
+ public static void createDatabaseAndSchema(IThreadContext tc, String superuserName, String superuserPassword)
+ throws ManifoldCFException
+ {
+ ManifoldCF.createSystemDatabase(tc,superuserName,superuserPassword);
+ ManifoldCF.installTables(tc);
+ }
+
+ /** Register the agents */
+ public static void registerAgents(IThreadContext tc)
+ throws ManifoldCFException
+ {
+ // Register
+ IAgentManager agentMgr = AgentManagerFactory.make(tc);
+ agentMgr.registerAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
+ }
+
+ /** Read connectors configuration file.
+ */
+ public static Connectors readConnectorDeclarations(File connectorConfigFile)
+ throws ManifoldCFException
+ {
+ Connectors c = null;
+ if (connectorConfigFile != null)
+ {
+ try
+ {
+ // Open the file, read it, and attempt to do the connector registrations
+ InputStream is = new FileInputStream(connectorConfigFile);
+ try
+ {
+ c = new Connectors(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+ catch (FileNotFoundException e)
+ {
+ throw new ManifoldCFException("Couldn't find connector configuration file: "+e.getMessage(),e);
+ }
+ catch (IOException e)
+ {
+ throw new ManifoldCFException("Error reading connector configuration file: "+e.getMessage(),e);
+ }
+ }
+ return c;
+ }
+
+ /** Unregister all connectors.
+ */
+ public static void unregisterAllConnectors(IThreadContext tc)
+ throws ManifoldCFException
+ {
+ // Grab a database handle, so we can use transactions later.
+ IDBInterface database = DBInterfaceFactory.make(tc,
+ ManifoldCF.getMasterDatabaseName(),
+ ManifoldCF.getMasterDatabaseUsername(),
+ ManifoldCF.getMasterDatabasePassword());
+
+ // Output connectors...
+ {
+ IOutputConnectorManager mgr = OutputConnectorManagerFactory.make(tc);
+ IOutputConnectionManager connManager = OutputConnectionManagerFactory.make(tc);
+ IResultSet classNames = mgr.getConnectors();
+ int i = 0;
+ while (i < classNames.getRowCount())
+ {
+ IResultRow row = classNames.getRow(i++);
+ String className = (String)row.getValue("classname");
+ // Deregistration should be done in a transaction
+ database.beginTransaction();
+ try
+ {
+ // Find the connection names that come with this class
+ String[] connectionNames = connManager.findConnectionsForConnector(className);
+ // For all connection names, notify all agents of the deregistration
+ AgentManagerFactory.noteOutputConnectorDeregistration(tc,connectionNames);
+ // Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
+ mgr.unregisterConnector(className);
+ }
+ catch (ManifoldCFException e)
+ {
+ database.signalRollback();
+ throw e;
+ }
+ catch (Error e)
+ {
+ database.signalRollback();
+ throw e;
+ }
+ finally
+ {
+ database.endTransaction();
+ }
+ }
+ System.err.println("Successfully unregistered all output connectors");
+ }
+
+ // Authority connectors...
+ {
+ IAuthorityConnectorManager mgr = AuthorityConnectorManagerFactory.make(tc);
+ IResultSet classNames = mgr.getConnectors();
+ int i = 0;
+ while (i < classNames.getRowCount())
+ {
+ IResultRow row = classNames.getRow(i++);
+ mgr.unregisterConnector((String)row.getValue("classname"));
+ }
+ System.err.println("Successfully unregistered all authority connectors");
+ }
+
+ // Repository connectors...
+ {
+ IConnectorManager mgr = ConnectorManagerFactory.make(tc);
+ IJobManager jobManager = JobManagerFactory.make(tc);
+ IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
+ IResultSet classNames = mgr.getConnectors();
+ int i = 0;
+ while (i < classNames.getRowCount())
+ {
+ IResultRow row = classNames.getRow(i++);
+ String className = (String)row.getValue("classname");
+ // Deregistration should be done in a transaction
+ database.beginTransaction();
+ try
+ {
+ // Find the connection names that come with this class
+ String[] connectionNames = connManager.findConnectionsForConnector(className);
+ // For each connection name, modify the jobs to note that the connector is no longer installed
+ jobManager.noteConnectorDeregistration(connectionNames);
+ // Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
+ mgr.unregisterConnector(className);
+ }
+ catch (ManifoldCFException e)
+ {
+ database.signalRollback();
+ throw e;
+ }
+ catch (Error e)
+ {
+ database.signalRollback();
+ throw e;
+ }
+ finally
+ {
+ database.endTransaction();
+ }
+ }
+ System.err.println("Successfully unregistered all repository connectors");
+ }
+ }
+
+ /** Register all connectors as specified by a Connectors structure, usually read from the connectors.xml file.
+ */
+ public static void registerConnectors(IThreadContext tc, Connectors c)
+ throws ManifoldCFException
+ {
+ if (c != null)
+ {
+ // Grab a database handle, so we can use transactions later.
+ IDBInterface database = DBInterfaceFactory.make(tc,
+ ManifoldCF.getMasterDatabaseName(),
+ ManifoldCF.getMasterDatabaseUsername(),
+ ManifoldCF.getMasterDatabasePassword());
+
+ // Other code will go here to discover and register various connectors that exist in the classpath
+ int i = 0;
+ while (i < c.getChildCount())
+ {
+ ConfigurationNode cn = c.findChild(i++);
+ if (cn.getType().equals(NODE_OUTPUTCONNECTOR))
+ {
+ String name = cn.getAttributeValue(ATTRIBUTE_NAME);
+ String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
+ IOutputConnectorManager mgr = OutputConnectorManagerFactory.make(tc);
+ IOutputConnectionManager connManager = OutputConnectionManagerFactory.make(tc);
+ // Registration should be done in a transaction
+ database.beginTransaction();
+ try
+ {
+ // First, register connector
+ mgr.registerConnector(name,className);
+ // Then, signal to all jobs that might depend on this connector that they can switch state
+ // Find the connection names that come with this class
+ String[] connectionNames = connManager.findConnectionsForConnector(className);
+ // For all connection names, notify all agents of the registration
+ AgentManagerFactory.noteOutputConnectorRegistration(tc,connectionNames);
+ }
+ catch (ManifoldCFException e)
+ {
+ database.signalRollback();
+ throw e;
+ }
+ catch (Error e)
+ {
+ database.signalRollback();
+ throw e;
+ }
+ finally
+ {
+ database.endTransaction();
+ }
+ System.err.println("Successfully registered output connector '"+className+"'");
+ }
+ else if (cn.getType().equals(NODE_AUTHORITYCONNECTOR))
+ {
+ String name = cn.getAttributeValue(ATTRIBUTE_NAME);
+ String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
+ IAuthorityConnectorManager mgr = AuthorityConnectorManagerFactory.make(tc);
+ mgr.registerConnector(name,className);
+ System.err.println("Successfully registered authority connector '"+className+"'");
+ }
+ else if (cn.getType().equals(NODE_REPOSITORYCONNECTOR))
+ {
+ String name = cn.getAttributeValue(ATTRIBUTE_NAME);
+ String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
+ IConnectorManager mgr = ConnectorManagerFactory.make(tc);
+ IJobManager jobManager = JobManagerFactory.make(tc);
+ IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
+ // Deregistration should be done in a transaction
+ database.beginTransaction();
+ try
+ {
+ // First, register connector
+ mgr.registerConnector(name,className);
+ // Then, signal to all jobs that might depend on this connector that they can switch state
+ // Find the connection names that come with this class
+ String[] connectionNames = connManager.findConnectionsForConnector(className);
+ // For each connection name, modify the jobs to note that the connector is now installed
+ jobManager.noteConnectorRegistration(connectionNames);
+ }
+ catch (ManifoldCFException e)
+ {
+ database.signalRollback();
+ throw e;
+ }
+ catch (Error e)
+ {
+ database.signalRollback();
+ throw e;
+ }
+ finally
+ {
+ database.endTransaction();
+ }
+ System.err.println("Successfully registered repository connector '"+className+"'");
+ }
+ else
+ throw new ManifoldCFException("Unrecognized connectors node type '"+cn.getType()+"'");
+ }
+ }
+ }
+
+}
+
+