You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/01/13 10:13:32 UTC

[GitHub] [hbase] virajjasani commented on a change in pull request #2866: HBASE-25478 - Implement retries when enabling tables in TestRegionReplicaReplicationEndpoint

virajjasani commented on a change in pull request #2866:
URL: https://github.com/apache/hbase/pull/2866#discussion_r556405136



##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
##########
@@ -487,4 +488,25 @@ private void testRegionReplicaReplicationIgnores(boolean dropTable, boolean disa
       connection.close();
     }
   }
+  private void enableTableWithRetries(TableDescriptor htd, boolean createTableOperation) throws InterruptedException {

Review comment:
       nit: leave one line just before this method?

##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
##########
@@ -487,4 +488,25 @@ private void testRegionReplicaReplicationIgnores(boolean dropTable, boolean disa
       connection.close();
     }
   }
+  private void enableTableWithRetries(TableDescriptor htd, boolean createTableOperation) throws InterruptedException {

Review comment:
       The purpose of this method is to either `create` or `enable` table, so let's rename method name to `createOrEnableTableWithRetries`

##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
##########
@@ -487,4 +488,25 @@ private void testRegionReplicaReplicationIgnores(boolean dropTable, boolean disa
       connection.close();
     }
   }
+  private void enableTableWithRetries(TableDescriptor htd, boolean createTableOperation) throws InterruptedException {
+    // Helper function to run create/enable table operations with a retry feature
+    boolean continueToRetry = true;
+    int tries = 0;
+    while (continueToRetry && tries < 100) {
+      try {
+        continueToRetry = false;
+        if (createTableOperation) {
+          HTU.getAdmin().createTable(htd);
+        } else {
+          HTU.getAdmin().enableTable(htd.getTableName());
+        }
+      } catch (IOException e) {
+        if (e.getCause() instanceof ReplicationException) {
+          continueToRetry = true;
+          tries++;
+          Thread.sleep(1000);

Review comment:
       Let's use `Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS)` so as to avoid throws clause for `InterruptedException`. 
   
   The import package: 
   `import org.apache.hbase.thirdparty.com.google.common.util.concurrent.Uninterruptibles`




----------------------------------------------------------------
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.

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