You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2021/12/14 00:10:59 UTC

[hbase] branch branch-2.5 updated (9cf0af6 -> bbdc840)

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

apurtell pushed a change to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git.


    from 9cf0af6  HBASE-26537: Make HBASE-15676 backwards compatible, using a flag on the proto (#3931)
     new 49d4c4a  HBASE-26027 The calling of HTable.batch blocked at AsyncRequestFutureImpl.waitUntilDone caused by ArrayStoreException (#3925)
     new bbdc840  HBASE-26530 Backport HBASE-26524 Support remove coprocessor by class name via alter table command (#3908)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../hadoop/hbase/client/AsyncRequestFutureImpl.java   | 15 +++++++++++++--
 .../hadoop/hbase/client/TableDescriptorBuilder.java   |  2 ++
 .../hbase/client/TestTableDescriptorBuilder.java      | 14 ++++++++++++++
 .../hadoop/hbase/TestClientOperationTimeout.java      |  5 ++---
 hbase-shell/src/main/ruby/hbase/admin.rb              | 11 +++++++++++
 hbase-shell/src/main/ruby/hbase_constants.rb          |  1 +
 hbase-shell/src/main/ruby/shell/commands/alter.rb     | 12 ++++++++++++
 hbase-shell/src/test/ruby/hbase/admin_test.rb         | 19 +++++++++++++++++++
 8 files changed, 74 insertions(+), 5 deletions(-)

[hbase] 02/02: HBASE-26530 Backport HBASE-26524 Support remove coprocessor by class name via alter table command (#3908)

Posted by ap...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit bbdc84003fca440f2c516012c3b9dd750bbb4cd4
Author: Tak Lon (Stephen) Wu <ta...@apache.org>
AuthorDate: Fri Dec 10 10:12:30 2021 -0800

    HBASE-26530 Backport HBASE-26524 Support remove coprocessor by class name via alter table command (#3908)
    
     Signed-off-by: Ankit Singhal <an...@apache.org>
---
 .../hadoop/hbase/client/TableDescriptorBuilder.java   |  2 ++
 .../hbase/client/TestTableDescriptorBuilder.java      | 14 ++++++++++++++
 hbase-shell/src/main/ruby/hbase/admin.rb              | 11 +++++++++++
 hbase-shell/src/main/ruby/hbase_constants.rb          |  1 +
 hbase-shell/src/main/ruby/shell/commands/alter.rb     | 12 ++++++++++++
 hbase-shell/src/test/ruby/hbase/admin_test.rb         | 19 +++++++++++++++++++
 6 files changed, 59 insertions(+)

diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
index 01d2753..c2ca5a1 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
@@ -1600,6 +1600,8 @@ public class TableDescriptorBuilder {
       // if we found a match, remove it
       if (match != null) {
         ModifyableTableDescriptor.this.removeValue(match);
+      } else {
+        LOG.warn("coprocessor with class name {} was not found in the table attribute", className);
       }
     }
 
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestTableDescriptorBuilder.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestTableDescriptorBuilder.java
index aa4d5a1..658ad06 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestTableDescriptorBuilder.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestTableDescriptorBuilder.java
@@ -159,6 +159,20 @@ public class TestTableDescriptorBuilder {
   }
 
   /**
+   * Test removing cps in the table description that does not exist
+   */
+  @Test
+  public void testRemoveNonExistingCoprocessor() throws Exception {
+    String className = "org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver";
+    TableDescriptor desc = TableDescriptorBuilder
+      .newBuilder(TableName.valueOf(name.getMethodName()))
+      .build();
+    assertFalse(desc.hasCoprocessor(className));
+    desc = TableDescriptorBuilder.newBuilder(desc).removeCoprocessor(className).build();
+    assertFalse(desc.hasCoprocessor(className));
+  }
+
+  /**
    * Test that we add and remove strings from settings properly.
    */
   @Test
diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index c1da4bb..f4cfd31 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -758,6 +758,17 @@ module Hbase
               htd.remove(name)
             end
             hasTableUpdate = true
+          elsif method == 'table_remove_coprocessor'
+            classname = arg.delete(CLASSNAME)
+            raise(ArgumentError, 'CLASSNAME parameter missing for table_remove_coprocessor method') unless classname
+            if classname.is_a?(Array)
+              classname.each do |key|
+                htd.removeCoprocessor(key)
+              end
+            else
+              htd.removeCoprocessor(classname)
+            end
+            hasTableUpdate = true
           # Unset table configuration
           elsif method == 'table_conf_unset'
             raise(ArgumentError, 'NAME parameter missing for table_conf_unset method') unless name
diff --git a/hbase-shell/src/main/ruby/hbase_constants.rb b/hbase-shell/src/main/ruby/hbase_constants.rb
index c7b133e..3c637b8 100644
--- a/hbase-shell/src/main/ruby/hbase_constants.rb
+++ b/hbase-shell/src/main/ruby/hbase_constants.rb
@@ -39,6 +39,7 @@ module HBaseConstants
   BATCH = 'BATCH'.freeze
   CACHE = 'CACHE'.freeze
   CACHE_BLOCKS = 'CACHE_BLOCKS'.freeze
+  CLASSNAME = 'CLASSNAME'.freeze
   CLUSTER_KEY = 'CLUSTER_KEY'.freeze
   COLUMN = 'COLUMN'.freeze
   COLUMNS = 'COLUMNS'.freeze
diff --git a/hbase-shell/src/main/ruby/shell/commands/alter.rb b/hbase-shell/src/main/ruby/shell/commands/alter.rb
index 93323be..9d95bff 100644
--- a/hbase-shell/src/main/ruby/shell/commands/alter.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/alter.rb
@@ -82,6 +82,18 @@ You can also remove a table-scope attribute:
 
   hbase> alter 't1', METHOD => 'table_att_unset', NAME => 'coprocessor$1'
 
+Other than removing coprocessor from the table-scope attribute via 'table_att_unset', you can also
+use 'table_remove_coprocessor' by specifying the class name:
+
+  hbase> alter 't1', METHOD => 'table_remove_coprocessor', CLASSNAME =>
+           'org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver'
+
+You can also remove multiple coprocessors at once:
+
+  hbase> alter 't1', METHOD => 'table_remove_coprocessor', CLASSNAME =>
+           ['org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver',
+            'org.apache.hadoop.hbase.coprocessor.Export']
+
 You can also set REGION_REPLICATION:
 
   hbase> alter 't1', {REGION_REPLICATION => 2}
diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb
index 26793a1..e84ffd6 100644
--- a/hbase-shell/src/test/ruby/hbase/admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb
@@ -977,6 +977,25 @@ module Hbase
       assert_no_match(eval("/" + key + "/"), admin.describe(@test_name))
     end
 
+    define_test "alter should be able to remove a coprocessor by class name" do
+      drop_test_table(@test_name)
+      create_test_table(@test_name)
+
+      cp_key = "coprocessor"
+      class_name = "org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver"
+      cp_value = "|" + class_name + "|12|arg1=1,arg2=2"
+
+      command(:alter, @test_name, 'METHOD' => 'table_att', cp_key => cp_value)
+      describe_text = admin.describe(@test_name)
+      assert_match(eval("/" + class_name + "/"), describe_text)
+      assert_match(eval("/" + cp_key + "\\$(\\d+)/"), describe_text)
+      assert_match(/arg1=1,arg2=2/, describe_text)
+
+      command(:alter, @test_name, 'METHOD' => 'table_remove_coprocessor', 'CLASSNAME' => class_name)
+      describe_text = admin.describe(@test_name)
+      assert_no_match(eval("/" + class_name + "/"), describe_text)
+    end
+
     define_test "alter should be able to remove a list of table attributes" do
       drop_test_table(@test_name)
 

[hbase] 01/02: HBASE-26027 The calling of HTable.batch blocked at AsyncRequestFutureImpl.waitUntilDone caused by ArrayStoreException (#3925)

Posted by ap...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 49d4c4a4c0f189503b95b7fb4407f6bfd56be37a
Author: bsglz <18...@qq.com>
AuthorDate: Fri Dec 10 14:34:17 2021 +0800

    HBASE-26027 The calling of HTable.batch blocked at AsyncRequestFutureImpl.waitUntilDone caused by ArrayStoreException (#3925)
    
    * HBASE-26027 The calling of HTable.batch blocked at AsyncRequestFutureImpl.waitUntilDone caused by ArrayStoreException
---
 .../hadoop/hbase/client/AsyncRequestFutureImpl.java       | 15 +++++++++++++--
 .../apache/hadoop/hbase/TestClientOperationTimeout.java   |  5 ++---
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java
index 8cfcf0c..ca6d534 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.client;
 
 import java.io.IOException;
 import java.io.InterruptedIOException;
+import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -1132,7 +1133,17 @@ class AsyncRequestFutureImpl<CResult> implements AsyncRequestFuture {
   @Override
   public void waitUntilDone() throws InterruptedIOException {
     try {
-      waitUntilDone(Long.MAX_VALUE);
+      if (this.operationTimeout > 0) {
+        // the worker thread maybe over by some exception without decrement the actionsInProgress,
+        // then the guarantee of operationTimeout will be broken, so we should set cutoff to avoid
+        // stuck here forever
+        long cutoff = (EnvironmentEdgeManager.currentTime() + this.operationTimeout) * 1000L;
+        if (!waitUntilDone(cutoff)) {
+          throw new SocketTimeoutException("time out before the actionsInProgress changed to zero");
+        }
+      } else {
+        waitUntilDone(Long.MAX_VALUE);
+      }
     } catch (InterruptedException iex) {
       throw new InterruptedIOException(iex.getMessage());
     } finally {
@@ -1144,7 +1155,7 @@ class AsyncRequestFutureImpl<CResult> implements AsyncRequestFuture {
     }
   }
 
-  private boolean waitUntilDone(long cutoff) throws InterruptedException {
+  private boolean waitUntilDone(long cutoff) throws InterruptedException{
     boolean hasWait = cutoff != Long.MAX_VALUE;
     long lastLog = EnvironmentEdgeManager.currentTime();
     long currentInProgress;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClientOperationTimeout.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClientOperationTimeout.java
index 09bdf7a..20424c9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClientOperationTimeout.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClientOperationTimeout.java
@@ -29,7 +29,6 @@ import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.RetriesExhaustedException;
-import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
@@ -158,7 +157,7 @@ public class TestClientOperationTimeout {
   }
 
   /**
-   * Tests that a batch mutate on a table throws {@link RetriesExhaustedException} when the
+   * Tests that a batch mutate on a table throws {@link SocketTimeoutException} when the
    * operation takes longer than 'hbase.client.operation.timeout'.
    */
   @Test
@@ -175,7 +174,7 @@ public class TestClientOperationTimeout {
       TABLE.batch(puts, new Object[2]);
       Assert.fail("should not reach here");
     } catch (Exception e) {
-      Assert.assertTrue(e instanceof RetriesExhaustedWithDetailsException);
+      Assert.assertTrue(e instanceof SocketTimeoutException);
     }
   }