hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject [1/3] hbase git commit: HBASE-17045 Unify the implementation of small scan and regular scan
Date Wed, 25 Jan 2017 01:53:48 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 616f4801b -> 85d701892


http://git-wip-us.apache.org/repos/asf/hbase/blob/85d70189/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java
new file mode 100644
index 0000000..a9a3e43
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java
@@ -0,0 +1,132 @@
+/**
+ * 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.hadoop.hbase.client;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ForkJoinPool;
+import java.util.function.Supplier;
+import java.util.stream.IntStream;
+
+import org.apache.hadoop.hbase.client.Scan.ReadType;
+import org.apache.hadoop.hbase.testclassification.ClientTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+@Category({ MediumTests.class, ClientTests.class })
+public class TestAsyncTableScanAll extends AbstractTestAsyncTableScan {
+
+  @Parameter(0)
+  public String tableType;
+
+  @Parameter(1)
+  public Supplier<AsyncTableBase> getTable;
+
+  @Parameter(2)
+  public String scanType;
+
+  @Parameter(3)
+  public Supplier<Scan> scanCreator;
+
+  private static RawAsyncTable getRawTable() {
+    return ASYNC_CONN.getRawTable(TABLE_NAME);
+  }
+
+  private static AsyncTable getTable() {
+    return ASYNC_CONN.getTable(TABLE_NAME, ForkJoinPool.commonPool());
+  }
+
+  private static Scan createNormalScan() {
+    return new Scan();
+  }
+
+  // test if we can handle partial result when open scanner.
+  private static Scan createSmallResultSizeScan() {
+    return new Scan().setMaxResultSize(1);
+  }
+
+  @Parameters(name = "{index}: table={0}, scan={2}")
+  public static List<Object[]> params() {
+    Supplier<AsyncTableBase> rawTable = TestAsyncTableScanAll::getRawTable;
+    Supplier<AsyncTableBase> normalTable = TestAsyncTableScanAll::getTable;
+    Supplier<Scan> normalScan = TestAsyncTableScanAll::createNormalScan;
+    Supplier<Scan> smallResultSizeScan = TestAsyncTableScanAll::createSmallResultSizeScan;
+    return Arrays.asList(new Object[] { "raw", rawTable, "normal", normalScan },
+      new Object[] { "raw", rawTable, "smallResultSize", smallResultSizeScan },
+      new Object[] { "normal", normalTable, "normal", normalScan },
+      new Object[] { "normal", normalTable, "smallResultSize", smallResultSizeScan });
+  }
+
+  @Test
+  public void testScanWithLimit() throws InterruptedException, ExecutionException {
+    int start = 111;
+    int stop = 888;
+    int limit = 300;
+    List<Result> results = getTable.get()
+        .scanAll(scanCreator.get().withStartRow(Bytes.toBytes(String.format("%03d", start)))
+            .withStopRow(Bytes.toBytes(String.format("%03d", stop))).setLimit(limit)
+            .setReadType(ReadType.PREAD))
+        .get();
+    assertEquals(limit, results.size());
+    IntStream.range(0, limit).forEach(i -> {
+      Result result = results.get(i);
+      int actualIndex = start + i;
+      assertEquals(String.format("%03d", actualIndex), Bytes.toString(result.getRow()));
+      assertEquals(actualIndex, Bytes.toInt(result.getValue(FAMILY, CQ1)));
+    });
+  }
+
+  @Test
+  public void testReversedScanWithLimit() throws InterruptedException, ExecutionException
{
+    int start = 888;
+    int stop = 111;
+    int limit = 300;
+    List<Result> results = getTable.get()
+        .scanAll(scanCreator.get().withStartRow(Bytes.toBytes(String.format("%03d", start)))
+            .withStopRow(Bytes.toBytes(String.format("%03d", stop))).setLimit(limit)
+            .setReadType(ReadType.PREAD).setReversed(true))
+        .get();
+    assertEquals(limit, results.size());
+    IntStream.range(0, limit).forEach(i -> {
+      Result result = results.get(i);
+      int actualIndex = start - i;
+      assertEquals(String.format("%03d", actualIndex), Bytes.toString(result.getRow()));
+      assertEquals(actualIndex, Bytes.toInt(result.getValue(FAMILY, CQ1)));
+    });
+  }
+
+  @Override
+  protected Scan createScan() {
+    return scanCreator.get();
+  }
+
+  @Override
+  protected List<Result> doScan(Scan scan) throws Exception {
+    return getTable.get().scanAll(scan).get();
+  }
+}

http://git-wip-us.apache.org/repos/asf/hbase/blob/85d70189/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableSmallScan.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableSmallScan.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableSmallScan.java
deleted file mode 100644
index 3737af2..0000000
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableSmallScan.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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.hadoop.hbase.client;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ForkJoinPool;
-import java.util.function.Supplier;
-import java.util.stream.IntStream;
-
-import org.apache.hadoop.hbase.testclassification.ClientTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-@Category({ MediumTests.class, ClientTests.class })
-public class TestAsyncTableSmallScan extends AbstractTestAsyncTableScan {
-
-  @Parameter
-  public Supplier<AsyncTableBase> getTable;
-
-  private static RawAsyncTable getRawTable() {
-    return ASYNC_CONN.getRawTable(TABLE_NAME);
-  }
-
-  private static AsyncTable getTable() {
-    return ASYNC_CONN.getTable(TABLE_NAME, ForkJoinPool.commonPool());
-  }
-
-  @Parameters
-  public static List<Object[]> params() {
-    return Arrays.asList(new Supplier<?>[] { TestAsyncTableSmallScan::getRawTable },
-      new Supplier<?>[] { TestAsyncTableSmallScan::getTable });
-  }
-
-  @Test
-  public void testScanWithLimit() throws InterruptedException, ExecutionException {
-    AsyncTableBase table = getTable.get();
-    int start = 111;
-    int stop = 888;
-    int limit = 300;
-    List<Result> results =
-        table
-            .smallScan(new Scan(Bytes.toBytes(String.format("%03d", start)))
-                .setStopRow(Bytes.toBytes(String.format("%03d", stop))).setSmall(true),
-              limit)
-            .get();
-    assertEquals(limit, results.size());
-    IntStream.range(0, limit).forEach(i -> {
-      Result result = results.get(i);
-      int actualIndex = start + i;
-      assertEquals(String.format("%03d", actualIndex), Bytes.toString(result.getRow()));
-      assertEquals(actualIndex, Bytes.toInt(result.getValue(FAMILY, CQ1)));
-    });
-  }
-
-  @Test
-  public void testReversedScanWithLimit() throws InterruptedException, ExecutionException
{
-    AsyncTableBase table = getTable.get();
-    int start = 888;
-    int stop = 111;
-    int limit = 300;
-    List<Result> results = table.smallScan(
-      new Scan(Bytes.toBytes(String.format("%03d", start)))
-          .setStopRow(Bytes.toBytes(String.format("%03d", stop))).setSmall(true).setReversed(true),
-      limit).get();
-    assertEquals(limit, results.size());
-    IntStream.range(0, limit).forEach(i -> {
-      Result result = results.get(i);
-      int actualIndex = start - i;
-      assertEquals(String.format("%03d", actualIndex), Bytes.toString(result.getRow()));
-      assertEquals(actualIndex, Bytes.toInt(result.getValue(FAMILY, CQ1)));
-    });
-  }
-
-  @Override
-  protected Scan createScan() {
-    return new Scan().setSmall(true);
-  }
-
-  @Override
-  protected List<Result> doScan(Scan scan) throws Exception {
-    return getTable.get().smallScan(scan).get();
-  }
-}

http://git-wip-us.apache.org/repos/asf/hbase/blob/85d70189/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java
index 9f3970b..a8ef353 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java
@@ -57,11 +57,6 @@ public class TestRawAsyncTableScan extends AbstractTestAsyncTableScan {
     }
 
     @Override
-    public boolean onHeartbeat() {
-      return true;
-    }
-
-    @Override
     public synchronized void onError(Throwable error) {
       finished = true;
       this.error = error;

http://git-wip-us.apache.org/repos/asf/hbase/blob/85d70189/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
index 3c5fe27..1b3c4e6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
@@ -28,6 +28,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.KeyValueUtil;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Put;
@@ -369,7 +370,10 @@ public class TestMultiRowRangeFilter {
   @Test
   public void testMultiRowRangeFilterWithExclusive() throws IOException {
     tableName = TableName.valueOf("testMultiRowRangeFilterWithExclusive");
+    TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, 6000000);
     Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+    ht.setReadRpcTimeout(600000);
+    ht.setOperationTimeout(6000000);
     generateRows(numRows, ht, family, qf, value);
 
     Scan scan = new Scan();


Mime
View raw message