keith-turner commented on code in PR #3388:
URL: https://github.com/apache/accumulo/pull/3388#discussion_r1193874618


##########
test/src/main/java/org/apache/accumulo/test/ScanServerIT.java:
##########
@@ -205,6 +217,124 @@ public void testBatchScannerTimeout() throws Exception {
     }
   }
 
+  @Test
+  public void testScanWithTabletHostingMix() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String tableName = getUniqueNames(1)[0];
+
+      SortedSet<Text> splits = new TreeSet<>();
+      splits.add(new Text("row_0000000001"));
+      splits.add(new Text("row_0000000002"));
+      splits.add(new Text("row_0000000003"));
+      splits.add(new Text("row_0000000004"));
+      splits.add(new Text("row_0000000005"));
+      splits.add(new Text("row_0000000006"));
+      splits.add(new Text("row_0000000007"));
+      splits.add(new Text("row_0000000008"));
+      splits.add(new Text("row_0000000009"));
+      NewTableConfiguration ntc = new NewTableConfiguration();
+      ntc.withSplits(splits);
+      ntc.withInitialHostingGoal(TabletHostingGoal.ALWAYS); // speed up ingest
+      final int ingestedEntryCount = createTableAndIngest(client, tableName, 
ntc, 10, 10, "colf");
+
+      String tableId = client.tableOperations().tableIdMap().get(tableName);
+
+      // row 1 -> 3 are always
+      client.tableOperations().setTabletHostingGoal(tableName,
+          new Range(null, true, "row_0000000003", true), 
TabletHostingGoal.ALWAYS);
+      // row 4 -> 7 are never
+      client.tableOperations().setTabletHostingGoal(tableName,
+          new Range("row_0000000004", true, "row_0000000007", true), 
TabletHostingGoal.NEVER);
+      // row 8 and 9 are ondemand
+      client.tableOperations().setTabletHostingGoal(tableName,
+          new Range("row_0000000008", true, null, true), 
TabletHostingGoal.ONDEMAND);
+
+      // Wait for the NEVER and ONDEMAND tablets to be unloaded
+      int hosted = getNumHostedTablets(client, tableId);
+      // Waiting for tablets to be unloaded due to inactivity
+      while (hosted != 3) {
+        Thread.sleep(1000);
+        hosted = getNumHostedTablets(client, tableId);
+      }
+
+      try (Scanner scanner = client.createScanner(tableName, 
Authorizations.EMPTY)) {
+        scanner.setRange(new Range());
+        scanner.setConsistencyLevel(ConsistencyLevel.EVENTUAL);
+        assertEquals(ingestedEntryCount, Iterables.size(scanner),
+            "The scan server scanner should have seen all ingested and flushed 
entries");
+        // Throws an exception because of the tablets with the NEVER hosting 
goal
+        scanner.setConsistencyLevel(ConsistencyLevel.IMMEDIATE);
+        assertThrows(RuntimeException.class, () -> Iterables.size(scanner));
+
+        // Test that hosted ranges work
+        scanner.setRange(new Range(null, "row_0000000003"));
+        assertEquals(40, Iterables.size(scanner));
+
+        scanner.setRange(new Range("row_0000000008", null));
+        assertEquals(20, Iterables.size(scanner));
+      } // when the scanner is closed, all open sessions should be closed
+    }
+  }
+
+  @Test
+  public void testBatchScanWithTabletHostingMix() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String tableName = getUniqueNames(1)[0];
+
+      SortedSet<Text> splits = new TreeSet<>();
+      splits.add(new Text("row_0000000001"));
+      splits.add(new Text("row_0000000002"));
+      splits.add(new Text("row_0000000003"));
+      splits.add(new Text("row_0000000004"));
+      splits.add(new Text("row_0000000005"));
+      splits.add(new Text("row_0000000006"));
+      splits.add(new Text("row_0000000007"));
+      splits.add(new Text("row_0000000008"));
+      splits.add(new Text("row_0000000009"));
+      NewTableConfiguration ntc = new NewTableConfiguration();
+      ntc.withSplits(splits);
+      ntc.withInitialHostingGoal(TabletHostingGoal.ALWAYS); // speed up ingest
+      final int ingestedEntryCount = createTableAndIngest(client, tableName, 
ntc, 10, 10, "colf");
+
+      String tableId = client.tableOperations().tableIdMap().get(tableName);
+
+      // row 1 -> 3 are always
+      client.tableOperations().setTabletHostingGoal(tableName,
+          new Range(null, true, "row_0000000003", true), 
TabletHostingGoal.ALWAYS);
+      // row 4 -> 7 are never
+      client.tableOperations().setTabletHostingGoal(tableName,
+          new Range("row_0000000004", true, "row_0000000007", true), 
TabletHostingGoal.NEVER);
+      // row 8 and 9 are ondemand
+      client.tableOperations().setTabletHostingGoal(tableName,
+          new Range("row_0000000008", true, null, true), 
TabletHostingGoal.ONDEMAND);
+
+      // Wait for the NEVER and ONDEMAND tablets to be unloaded
+      int hosted = getNumHostedTablets(client, tableId);
+      // Waiting for tablets to be unloaded due to inactivity
+      while (hosted != 3) {
+        Thread.sleep(1000);
+        hosted = getNumHostedTablets(client, tableId);
+      }
+
+      try (BatchScanner scanner = client.createBatchScanner(tableName, 
Authorizations.EMPTY)) {
+        scanner.setRanges(Collections.singleton(new Range()));
+        scanner.setConsistencyLevel(ConsistencyLevel.EVENTUAL);
+        assertEquals(ingestedEntryCount, Iterables.size(scanner),
+            "The scan server scanner should have seen all ingested and flushed 
entries");
+        // Throws an exception because of the tablets with the NEVER hosting 
goal
+        scanner.setConsistencyLevel(ConsistencyLevel.IMMEDIATE);
+        assertThrows(RuntimeException.class, () -> Iterables.size(scanner));
+
+        // Test that hosted ranges work
+        Collection<Range> ranges = new ArrayList<>();
+        ranges.add(new Range(null, "row_0000000003"));
+        ranges.add(new Range("row_0000000008", null));
+        scanner.setRanges(ranges);
+        assertEquals(60, Iterables.size(scanner));

Review Comment:
   This is neat, a single batch scan against ranges with diff hosting goals.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to