You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/12/08 19:54:11 UTC
svn commit: r1549105 [2/2] - in /manifoldcf/trunk: ./
connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/
connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors...
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java Sun Dec 8 18:54:09 2013
@@ -79,14 +79,46 @@ public class BaseLockManager implements
// By building on other primitives in this way, the same implementation will suffice for many derived
// lockmanager implementations - although ZooKeeper will want a native form.
- /** The global write lock to control sync */
- protected final static String serviceLock = "_SERVICELOCK_";
+ /** The service-type global write lock to control sync, followed by the service type */
+ protected final static String serviceTypeLockPrefix = "_SERVICELOCK_";
/** A data name prefix, followed by the service type, and then followed by "_" and the instance number */
protected final static String serviceListPrefix = "_SERVICELIST_";
/** A flag prefix, followed by the service type, and then followed by "_" and the service name */
protected final static String servicePrefix = "_SERVICE_";
/** A flag prefix, followed by the service type, and then followed by "_" and the service name */
protected final static String activePrefix = "_ACTIVE_";
+ /** A data name prefix, followed by the service type, and then followed by "_" and the service name and "_" and the datatype */
+ protected final static String serviceDataPrefix = "_SERVICEDATA_";
+ /** Anonymous service name prefix, to be followed by an integer */
+ protected final static String anonymousServiceNamePrefix = "_ANON_";
+ /** Anonymous global variable name prefix, to be followed by the service type */
+ protected final static String anonymousServiceTypeCounter = "_SERVICECOUNTER_";
+
+
+ /** Register a service and begin service activity.
+ * This atomic operation creates a permanent registration entry for a service.
+ * If the permanent registration entry already exists, this method will not create it or
+ * treat it as an error. This operation also enters the "active" zone for the service. The "active" zone will remain in force until it is
+ * canceled, or until the process is interrupted. Ideally, the corresponding endServiceActivity method will be
+ * called when the service shuts down. Some ILockManager implementations require that this take place for
+ * proper management.
+ * If the transient registration already exists, it is treated as an error and an exception will be thrown.
+ * If registration will succeed, then this method may call an appropriate IServiceCleanup method to clean up either the
+ * current service, or all services on the cluster.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service to register. If null is passed, a transient unique service name will be
+ * created, and will be returned to the caller.
+ *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
+ * May be null. Local service cleanup is never called if the serviceName argument is null.
+ *@return the actual service name.
+ */
+ @Override
+ public String registerServiceBeginServiceActivity(String serviceType, String serviceName,
+ IServiceCleanup cleanup)
+ throws ManifoldCFException
+ {
+ return registerServiceBeginServiceActivity(serviceType, serviceName, null, cleanup);
+ }
/** Register a service and begin service activity.
* This atomic operation creates a permanent registration entry for a service.
@@ -99,16 +131,25 @@ public class BaseLockManager implements
* If registration will succeed, then this method may call an appropriate IServiceCleanup method to clean up either the
* current service, or all services on the cluster.
*@param serviceType is the type of service.
- *@param serviceName is the name of the service to register.
- *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists
+ *@param serviceName is the name of the service to register. If null is passed, a transient unique service name will be
+ * created, and will be returned to the caller.
+ *@param initialData is the initial service data for this service.
+ *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
+ * May be null. Local service cleanup is never called if the serviceName argument is null.
+ *@return the actual service name.
*/
@Override
- public void registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup)
+ public String registerServiceBeginServiceActivity(String serviceType, String serviceName,
+ byte[] initialData, IServiceCleanup cleanup)
throws ManifoldCFException
{
- enterWriteLock(serviceLock);
+ String serviceTypeLockName = buildServiceTypeLockName(serviceType);
+ enterWriteLock(serviceTypeLockName);
try
{
+ if (serviceName == null)
+ serviceName = constructUniqueServiceName(serviceType);
+
// First, do an active check
String serviceActiveFlag = makeActiveServiceFlagName(serviceType, serviceName);
if (checkGlobalFlag(serviceActiveFlag))
@@ -197,13 +238,103 @@ public class BaseLockManager implements
// Last, set the appropriate active flag
setGlobalFlag(serviceActiveFlag);
+ writeServiceData(serviceType, serviceName, initialData);
+
+ return serviceName;
}
finally
{
- leaveWriteLock(serviceLock);
+ leaveWriteLock(serviceTypeLockName);
}
}
+ /** Set service data for a service.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service.
+ *@param serviceData is the data to update to (may be null).
+ * This updates the service's transient data (or deletes it). If the service is not active, an exception is thrown.
+ */
+ @Override
+ public void updateServiceData(String serviceType, String serviceName, byte[] serviceData)
+ throws ManifoldCFException
+ {
+ String serviceTypeLockName = buildServiceTypeLockName(serviceType);
+ enterWriteLock(serviceTypeLockName);
+ try
+ {
+ String serviceActiveFlag = makeActiveServiceFlagName(serviceType, serviceName);
+ if (!checkGlobalFlag(serviceActiveFlag))
+ throw new ManifoldCFException("Service '"+serviceName+"' of type '"+serviceType+"' is not active");
+ writeServiceData(serviceType, serviceName, serviceData);
+ }
+ finally
+ {
+ leaveWriteLock(serviceTypeLockName);
+ }
+ }
+
+ /** Retrieve service data for a service.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service.
+ *@return the service's transient data.
+ */
+ @Override
+ public byte[] retrieveServiceData(String serviceType, String serviceName)
+ throws ManifoldCFException
+ {
+ String serviceTypeLockName = buildServiceTypeLockName(serviceType);
+ enterReadLock(serviceTypeLockName);
+ try
+ {
+ String serviceActiveFlag = makeActiveServiceFlagName(serviceType, serviceName);
+ if (!checkGlobalFlag(serviceActiveFlag))
+ return null;
+ byte[] rval = readServiceData(serviceType, serviceName);
+ if (rval == null)
+ rval = new byte[0];
+ return rval;
+ }
+ finally
+ {
+ leaveReadLock(serviceTypeLockName);
+ }
+ }
+
+ /** Scan service data for a service type. Only active service data will be considered.
+ *@param serviceType is the type of service.
+ *@param dataType is the type of data.
+ *@param dataAcceptor is the object that will be notified of each item of data for each service name found.
+ */
+ @Override
+ public void scanServiceData(String serviceType, IServiceDataAcceptor dataAcceptor)
+ throws ManifoldCFException
+ {
+ String serviceTypeLockName = buildServiceTypeLockName(serviceType);
+ enterReadLock(serviceTypeLockName);
+ try
+ {
+ int i = 0;
+ while (true)
+ {
+ String resourceName = buildServiceListEntry(serviceType, i);
+ String x = readServiceName(resourceName);
+ if (x == null)
+ break;
+ if (checkGlobalFlag(makeActiveServiceFlagName(serviceType, x)))
+ {
+ byte[] serviceData = readServiceData(serviceType, x);
+ if (dataAcceptor.acceptServiceData(x, serviceData))
+ break;
+ }
+ i++;
+ }
+ }
+ finally
+ {
+ leaveReadLock(serviceTypeLockName);
+ }
+ }
+
/** Count all active services of a given type.
*@param serviceType is the service type.
*@return the count.
@@ -212,7 +343,8 @@ public class BaseLockManager implements
public int countActiveServices(String serviceType)
throws ManifoldCFException
{
- enterWriteLock(serviceLock);
+ String serviceTypeLockName = buildServiceTypeLockName(serviceType);
+ enterReadLock(serviceTypeLockName);
try
{
int count = 0;
@@ -231,7 +363,7 @@ public class BaseLockManager implements
}
finally
{
- leaveWriteLock(serviceLock);
+ leaveReadLock(serviceTypeLockName);
}
}
@@ -249,7 +381,8 @@ public class BaseLockManager implements
public boolean cleanupInactiveService(String serviceType, IServiceCleanup cleanup)
throws ManifoldCFException
{
- enterWriteLock(serviceLock);
+ String serviceTypeLockName = buildServiceTypeLockName(serviceType);
+ enterWriteLock(serviceTypeLockName);
try
{
// We find ONE service that is registered but inactive, and clean up after that one.
@@ -300,7 +433,7 @@ public class BaseLockManager implements
}
finally
{
- leaveWriteLock(serviceLock);
+ leaveWriteLock(serviceTypeLockName);
}
}
@@ -314,17 +447,19 @@ public class BaseLockManager implements
public void endServiceActivity(String serviceType, String serviceName)
throws ManifoldCFException
{
- enterWriteLock(serviceLock);
+ String serviceTypeLockName = buildServiceTypeLockName(serviceType);
+ enterWriteLock(serviceTypeLockName);
try
{
String serviceActiveFlag = makeActiveServiceFlagName(serviceType, serviceName);
if (!checkGlobalFlag(serviceActiveFlag))
throw new ManifoldCFException("Service '"+serviceName+"' of type '"+serviceType+" is not active");
+ deleteServiceData(serviceType, serviceName);
clearGlobalFlag(serviceActiveFlag);
}
finally
{
- leaveWriteLock(serviceLock);
+ leaveWriteLock(serviceTypeLockName);
}
}
@@ -339,17 +474,86 @@ public class BaseLockManager implements
public boolean checkServiceActive(String serviceType, String serviceName)
throws ManifoldCFException
{
- enterWriteLock(serviceLock);
+ String serviceTypeLockName = buildServiceTypeLockName(serviceType);
+ enterReadLock(serviceTypeLockName);
try
{
return checkGlobalFlag(makeActiveServiceFlagName(serviceType, serviceName));
}
finally
{
- leaveWriteLock(serviceLock);
+ leaveReadLock(serviceTypeLockName);
}
}
+ /** Construct a unique service name given the service type.
+ */
+ protected String constructUniqueServiceName(String serviceType)
+ throws ManifoldCFException
+ {
+ String serviceCounterName = makeServiceCounterName(serviceType);
+ int serviceUID = readServiceCounter(serviceCounterName);
+ writeServiceCounter(serviceCounterName,serviceUID+1);
+ return anonymousServiceNamePrefix + serviceUID;
+ }
+
+ /** Make the service counter name for a service type.
+ */
+ protected static String makeServiceCounterName(String serviceType)
+ {
+ return anonymousServiceTypeCounter + serviceType;
+ }
+
+ /** Read service counter.
+ */
+ protected int readServiceCounter(String serviceCounterName)
+ throws ManifoldCFException
+ {
+ byte[] serviceCounterData = readData(serviceCounterName);
+ if (serviceCounterData == null || serviceCounterData.length != 4)
+ return 0;
+ return ((int)serviceCounterData[0]) & 0xff +
+ (((int)serviceCounterData[1]) << 8) & 0xff00 +
+ (((int)serviceCounterData[2]) << 16) & 0xff0000 +
+ (((int)serviceCounterData[3]) << 24) & 0xff000000;
+ }
+
+ /** Write service counter.
+ */
+ protected void writeServiceCounter(String serviceCounterName, int counter)
+ throws ManifoldCFException
+ {
+ byte[] serviceCounterData = new byte[4];
+ serviceCounterData[0] = (byte)(counter & 0xff);
+ serviceCounterData[1] = (byte)((counter >> 8) & 0xff);
+ serviceCounterData[2] = (byte)((counter >> 16) & 0xff);
+ serviceCounterData[3] = (byte)((counter >> 24) & 0xff);
+ writeData(serviceCounterName,serviceCounterData);
+ }
+
+ protected void writeServiceData(String serviceType, String serviceName, byte[] serviceData)
+ throws ManifoldCFException
+ {
+ writeData(makeServiceDataName(serviceType, serviceName), serviceData);
+ }
+
+ protected byte[] readServiceData(String serviceType, String serviceName)
+ throws ManifoldCFException
+ {
+ return readData(makeServiceDataName(serviceType, serviceName));
+ }
+
+ protected void deleteServiceData(String serviceType, String serviceName)
+ throws ManifoldCFException
+ {
+ writeServiceData(serviceType, serviceName, null);
+ }
+
+ protected static String makeServiceDataName(String serviceType, String serviceName)
+ {
+ return serviceDataPrefix + serviceType + "_" + serviceName;
+ }
+
protected static String makeActiveServiceFlagName(String serviceType, String serviceName)
{
return activePrefix + serviceType + "_" + serviceName;
@@ -394,6 +598,11 @@ public class BaseLockManager implements
return serviceListPrefix + serviceType + "_" + i;
}
+ protected static String buildServiceTypeLockName(String serviceType)
+ {
+ return serviceTypeLockPrefix + serviceType;
+ }
+
/** Get the current shared configuration. This configuration is available in common among all nodes,
* and thus must not be accessed through here for the purpose of finding configuration data that is specific to any one
* specific node.
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockManager.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockManager.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockManager.java Sun Dec 8 18:54:09 2013
@@ -55,16 +55,82 @@ public class LockManager implements ILoc
* If registration will succeed, then this method may call an appropriate IServiceCleanup method to clean up either the
* current service, or all services on the cluster.
*@param serviceType is the type of service.
- *@param serviceName is the name of the service to register.
- *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists
+ *@param serviceName is the name of the service to register. If null is passed, a transient unique service name will be
+ * created, and will be returned to the caller.
+ *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
+ * May be null. Local service cleanup is never called if the serviceName argument is null.
+ *@return the actual service name.
*/
@Override
- public void registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup)
+ public String registerServiceBeginServiceActivity(String serviceType, String serviceName,
+ IServiceCleanup cleanup)
throws ManifoldCFException
{
- lockManager.registerServiceBeginServiceActivity(serviceType, serviceName, cleanup);
+ return lockManager.registerServiceBeginServiceActivity(serviceType, serviceName, cleanup);
}
+ /** Register a service and begin service activity.
+ * This atomic operation creates a permanent registration entry for a service.
+ * If the permanent registration entry already exists, this method will not create it or
+ * treat it as an error. This operation also enters the "active" zone for the service. The "active" zone will remain in force until it is
+ * canceled, or until the process is interrupted. Ideally, the corresponding endServiceActivity method will be
+ * called when the service shuts down. Some ILockManager implementations require that this take place for
+ * proper management.
+ * If the transient registration already exists, it is treated as an error and an exception will be thrown.
+ * If registration will succeed, then this method may call an appropriate IServiceCleanup method to clean up either the
+ * current service, or all services on the cluster.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service to register. If null is passed, a transient unique service name will be
+ * created, and will be returned to the caller.
+ *@param initialData is the initial service data for this service.
+ *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
+ * May be null. Local service cleanup is never called if the serviceName argument is null.
+ *@return the actual service name.
+ */
+ @Override
+ public String registerServiceBeginServiceActivity(String serviceType, String serviceName,
+ byte[] initialData, IServiceCleanup cleanup)
+ throws ManifoldCFException
+ {
+ return lockManager.registerServiceBeginServiceActivity(serviceType, serviceName, initialData, cleanup);
+ }
+
+ /** Set service data for a service.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service.
+ *@param serviceData is the data to update to (may be null).
+ * This updates the service's transient data (or deletes it). If the service is not active, an exception is thrown.
+ */
+ @Override
+ public void updateServiceData(String serviceType, String serviceName, byte[] serviceData)
+ throws ManifoldCFException
+ {
+ lockManager.updateServiceData(serviceType, serviceName, serviceData);
+ }
+
+ /** Retrieve service data for a service.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service.
+ *@return the service's transient data.
+ */
+ @Override
+ public byte[] retrieveServiceData(String serviceType, String serviceName)
+ throws ManifoldCFException
+ {
+ return lockManager.retrieveServiceData(serviceType, serviceName);
+ }
+
+ /** Scan service data for a service type. Only active service data will be considered.
+ *@param serviceType is the type of service.
+ *@param dataAcceptor is the object that will be notified of each item of data for each service name found.
+ */
+ @Override
+ public void scanServiceData(String serviceType, IServiceDataAcceptor dataAcceptor)
+ throws ManifoldCFException
+ {
+ lockManager.scanServiceData(serviceType, dataAcceptor);
+ }
+
/** Clean up any inactive services found.
* Calling this method will invoke cleanup of one inactive service at a time.
* If there are no inactive services around, then false will be returned.
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java Sun Dec 8 18:54:09 2013
@@ -72,12 +72,12 @@ public class ZooKeeperConnection
/** Create a transient node.
*/
- public void createNode(String nodePath)
+ public void createNode(String nodePath, byte[] nodeData)
throws ManifoldCFException, InterruptedException
{
try
{
- zookeeper.create(nodePath, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
+ zookeeper.create(nodePath, nodeData, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
}
catch (KeeperException e)
{
@@ -87,14 +87,49 @@ public class ZooKeeperConnection
/** Check whether a node exists.
*@param nodePath is the path of the node.
- *@return true if exists.
+ *@return the data, if the node if exists, otherwise null.
*/
public boolean checkNodeExists(String nodePath)
throws ManifoldCFException, InterruptedException
{
try
{
- return zookeeper.exists(nodePath,false) != null;
+ return (zookeeper.exists(nodePath,false) != null);
+ }
+ catch (KeeperException e)
+ {
+ throw new ManifoldCFException(e.getMessage(),e);
+ }
+ }
+
+ /** Get node data.
+ *@param nodePath is the path of the node.
+ *@return the data, if the node if exists, otherwise null.
+ */
+ public byte[] getNodeData(String nodePath)
+ throws ManifoldCFException, InterruptedException
+ {
+ try
+ {
+ Stat s = zookeeper.exists(nodePath,false);
+ if (s == null)
+ return null;
+ return zookeeper.getData(nodePath,false,s);
+ }
+ catch (KeeperException e)
+ {
+ throw new ManifoldCFException(e.getMessage(),e);
+ }
+ }
+
+ /** Set node data.
+ */
+ public void setNodeData(String nodePath, byte[] data)
+ throws ManifoldCFException, InterruptedException
+ {
+ try
+ {
+ zookeeper.setData(nodePath, data, -1);
}
catch (KeeperException e)
{
@@ -117,6 +152,28 @@ public class ZooKeeperConnection
}
}
+ /** Delete all a node's children.
+ */
+ public void deleteNodeChildren(String nodePath)
+ throws ManifoldCFException, InterruptedException
+ {
+ try
+ {
+ List<String> children = zookeeper.getChildren(nodePath,false);
+ for (String child : children)
+ {
+ zookeeper.delete(nodePath + "/" + child,-1);
+ }
+ }
+ catch (KeeperException.NoNodeException e)
+ {
+ }
+ catch (KeeperException e)
+ {
+ throw new ManifoldCFException(e.getMessage(),e);
+ }
+ }
+
/** Get the relative paths of all node's children. If the node does not exist,
* return an empty list.
*/
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java Sun Dec 8 18:54:09 2013
@@ -44,6 +44,11 @@ public class ZooKeeperLockManager extend
private final static String SERVICETYPE_ACTIVE_PATH_PREFIX = "/org.apache.manifoldcf.serviceactive-";
private final static String SERVICETYPE_REGISTER_PATH_PREFIX = "/org.apache.manifoldcf.service-";
+ /** Anonymous service name prefix, to be followed by an integer */
+ protected final static String anonymousServiceNamePrefix = "_ANON_";
+ /** Anonymous global variable name prefix, to be followed by the service type */
+ protected final static String anonymousServiceTypeCounter = "_SERVICECOUNTER_";
+
// ZooKeeper connection pool
protected static Integer connectionPoolLock = new Integer(0);
protected static ZooKeeperConnectionPool pool = null;
@@ -100,11 +105,40 @@ public class ZooKeeperLockManager extend
* If registration will succeed, then this method may call an appropriate IServiceCleanup method to clean up either the
* current service, or all services on the cluster.
*@param serviceType is the type of service.
- *@param serviceName is the name of the service to register.
- *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists
+ *@param serviceName is the name of the service to register. If null is passed, a transient unique service name will be
+ * created, and will be returned to the caller.
+ *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
+ * May be null. Local service cleanup is never called if the serviceName argument is null.
+ *@return the actual service name.
*/
@Override
- public void registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup)
+ public String registerServiceBeginServiceActivity(String serviceType, String serviceName,
+ IServiceCleanup cleanup)
+ throws ManifoldCFException
+ {
+ return registerServiceBeginServiceActivity(serviceType, serviceName, null, cleanup);
+ }
+
+ /** Register a service and begin service activity.
+ * This atomic operation creates a permanent registration entry for a service.
+ * If the permanent registration entry already exists, this method will not create it or
+ * treat it as an error. This operation also enters the "active" zone for the service. The "active" zone will remain in force until it is
+ * canceled, or until the process is interrupted. Ideally, the corresponding endServiceActivity method will be
+ * called when the service shuts down. Some ILockManager implementations require that this take place for
+ * proper management.
+ * If the transient registration already exists, it is treated as an error and an exception will be thrown.
+ * If registration will succeed, then this method may call an appropriate IServiceCleanup method to clean up either the
+ * current service, or all services on the cluster.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service to register. If null is passed, a transient unique service name will be
+ * created, and will be returned to the caller.
+ *@param initialData is the initial service data for this service.
+ *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
+ * May be null. Local service cleanup is never called if the serviceName argument is null.
+ *@return the actual service name.
+ */
+ public String registerServiceBeginServiceActivity(String serviceType, String serviceName,
+ byte[] initialData, IServiceCleanup cleanup)
throws ManifoldCFException
{
try
@@ -112,9 +146,12 @@ public class ZooKeeperLockManager extend
ZooKeeperConnection connection = pool.grab();
try
{
- enterServiceRegistryLock(connection, serviceType);
+ enterServiceRegistryWriteLock(connection, serviceType);
try
{
+ if (serviceName == null)
+ serviceName = constructUniqueServiceName(serviceType);
+
String activePath = buildServiceTypeActivePath(serviceType, serviceName);
if (connection.checkNodeExists(activePath))
throw new ManifoldCFException("Service '"+serviceName+"' of type '"+serviceType+"' is already active");
@@ -174,7 +211,8 @@ public class ZooKeeperLockManager extend
}
// Last, set the appropriate active flag
- connection.createNode(activePath);
+ connection.createNode(activePath, initialData);
+ return serviceName;
}
finally
{
@@ -192,6 +230,125 @@ public class ZooKeeperLockManager extend
}
}
+ /** Set service data for a service.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service.
+ *@param serviceData is the data to update to (may be null).
+ * This updates the service's transient data (or deletes it). If the service is not active, an exception is thrown.
+ */
+ @Override
+ public void updateServiceData(String serviceType, String serviceName, byte[] serviceData)
+ throws ManifoldCFException
+ {
+ try
+ {
+ ZooKeeperConnection connection = pool.grab();
+ try
+ {
+ enterServiceRegistryWriteLock(connection, serviceType);
+ try
+ {
+ String activePath = buildServiceTypeActivePath(serviceType, serviceName);
+ connection.setNodeData(activePath, (serviceData==null)?new byte[0]:serviceData);
+ }
+ finally
+ {
+ leaveServiceRegistryLock(connection);
+ }
+ }
+ finally
+ {
+ pool.release(connection);
+ }
+ }
+ catch (InterruptedException e)
+ {
+ throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+ }
+ }
+
+ /** Retrieve service data for a service.
+ *@param serviceType is the type of service.
+ *@param serviceName is the name of the service.
+ *@return the service's transient data.
+ */
+ @Override
+ public byte[] retrieveServiceData(String serviceType, String serviceName)
+ throws ManifoldCFException
+ {
+ try
+ {
+ ZooKeeperConnection connection = pool.grab();
+ try
+ {
+ enterServiceRegistryReadLock(connection, serviceType);
+ try
+ {
+ String activePath = buildServiceTypeActivePath(serviceType, serviceName);
+ return connection.getNodeData(activePath);
+ }
+ finally
+ {
+ leaveServiceRegistryLock(connection);
+ }
+ }
+ finally
+ {
+ pool.release(connection);
+ }
+ }
+ catch (InterruptedException e)
+ {
+ throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+ }
+ }
+
+ /** Scan service data for a service type. Only active service data will be considered.
+ *@param serviceType is the type of service.
+ *@param dataAcceptor is the object that will be notified of each item of data for each service name found.
+ */
+ @Override
+ public void scanServiceData(String serviceType, IServiceDataAcceptor dataAcceptor)
+ throws ManifoldCFException
+ {
+ try
+ {
+ ZooKeeperConnection connection = pool.grab();
+ try
+ {
+ enterServiceRegistryReadLock(connection, serviceType);
+ try
+ {
+ String registrationNodePath = buildServiceTypeRegistrationPath(serviceType);
+ List<String> children = connection.getChildren(registrationNodePath);
+ for (String registeredServiceName : children)
+ {
+ String activeNodePath = buildServiceTypeActivePath(serviceType, registeredServiceName);
+ if (connection.checkNodeExists(activeNodePath))
+ {
+ byte[] serviceData = connection.getNodeData(activeNodePath);
+ if (dataAcceptor.acceptServiceData(registeredServiceName, serviceData))
+ break;
+ }
+ }
+ }
+ finally
+ {
+ leaveServiceRegistryLock(connection);
+ }
+ }
+ finally
+ {
+ pool.release(connection);
+ }
+ }
+ catch (InterruptedException e)
+ {
+ throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+ }
+
+ }
+
/** Count all active services of a given type.
*@param serviceType is the service type.
*@return the count.
@@ -205,7 +362,7 @@ public class ZooKeeperLockManager extend
ZooKeeperConnection connection = pool.grab();
try
{
- enterServiceRegistryLock(connection, serviceType);
+ enterServiceRegistryReadLock(connection, serviceType);
try
{
String registrationNodePath = buildServiceTypeRegistrationPath(serviceType);
@@ -253,7 +410,7 @@ public class ZooKeeperLockManager extend
ZooKeeperConnection connection = pool.grab();
try
{
- enterServiceRegistryLock(connection, serviceType);
+ enterServiceRegistryWriteLock(connection, serviceType);
try
{
// We find ONE service that is registered but inactive, and clean up after that one.
@@ -313,7 +470,7 @@ public class ZooKeeperLockManager extend
ZooKeeperConnection connection = pool.grab();
try
{
- enterServiceRegistryLock(connection, serviceType);
+ enterServiceRegistryWriteLock(connection, serviceType);
try
{
connection.deleteNode(buildServiceTypeActivePath(serviceType, serviceName));
@@ -350,7 +507,7 @@ public class ZooKeeperLockManager extend
ZooKeeperConnection connection = pool.grab();
try
{
- enterServiceRegistryLock(connection, serviceType);
+ enterServiceRegistryReadLock(connection, serviceType);
try
{
return connection.checkNodeExists(buildServiceTypeActivePath(serviceType, serviceName));
@@ -371,13 +528,27 @@ public class ZooKeeperLockManager extend
}
}
- /** Enter service registry lock */
- protected void enterServiceRegistryLock(ZooKeeperConnection connection, String serviceType)
+ /** Enter service registry read lock */
+ protected void enterServiceRegistryReadLock(ZooKeeperConnection connection, String serviceType)
+ throws ManifoldCFException, InterruptedException
+ {
+ String serviceTypeLock = buildServiceTypeLockPath(serviceType);
+ while (true)
+ {
+ if (connection.obtainReadLockNoWait(serviceTypeLock))
+ return;
+ ManifoldCF.sleep(100L);
+ }
+ }
+
+ /** Enter service registry write lock */
+ protected void enterServiceRegistryWriteLock(ZooKeeperConnection connection, String serviceType)
throws ManifoldCFException, InterruptedException
{
+ String serviceTypeLock = buildServiceTypeLockPath(serviceType);
while (true)
{
- if (connection.obtainWriteLockNoWait(buildServiceTypeLockPath(serviceType)))
+ if (connection.obtainWriteLockNoWait(serviceTypeLock))
return;
ManifoldCF.sleep(100L);
}
@@ -390,6 +561,51 @@ public class ZooKeeperLockManager extend
connection.releaseLock();
}
+ /** Construct a unique service name given the service type.
+ */
+ protected String constructUniqueServiceName(String serviceType)
+ throws ManifoldCFException
+ {
+ String serviceCounterName = makeServiceCounterName(serviceType);
+ int serviceUID = readServiceCounter(serviceCounterName);
+ writeServiceCounter(serviceCounterName,serviceUID+1);
+ return anonymousServiceNamePrefix + serviceUID;
+ }
+
+ /** Make the service counter name for a service type.
+ */
+ protected static String makeServiceCounterName(String serviceType)
+ {
+ return anonymousServiceTypeCounter + serviceType;
+ }
+
+ /** Read service counter.
+ */
+ protected int readServiceCounter(String serviceCounterName)
+ throws ManifoldCFException
+ {
+ byte[] serviceCounterData = readData(serviceCounterName);
+ if (serviceCounterData == null || serviceCounterData.length != 4)
+ return 0;
+ return ((int)serviceCounterData[0]) & 0xff +
+ (((int)serviceCounterData[1]) << 8) & 0xff00 +
+ (((int)serviceCounterData[2]) << 16) & 0xff0000 +
+ (((int)serviceCounterData[3]) << 24) & 0xff000000;
+ }
+
+ /** Write service counter.
+ */
+ protected void writeServiceCounter(String serviceCounterName, int counter)
+ throws ManifoldCFException
+ {
+ byte[] serviceCounterData = new byte[4];
+ serviceCounterData[0] = (byte)(counter & 0xff);
+ serviceCounterData[1] = (byte)((counter >> 8) & 0xff);
+ serviceCounterData[2] = (byte)((counter >> 16) & 0xff);
+ serviceCounterData[3] = (byte)((counter >> 24) & 0xff);
+ writeData(serviceCounterName,serviceCounterData);
+ }
+
/** Build a zk path for the lock for a specific service type.
*/
protected static String buildServiceTypeLockPath(String serviceType)
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp Sun Dec 8 18:54:09 2013
@@ -416,7 +416,7 @@
}
finally
{
- outputConnectorPool.release(outputConnector);
+ outputConnectorPool.release(outputConnection,outputConnector);
}
}
}
@@ -434,7 +434,7 @@
}
finally
{
- repositoryConnectorPool.release(repositoryConnector);
+ repositoryConnectorPool.release(connection,repositoryConnector);
}
}
}
@@ -1282,7 +1282,7 @@
}
finally
{
- outputConnectorPool.release(outputConnector);
+ outputConnectorPool.release(outputConnection,outputConnector);
}
%>
<input type="hidden" name="outputpresent" value="true"/>
@@ -1301,7 +1301,7 @@
}
finally
{
- repositoryConnectorPool.release(repositoryConnector);
+ repositoryConnectorPool.release(connection,repositoryConnector);
}
%>
<input type="hidden" name="connectionpresent" value="true"/>
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp Sun Dec 8 18:54:09 2013
@@ -1048,7 +1048,7 @@
}
finally
{
- outputConnectorPool.release(outputConnector);
+ outputConnectorPool.release(outputConnection,outputConnector);
}
}
}
@@ -1072,7 +1072,7 @@
}
finally
{
- repositoryConnectorPool.release(repositoryConnector);
+ repositoryConnectorPool.release(connection,repositoryConnector);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp Sun Dec 8 18:54:09 2013
@@ -115,7 +115,7 @@
}
finally
{
- authorityConnectorPool.release(c);
+ authorityConnectorPool.release(connection,c);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp Sun Dec 8 18:54:09 2013
@@ -120,7 +120,7 @@
}
finally
{
- repositoryConnectorPool.release(c);
+ repositoryConnectorPool.release(connection,c);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp Sun Dec 8 18:54:09 2013
@@ -644,7 +644,7 @@
}
finally
{
- outputConnectorPool.release(outputConnector);
+ outputConnectorPool.release(outputConnection,outputConnector);
}
}
}
@@ -668,7 +668,7 @@
}
finally
{
- repositoryConnectorPool.release(repositoryConnector);
+ repositoryConnectorPool.release(connection,repositoryConnector);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp Sun Dec 8 18:54:09 2013
@@ -105,7 +105,7 @@
}
finally
{
- mappingConnectorPool.release(c);
+ mappingConnectorPool.release(connection,c);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp Sun Dec 8 18:54:09 2013
@@ -116,7 +116,7 @@
}
finally
{
- outputConnectorPool.release(c);
+ outputConnectorPool.release(connection,c);
}
}
}
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java Sun Dec 8 18:54:09 2013
@@ -80,7 +80,7 @@ public class CheckAll
}
finally
{
- authorityConnectorPool.release(c);
+ authorityConnectorPool.release(connection,c);
}
}
else
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/AuthorityConnectorPool.java Sun Dec 8 18:54:09 2013
@@ -59,18 +59,20 @@ public class AuthorityConnectorPool impl
{
// For now, use the AuthorityConnectorFactory method. This will require us to extract info
// from each authority connection, however.
+ String[] connectionNames = new String[authorityConnections.length];
String[] classNames = new String[authorityConnections.length];
ConfigParams[] configInfos = new ConfigParams[authorityConnections.length];
int[] maxPoolSizes = new int[authorityConnections.length];
for (int i = 0; i < authorityConnections.length; i++)
{
+ connectionNames[i] = authorityConnections[i].getName();
classNames[i] = authorityConnections[i].getClassName();
configInfos[i] = authorityConnections[i].getConfigParams();
maxPoolSizes[i] = authorityConnections[i].getMaxConnections();
}
return localPool.grabMultiple(threadContext,
- orderingKeys, classNames, configInfos, maxPoolSizes);
+ orderingKeys, connectionNames, classNames, configInfos, maxPoolSizes);
}
/** Get an authority connector.
@@ -81,28 +83,35 @@ public class AuthorityConnectorPool impl
public IAuthorityConnector grab(IAuthorityConnection authorityConnection)
throws ManifoldCFException
{
- return localPool.grab(threadContext, authorityConnection.getClassName(),
+ return localPool.grab(threadContext, authorityConnection.getName(), authorityConnection.getClassName(),
authorityConnection.getConfigParams(), authorityConnection.getMaxConnections());
}
/** Release multiple authority connectors.
+ *@param connections are the connections describing the instances to release.
*@param connectors are the connector instances to release.
*/
@Override
- public void releaseMultiple(IAuthorityConnector[] connectors)
+ public void releaseMultiple(IAuthorityConnection[] connections, IAuthorityConnector[] connectors)
throws ManifoldCFException
{
- localPool.releaseMultiple(connectors);
+ String[] connectionNames = new String[connections.length];
+ for (int i = 0; i < connections.length; i++)
+ {
+ connectionNames[i] = connections[i].getName();
+ }
+ localPool.releaseMultiple(threadContext, connectionNames, connectors);
}
- /** Release an authority connector.
+ /** Release an output connector.
+ *@param connection is the connection describing the instance to release.
*@param connector is the connector to release.
*/
@Override
- public void release(IAuthorityConnector connector)
+ public void release(IAuthorityConnection connection, IAuthorityConnector connector)
throws ManifoldCFException
{
- localPool.release(connector);
+ localPool.release(threadContext, connection.getName(), connector);
}
/** Idle notification for inactive authority connector handles.
@@ -140,6 +149,7 @@ public class AuthorityConnectorPool impl
{
public LocalPool()
{
+ super("_AUTHORITYCONNECTORPOOL_");
}
@Override
@@ -149,11 +159,19 @@ public class AuthorityConnectorPool impl
IAuthorityConnectorManager connectorManager = AuthorityConnectorManagerFactory.make(tc);
return connectorManager.isInstalled(className);
}
+
+ @Override
+ protected boolean isConnectionNameValid(IThreadContext tc, String connectionName)
+ throws ManifoldCFException
+ {
+ IAuthorityConnectionManager connectionManager = AuthorityConnectionManagerFactory.make(tc);
+ return connectionManager.load(connectionName) != null;
+ }
- public IAuthorityConnector[] grabMultiple(IThreadContext tc, String[] orderingKeys, String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
+ public IAuthorityConnector[] grabMultiple(IThreadContext tc, String[] orderingKeys, String connectionNames[], String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
throws ManifoldCFException
{
- return grabMultiple(tc,IAuthorityConnector.class,orderingKeys,classNames,configInfos,maxPoolSizes);
+ return grabMultiple(tc,IAuthorityConnector.class,orderingKeys,connectionNames,classNames,configInfos,maxPoolSizes);
}
}
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java Sun Dec 8 18:54:09 2013
@@ -47,15 +47,17 @@ public interface IAuthorityConnectorPool
throws ManifoldCFException;
/** Release multiple authority connectors.
+ *@param connections are the connections describing the instances to release.
*@param connectors are the connector instances to release.
*/
- public void releaseMultiple(IAuthorityConnector[] connectors)
+ public void releaseMultiple(IAuthorityConnection[] connections, IAuthorityConnector[] connectors)
throws ManifoldCFException;
/** Release an authority connector.
+ *@param connection is the connection describing the instance to release.
*@param connector is the connector to release.
*/
- public void release(IAuthorityConnector connector)
+ public void release(IAuthorityConnection connection, IAuthorityConnector connector)
throws ManifoldCFException;
/** Idle notification for inactive authority connector handles.
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java Sun Dec 8 18:54:09 2013
@@ -47,15 +47,17 @@ public interface IMappingConnectorPool
throws ManifoldCFException;
/** Release multiple mapping connectors.
+ *@param connections are the connections describing the instances to release.
*@param connectors are the connector instances to release.
*/
- public void releaseMultiple(IMappingConnector[] connectors)
+ public void releaseMultiple(IMappingConnection[] connections, IMappingConnector[] connectors)
throws ManifoldCFException;
/** Release a mapping connector.
+ *@param connection is the connection describing the instance to release.
*@param connector is the connector to release.
*/
- public void release(IMappingConnector connector)
+ public void release(IMappingConnection connection, IMappingConnector connector)
throws ManifoldCFException;
/** Idle notification for inactive mapping connector handles.
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/MappingConnectorPool.java Sun Dec 8 18:54:09 2013
@@ -59,18 +59,20 @@ public class MappingConnectorPool implem
{
// For now, use the MappingConnectorFactory method. This will require us to extract info
// from each mapping connection, however.
+ String[] connectionNames = new String[mappingConnections.length];
String[] classNames = new String[mappingConnections.length];
ConfigParams[] configInfos = new ConfigParams[mappingConnections.length];
int[] maxPoolSizes = new int[mappingConnections.length];
for (int i = 0; i < mappingConnections.length; i++)
{
+ connectionNames[i] = mappingConnections[i].getName();
classNames[i] = mappingConnections[i].getClassName();
configInfos[i] = mappingConnections[i].getConfigParams();
maxPoolSizes[i] = mappingConnections[i].getMaxConnections();
}
return localPool.grabMultiple(threadContext,
- orderingKeys, classNames, configInfos, maxPoolSizes);
+ orderingKeys, connectionNames, classNames, configInfos, maxPoolSizes);
}
/** Get a mapping connector.
@@ -81,28 +83,36 @@ public class MappingConnectorPool implem
public IMappingConnector grab(IMappingConnection mappingConnection)
throws ManifoldCFException
{
- return localPool.grab(threadContext, mappingConnection.getClassName(),
+ return localPool.grab(threadContext, mappingConnection.getName(),
+ mappingConnection.getClassName(),
mappingConnection.getConfigParams(), mappingConnection.getMaxConnections());
}
/** Release multiple mapping connectors.
+ *@param connections are the connections describing the instances to release.
*@param connectors are the connector instances to release.
*/
@Override
- public void releaseMultiple(IMappingConnector[] connectors)
+ public void releaseMultiple(IMappingConnection[] connections, IMappingConnector[] connectors)
throws ManifoldCFException
{
- localPool.releaseMultiple(connectors);
+ String[] connectionNames = new String[connections.length];
+ for (int i = 0; i < connections.length; i++)
+ {
+ connectionNames[i] = connections[i].getName();
+ }
+ localPool.releaseMultiple(threadContext, connectionNames, connectors);
}
/** Release a mapping connector.
+ *@param connection is the connection describing the instance to release.
*@param connector is the connector to release.
*/
@Override
- public void release(IMappingConnector connector)
+ public void release(IMappingConnection connection, IMappingConnector connector)
throws ManifoldCFException
{
- localPool.release(connector);
+ localPool.release(threadContext, connection.getName(), connector);
}
/** Idle notification for inactive mapping connector handles.
@@ -140,6 +150,7 @@ public class MappingConnectorPool implem
{
public LocalPool()
{
+ super("_MAPPINGCONNECTORPOOL_");
}
@Override
@@ -150,10 +161,18 @@ public class MappingConnectorPool implem
return connectorManager.isInstalled(className);
}
- public IMappingConnector[] grabMultiple(IThreadContext tc, String[] orderingKeys, String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
+ @Override
+ protected boolean isConnectionNameValid(IThreadContext tc, String connectionName)
+ throws ManifoldCFException
+ {
+ IMappingConnectionManager connectionManager = MappingConnectionManagerFactory.make(tc);
+ return connectionManager.load(connectionName) != null;
+ }
+
+ public IMappingConnector[] grabMultiple(IThreadContext tc, String[] orderingKeys, String[] connectionNames, String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
throws ManifoldCFException
{
- return grabMultiple(tc,IMappingConnector.class,orderingKeys,classNames,configInfos,maxPoolSizes);
+ return grabMultiple(tc,IMappingConnector.class,orderingKeys,connectionNames,classNames,configInfos,maxPoolSizes);
}
}
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java Sun Dec 8 18:54:09 2013
@@ -107,7 +107,7 @@ public class AuthCheckThread extends Thr
}
finally
{
- authorityConnectorPool.release(connector);
+ authorityConnectorPool.release(theRequest.getAuthorityConnection(),connector);
}
}
catch (ManifoldCFException e)
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java Sun Dec 8 18:54:09 2013
@@ -67,7 +67,7 @@ public class IdleCleanupThread extends T
cacheManager.expireObjects(System.currentTimeMillis());
// Sleep for the retry interval.
- ManifoldCF.sleep(15000L);
+ ManifoldCF.sleep(5000L);
}
catch (ManifoldCFException e)
{
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java Sun Dec 8 18:54:09 2013
@@ -101,7 +101,7 @@ public class MappingThread extends Threa
}
finally
{
- mappingConnectorPool.release(connector);
+ mappingConnectorPool.release(theRequest.getMappingConnection(),connector);
}
}
catch (ManifoldCFException e)
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectorPool.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectorPool.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectorPool.java Sun Dec 8 18:54:09 2013
@@ -47,15 +47,17 @@ public interface IRepositoryConnectorPoo
throws ManifoldCFException;
/** Release multiple repository connectors.
+ *@param connections are the connections describing the instances to release.
*@param connectors are the connector instances to release.
*/
- public void releaseMultiple(IRepositoryConnector[] connectors)
+ public void releaseMultiple(IRepositoryConnection[] connections, IRepositoryConnector[] connectors)
throws ManifoldCFException;
/** Release a repository connector.
+ *@param connection is the connection describing the instance to release.
*@param connector is the connector to release.
*/
- public void release(IRepositoryConnector connector)
+ public void release(IRepositoryConnection connection, IRepositoryConnector connector)
throws ManifoldCFException;
/** Idle notification for inactive repository connector handles.
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java Sun Dec 8 18:54:09 2013
@@ -2766,7 +2766,7 @@ public class JobManager implements IJobM
}
finally
{
- repositoryConnectorPool.releaseMultiple(connectors);
+ repositoryConnectorPool.releaseMultiple(connections,connectors);
}
}
finally
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/RepositoryConnectorPool.java Sun Dec 8 18:54:09 2013
@@ -59,18 +59,20 @@ public class RepositoryConnectorPool imp
{
// For now, use the RepositoryConnectorFactory method. This will require us to extract info
// from each repository connection, however.
+ String[] connectionNames = new String[repositoryConnections.length];
String[] classNames = new String[repositoryConnections.length];
ConfigParams[] configInfos = new ConfigParams[repositoryConnections.length];
int[] maxPoolSizes = new int[repositoryConnections.length];
for (int i = 0; i < repositoryConnections.length; i++)
{
+ connectionNames[i] = repositoryConnections[i].getName();
classNames[i] = repositoryConnections[i].getClassName();
configInfos[i] = repositoryConnections[i].getConfigParams();
maxPoolSizes[i] = repositoryConnections[i].getMaxConnections();
}
return localPool.grabMultiple(threadContext,
- orderingKeys, classNames, configInfos, maxPoolSizes);
+ orderingKeys, connectionNames, classNames, configInfos, maxPoolSizes);
}
/** Get a repository connector.
@@ -81,28 +83,35 @@ public class RepositoryConnectorPool imp
public IRepositoryConnector grab(IRepositoryConnection repositoryConnection)
throws ManifoldCFException
{
- return localPool.grab(threadContext, repositoryConnection.getClassName(),
+ return localPool.grab(threadContext, repositoryConnection.getName(), repositoryConnection.getClassName(),
repositoryConnection.getConfigParams(), repositoryConnection.getMaxConnections());
}
/** Release multiple repository connectors.
+ *@param connections are the connections describing the instances to release.
*@param connectors are the connector instances to release.
*/
@Override
- public void releaseMultiple(IRepositoryConnector[] connectors)
+ public void releaseMultiple(IRepositoryConnection[] connections, IRepositoryConnector[] connectors)
throws ManifoldCFException
{
- localPool.releaseMultiple(connectors);
+ String[] connectionNames = new String[connections.length];
+ for (int i = 0; i < connections.length; i++)
+ {
+ connectionNames[i] = connections[i].getName();
+ }
+ localPool.releaseMultiple(threadContext, connectionNames, connectors);
}
/** Release a repository connector.
+ *@param connection is the connection describing the instance to release.
*@param connector is the connector to release.
*/
@Override
- public void release(IRepositoryConnector connector)
+ public void release(IRepositoryConnection connection, IRepositoryConnector connector)
throws ManifoldCFException
{
- localPool.release(connector);
+ localPool.release(threadContext, connection.getName(), connector);
}
/** Idle notification for inactive repository connector handles.
@@ -140,6 +149,7 @@ public class RepositoryConnectorPool imp
{
public LocalPool()
{
+ super("_REPOSITORYCONNECTORPOOL_");
}
@Override
@@ -150,10 +160,18 @@ public class RepositoryConnectorPool imp
return connectorManager.isInstalled(className);
}
- public IRepositoryConnector[] grabMultiple(IThreadContext tc, String[] orderingKeys, String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
+ @Override
+ protected boolean isConnectionNameValid(IThreadContext tc, String connectionName)
+ throws ManifoldCFException
+ {
+ IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(tc);
+ return connectionManager.load(connectionName) != null;
+ }
+
+ public IRepositoryConnector[] grabMultiple(IThreadContext tc, String[] orderingKeys, String[] connectionNames, String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
throws ManifoldCFException
{
- return grabMultiple(tc,IRepositoryConnector.class,orderingKeys,classNames,configInfos,maxPoolSizes);
+ return grabMultiple(tc,IRepositoryConnector.class,orderingKeys,connectionNames,classNames,configInfos,maxPoolSizes);
}
}
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/DocumentCleanupThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/DocumentCleanupThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/DocumentCleanupThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/DocumentCleanupThread.java Sun Dec 8 18:54:09 2013
@@ -249,7 +249,7 @@ public class DocumentCleanupThread exten
finally
{
// Free up the reserved connector instance
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
}
catch (ManifoldCFException e)
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java Sun Dec 8 18:54:09 2013
@@ -252,7 +252,7 @@ public class ExpireThread extends Thread
finally
{
// Free up the reserved connector instance
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
}
catch (ManifoldCFException e)
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java Sun Dec 8 18:54:09 2013
@@ -70,7 +70,7 @@ public class IdleCleanupThread extends T
cacheManager.expireObjects(System.currentTimeMillis());
// Sleep for the retry interval.
- ManifoldCF.sleep(15000L);
+ ManifoldCF.sleep(5000L);
}
catch (ManifoldCFException e)
{
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java Sun Dec 8 18:54:09 2013
@@ -140,7 +140,7 @@ public class JobNotificationThread exten
}
finally
{
- outputConnectorPool.release(connector);
+ outputConnectorPool.release(connection,connector);
}
}
}
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java Sun Dec 8 18:54:09 2013
@@ -1014,7 +1014,7 @@ public class ManifoldCF extends org.apac
}
finally
{
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
priorities[i] = new PriorityCalculator(rt,connection,binNames);
@@ -1247,7 +1247,7 @@ public class ManifoldCF extends org.apac
}
finally
{
- outputConnectorPool.release(connector);
+ outputConnectorPool.release(connection,connector);
}
ConfigurationNode response = new ConfigurationNode(API_CHECKRESULTNODE);
@@ -1289,7 +1289,7 @@ public class ManifoldCF extends org.apac
}
finally
{
- authorityConnectorPool.release(connector);
+ authorityConnectorPool.release(connection,connector);
}
ConfigurationNode response = new ConfigurationNode(API_CHECKRESULTNODE);
@@ -1331,7 +1331,7 @@ public class ManifoldCF extends org.apac
}
finally
{
- mappingConnectorPool.release(connector);
+ mappingConnectorPool.release(connection,connector);
}
ConfigurationNode response = new ConfigurationNode(API_CHECKRESULTNODE);
@@ -1373,7 +1373,7 @@ public class ManifoldCF extends org.apac
}
finally
{
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
ConfigurationNode response = new ConfigurationNode(API_CHECKRESULTNODE);
@@ -1411,7 +1411,7 @@ public class ManifoldCF extends org.apac
}
finally
{
- outputConnectorPool.release(connector);
+ outputConnectorPool.release(connection,connector);
}
}
catch (ManifoldCFException e)
@@ -1444,7 +1444,7 @@ public class ManifoldCF extends org.apac
}
finally
{
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
}
catch (ManifoldCFException e)
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/SeedingThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/SeedingThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/SeedingThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/SeedingThread.java Sun Dec 8 18:54:09 2013
@@ -166,7 +166,7 @@ public class SeedingThread extends Threa
}
finally
{
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StartupThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StartupThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StartupThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StartupThread.java Sun Dec 8 18:54:09 2013
@@ -169,7 +169,7 @@ public class StartupThread extends Threa
}
finally
{
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
// Start this job!
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StufferThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StufferThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StufferThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StufferThread.java Sun Dec 8 18:54:09 2013
@@ -269,7 +269,7 @@ public class StufferThread extends Threa
}
finally
{
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
}
}
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/WorkerThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/WorkerThread.java?rev=1549105&r1=1549104&r2=1549105&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/WorkerThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/WorkerThread.java Sun Dec 8 18:54:09 2013
@@ -831,7 +831,7 @@ public class WorkerThread extends Thread
}
finally
{
- repositoryConnectorPool.release(connector);
+ repositoryConnectorPool.release(connection,connector);
}
}