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 03:25:16 UTC
svn commit: r1551105 - in
/manifoldcf/branches/CONNECTORS-829/framework/core/src:
main/java/org/apache/manifoldcf/core/throttler/
test/java/org/apache/manifoldcf/core/throttler/
Author: kwright
Date: Mon Dec 16 02:25:16 2013
New Revision: 1551105
URL: http://svn.apache.org/r1551105
Log:
Lots of debugging; still hangs in the multiconnection case
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
manifoldcf/branches/CONNECTORS-829/framework/core/src/test/java/org/apache/manifoldcf/core/throttler/TestThrottler.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=1551105&r1=1551104&r2=1551105&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 02:25:16 2013
@@ -101,7 +101,11 @@ public class ThrottleBin
/** Update minimumMillisecondsPerBytePerServer */
public void updateMinimumMillisecondsPerByte(double min)
{
- this.minimumMillisecondsPerByte = min;
+ synchronized (this)
+ {
+ this.minimumMillisecondsPerByte = min;
+ notifyAll();
+ }
}
/** Note the start of a fetch operation for a bin. Call this method just before the actual stream access begins.
@@ -168,6 +172,13 @@ public class ThrottleBin
return true;
}
+ // If we haven't set a proper throttle yet, wait until we do.
+ if (minimumMillisecondsPerByte == Double.MAX_VALUE)
+ {
+ wait();
+ continue;
+ }
+
// Estimate the time this read will take, and wait accordingly
long estimatedTime = (long)(rateEstimate * (double)byteCount);
@@ -175,7 +186,7 @@ public class ThrottleBin
long desiredEndTime = seriesStartTime + (long)(((double)(totalBytesRead + (long)byteCount)) * minimumMillisecondsPerByte);
- // The wait time is the different between our desired end time, minus the estimated time to read the data, and the
+ // The wait time is the difference between our desired end time, minus the estimated time to read the data, and the
// current time. But it can't be negative.
long waitTime = (desiredEndTime - estimatedTime) - currentTime;
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=1551105&r1=1551104&r2=1551105&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 02:25:16 2013
@@ -679,7 +679,7 @@ public class Throttler
{
bin = throttleBins.get(binName);
}
- if (bin == null || bin.beginRead(byteCount))
+ if (bin == null || !bin.beginRead(byteCount))
{
// End bins we've already done, and exit
while (i > 0)
Modified: manifoldcf/branches/CONNECTORS-829/framework/core/src/test/java/org/apache/manifoldcf/core/throttler/TestThrottler.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-829/framework/core/src/test/java/org/apache/manifoldcf/core/throttler/TestThrottler.java?rev=1551105&r1=1551104&r2=1551105&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-829/framework/core/src/test/java/org/apache/manifoldcf/core/throttler/TestThrottler.java (original)
+++ manifoldcf/branches/CONNECTORS-829/framework/core/src/test/java/org/apache/manifoldcf/core/throttler/TestThrottler.java Mon Dec 16 02:25:16 2013
@@ -45,6 +45,9 @@ public class TestThrottler extends org.a
// while generating a log that includes timestamps for everything that happens. At the end, the log will be
// analyzed for violations of throttling policy.
+ PollingThread pt = new PollingThread();
+ pt.start();
+
EventLog eventLog = new EventLog();
int numThreads = 10;
@@ -62,12 +65,65 @@ public class TestThrottler extends org.a
threads[i].finishUp();
}
+ pt.interrupt();
+ pt.finishUp();
+
// Finally, do the log analysis
eventLog.analyze();
System.out.println("Done test");
}
+ protected static class PollingThread extends Thread
+ {
+ protected Throwable exception = null;
+
+ public PollingThread()
+ {
+ }
+
+ public void run()
+ {
+ try
+ {
+ IThreadContext threadContext = ThreadContextFactory.make();
+ IThrottleGroups throttleGroups = ThrottleGroupsFactory.make(threadContext);
+
+ while (true)
+ {
+ throttleGroups.poll("test");
+ Thread.sleep(1000L);
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ }
+
+ }
+
+ public void finishUp()
+ throws Exception
+ {
+ join();
+ if (exception != null)
+ {
+ if (exception instanceof RuntimeException)
+ throw (RuntimeException)exception;
+ else if (exception instanceof Error)
+ throw (Error)exception;
+ else if (exception instanceof Exception)
+ throw (Exception)exception;
+ else
+ throw new RuntimeException("Unknown exception: "+exception.getClass().getName()+": "+exception.getMessage(),exception);
+ }
+ }
+
+ }
+
protected static class TesterThread extends Thread
{
protected final EventLog eventLog;
@@ -188,9 +244,9 @@ public class TestThrottler extends org.a
public int getMaxOpenConnections(String binName)
{
if (binName.equals("A"))
- return 2;
+ return 3;
if (binName.equals("B"))
- return 1;
+ return 4;
return Integer.MAX_VALUE;
}
@@ -203,7 +259,7 @@ public class TestThrottler extends org.a
if (binName.equals("B"))
return 10.0;
if (binName.equals("C"))
- return 5.0;
+ return 15.0;
return 0.0;
}