wchevreuil commented on a change in pull request #749: HBASE-23205 Correctly update the position of WALs currently being replicated URL: https://github.com/apache/hbase/pull/749#discussion_r352175795
########## File path: hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStream.java ########## @@ -436,6 +439,56 @@ public void testWALKeySerialization() throws Exception { } } + @Test + public void testReplicationSourceWALReaderThreadWithFilter() throws Exception { + final byte[] notReplicatedCf = Bytes.toBytes("notReplicated"); + final Map<TableName, List<String>> tableCfs = new HashMap<>(); + tableCfs.put(tableName, Collections.singletonList(Bytes.toString(family))); + ReplicationPeer peer = mock(ReplicationPeer.class); + when(peer.getTableCFs()).thenReturn(tableCfs); + WALEntryFilter filter = new ChainWALEntryFilter(new TableCfWALEntryFilter(peer)); + + appendToLogPlus(3, notReplicatedCf); + + Path firstWAL = walQueue.peek(); + ReplicationSourceManager mockSourceManager = mock(ReplicationSourceManager.class); + when(mockSourceManager.getTotalBufferUsed()).thenReturn(new AtomicLong(0)); + final ReplicationSourceWALReaderThread reader = + new ReplicationSourceWALReaderThread(mockSourceManager, getQueueInfo(), walQueue, + 0, fs, conf, filter, new MetricsSource("1")); + reader.start(); + + // reader won't put any batch, even if EOF reached. + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future<WALEntryBatch> future = executor.submit(new Callable<WALEntryBatch>() { + @Override + public WALEntryBatch call() throws Exception { + return reader.take(); + } + }); + Thread.sleep(2000); + assertFalse(future.isDone()); Review comment: Just a _heads up_ here: we may simplify this part if we decide to make `ReplicationSourceWALReaderThread.lastReadPosition` exposed via _getter_ method. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services