Apache9 commented on code in PR #5507:
URL: https://github.com/apache/hbase/pull/5507#discussion_r1398205020


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRolling.java:
##########
@@ -158,6 +169,130 @@ private void startAndWriteData() throws IOException, 
InterruptedException {
     }
   }
 
+  private static void setSyncLatencyMillis(int latency) {
+    syncLatencyMillis = latency;
+  }
+
+  @Test
+  public void testSlowSyncLogRolling() throws Exception {
+    // Create the test table
+    TableDescriptor desc = 
TableDescriptorBuilder.newBuilder(TableName.valueOf(getName()))
+      
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(HConstants.CATALOG_FAMILY)).build();
+    admin.createTable(desc);
+    int row = 1;
+    try (Table table = 
TEST_UTIL.getConnection().getTable(desc.getTableName())) {
+      server = TEST_UTIL.getRSForFirstRegionInTable(desc.getTableName());
+      RegionInfo region = 
server.getRegions(desc.getTableName()).get(0).getRegionInfo();
+      // Get a reference to the wal.
+      final AbstractFSWAL log = (AbstractFSWAL) server.getWAL(region);
+
+      final AtomicBoolean slowSyncHookCalled = new AtomicBoolean();
+      // Register a WALActionsListener to observe if a SLOW_SYNC roll is 
requested
+      log.registerWALActionsListener(new WALActionsListener() {
+        @Override
+        public void logRollRequested(WALActionsListener.RollRequestReason 
reason) {
+          switch (reason) {
+            case SLOW_SYNC:
+              slowSyncHookCalled.lazySet(true);
+              break;
+            default:
+              break;
+          }
+        }
+      });
+
+      // Write some data
+      for (int i = 0; i < 10; i++) {
+        writeData(table, row++);
+      }
+
+      assertFalse("Should not have triggered log roll due to SLOW_SYNC", 
slowSyncHookCalled.get());
+
+      // Only test for FSHLog.
+      if 
("filesystem".equals(TEST_UTIL.getConfiguration().get(WALFactory.WAL_PROVIDER)))
 {

Review Comment:
   OK, if we need to write code like this, I think it is OK to have two test 
methods in TestAsyncLogRolling and TestLogRolling. For the common part of this 
method, I think we could introduce some protected final methods in this parent 
class, and reference them in TestAsyncLogRolling and TestLogRolling, so we do 
not need to write the same code two times.



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

To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to