You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by dl...@apache.org on 2022/12/01 17:20:09 UTC

[accumulo] 01/01: Revert "Allow ScanServers to scan offline tables (#3082)"

This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch revert-3082-allow-sserver-offline-scans
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit ac3d668500ef749d8593c03d169ce67d6a8345ad
Author: Dave Marion <dl...@apache.org>
AuthorDate: Thu Dec 1 12:20:03 2022 -0500

    Revert "Allow ScanServers to scan offline tables (#3082)"
    
    This reverts commit 557125539cf35362c69002ad72b00af5dd69e672.
---
 .../apache/accumulo/core/clientImpl/ClientContext.java  |  7 ++++---
 .../apache/accumulo/core/clientImpl/ScannerImpl.java    | 11 -----------
 .../core/clientImpl/TabletServerBatchReader.java        |  4 ----
 .../gc/src/main/java/org/apache/accumulo/gc/GCRun.java  |  4 +---
 .../accumulo/gc/GarbageCollectWriteAheadLogs.java       |  4 +---
 .../java/org/apache/accumulo/test/ScanServerIT.java     | 17 +++++++++--------
 6 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
index d600457ffd..a87167d65f 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
@@ -707,8 +707,8 @@ public class ClientContext implements AccumuloClient {
       int numQueryThreads) throws TableNotFoundException {
     ensureOpen();
     checkArgument(authorizations != null, "authorizations is null");
-    return new TabletServerBatchReader(this, getTableId(tableName), tableName, authorizations,
-        numQueryThreads);
+    return new TabletServerBatchReader(this, requireNotOffline(getTableId(tableName), tableName),
+        tableName, authorizations, numQueryThreads);
   }
 
   @Override
@@ -795,7 +795,8 @@ public class ClientContext implements AccumuloClient {
       throws TableNotFoundException {
     ensureOpen();
     checkArgument(authorizations != null, "authorizations is null");
-    Scanner scanner = new ScannerImpl(this, getTableId(tableName), authorizations);
+    Scanner scanner =
+        new ScannerImpl(this, requireNotOffline(getTableId(tableName), tableName), authorizations);
     Integer batchSize = ClientProperty.SCANNER_BATCH_SIZE.getInteger(getProperties());
     if (batchSize != null) {
       scanner.setBatchSize(batchSize);
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerImpl.java
index 5fbacd7f7f..c418e5a412 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerImpl.java
@@ -28,7 +28,6 @@ import java.util.Map.Entry;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.TableId;
@@ -153,16 +152,6 @@ public class ScannerImpl extends ScannerOptions implements Scanner {
   @Override
   public synchronized Iterator<Entry<Key,Value>> iterator() {
     ensureOpen();
-
-    if (getConsistencyLevel() == ConsistencyLevel.IMMEDIATE) {
-      try {
-        String tableName = context.getTableName(tableId);
-        context.requireNotOffline(tableId, tableName);
-      } catch (TableNotFoundException e) {
-        throw new RuntimeException("Table not found", e);
-      }
-    }
-
     ScannerIterator iter = new ScannerIterator(context, tableId, authorizations, range, size,
         getTimeout(SECONDS), this, isolated, readaheadThreshold, new Reporter());
 
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReader.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReader.java
index 9508f06aa6..c0de759516 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReader.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReader.java
@@ -115,10 +115,6 @@ public class TabletServerBatchReader extends ScannerOptions implements BatchScan
       throw new IllegalStateException("batch reader closed");
     }
 
-    if (getConsistencyLevel() == ConsistencyLevel.IMMEDIATE) {
-      context.requireNotOffline(tableId, tableName);
-    }
-
     return new TabletServerBatchReaderIterator(context, tableId, tableName, authorizations, ranges,
         numThreads, queryThreadPool, this, timeOut);
   }
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
index f72af11c34..699e793d34 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
@@ -44,7 +44,6 @@ import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.client.IsolatedScanner;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.TableOfflineException;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.TableId;
@@ -384,8 +383,7 @@ public class GCRun implements GarbageCollectionEnvironment {
         }
         return Maps.immutableEntry(file, stat);
       });
-    } catch (org.apache.accumulo.core.replication.ReplicationTableOfflineException
-        | TableOfflineException e) {
+    } catch (org.apache.accumulo.core.replication.ReplicationTableOfflineException e) {
       // No elements that we need to preclude
       return Collections.emptyIterator();
     }
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
index b180bc762a..631e6ca531 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
@@ -31,7 +31,6 @@ import java.util.UUID;
 
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.TableOfflineException;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.gc.thrift.GCStatus;
@@ -358,8 +357,7 @@ public class GarbageCollectWriteAheadLogs {
           candidates.remove(id);
           log.info("Ignore closed log " + id + " because it is being replicated");
         }
-      } catch (org.apache.accumulo.core.replication.ReplicationTableOfflineException
-          | TableOfflineException ex) {
+      } catch (org.apache.accumulo.core.replication.ReplicationTableOfflineException ex) {
         return candidates.size();
       }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/ScanServerIT.java b/test/src/main/java/org/apache/accumulo/test/ScanServerIT.java
index f9557859a9..528fd7f441 100644
--- a/test/src/main/java/org/apache/accumulo/test/ScanServerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ScanServerIT.java
@@ -36,6 +36,7 @@ import org.apache.accumulo.core.client.BatchScanner;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.ScannerBase.ConsistencyLevel;
+import org.apache.accumulo.core.client.TableOfflineException;
 import org.apache.accumulo.core.client.TimedOutException;
 import org.apache.accumulo.core.client.admin.NewTableConfiguration;
 import org.apache.accumulo.core.conf.ClientProperty;
@@ -149,19 +150,19 @@ public class ScanServerIT extends SharedMiniClusterBase {
 
   @Test
   public void testScanOfflineTable() throws Exception {
-
     try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
       String tableName = getUniqueNames(1)[0];
 
-      final int ingestedEntryCount = createTableAndIngest(client, tableName, null, 10, 10, "colf");
+      createTableAndIngest(client, tableName, null, 10, 10, "colf");
       client.tableOperations().offline(tableName, true);
 
-      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");
-      } // when the scanner is closed, all open sessions should be closed
+      assertThrows(TableOfflineException.class, () -> {
+        try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) {
+          scanner.setRange(new Range());
+          scanner.setConsistencyLevel(ConsistencyLevel.EVENTUAL);
+          assertEquals(100, Iterables.size(scanner));
+        } // when the scanner is closed, all open sessions should be closed
+      });
     }
   }