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/16 17:12:27 UTC
svn commit: r1551248 - in
/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler:
ConnectionBin.java FetchBin.java ThrottleBin.java Throttler.java
Author: kwright
Date: Mon Dec 16 16:12:27 2013
New Revision: 1551248
URL: http://svn.apache.org/r1551248
Log:
Remove service registration for ThrottlingGroup and add it for each bin.
Modified:
manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionBin.java
manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/FetchBin.java
manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ThrottleBin.java
manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java
Modified: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionBin.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionBin.java?rev=1551248&r1=1551247&r2=1551248&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionBin.java (original)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ConnectionBin.java Mon Dec 16 16:12:27 2013
@@ -46,6 +46,10 @@ public class ConnectionBin
protected boolean isAlive = true;
/** This is the bin name which this connection pool belongs to */
protected final String binName;
+ /** Service type name */
+ protected final String serviceTypeName;
+ /** The (anonymous) service name */
+ protected final String serviceName;
/** This is the maximum number of active connections allowed for this bin */
protected int maxActiveConnections = 0;
/** This is the number of connections in this bin that have been reserved - that is, they
@@ -55,10 +59,23 @@ public class ConnectionBin
* in use or in a pool somewhere. */
protected int inUseConnections = 0;
+ /** The service type prefix for connection bins */
+ protected final static String serviceTypePrefix = "_CONNECTIONBIN_";
+
/** Constructor. */
- public ConnectionBin(IThreadContext threadContext, String binName)
+ public ConnectionBin(IThreadContext threadContext, String throttlingGroupName, String binName)
+ throws ManifoldCFException
{
this.binName = binName;
+ this.serviceTypeName = buildServiceTypeName(throttlingGroupName, binName);
+ // 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);
+ }
+
+ protected String buildServiceTypeName(String throttlingGroupName, String binName)
+ {
+ return serviceTypePrefix + throttlingGroupName + "_" + binName;
}
/** Get the bin name. */
@@ -205,6 +222,13 @@ public class ConnectionBin
notifyAll();
}
+ /** Poll this bin */
+ public synchronized void poll(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
/** Shut down the bin, and release everything that is waiting on it.
*/
public synchronized void shutDown(IThreadContext threadContext)
@@ -212,6 +236,8 @@ public class ConnectionBin
{
isAlive = false;
notifyAll();
+ ILockManager lockManager = LockManagerFactory.make(threadContext);
+ lockManager.endServiceActivity(serviceTypeName, serviceName);
}
}
Modified: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/FetchBin.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/FetchBin.java?rev=1551248&r1=1551247&r2=1551248&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/FetchBin.java (original)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/FetchBin.java Mon Dec 16 16:12:27 2013
@@ -34,6 +34,10 @@ public class FetchBin
protected boolean isAlive = true;
/** This is the bin name which this connection pool belongs to */
protected final String binName;
+ /** Service type name */
+ protected final String serviceTypeName;
+ /** The (anonymous) service name */
+ protected final String serviceName;
/** This is the last time a fetch was done on this bin */
protected long lastFetchTime = 0L;
/** This is the minimum time between fetches for this bin, in ms. */
@@ -41,10 +45,23 @@ public class FetchBin
/** Is the next fetch reserved? */
protected boolean reserveNextFetch = false;
+ /** The service type prefix for fetch bins */
+ protected final static String serviceTypePrefix = "_FETCHBIN_";
+
/** Constructor. */
- public FetchBin(IThreadContext threadContext, String binName)
+ public FetchBin(IThreadContext threadContext, String throttlingGroupName, String binName)
+ throws ManifoldCFException
{
this.binName = binName;
+ this.serviceTypeName = buildServiceTypeName(throttlingGroupName, binName);
+ // 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);
+ }
+
+ protected String buildServiceTypeName(String throttlingGroupName, String binName)
+ {
+ return serviceTypePrefix + throttlingGroupName + "_" + binName;
}
/** Get the bin name. */
@@ -132,6 +149,13 @@ public class FetchBin
}
}
+ /** Poll this bin */
+ public synchronized void poll(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
/** Shut the bin down, and wake up all threads waiting on it.
*/
public synchronized void shutDown(IThreadContext threadContext)
@@ -139,6 +163,8 @@ public class FetchBin
{
isAlive = false;
notifyAll();
+ ILockManager lockManager = LockManagerFactory.make(threadContext);
+ lockManager.endServiceActivity(serviceTypeName, serviceName);
}
}
Modified: manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ThrottleBin.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ThrottleBin.java?rev=1551248&r1=1551247&r2=1551248&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ThrottleBin.java (original)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/ThrottleBin.java Mon Dec 16 16:12:27 2013
@@ -71,6 +71,10 @@ public class ThrottleBin
protected boolean isAlive = true;
/** This is the bin name which this throttle belongs to. */
protected final String binName;
+ /** Service type name */
+ protected final String serviceTypeName;
+ /** The (anonymous) service name */
+ protected final String serviceName;
/** This is the reference count for this bin (which records active references) */
protected volatile int refCount = 0;
/** The inverse rate estimate of the first fetch, in ms/byte */
@@ -86,12 +90,25 @@ public class ThrottleBin
/** The minimum milliseconds per byte */
protected double minimumMillisecondsPerByte = Double.MAX_VALUE;
+ /** The service type prefix for throttle bins */
+ protected final static String serviceTypePrefix = "_THROTTLEBIN_";
+
/** Constructor. */
- public ThrottleBin(IThreadContext threadContext, String binName)
+ public ThrottleBin(IThreadContext threadContext, String throttlingGroupName, String binName)
+ throws ManifoldCFException
{
this.binName = binName;
+ this.serviceTypeName = buildServiceTypeName(throttlingGroupName, binName);
+ // 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);
}
+ protected String buildServiceTypeName(String throttlingGroupName, String binName)
+ {
+ return serviceTypePrefix + throttlingGroupName + "_" + binName;
+ }
+
/** Get the bin name. */
public String getBinName()
{
@@ -252,6 +269,13 @@ public class ThrottleBin
}
+ /** Poll this bin */
+ public synchronized void poll(IThreadContext threadContext)
+ throws ManifoldCFException
+ {
+ // MHL
+ }
+
/** Shut down this bin.
*/
public synchronized void shutDown(IThreadContext threadContext)
@@ -259,6 +283,8 @@ public class ThrottleBin
{
isAlive = false;
notifyAll();
+ ILockManager lockManager = LockManagerFactory.make(threadContext);
+ lockManager.endServiceActivity(serviceTypeName, serviceName);
}
}
Modified: 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=1551248&r1=1551247&r2=1551248&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java (original)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java Mon Dec 16 16:12:27 2013
@@ -40,9 +40,6 @@ public class Throttler
{
public static final String _rcsid = "@(#)$Id$";
- /** The service type prefix for throttle pools */
- protected final static String serviceTypePrefix = "_THROTTLEPOOL_";
-
/** Throttle group hash table. Keyed by throttle group type, value is throttling groups */
protected final Map<String,ThrottlingGroups> throttleGroupsHash = new HashMap<String,ThrottlingGroups>();
@@ -193,11 +190,10 @@ public class Throttler
// Protected methods and classes
- protected String buildServiceTypeName(String throttlingGroupType, String throttleGroupName)
+ protected static String buildThrottlingGroupName(String throttlingGroupType, String throttlingGroupName)
{
- return serviceTypePrefix + throttlingGroupType + "_" + throttleGroupName;
+ return throttlingGroupType + "_" + throttlingGroupName;
}
-
/** This class represents a throttling group pool */
protected class ThrottlingGroups
@@ -316,12 +312,8 @@ public class Throttler
*/
protected class ThrottlingGroup
{
- /** 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 throttling group name */
+ protected final String throttlingGroupName;
/** The current throttle spec */
protected IThrottleSpec throttleSpec;
@@ -341,11 +333,8 @@ public class Throttler
public ThrottlingGroup(IThreadContext threadContext, String throttlingGroupType, String throttleGroup, IThrottleSpec throttleSpec)
throws ManifoldCFException
{
- this.serviceTypeName = buildServiceTypeName(throttlingGroupType, throttleGroup);
+ this.throttlingGroupName = buildThrottlingGroupName(throttlingGroupType, 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);
// Once all that is done, perform the initial setting of all the bin cutoffs
poll(threadContext);
}
@@ -364,7 +353,7 @@ public class Throttler
ConnectionBin bin = connectionBins.get(binName);
if (bin == null)
{
- bin = new ConnectionBin(threadContext, binName);
+ bin = new ConnectionBin(threadContext, throttlingGroupName, binName);
connectionBins.put(binName, bin);
}
}
@@ -377,7 +366,7 @@ public class Throttler
FetchBin bin = fetchBins.get(binName);
if (bin == null)
{
- bin = new FetchBin(threadContext, binName);
+ bin = new FetchBin(threadContext, throttlingGroupName, binName);
fetchBins.put(binName, bin);
}
}
@@ -390,7 +379,7 @@ public class Throttler
ThrottleBin bin = throttleBins.get(binName);
if (bin == null)
{
- bin = new ThrottleBin(threadContext, binName);
+ bin = new ThrottleBin(threadContext, throttlingGroupName, binName);
throttleBins.put(binName, bin);
}
}
@@ -775,15 +764,13 @@ public class Throttler
public synchronized void poll(IThreadContext threadContext)
throws ManifoldCFException
{
- // This is where we reset all the bin targets using ILockManager.
- // But for now, to get things working, we just do the "stupid" thing,
- // and presume we're the only actor.
- // MHL
+ // Go through all existing bins and update each one.
synchronized (connectionBins)
{
for (ConnectionBin bin : connectionBins.values())
{
bin.updateMaxActiveConnections(throttleSpec.getMaxOpenConnections(bin.getBinName()));
+ bin.poll(threadContext);
}
}
@@ -792,6 +779,7 @@ public class Throttler
for (FetchBin bin : fetchBins.values())
{
bin.updateMinTimeBetweenFetches(throttleSpec.getMinimumMillisecondsPerFetch(bin.getBinName()));
+ bin.poll(threadContext);
}
}
@@ -800,6 +788,7 @@ public class Throttler
for (ThrottleBin bin : throttleBins.values())
{
bin.updateMinimumMillisecondsPerByte(throttleSpec.getMinimumMillisecondsPerByte(bin.getBinName()));
+ bin.poll(threadContext);
}
}
@@ -851,11 +840,6 @@ public class Throttler
}
}
- // End service activity
- isAlive = false;
- notifyAll();
- ILockManager lockManager = LockManagerFactory.make(threadContext);
- lockManager.endServiceActivity(serviceTypeName, serviceName);
}
}