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 20:25:40 UTC
svn commit: r1551325 -
/manifoldcf/branches/CONNECTORS-829/framework/core/src/test/java/org/apache/manifoldcf/core/throttler/TestThrottler.java
Author: kwright
Date: Mon Dec 16 19:25:39 2013
New Revision: 1551325
URL: http://svn.apache.org/r1551325
Log:
Add a fudge factor for fetch throttle, and hook up byte rate sanity check
Modified:
manifoldcf/branches/CONNECTORS-829/framework/core/src/test/java/org/apache/manifoldcf/core/throttler/TestThrottler.java
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=1551325&r1=1551324&r2=1551325&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 19:25:39 2013
@@ -415,7 +415,7 @@ public class TestThrottler extends org.a
public void apply(State state)
throws Exception
{
- if (timestamp < state.lastFetch + 20L)
+ if (timestamp < state.lastFetch + 20L - 1L)
throw new Exception("Fetch too fast: took place in "+ (timestamp - state.lastFetch) + " milliseconds");
state.lastFetch = timestamp;
}
@@ -457,7 +457,15 @@ public class TestThrottler extends org.a
public void apply(State state)
throws Exception
{
- // MHL
+ if (state.firstByteReadTime == -1L)
+ state.firstByteReadTime = timestamp;
+ else
+ {
+ // Calculate running minimum amount of time it should have taken for the bytes given
+ long minTime = (long)(((double)state.byteTotal) * 1.5 + 0.5);
+ if (timestamp - state.firstByteReadTime < minTime)
+ throw new Exception("Took too short a time to read "+state.byteTotal+" bytes: "+(timestamp - state.firstByteReadTime));
+ }
}
public String toString()
@@ -479,7 +487,7 @@ public class TestThrottler extends org.a
public void apply(State state)
throws Exception
{
- // MHL
+ state.byteTotal += actual;
}
public String toString()
@@ -492,8 +500,8 @@ public class TestThrottler extends org.a
{
public int outstandingConnections = 0;
public long lastFetch = 0L;
- public long lastByteRead = 0L;
- public int lastByteAmt = 0;
+ public long firstByteReadTime = -1L;
+ public long byteTotal = 0L;
}
}