manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1550863 - in /manifoldcf/branches/CONNECTORS-829/framework/core/src/main/java/org/apache/manifoldcf/core/throttler: ThrottleBin.java Throttler.java
Date Sat, 14 Dec 2013 01:09:41 GMT
Author: kwright
Date: Sat Dec 14 01:09:40 2013
New Revision: 1550863

URL: http://svn.apache.org/r1550863
Log:
Add runt polling infrastructure that assumes only one cluster member, for debugging

Modified:
    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/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=1550863&r1=1550862&r2=1550863&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
Sat Dec 14 01:09:40 2013
@@ -81,7 +81,9 @@ public class ThrottleBin
   protected long seriesStartTime = -1L;
   /** Total actual bytes read in this series; this includes fetches in progress */
   protected long totalBytesRead = -1L;
-
+  /** The minimum milliseconds per byte per server */
+  protected double minimumMillisecondsPerBytePerServer = Double.MAX_VALUE;
+  
   /** Constructor. */
   public ThrottleBin(String binName)
   {
@@ -94,6 +96,12 @@ public class ThrottleBin
     return binName;
   }
 
+  /** Update minimumMillisecondsPerBytePerServer */
+  public void updateMinimumMillisecondsPerBytePerServer(double min)
+  {
+    this.minimumMillisecondsPerBytePerServer = min;
+  }
+  
   /** Note the start of a fetch operation for a bin.  Call this method just before the actual
stream access begins.
   * May wait until schedule allows.
   */
@@ -129,7 +137,7 @@ public class ThrottleBin
   /** Note the start of an individual byte read of a specified size.  Call this method just
before the
   * read request takes place.  Performs the necessary delay prior to reading specified number
of bytes from the server.
   */
-  public void beginRead(int byteCount, double minimumMillisecondsPerBytePerServer)
+  public void beginRead(int byteCount)
     throws InterruptedException
   {
     long currentTime = System.currentTimeMillis();

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=1550863&r1=1550862&r2=1550863&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
Sat Dec 14 01:09:40 2013
@@ -333,6 +333,10 @@ public class Throttler
     /** The throttle bins */
     protected final Map<String,ThrottleBin> throttleBins = new HashMap<String,ThrottleBin>();
 
+    // For synchronization, we use several in this class.
+    // Modification to the connectionBins, fetchBins, or throttleBins hashes uses the appropriate
local synchronizer.
+    // Changes to other local variables use the main synchronizer.
+    
     /** Constructor
     */
     public ThrottlingGroup(IThreadContext threadContext, String throttlingGroupType, String
throttleGroup, IThrottleSpec throttleSpec)
@@ -343,6 +347,8 @@ public class Throttler
       // 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);
     }
 
     /** Update the throttle spec.
@@ -361,7 +367,34 @@ 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
+      synchronized (connectionBins)
+      {
+        for (ConnectionBin bin : connectionBins.values())
+        {
+          bin.updateMaxActiveConnections(throttleSpec.getMaxOpenConnections(bin.getBinName()));
+        }
+      }
+  
+      synchronized (fetchBins)
+      {
+        for (FetchBin bin : fetchBins.values())
+        {
+          bin.updateMinTimeBetweenFetches(throttleSpec.getMinimumMillisecondsPerFetch(bin.getBinName()));
+        }
+      }
+      
+      synchronized (throttleBins)
+      {
+        for (ThrottleBin bin : throttleBins.values())
+        {
+          bin.updateMinimumMillisecondsPerBytePerServer(throttleSpec.getMinimumMillisecondsPerByte(bin.getBinName()));
+        }
+      }
+      
     }
     
     /** Free unused resources.



Mime
View raw message