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/12 01:57:39 UTC
svn commit: r1550329 - in
/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core:
interfaces/ throttler/
Author: kwright
Date: Thu Dec 12 00:57:38 2013
New Revision: 1550329
URL: http://svn.apache.org/r1550329
Log:
Add basic structure of a thread-local throttler with a static pool supporting it.
Added:
manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectionThrottlerFactory.java (with props)
manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IConnectionThrottler.java (with props)
manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionThrottler.java (with props)
manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java (with props)
Added: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectionThrottlerFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectionThrottlerFactory.java?rev=1550329&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectionThrottlerFactory.java (added)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectionThrottlerFactory.java Thu Dec 12 00:57:38 2013
@@ -0,0 +1,50 @@
+/* $Id$ */
+
+/**
+* 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.core.interfaces;
+
+/** Thread-local IConnectionThrottle factory.
+*/
+public class ConnectionThrottlerFactory
+{
+ public static final String _rcsid = "@(#)$Id$";
+
+ // name to use in thread context pool of objects
+ private final static String objectName = "_ConnectionThrottler_";
+
+ private ConnectionThrottlerFactory()
+ {
+ }
+
+ /** Make a connection throttle handle.
+ *@param tc is the thread context.
+ *@return the handle.
+ */
+ public static IConnectionThrottler make(IThreadContext tc)
+ throws ManifoldCFException
+ {
+ Object o = tc.get(objectName);
+ if (o == null || !(o instanceof IConnectionThrottler))
+ {
+ o = new org.apache.manifoldcf.core.throttler.ConnectionThrottler(tc);
+ tc.save(objectName,o);
+ }
+ return (IConnectionThrottler)o;
+ }
+
+}
Propchange: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectionThrottlerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectionThrottlerFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IConnectionThrottler.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IConnectionThrottler.java?rev=1550329&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IConnectionThrottler.java (added)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IConnectionThrottler.java Thu Dec 12 00:57:38 2013
@@ -0,0 +1,115 @@
+/* $Id$ */
+
+/**
+* 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.core.interfaces;
+
+/** An IConnectionThrottler object is thread-local and creates a virtual pool
+* of connections to resources whose access needs to be throttled in number,
+* rate of use, and byte rate.
+*/
+public interface IConnectionThrottler
+{
+ public static final String _rcsid = "@(#)$Id$";
+
+ /** Get permission to use a connection, which is described by the passed array of bin names.
+ * The connection can be used multiple
+ * times until the releaseConnectionPermission() method is called.
+ *@param throttleGroup is the throttle group.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names to throttle for, within the throttle group.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void obtainConnectionPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException;
+
+ /** Release permission to use a connection. This presumes that obtainConnectionPermission()
+ * was called earlier in the same thread and was successful.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void releaseConnectionPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException;
+
+ /** Get permission to fetch a document. This grants permission to start
+ * fetching a single document. When done (or aborting), call
+ * releaseFetchDocumentPermission() to note the completion of the document
+ * fetch activity.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void obtainFetchDocumentPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException;
+
+ /** Release permission to fetch a document. Call this only when you
+ * called obtainFetchDocumentPermission() successfully earlier in the same
+ * thread.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void releaseFetchDocumentPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException;
+
+ /** Obtain permission to read a block of bytes.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ *@param byteCount is the number of bytes to get permissions to read.
+ */
+ public void obtainReadPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime, int byteCount)
+ throws ManifoldCFException;
+
+ /** Note the completion of the read of a block of bytes. Call this after
+ * obtainReadPermission() was successfully called in the same thread.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ *@param origByteCount is the originally requested number of bytes to get permissions to read.
+ *@param actualByteCount is the number of bytes actually read.
+ */
+ public void releaseReadPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime, int origByteCount, int actualByteCount)
+ throws ManifoldCFException;
+
+ /** Poll periodically.
+ */
+ public void poll()
+ throws ManifoldCFException;
+
+ /** Free unused resources.
+ */
+ public void freeUnusedResources()
+ throws ManifoldCFException;
+
+ /** Shut down throttler permanently.
+ */
+ public void destroy()
+ throws ManifoldCFException;
+
+}
Propchange: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IConnectionThrottler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IConnectionThrottler.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionThrottler.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionThrottler.java?rev=1550329&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionThrottler.java (added)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionThrottler.java Thu Dec 12 00:57:38 2013
@@ -0,0 +1,162 @@
+/* $Id$ */
+
+/**
+* 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.core.throttler;
+
+import org.apache.manifoldcf.core.interfaces.*;
+
+/** An implementation of IConnectionThrottler, which establishes a JVM-wide
+* pool of throttlers that can be used as a resource by any connector that needs
+* it.
+*/
+public class ConnectionThrottler implements IConnectionThrottler
+{
+ public static final String _rcsid = "@(#)$Id$";
+
+ /** The thread context */
+ protected final IThreadContext threadContext;
+ /** The actual static pool */
+ protected final static Throttler throttler = new Throttler();
+
+ /** Constructor */
+ public ConnectionThrottler(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ this.threadContext = threadContext;
+ }
+
+ /** Get permission to use a connection, which is described by the passed array of bin names.
+ * The connection can be used multiple
+ * times until the releaseConnectionPermission() method is called.
+ *@param throttleGroup is the throttle group.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names to throttle for, within the throttle group.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void obtainConnectionPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException
+ {
+ throttler.obtainConnectionPermission(threadContext, throttleGroup,
+ throttleSpec, binNames, currentTime);
+ }
+
+ /** Release permission to use a connection. This presumes that obtainConnectionPermission()
+ * was called earlier in the same thread and was successful.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void releaseConnectionPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException
+ {
+ throttler.releaseConnectionPermission(threadContext, throttleGroup,
+ throttleSpec, binNames, currentTime);
+ }
+
+ /** Get permission to fetch a document. This grants permission to start
+ * fetching a single document. When done (or aborting), call
+ * releaseFetchDocumentPermission() to note the completion of the document
+ * fetch activity.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void obtainFetchDocumentPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException
+ {
+ throttler.obtainFetchDocumentPermission(threadContext, throttleGroup,
+ throttleSpec, binNames, currentTime);
+ }
+
+ /** Release permission to fetch a document. Call this only when you
+ * called obtainFetchDocumentPermission() successfully earlier in the same
+ * thread.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void releaseFetchDocumentPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException
+ {
+ throttler.releaseFetchDocumentPermission(threadContext, throttleGroup,
+ throttleSpec, binNames, currentTime);
+ }
+
+ /** Obtain permission to read a block of bytes.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ *@param byteCount is the number of bytes to get permissions to read.
+ */
+ public void obtainReadPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime, int byteCount)
+ throws ManifoldCFException
+ {
+ throttler.obtainReadPermission(threadContext, throttleGroup,
+ throttleSpec, binNames, currentTime, byteCount);
+ }
+
+ /** Note the completion of the read of a block of bytes. Call this after
+ * obtainReadPermission() was successfully called in the same thread.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ *@param origByteCount is the originally requested number of bytes to get permissions to read.
+ *@param actualByteCount is the number of bytes actually read.
+ */
+ public void releaseReadPermission(String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime, int origByteCount, int actualByteCount)
+ throws ManifoldCFException
+ {
+ throttler.releaseReadPermission(threadContext, throttleGroup,
+ throttleSpec, binNames, currentTime, origByteCount, actualByteCount);
+ }
+
+ /** Poll periodically.
+ */
+ public void poll()
+ throws ManifoldCFException
+ {
+ throttler.poll(threadContext);
+ }
+
+ /** Free unused resources.
+ */
+ public void freeUnusedResources()
+ throws ManifoldCFException
+ {
+ throttler.freeUnusedResources(threadContext);
+ }
+
+ /** Shut down throttler permanently.
+ */
+ public void destroy()
+ throws ManifoldCFException
+ {
+ throttler.destroy(threadContext);
+ }
+
+}
Propchange: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionThrottler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionThrottler.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java?rev=1550329&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java (added)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java Thu Dec 12 00:57:38 2013
@@ -0,0 +1,256 @@
+/* $Id$ */
+
+/**
+* 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.core.throttler;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import java.util.*;
+
+/** A Throttler object creates a virtual pool of connections to resources
+* whose access needs to be throttled in number, rate of use, and byte rate.
+*/
+public class Throttler
+{
+ public static final String _rcsid = "@(#)$Id$";
+
+ /** The service type prefix for throttle pools */
+ protected final static String serviceTypePrefix = "_THROTTLEPOOL_";
+
+ /** Pool hash table. Keyed by throttle group name; value is Pool */
+ protected final Map<String,Pool> poolHash = new HashMap<String,Pool>();
+
+ /** Create a throttler instance. Usually there will be one of these per connector
+ * type that needs throttling.
+ */
+ public Throttler()
+ {
+ }
+
+ /** Get permission to use a connection, which is described by the passed array of bin names.
+ * The connection can be used multiple
+ * times until the releaseConnectionPermission() method is called.
+ *@param threadContext is the thread context.
+ *@param throttleGroup is the throttle group.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names to throttle for, within the throttle group.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void obtainConnectionPermission(IThreadContext threadContext, String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Release permission to use a connection. This presumes that obtainConnectionPermission()
+ * was called earlier in the same thread and was successful.
+ *@param threadContext is the thread context.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void releaseConnectionPermission(IThreadContext threadContext, String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Get permission to fetch a document. This grants permission to start
+ * fetching a single document. When done (or aborting), call
+ * releaseFetchDocumentPermission() to note the completion of the document
+ * fetch activity.
+ *@param threadContext is the thread context.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void obtainFetchDocumentPermission(IThreadContext threadContext, String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Release permission to fetch a document. Call this only when you
+ * called obtainFetchDocumentPermission() successfully earlier in the same
+ * thread.
+ *@param threadContext is the thread context.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ */
+ public void releaseFetchDocumentPermission(IThreadContext threadContext, String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Obtain permission to read a block of bytes.
+ *@param threadContext is the thread context.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ *@param byteCount is the number of bytes to get permissions to read.
+ */
+ public void obtainReadPermission(IThreadContext threadContext, String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime, int byteCount)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Note the completion of the read of a block of bytes. Call this after
+ * obtainReadPermission() was successfully called in the same thread.
+ *@param threadContext is the thread context.
+ *@param throttleGroup is the throttle group name.
+ *@param throttleSpec is the throttle specification to use for the throttle group,
+ *@param binNames is the set of bin names describing this documemnt.
+ *@param currentTime is the current time, in ms. since epoch.
+ *@param origByteCount is the originally requested number of bytes to get permissions to read.
+ *@param actualByteCount is the number of bytes actually read.
+ */
+ public void releaseReadPermission(IThreadContext threadContext, String throttleGroup,
+ IThrottleSpec throttleSpec, String[] binNames, long currentTime, int origByteCount, int actualByteCount)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Poll periodically.
+ */
+ public void poll(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Free unused resources.
+ */
+ public void freeUnusedResources(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ // Go through the whole pool and clean it out
+ synchronized (poolHash)
+ {
+ Iterator<Pool> iter = poolHash.values().iterator();
+ while (iter.hasNext())
+ {
+ Pool p = iter.next();
+ p.freeUnusedResources(threadContext);
+ }
+ }
+ }
+
+ /** Shut down throttler permanently.
+ */
+ public void destroy(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ // Go through the whole pool and clean it out
+ synchronized (poolHash)
+ {
+ Iterator<Pool> iter = poolHash.values().iterator();
+ while (iter.hasNext())
+ {
+ Pool p = iter.next();
+ p.destroy(threadContext);
+ iter.remove();
+ }
+ }
+ }
+
+ // Protected methods and classes
+
+ protected String buildServiceTypeName(String throttleGroupName)
+ {
+ return serviceTypePrefix + throttleGroupName;
+ }
+
+
+ /** This class represents a value in the pool hash, which corresponds to a given key.
+ */
+ protected class Pool
+ {
+ /** Whether this pool is alive */
+ protected boolean isAlive = true;
+ /** Service type name */
+ protected final String serviceTypeName;
+ /** The (anonymous) service name */
+ protected final String serviceName;
+ /** The current throttle spec */
+ protected IThrottleSpec throttleSpec;
+
+ /** Constructor
+ */
+ public Pool(IThreadContext threadContext, String throttleGroup, IThrottleSpec throttleSpec)
+ throws ManifoldCFException
+ {
+ this.serviceTypeName = buildServiceTypeName(throttleGroup);
+ this.throttleSpec = throttleSpec;
+ // Now, register and activate service anonymously, and record the service name we get.
+ ILockManager lockManager = LockManagerFactory.make(threadContext);
+ this.serviceName = lockManager.registerServiceBeginServiceActivity(serviceTypeName, null, null);
+ }
+
+ /** Update the throttle spec.
+ *@param throttleSpec is the new throttle spec for this throttle group.
+ */
+ public synchronized void updateThrottleSpec(IThreadContext threadContext, IThrottleSpec throttleSpec)
+ throws ManifoldCFException
+ {
+ this.throttleSpec = throttleSpec;
+ }
+
+ // MHL
+
+ /** Call this periodically.
+ */
+ public synchronized void poll(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Free unused resources.
+ */
+ public synchronized void freeUnusedResources(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
+ /** Destroy this pool.
+ */
+ public synchronized void destroy(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ freeUnusedResources(threadContext);
+ // End service activity
+ isAlive = false;
+ notifyAll();
+ ILockManager lockManager = LockManagerFactory.make(threadContext);
+ lockManager.endServiceActivity(serviceTypeName, serviceName);
+ }
+ }
+
+}
Propchange: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java
------------------------------------------------------------------------------
svn:keywords = Id