Package org.apache.lucene.store.RateLimiter

Examples of org.apache.lucene.store.RateLimiter.SimpleRateLimiter.pause()


*/
public final class TestRateLimiter extends LuceneTestCase {

  public void testPause() {
    SimpleRateLimiter limiter = new SimpleRateLimiter(10); // 10 MB / Sec
    limiter.pause(2);//init
    long pause = 0;
    for (int i = 0; i < 3; i++) {
      pause += limiter.pause(4 * 1024 * 1024); // fire up 3 * 4 MB
    }
    final long convert = TimeUnit.MILLISECONDS.convert(pause, TimeUnit.NANOSECONDS);
View Full Code Here


  public void testPause() {
    SimpleRateLimiter limiter = new SimpleRateLimiter(10); // 10 MB / Sec
    limiter.pause(2);//init
    long pause = 0;
    for (int i = 0; i < 3; i++) {
      pause += limiter.pause(4 * 1024 * 1024); // fire up 3 * 4 MB
    }
    final long convert = TimeUnit.MILLISECONDS.convert(pause, TimeUnit.NANOSECONDS);
    assertTrue("we should sleep less than 2 seconds but did: " + convert + " millis", convert < 2000l);
    assertTrue("we should sleep at least 1 second but did only: " + convert + " millis", convert > 1000l);
  }
View Full Code Here

            for(int i=0;i<500;i++) {
              long numBytes = TestUtil.nextInt(random(), 1000, 10000);
              totBytes.addAndGet(numBytes);
              bytesSinceLastPause += numBytes;
              if (bytesSinceLastPause > limiter.getMinPauseCheckBytes()) {
                limiter.pause(bytesSinceLastPause);
                bytesSinceLastPause = 0;
              }
            }
          }
        };
View Full Code Here

*/
public final class TestRateLimiter extends LuceneTestCase {

  public void testPause() {
    SimpleRateLimiter limiter = new SimpleRateLimiter(10); // 10 MB / Sec
    limiter.pause(2);//init
    long pause = 0;
    for (int i = 0; i < 3; i++) {
      pause += limiter.pause(4 * 1024 * 1024); // fire up 3 * 4 MB
    }
    final long convert = TimeUnit.MILLISECONDS.convert(pause, TimeUnit.NANOSECONDS);
View Full Code Here

  public void testPause() {
    SimpleRateLimiter limiter = new SimpleRateLimiter(10); // 10 MB / Sec
    limiter.pause(2);//init
    long pause = 0;
    for (int i = 0; i < 3; i++) {
      pause += limiter.pause(4 * 1024 * 1024); // fire up 3 * 4 MB
    }
    final long convert = TimeUnit.MILLISECONDS.convert(pause, TimeUnit.NANOSECONDS);
    assertTrue("we should sleep less than 2 seconds but did: " + convert + " millis", convert < 2000l);
    assertTrue("we should sleep at least 1 second but did only: " + convert + " millis", convert > 1000l);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.