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 2022/05/14 01:35:22 UTC

[hbase] 01/02: HBASE-26905 ReplicationPeerManager#checkPeerExists should throw ReplicationPeerNotFoundException if peer doesn't exists (#4422)

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

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

commit 7bc7eb5f48eac4aebe41f2b7360998d728997012
Author: Rushabh Shah <sh...@gmail.com>
AuthorDate: Fri May 13 18:24:19 2022 -0700

    HBASE-26905 ReplicationPeerManager#checkPeerExists should throw ReplicationPeerNotFoundException if peer doesn't exists (#4422)
    
    Signed-off-by: Andrew Purtell <ap...@apache.org>
---
 .../hbase/master/replication/ReplicationPeerManager.java  |  3 ++-
 .../hadoop/hbase/client/TestAsyncReplicationAdminApi.java | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java
index 57f2a177e9e..58c9e33510d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java
@@ -32,6 +32,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.replication.ReplicationPeerConfigUtil;
@@ -116,7 +117,7 @@ public class ReplicationPeerManager {
   private ReplicationPeerDescription checkPeerExists(String peerId) throws DoNotRetryIOException {
     ReplicationPeerDescription desc = peers.get(peerId);
     if (desc == null) {
-      throw new DoNotRetryIOException("Replication peer " + peerId + " does not exist");
+      throw new ReplicationPeerNotFoundException(peerId);
     }
     return desc;
   }
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java
index 8a674b992c8..59d9e1d8dec 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java
@@ -40,6 +40,7 @@ import java.util.concurrent.ExecutionException;
 import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.replication.ReplicationException;
@@ -517,4 +518,18 @@ public class TestAsyncReplicationAdminApi extends TestAsyncAdminBase {
       assertThat(e.getCause(), instanceOf(DoNotRetryIOException.class));
     }
   }
+
+  /*
+   * Tests that admin api throws ReplicationPeerNotFoundException if peer doesn't exist.
+   */
+  @Test
+  public void testReplicationPeerNotFoundException() throws InterruptedException {
+    String dummyPeer = "dummy_peer";
+    try {
+      admin.removeReplicationPeer(dummyPeer).get();
+      fail();
+    } catch (ExecutionException e) {
+      assertThat(e.getCause(), instanceOf(ReplicationPeerNotFoundException.class));
+    }
+  }
 }