This is an automated email from the ASF dual-hosted git repository.
krathbun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 4da60e3378 Minor TableOperations changes (#5510)
4da60e3378 is described below
commit 4da60e3378ab98363e9ab60a09475848400385d7
Author: Kevin Rathbun <[email protected]>
AuthorDate: Wed May 21 12:33:48 2025 -0400
Minor TableOperations changes (#5510)
* Minor TableOperations changes:
- Added early `return true` for all system tables for
`TableOperations.exists()`
- system table check for `TableOperations.setTabletAvailability()` would
only occur client side. Now occurs server side as well. The client side check
now results in a `AccumuloException` instead of the previous
`IllegalArgumentException`. All the other `TableOperations` that can't be
called on a system table result in an `AccumuloException` if they are called on
a system table, so this change keeps consistency with the other
`TableOperations`
* ensure table is not system table for offline, online client-side
---
.../accumulo/core/clientImpl/TableOperationsImpl.java | 15 +++++++--------
.../org/apache/accumulo/manager/FateServiceHandler.java | 4 ++--
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
index ccc16df7c4..617db4c708 100644
---
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
+++
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
@@ -41,7 +41,6 @@ import static
org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType
import static org.apache.accumulo.core.util.LazySingletons.RANDOM;
import static org.apache.accumulo.core.util.Validators.EXISTING_TABLE_NAME;
import static org.apache.accumulo.core.util.Validators.NEW_TABLE_NAME;
-import static org.apache.accumulo.core.util.Validators.NOT_BUILTIN_TABLE;
import static
org.apache.accumulo.core.util.threads.ThreadPoolNames.SPLIT_START_POOL;
import static
org.apache.accumulo.core.util.threads.ThreadPoolNames.SPLIT_WAIT_POOL;
@@ -223,8 +222,7 @@ public class TableOperationsImpl extends
TableOperationsHelper {
public boolean exists(String tableName) {
EXISTING_TABLE_NAME.validate(tableName);
- if (tableName.equals(SystemTables.METADATA.tableName())
- || tableName.equals(SystemTables.ROOT.tableName())) {
+ if (SystemTables.containsTableName(tableName)) {
return true;
}
@@ -1517,15 +1515,13 @@ public class TableOperationsImpl extends
TableOperationsHelper {
switch (newState) {
case OFFLINE:
op = TFateOperation.TABLE_OFFLINE;
- if (tableName.equals(SystemTables.METADATA.tableName())
- || tableName.equals(SystemTables.ROOT.tableName())) {
+ if (SystemTables.containsTableName(tableName)) {
throw new AccumuloException("Cannot set table to offline state");
}
break;
case ONLINE:
op = TFateOperation.TABLE_ONLINE;
- if (tableName.equals(SystemTables.METADATA.tableName())
- || tableName.equals(SystemTables.ROOT.tableName())) {
+ if (SystemTables.containsTableName(tableName)) {
// Don't submit a Fate operation for this, these tables can only be
online.
return;
}
@@ -2249,7 +2245,10 @@ public class TableOperationsImpl extends
TableOperationsHelper {
public void setTabletAvailability(String tableName, Range range,
TabletAvailability availability)
throws AccumuloSecurityException, AccumuloException {
EXISTING_TABLE_NAME.validate(tableName);
- NOT_BUILTIN_TABLE.validate(tableName);
+ if (SystemTables.containsTableName(tableName)) {
+ throw new AccumuloException("Cannot set set tablet availability for
table " + tableName);
+ }
+
checkArgument(range != null, "range is null");
checkArgument(availability != null, "tabletAvailability is null");
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java
b/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java
index 75e682b1f3..4bfa9474c2 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java
@@ -27,7 +27,6 @@ import static
org.apache.accumulo.core.util.Validators.NEW_TABLE_NAME;
import static org.apache.accumulo.core.util.Validators.NOT_BUILTIN_NAMESPACE;
import static org.apache.accumulo.core.util.Validators.NOT_BUILTIN_TABLE;
import static org.apache.accumulo.core.util.Validators.NOT_BUILTIN_TABLE_ID;
-import static org.apache.accumulo.core.util.Validators.NOT_METADATA_TABLE;
import static org.apache.accumulo.core.util.Validators.NOT_ROOT_TABLE_ID;
import static org.apache.accumulo.core.util.Validators.VALID_TABLE_ID;
import static org.apache.accumulo.core.util.Validators.sameNamespaceAs;
@@ -671,7 +670,8 @@ class FateServiceHandler implements FateService.Iface {
case TABLE_TABLET_AVAILABILITY: {
TableOperation tableOp = TableOperation.SET_TABLET_AVAILABILITY;
validateArgumentCount(arguments, tableOp, 3);
- String tableName = validateName(arguments.get(0), tableOp,
NOT_METADATA_TABLE);
+ String tableName =
+ validateName(arguments.get(0), tableOp,
NOT_BUILTIN_TABLE.and(EXISTING_TABLE_NAME));
TableId tableId = null;
try {
tableId = manager.getContext().getTableId(tableName);