Copilot commented on code in PR #7429:
URL: https://github.com/apache/hbase/pull/7429#discussion_r2483750337


##########
hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/TableReplicationQueueStorage.java:
##########
@@ -213,6 +213,37 @@ private void listAllQueueIds(Table table, String peerId, 
ServerName serverName,
       queueIds);
   }
 
+  @Override
+  public List<String> listAllPeerIds() throws ReplicationException {
+    List<String> peerIds = new ArrayList<>();
+    try (Table table = conn.getTable(tableName)) {
+      KeyOnlyFilter keyOnlyFilter = new KeyOnlyFilter();
+      String previousPeerId = null;
+      for (;;) {
+        // first, get the next peerId
+        Scan peerScan =
+          new 
Scan().addFamily(QUEUE_FAMILY).setOneRowLimit().setFilter(keyOnlyFilter);
+        if (previousPeerId != null) {
+          
peerScan.withStartRow(ReplicationQueueId.getScanStartRowForNextPeerId(previousPeerId));
+        }

Review Comment:
   The scan configuration logic is duplicated in both `listAllPeerIds()` (lines 
224-228) and `listAllQueueIds(ServerName)` (lines 269-273). Consider extracting 
this logic into a private helper method to reduce duplication and improve 
maintainability.



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestTableReplicationQueueStorage.java:
##########
@@ -51,48 +51,41 @@
 import org.apache.zookeeper.KeeperException;
 import org.hamcrest.Matchers;
 import org.hamcrest.collection.IsEmptyCollection;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;
 
-@Category({ ReplicationTests.class, MediumTests.class })
+@Tag(ReplicationTests.TAG)
+@Tag(MediumTests.TAG)
 public class TestTableReplicationQueueStorage {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestTableReplicationQueueStorage.class);
-
   private static final Logger LOG = 
LoggerFactory.getLogger(TestTableReplicationQueueStorage.class);
 
   private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
 
-  @Rule
-  public TableNameTestRule tableNameRule = new TableNameTestRule();
-
   private TableReplicationQueueStorage storage;
 
-  @BeforeClass
+  @BeforeAll
   public static void setUp() throws Exception {
     UTIL.startMiniCluster();
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDown() throws IOException {
     UTIL.shutdownMiniCluster();
   }
 
-  @Before
-  public void setUpBeforeTest() throws Exception {
-    TableName tableName = tableNameRule.getTableName();
+  @BeforeEach
+  public void setUpBeforeTest(TestInfo testInfo) throws Exception {
+    TableName tableName = 
TableName.valueOf(testInfo.getTestMethod().get().getName());

Review Comment:
   Calling `.get()` on `Optional<Method>` without checking if it's present can 
throw `NoSuchElementException`. Consider using 
`testInfo.getTestMethod().orElseThrow()` or adding a check to make the 
potential failure more explicit.
   ```suggestion
       TableName tableName = TableName.valueOf(
           testInfo.getTestMethod()
               .orElseThrow(() -> new IllegalStateException("Test method not 
present in TestInfo"))
               .getName());
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to