17
17
*/
18
18
package org .apache .hadoop .hbase .replication ;
19
19
20
+ import static org .hamcrest .CoreMatchers .instanceOf ;
20
21
import static org .junit .Assert .assertEquals ;
21
22
import static org .junit .Assert .assertFalse ;
23
+ import static org .junit .Assert .assertThat ;
22
24
import static org .junit .Assert .assertTrue ;
23
25
import static org .junit .Assert .fail ;
24
26
51
53
import org .apache .hadoop .hbase .wal .WAL .Entry ;
52
54
import org .apache .hadoop .hbase .wal .WALEdit ;
53
55
import org .apache .hadoop .hbase .wal .WALKeyImpl ;
56
+ import org .apache .hadoop .ipc .RemoteException ;
54
57
import org .junit .AfterClass ;
55
58
import org .junit .BeforeClass ;
56
59
@@ -247,6 +250,12 @@ protected final void verifyRemovedPeer(String peerId, Path remoteWALDir,
247
250
}
248
251
}
249
252
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
+
250
259
protected final void verifyReplicationRequestRejection (HBaseTestingUtility utility ,
251
260
boolean expectedRejection ) throws Exception {
252
261
HRegionServer regionServer = utility .getRSForFirstRegionInTable (TABLE_NAME );
@@ -264,9 +273,10 @@ protected final void verifyReplicationRequestRejection(HBaseTestingUtility utili
264
273
ReplicationProtbufUtil .replicateWALEntry (
265
274
connection .getRegionServerAdmin (regionServer .getServerName ()), entries , null , null , null );
266
275
fail ("Should throw IOException when sync-replication state is in A or DA" );
276
+ } catch (RemoteException e ) {
277
+ assertRejection (e .unwrapRemoteException ());
267
278
} 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 );
270
280
}
271
281
}
272
282
}
0 commit comments