virajjasani commented on a change in pull request #2908:
URL: https://github.com/apache/hbase/pull/2908#discussion_r566619352



##########
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStream.java
##########
@@ -652,4 +653,33 @@ public void testReadBeyondCommittedLength() throws 
IOException, InterruptedExcep
       assertFalse(entryStream.hasNext());
     }
   }
+
+  /*
+    Test removal of 0 length log from logQueue if the source is a recovered 
source and
+    size of logQueue is only 1.
+   */
+  @Test
+  public void testEOFExceptionForRecoveredQueue() throws Exception {
+    PriorityBlockingQueue<Path> queue = new PriorityBlockingQueue<>();
+    // Create a 0 length log.
+    Path emptyLog = new Path("emptyLog");
+    FSDataOutputStream fsdos = fs.create(emptyLog);
+    fsdos.close();
+    assertEquals(0, fs.getFileStatus(emptyLog).getLen());
+    queue.add(emptyLog);
+
+    Configuration conf = new Configuration(CONF);
+    // Override the max retries multiplier to fail fast.
+    conf.setInt("replication.source.maxretriesmultiplier", 1);
+    conf.setBoolean("replication.source.eof.autorecovery", true);
+    // Create a reader thread with source as recovered source.
+    ReplicationSource source = mockReplicationSource(true, conf);
+    when(source.isPeerEnabled()).thenReturn(true);
+    ReplicationSourceWALReader reader =
+      new ReplicationSourceWALReader(fs, conf, queue, 0, getDummyFilter(), 
source);
+    reader.run();
+    // ReplicationSourceWALReaderThread#handleEofException method will
+    // remove empty log from logQueue.
+    assertEquals(0, queue.size());

Review comment:
       I see, If we use `thread.start()`, this could be flaky if we reach here 
before reader thread removes entry from queue so we will need to add some wait 
here based on this exit condition (queue.isEmpty()). It's a trade off with 
starting thread separately as opposed to synchronously executing it with 
`thread.run()`.
   
   It's upto you, this is anyways trivial. `thread.run()` is also fine.




----------------------------------------------------------------
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


Reply via email to