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 716c3898f62..ad37bcc6b09 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 @@ -36,6 +36,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; 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; @@ -142,7 +143,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 d7b1263992a..e50b14aa3ff 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; @@ -507,4 +508,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)); + } + } }