Skip to content

Commit 01c420e

Browse files
rmdmattinglyRay Mattingly
andauthored
HBASE-29207 The backup system table should be considered a system table (#6842) (#6930)
Signed-off-by: Nick Dimiduk <[email protected]> Signed-off-by: Nihal Jain <[email protected]> Co-authored-by: Ray Mattingly <[email protected]>
1 parent c9b373f commit 01c420e

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/BackupRestoreConstants.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.hadoop.hbase.backup;
1919

2020
import org.apache.hadoop.hbase.HConstants;
21+
import org.apache.hadoop.hbase.NamespaceDescriptor;
2122
import org.apache.yetus.audience.InterfaceAudience;
2223

2324
/**
@@ -29,7 +30,8 @@ public interface BackupRestoreConstants {
2930
* Backup/Restore constants
3031
*/
3132
String BACKUP_SYSTEM_TABLE_NAME_KEY = "hbase.backup.system.table.name";
32-
String BACKUP_SYSTEM_TABLE_NAME_DEFAULT = "backup:system";
33+
String BACKUP_SYSTEM_TABLE_NAME_DEFAULT =
34+
NamespaceDescriptor.BACKUP_NAMESPACE_NAME_STR + ":system";
3335

3436
String BACKUP_SYSTEM_TTL_KEY = "hbase.backup.system.ttl";
3537

hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ClientSnapshotDescriptionUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescripti
4646
// make sure the table name is valid, this will implicitly check validity
4747
TableName tableName = TableName.valueOf(snapshot.getTable());
4848

49-
if (tableName.isSystemTable()) {
49+
if (tableName.isSystemTable() && !tableName.isBackupsTable()) {
5050
throw new IllegalArgumentException("System table snapshots are not allowed");
5151
}
5252
}

hbase-common/src/main/java/org/apache/hadoop/hbase/NamespaceDescriptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class NamespaceDescriptor {
4141
/** Default namespace name. */
4242
public static final byte[] DEFAULT_NAMESPACE_NAME = Bytes.toBytes("default");
4343
public static final String DEFAULT_NAMESPACE_NAME_STR = Bytes.toString(DEFAULT_NAMESPACE_NAME);
44+
/** Backup namespace name. */
45+
public static final byte[] BACKUP_NAMESPACE_NAME = Bytes.toBytes("backup");
46+
public static final String BACKUP_NAMESPACE_NAME_STR = Bytes.toString(BACKUP_NAMESPACE_NAME);
4447

4548
public static final NamespaceDescriptor DEFAULT_NAMESPACE =
4649
NamespaceDescriptor.create(DEFAULT_NAMESPACE_NAME_STR).build();

hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public static boolean isMetaTableName(final TableName tn) {
100100
private final byte[] qualifier;
101101
private final String qualifierAsString;
102102
private final boolean systemTable;
103+
private final boolean backupsTable;
103104
private final int hashCode;
104105

105106
/**
@@ -264,6 +265,10 @@ public boolean isSystemTable() {
264265
return systemTable;
265266
}
266267

268+
public boolean isBackupsTable() {
269+
return backupsTable;
270+
}
271+
267272
@Override
268273
public String toString() {
269274
return nameAsString;
@@ -287,6 +292,7 @@ private TableName(ByteBuffer namespace, ByteBuffer qualifier) throws IllegalArgu
287292
this.namespace = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME;
288293
this.namespaceAsString = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR;
289294
this.systemTable = false;
295+
this.backupsTable = false;
290296

291297
// The name does not include the namespace when it's the default one.
292298
this.nameAsString = qualifierAsString;
@@ -296,11 +302,18 @@ private TableName(ByteBuffer namespace, ByteBuffer qualifier) throws IllegalArgu
296302
this.namespace = NamespaceDescriptor.SYSTEM_NAMESPACE_NAME;
297303
this.namespaceAsString = NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR;
298304
this.systemTable = true;
305+
this.backupsTable = false;
306+
} else if (Bytes.equals(NamespaceDescriptor.BACKUP_NAMESPACE_NAME, namespace)) {
307+
this.namespace = NamespaceDescriptor.BACKUP_NAMESPACE_NAME;
308+
this.namespaceAsString = NamespaceDescriptor.BACKUP_NAMESPACE_NAME_STR;
309+
this.systemTable = true;
310+
this.backupsTable = true;
299311
} else {
300312
this.namespace = new byte[namespace.remaining()];
301313
namespace.duplicate().get(this.namespace);
302314
this.namespaceAsString = Bytes.toString(this.namespace);
303315
this.systemTable = false;
316+
this.backupsTable = false;
304317
}
305318
this.nameAsString = namespaceAsString + NAMESPACE_DELIM + qualifierAsString;
306319
this.name = Bytes.toBytes(nameAsString);
@@ -320,6 +333,7 @@ private TableName(String qualifier) {
320333
this.namespace = NamespaceDescriptor.SYSTEM_NAMESPACE_NAME;
321334
this.namespaceAsString = NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR;
322335
this.systemTable = true;
336+
this.backupsTable = false;
323337

324338
// WARNING: nameAsString is different than name for old meta & root!
325339
// This is by design.

0 commit comments

Comments
 (0)