hgromer commented on code in PR #5408:
URL: https://github.com/apache/hbase/pull/5408#discussion_r2360393577


##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java:
##########
@@ -770,4 +773,52 @@ public static String findMostRecentBackupId(String[] 
backupIds) {
     return BackupRestoreConstants.BACKUPID_PREFIX + recentTimestamp;
   }
 
+  /**
+   * roll WAL writer for all region servers and record the newest log roll 
result
+   */
+  public static void logRoll(Connection conn, String backupRootDir, 
Configuration conf)
+    throws IOException {
+    boolean legacy = conf.getBoolean("hbase.backup.logroll.legacy.used", 
false);
+    if (legacy) {
+      logRollV1(conn, backupRootDir);
+    } else {
+      logRollV2(conn, backupRootDir);
+    }
+  }
+
+  private static void logRollV1(Connection conn, String backupRootDir) throws 
IOException {
+    try (Admin admin = conn.getAdmin()) {
+      
admin.execProcedure(LogRollMasterProcedureManager.ROLLLOG_PROCEDURE_SIGNATURE,
+        LogRollMasterProcedureManager.ROLLLOG_PROCEDURE_NAME,
+        ImmutableMap.of("backupRoot", backupRootDir));
+    }
+  }
+
+  private static void logRollV2(Connection conn, String backupRootDir) throws 
IOException {

Review Comment:
   Do we need something like 
   
   BackupSystemTable
   
   ```java
   public void deleteRegionServerLastLogRollResult(String server, String 
backupRoot) throws IOException {
       LOG.trace("delete region server last roll log result to backup system 
table");
   
       try (Table table = connection.getTable(tableName)) {
         Delete delete = new Delete(rowkey(RS_LOG_TS_PREFIX, backupRoot, NULL, 
server));
         table.delete(delete);
       }
     }
   ```
   
   BackupUtils
   
   ```java
   private static void logRollV2(Connection conn, String backupRootDir) throws 
IOException {
       BackupSystemTable backupSystemTable = new BackupSystemTable(conn);
       HashMap<String, Long> lastLogRollResult =
         backupSystemTable.readRegionServerLastLogRollResult(backupRootDir);
       try (Admin admin = conn.getAdmin()) {
         Map<ServerName, Long> newLogRollResult = admin.rollAllWALWriters();
   
         for (Map.Entry<ServerName, Long> entry : newLogRollResult.entrySet()) {
           ServerName serverName = entry.getKey();
           long newHighestWALFilenum = entry.getValue();
   
           String address = serverName.getAddress().toString();
           Long lastHighestWALFilenum = lastLogRollResult.get(address);
           if (lastHighestWALFilenum != null && lastHighestWALFilenum > 
newHighestWALFilenum) {
             LOG.warn("Won't update last roll log result for server {}: current 
= {}, new = {}",
               serverName, lastHighestWALFilenum, newHighestWALFilenum);
           } else {
             backupSystemTable.writeRegionServerLastLogRollResult(address, 
newHighestWALFilenum,
               backupRootDir);
             if (LOG.isDebugEnabled()) {
               LOG.debug("updated last roll log result for {} from {} to {}", 
serverName,
                 lastHighestWALFilenum, newHighestWALFilenum);
             }
           }
         }
   
         // New Code Here
         for (String server: lastLogRollResult.keySet()) {
           if 
(!newLogRollResult.containsKey(ServerName.parseServerName(server))) {
             backupSystemTable.deleteRegionServerLastLogRollResult(server, 
backupRootDir);
           }
         }
       }
     }
   ```



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