You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "keith-turner (via GitHub)" <gi...@apache.org> on 2023/05/12 19:50:29 UTC

[GitHub] [accumulo] keith-turner commented on a diff in pull request #3388: Added ScanServer tests for different tablet hosting goals

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


##########
test/src/main/java/org/apache/accumulo/test/ScanServerIT.java:
##########
@@ -224,6 +234,110 @@ 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));
+      } // 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));

Review Comment:
   Could also try scanning the ranges of the table that should work.
   
   ```suggestion
           assertThrows(RuntimeException.class, () -> Iterables.size(scanner));
           
           scanner.setRange(new Range(null,"row_0000000003"));
           assertEquals(???, Iterables.size(scanner));
           
            scanner.setRange(new Range("row_0000000008",null));
            assertEquals(???, Iterables.size(scanner));
   ```



##########
test/src/main/java/org/apache/accumulo/test/ScanServerIT.java:
##########
@@ -224,6 +234,110 @@ 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));
+      } // when the scanner is closed, all open sessions should be closed

Review Comment:
   can also add immediates scans of the ranges that should work here



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org