You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2020/10/15 12:45:33 UTC
[accumulo] branch main updated: Add API to query if table's goal
state is online (#1735)
This is an automated email from the ASF dual-hosted git repository.
ctubbsii 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 5c365f9 Add API to query if table's goal state is online (#1735)
5c365f9 is described below
commit 5c365f984b13dec105ecb654cea486a06443d967
Author: Jeffrey Manno <je...@gmail.com>
AuthorDate: Thu Oct 15 08:45:23 2020 -0400
Add API to query if table's goal state is online (#1735)
---
.../accumulo/core/client/admin/TableOperations.java | 16 ++++++++++++++++
.../accumulo/core/clientImpl/TableOperationsImpl.java | 13 +++++++++++--
.../core/clientImpl/TableOperationsHelperTest.java | 5 +++++
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
index ea7ce2e..d8cf16f 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
@@ -862,6 +862,22 @@ public interface TableOperations {
throws AccumuloSecurityException, AccumuloException, TableNotFoundException;
/**
+ * Check if a table is online through its current goal state only. Could run into issues if the
+ * current state of the table is in between states. If you require a specific state, call
+ * <code>online(tableName, true)</code> or <code>offline(tableName, true)</code>, this will wait
+ * until the table reaches the desired state before proceeding.
+ *
+ * @param tableName
+ * the table to check if online
+ * @throws AccumuloException
+ * when there is a general accumulo error
+ * @return true if table's goal state is online
+ *
+ * @since 2.1.0
+ */
+ boolean isOnline(String tableName) throws AccumuloException, TableNotFoundException;
+
+ /**
* Clears the tablet locator cache for a specified table
*
* @param tableName
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 185f6ea..1fd0cf4 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
@@ -1374,6 +1374,16 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
@Override
+ public boolean isOnline(String tableName) throws AccumuloException, TableNotFoundException {
+ checkArgument(tableName != null, "tableName is null");
+
+ TableId tableId = Tables.getTableId(context, tableName);
+
+ TableState expectedState = Tables.getTableState(context, tableId, true);
+ return expectedState == TableState.ONLINE;
+ }
+
+ @Override
public void online(String tableName)
throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
online(tableName, false);
@@ -1390,8 +1400,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
* ACCUMULO-4574 if table is already online return without executing fate operation.
*/
- TableState expectedState = Tables.getTableState(context, tableId, true);
- if (expectedState == TableState.ONLINE) {
+ if (isOnline(tableName)) {
if (wait)
waitForTableStateTransition(tableId, TableState.ONLINE);
return;
diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/TableOperationsHelperTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/TableOperationsHelperTest.java
index e79359d..c8cd6c9 100644
--- a/core/src/test/java/org/apache/accumulo/core/clientImpl/TableOperationsHelperTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/TableOperationsHelperTest.java
@@ -173,6 +173,11 @@ public class TableOperationsHelperTest {
}
@Override
+ public boolean isOnline(String tableName) {
+ return true;
+ }
+
+ @Override
public void online(String tableName) {}
@Override