accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [3/3] git commit: ACCUMULO-1566 Add in an integration-test which checks that the readahead configuration works as intended.
Date Tue, 08 Oct 2013 17:24:08 GMT
ACCUMULO-1566 Add in an integration-test which checks that the readahead
configuration works as intended.

By applying the SlowIterator to sleep on next(), and then sleep for the same
amount of time in the main loop over the iterator from the Scanner, we should
only have to wait once when we're in "readahead mode", but wait twice when we're
not.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/dab1be96
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/dab1be96
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/dab1be96

Branch: refs/heads/master
Commit: dab1be962b6ab1ab095c4ccf7f3995ab1208c3d7
Parents: ff58f6b
Author: Josh Elser <elserj@apache.org>
Authored: Tue Oct 8 00:08:07 2013 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Tue Oct 8 00:55:46 2013 -0400

----------------------------------------------------------------------
 .../accumulo/test/functional/ScannerIT.java     | 112 +++++++++++++++++++
 1 file changed, 112 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/dab1be96/test/src/test/java/org/apache/accumulo/test/functional/ScannerIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ScannerIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ScannerIT.java
new file mode 100644
index 0000000..7913089
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/functional/ScannerIT.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.base.Stopwatch;
+
+/**
+ * 
+ */
+public class ScannerIT extends SimpleMacIT {
+
+  @Test(timeout = 60000)
+  public void testScannerReadaheadConfiguration() throws Exception {
+    final String table = "table";
+    Connector c = getConnector();
+    c.tableOperations().create(table);
+    
+    BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig());
+    
+    Mutation m = new Mutation("a");
+    for (int i = 0; i < 10; i++) {
+      m.put(Integer.toString(i), "", "");
+    }
+    
+    bw.addMutation(m);
+    bw.close();
+    
+    Scanner s = c.createScanner(table, new Authorizations());
+    
+    IteratorSetting cfg = new IteratorSetting(100, SlowIterator.class);
+    SlowIterator.setSleepTime(cfg, 100l);
+    s.addScanIterator(cfg);
+    s.setReadaheadThreshold(5);
+    s.setBatchSize(1);
+    s.setRange(new Range());
+    
+    Stopwatch sw = new Stopwatch();
+    Iterator<Entry<Key,Value>> iterator = s.iterator();
+    
+    sw.start();
+    while (iterator.hasNext()) {
+      sw.stop();
+      
+      // While we "do work" in the client, we should be fetching the next result
+      UtilWaitThread.sleep(100l);
+      iterator.next();
+      sw.start();
+    }
+    sw.stop();
+    
+    long millisWithWait = sw.elapsed(TimeUnit.MILLISECONDS);
+    
+    s = c.createScanner(table, new Authorizations());
+    s.addScanIterator(cfg);
+    s.setRange(new Range());
+    s.setBatchSize(1);
+    s.setReadaheadThreshold(0l);
+    
+    sw = new Stopwatch();
+    iterator = s.iterator();
+    
+    sw.start();
+    while (iterator.hasNext()) {
+      sw.stop();
+      
+      // While we "do work" in the client, we should be fetching the next result
+      UtilWaitThread.sleep(100l);
+      iterator.next();
+      sw.start();
+    }
+    sw.stop();
+
+    long millisWithNoWait = sw.elapsed(TimeUnit.MILLISECONDS);
+    
+    // The "no-wait" time should be much less than the "wait-time"
+    Assert.assertTrue("Expected less time to be taken with immediate readahead (" + millisWithNoWait

+        + ") than without immediate readahead (" + millisWithWait + ")", millisWithNoWait
< millisWithWait);
+  }
+
+}


Mime
View raw message