HBASE-26905 ReplicationPeerManager#checkPeerExists should throw ReplicationPeerNotFoundException if peer doesn't exists (#4422)

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Rushabh Shah 2022-05-13 18:24:19 -07:00 committed by GitHub
parent 0eb1a4e5ed
commit 27ced7074a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -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;
}

View File

@ -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));
}
}
}