This is an automated email from the ASF dual-hosted git repository.
charlesconnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new cb16834dd12 HBASE-30322: Persist all fields of BackupInfo (#8542)
cb16834dd12 is described below
commit cb16834dd12c42953b84aaf268767a7fe2586549
Author: Charles Connell <[email protected]>
AuthorDate: Wed Aug 12 10:16:54 2026 -0400
HBASE-30322: Persist all fields of BackupInfo (#8542)
Signed-off by: Duo Zhang <[email protected]>
---
.../org/apache/hadoop/hbase/backup/BackupInfo.java | 20 +++
.../hbase/backup/TestBackupInfoSerialization.java | 166 +++++++++++++++++++++
.../src/main/protobuf/Backup.proto | 4 +
3 files changed, 190 insertions(+)
diff --git
a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/BackupInfo.java
b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/BackupInfo.java
index edf5a2b517f..97ca0323fc9 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/BackupInfo.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/BackupInfo.java
@@ -435,6 +435,18 @@ public class BackupInfo implements Comparable<BackupInfo> {
builder.setBackupType(BackupProtos.BackupType.valueOf(getType().name()));
builder.setWorkersNumber(workers);
builder.setBandwidth(bandwidth);
+ builder.setTotalBytesCopied(totalBytesCopied);
+ builder.setNoChecksumVerify(noChecksumVerify);
+ if (incrBackupFileList != null) {
+ builder.addAllIncrBackupFileList(incrBackupFileList);
+ }
+ if (incrTimestampMap != null) {
+ for (Entry<TableName, Map<String, Long>> entry :
incrTimestampMap.entrySet()) {
+ builder.putIncrTimestampMap(entry.getKey().getNameAsString(),
+
BackupProtos.BackupInfo.RSTimestampMap.newBuilder().putAllRsTimestamp(entry.getValue())
+ .build());
+ }
+ }
return builder.build();
}
@@ -530,6 +542,14 @@ public class BackupInfo implements Comparable<BackupInfo> {
context.setType(BackupType.valueOf(proto.getBackupType().name()));
context.setWorkers(proto.getWorkersNumber());
context.setBandwidth(proto.getBandwidth());
+ context.setTotalBytesCopied(proto.getTotalBytesCopied());
+ context.setNoChecksumVerify(proto.getNoChecksumVerify());
+ if (proto.getIncrBackupFileListCount() > 0) {
+ context.setIncrBackupFileList(new
ArrayList<>(proto.getIncrBackupFileListList()));
+ }
+ if (proto.getIncrTimestampMapCount() > 0) {
+
context.setIncrTimestampMap(getTableSetTimestampMap(proto.getIncrTimestampMapMap()));
+ }
return context;
}
diff --git
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupInfoSerialization.java
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupInfoSerialization.java
new file mode 100644
index 00000000000..7701dfafe31
--- /dev/null
+++
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupInfoSerialization.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.backup;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+@Tag(SmallTests.TAG)
+public class TestBackupInfoSerialization {
+
+ private static BackupInfo newIncrementalBackupInfo() {
+ return new BackupInfo("backup_1234567890", BackupType.INCREMENTAL,
+ new TableName[] { TableName.valueOf("t1") }, "/hbase/backup");
+ }
+
+ @Test
+ public void testIncrBackupFileListSurvivesRoundTrip() throws IOException {
+ List<String> walFiles =
Arrays.asList("/hbase/oldWALs/host1.example.com,16020,1234567890.100",
+ "/hbase/oldWALs/host2.example.com,16020,1234567890.200");
+
+ BackupInfo original = newIncrementalBackupInfo();
+ original.setIncrBackupFileList(walFiles);
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertEquals(walFiles, roundTripped.getIncrBackupFileList());
+ }
+
+ @Test
+ public void testIncrBackupFileListOrderIsPreserved() throws IOException {
+ List<String> walFiles =
Arrays.asList("/hbase/oldWALs/c.example.com,16020,1.300",
+ "/hbase/oldWALs/a.example.com,16020,1.100",
"/hbase/oldWALs/b.example.com,16020,1.200");
+
+ BackupInfo original = newIncrementalBackupInfo();
+ original.setIncrBackupFileList(walFiles);
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertEquals(walFiles, roundTripped.getIncrBackupFileList());
+ }
+
+ @Test
+ public void testUnsetIncrBackupFileListRemainsNull() throws IOException {
+ BackupInfo original = newIncrementalBackupInfo();
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertNull(roundTripped.getIncrBackupFileList());
+ }
+
+ @Test
+ public void testEmptyIncrBackupFileListRemainsNull() throws IOException {
+ BackupInfo original = newIncrementalBackupInfo();
+ original.setIncrBackupFileList(Arrays.asList());
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertNull(roundTripped.getIncrBackupFileList());
+ }
+
+ @Test
+ public void testEqualsDistinguishesIncrBackupFileList() throws IOException {
+ BackupInfo withFiles = newIncrementalBackupInfo();
+
withFiles.setIncrBackupFileList(Arrays.asList("/hbase/oldWALs/host1,16020,1.100"));
+
+ BackupInfo withoutFiles = newIncrementalBackupInfo();
+
+ assertTrue(!withFiles.equals(withoutFiles));
+ }
+
+ @Test
+ public void testTotalBytesCopiedSurvivesRoundTrip() throws IOException {
+ BackupInfo original = newIncrementalBackupInfo();
+ original.setTotalBytesCopied(9876543210L);
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertEquals(9876543210L, roundTripped.getTotalBytesCopied());
+ }
+
+ @Test
+ public void testNoChecksumVerifySurvivesRoundTripWhenTrue() throws
IOException {
+ BackupInfo original = newIncrementalBackupInfo();
+ original.setNoChecksumVerify(true);
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertTrue(roundTripped.getNoChecksumVerify());
+ }
+
+ @Test
+ public void testNoChecksumVerifySurvivesRoundTripWhenFalse() throws
IOException {
+ BackupInfo original = newIncrementalBackupInfo();
+ original.setNoChecksumVerify(false);
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertFalse(roundTripped.getNoChecksumVerify());
+ }
+
+ @Test
+ public void testIncrTimestampMapSurvivesRoundTrip() throws IOException {
+ Map<String, Long> t1Timestamps = new HashMap<>();
+ t1Timestamps.put("host1.example.com:16020", 100L);
+ t1Timestamps.put("host2.example.com:16020", 200L);
+ Map<String, Long> t2Timestamps = new HashMap<>();
+ t2Timestamps.put("host1.example.com:16020", 300L);
+
+ Map<TableName, Map<String, Long>> incrTimestampMap = new HashMap<>();
+ incrTimestampMap.put(TableName.valueOf("t1"), t1Timestamps);
+ incrTimestampMap.put(TableName.valueOf("t2"), t2Timestamps);
+
+ BackupInfo original = newIncrementalBackupInfo();
+ original.setIncrTimestampMap(incrTimestampMap);
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertEquals(incrTimestampMap, roundTripped.getIncrTimestampMap());
+ }
+
+ @Test
+ public void testUnsetIncrTimestampMapRemainsNull() throws IOException {
+ BackupInfo original = newIncrementalBackupInfo();
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertNull(roundTripped.getIncrTimestampMap());
+ }
+
+ @Test
+ public void testIncrementalBackupRetainsHLogTargetDir() throws IOException {
+ BackupInfo original = newIncrementalBackupInfo();
+
+ BackupInfo roundTripped = BackupInfo.fromByteArray(original.toByteArray());
+
+ assertEquals(original.getHLogTargetDir(), roundTripped.getHLogTargetDir());
+ }
+
+}
diff --git a/hbase-protocol-shaded/src/main/protobuf/Backup.proto
b/hbase-protocol-shaded/src/main/protobuf/Backup.proto
index a114001ba50..4a830f5d8cb 100644
--- a/hbase-protocol-shaded/src/main/protobuf/Backup.proto
+++ b/hbase-protocol-shaded/src/main/protobuf/Backup.proto
@@ -93,6 +93,10 @@ message BackupInfo {
optional uint32 workers_number = 11;
optional uint64 bandwidth = 12;
map<string, RSTimestampMap> table_set_timestamp = 13;
+ repeated string incr_backup_file_list = 14;
+ optional uint64 total_bytes_copied = 15;
+ optional bool no_checksum_verify = 16;
+ map<string, RSTimestampMap> incr_timestamp_map = 17;
message RSTimestampMap {
map<string, uint64> rs_timestamp = 1;