LOL
On Thu, Oct 4, 2012 at 6:55 PM, <mikemccand@apache.org> wrote:
> Author: mikemccand
> Date: Thu Oct 4 22:55:11 2012
> New Revision: 1394317
>
> URL: http://svn.apache.org/viewvc?rev=1394317&view=rev
> Log:
> bring back third bum: he seems to find bugs
>
> Added:
> lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ThrottledIndexOutput.java
> - copied unchanged from r1392603, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/ThrottledIndexOutput.java
> Modified:
> lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
> lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java
>
> Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java?rev=1394317&r1=1394316&r2=1394317&view=diff
> ==============================================================================
> --- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
(original)
> +++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
Thu Oct 4 22:55:11 2012
> @@ -41,6 +41,7 @@ import org.apache.lucene.index.IndexWrit
> import org.apache.lucene.index.NoDeletionPolicy;
> import org.apache.lucene.index.SegmentInfos;
> import org.apache.lucene.util.LuceneTestCase;
> +import org.apache.lucene.util.ThrottledIndexOutput;
> import org.apache.lucene.util._TestUtil;
>
> /**
> @@ -76,6 +77,7 @@ public class MockDirectoryWrapper extend
> private Set<String> openFilesForWrite = new HashSet<String>();
> Set<String> openLocks = Collections.synchronizedSet(new HashSet<String>());
> volatile boolean crashed;
> + private ThrottledIndexOutput throttledOutput;
> private Throttling throttling = Throttling.SOMETIMES;
>
> final AtomicInteger inputCloneCount = new AtomicInteger();
> @@ -114,16 +116,22 @@ public class MockDirectoryWrapper extend
> // called from different threads; else test failures may
> // not be reproducible from the original seed
> this.randomState = new Random(random.nextInt());
> + this.throttledOutput = new ThrottledIndexOutput(ThrottledIndexOutput
> + .mBitsToBytes(40 + randomState.nextInt(10)), 5 + randomState.nextInt(5), null);
> // force wrapping of lockfactory
> this.lockFactory = new MockLockFactoryWrapper(this, delegate.getLockFactory());
>
> - // NOTE: we init rateLimiter always but we only
> - // sometimes use it (by default) in createOutput:
> - double maxMBPerSec = 10 + 5*(randomState.nextDouble()-0.5);
> - if (LuceneTestCase.VERBOSE) {
> - System.out.println("MockDirectoryWrapper: will rate limit output IO to " + maxMBPerSec
+ " MB/sec");
> + // 2% of the time use rate limiter
> + if (randomState.nextInt(50) == 17) {
> + // Use RateLimiter
> + double maxMBPerSec = 10 + 5*(randomState.nextDouble()-0.5);
> + if (LuceneTestCase.VERBOSE) {
> + System.out.println("MockDirectoryWrapper: will rate limit output IO to " + maxMBPerSec
+ " MB/sec");
> + }
> + rateLimiter = new RateLimiter(maxMBPerSec);
> + } else {
> + rateLimiter = null;
> }
> - rateLimiter = new RateLimiter(maxMBPerSec);
>
> init();
> }
> @@ -439,25 +447,22 @@ public class MockDirectoryWrapper extend
> ramdir.fileMap.put(name, file);
> }
> }
> -
> - RateLimiter thisRateLimiter;
> -
> +
> + //System.out.println(Thread.currentThread().getName() + ": MDW: create " + name);
> + IndexOutput io = new MockIndexOutputWrapper(this, delegate.createOutput(name, LuceneTestCase.newIOContext(randomState,
context)), name);
> + addFileHandle(io, name, Handle.Output);
> + openFilesForWrite.add(name);
> +
> // throttling REALLY slows down tests, so don't do it very often for SOMETIMES.
> if (throttling == Throttling.ALWAYS ||
> (throttling == Throttling.SOMETIMES && rateLimiter == null &&
randomState.nextInt(50) == 0)) {
> if (LuceneTestCase.VERBOSE) {
> System.out.println("MockDirectoryWrapper: throttling indexOutput");
> }
> - thisRateLimiter = rateLimiter;
> + return throttledOutput.newFromDelegate(io);
> } else {
> - thisRateLimiter = null;
> + return io;
> }
> -
> - //System.out.println(Thread.currentThread().getName() + ": MDW: create " + name);
> - IndexOutput io = new MockIndexOutputWrapper(this, delegate.createOutput(name, LuceneTestCase.newIOContext(randomState,
context)), name, thisRateLimiter);
> - addFileHandle(io, name, Handle.Output);
> - openFilesForWrite.add(name);
> - return io;
> }
>
> private static enum Handle {
>
> Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java?rev=1394317&r1=1394316&r2=1394317&view=diff
> ==============================================================================
> --- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java
(original)
> +++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java
Thu Oct 4 22:55:11 2012
> @@ -32,17 +32,15 @@ public class MockIndexOutputWrapper exte
> private MockDirectoryWrapper dir;
> private final IndexOutput delegate;
> private boolean first=true;
> - private final RateLimiter rateLimiter;
> final String name;
>
> byte[] singleByte = new byte[1];
>
> /** Construct an empty output buffer. */
> - public MockIndexOutputWrapper(MockDirectoryWrapper dir, IndexOutput delegate, String
name, RateLimiter rateLimiter) {
> + public MockIndexOutputWrapper(MockDirectoryWrapper dir, IndexOutput delegate, String
name) {
> this.dir = dir;
> this.name = name;
> this.delegate = delegate;
> - this.rateLimiter = rateLimiter;
> }
>
> @Override
> @@ -80,8 +78,8 @@ public class MockIndexOutputWrapper exte
> long freeSpace = dir.maxSize == 0 ? 0 : dir.maxSize - dir.sizeInBytes();
> long realUsage = 0;
>
> - if (rateLimiter != null && len >= 1000) {
> - rateLimiter.pause(len);
> + if (dir.rateLimiter != null && len >= 1000) {
> + dir.rateLimiter.pause(len);
> }
>
> // If MockRAMDir crashed since we were opened, then
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
|