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:
parent
0eb1a4e5ed
commit
27ced7074a
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue