ndimiduk commented on code in PR #6340:
URL: https://github.com/apache/hbase/pull/6340#discussion_r1802617631


##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalTableBackupClient.java:
##########
@@ -434,4 +445,86 @@ protected Path getBulkOutputDir() {
     path = new Path(path, backupId);
     return path;
   }
+
+  private Map<TableName, String> getFullBackupIds() throws IOException {
+    // Ancestors are stored from newest to oldest, so we can iterate backwards
+    // in order to populate our backupId map with the most recent full backup
+    // for a given table
+    List<BackupManifest.BackupImage> images = getAncestors(backupInfo);
+    Map<TableName, String> results = new HashMap<>();
+    for (int i = images.size() - 1; i >= 0; i--) {
+      BackupManifest.BackupImage image = images.get(i);
+      if (image.getType() != BackupType.FULL) {
+        continue;
+      }
+
+      for (TableName tn : image.getTableNames()) {
+        results.put(tn, image.getBackupId());
+      }
+    }
+    return results;
+  }
+
+  /**
+   * Verifies that the current table descriptor CFs matches the descriptor CFs 
of the last full
+   * backup for the tables. This ensures CF compatibility across incremental 
backups. If a mismatch
+   * is detected, a full table backup should be taken, rather than an 
incremental one
+   */
+  private void verifyCfCompatibility(Set<TableName> tables,
+    Map<TableName, String> tablesToFullBackupId) throws IOException, 
ColumnFamilyMismatchException {
+    ColumnFamilyMismatchException.ColumnFamilyMismatchExceptionBuilder 
exBuilder =
+      ColumnFamilyMismatchException.newBuilder();
+    try (Admin admin = conn.getAdmin(); BackupAdminImpl backupAdmin = new 
BackupAdminImpl(conn)) {
+      for (TableName tn : tables) {
+        String backupId = tablesToFullBackupId.get(tn);
+        BackupInfo fullBackupInfo = backupAdmin.getBackupInfo(backupId);
+
+        ColumnFamilyDescriptor[] currentCfs = 
admin.getDescriptor(tn).getColumnFamilies();
+        String snapshotName = fullBackupInfo.getSnapshotName(tn);
+        Path root = HBackupFileSystem.getTableBackupPath(tn,
+          new Path(fullBackupInfo.getBackupRootDir()), 
fullBackupInfo.getBackupId());
+        Path manifestDir = 
SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, root);
+
+        FileSystem fs;
+        try {
+          fs = FileSystem.get(new URI(fullBackupInfo.getBackupRootDir()), 
conf);
+        } catch (URISyntaxException e) {
+          throw new IOException("Unable to get fs", e);

Review Comment:
   nit: "unable to get fs for backup foo."



##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/ColumnFamilyMismatchException.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
+import org.apache.yetus.audience.InterfaceAudience;
+
+@InterfaceAudience.Public

Review Comment:
   Heya folks. This class hierarchy mixes IA public and private -- no can do. 
We can't just make its parent class, BackupException, public, because it 
exposes a non-public member.



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