1717 */
1818package org .apache .hadoop .hbase .replication ;
1919
20+ import static org .hamcrest .CoreMatchers .instanceOf ;
2021import static org .junit .Assert .assertEquals ;
2122import static org .junit .Assert .assertFalse ;
23+ import static org .junit .Assert .assertThat ;
2224import static org .junit .Assert .assertTrue ;
2325import static org .junit .Assert .fail ;
2426
5153import org .apache .hadoop .hbase .wal .WAL .Entry ;
5254import org .apache .hadoop .hbase .wal .WALEdit ;
5355import org .apache .hadoop .hbase .wal .WALKeyImpl ;
56+ import org .apache .hadoop .ipc .RemoteException ;
5457import org .junit .AfterClass ;
5558import org .junit .BeforeClass ;
5659
@@ -247,6 +250,12 @@ protected final void verifyRemovedPeer(String peerId, Path remoteWALDir,
247250 }
248251 }
249252
253+ private void assertRejection (Throwable error ) {
254+ assertThat (error , instanceOf (DoNotRetryIOException .class ));
255+ assertTrue (error .getMessage ().contains ("Reject to apply to sink cluster" ));
256+ assertTrue (error .getMessage ().contains (TABLE_NAME .toString ()));
257+ }
258+
250259 protected final void verifyReplicationRequestRejection (HBaseTestingUtility utility ,
251260 boolean expectedRejection ) throws Exception {
252261 HRegionServer regionServer = utility .getRSForFirstRegionInTable (TABLE_NAME );
@@ -264,9 +273,10 @@ protected final void verifyReplicationRequestRejection(HBaseTestingUtility utili
264273 ReplicationProtbufUtil .replicateWALEntry (
265274 connection .getRegionServerAdmin (regionServer .getServerName ()), entries , null , null , null );
266275 fail ("Should throw IOException when sync-replication state is in A or DA" );
276+ } catch (RemoteException e ) {
277+ assertRejection (e .unwrapRemoteException ());
267278 } catch (DoNotRetryIOException e ) {
268- assertTrue (e .getMessage ().contains ("Reject to apply to sink cluster" ));
269- assertTrue (e .getMessage ().contains (TABLE_NAME .toString ()));
279+ assertRejection (e );
270280 }
271281 }
272282 }
0 commit comments