Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.backup;

import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.yetus.audience.InterfaceAudience;

Expand All @@ -30,7 +31,8 @@ public interface BackupRestoreConstants {
* Backup/Restore constants
*/
String BACKUP_SYSTEM_TABLE_NAME_KEY = "hbase.backup.system.table.name";
String BACKUP_SYSTEM_TABLE_NAME_DEFAULT = "backup:system";
String BACKUP_SYSTEM_TABLE_NAME_DEFAULT =
NamespaceDescriptor.BACKUP_NAMESPACE_NAME_STR + ":system";

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescripti
// make sure the table name is valid, this will implicitly check validity
TableName tableName = TableName.valueOf(snapshot.getTable());

if (tableName.isSystemTable()) {
if (tableName.isSystemTable() && !tableName.isBackupsTable()) {
throw new IllegalArgumentException("System table snapshots are not allowed");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class NamespaceDescriptor {
/** Default namespace name. */
public static final byte[] DEFAULT_NAMESPACE_NAME = Bytes.toBytes("default");
public static final String DEFAULT_NAMESPACE_NAME_STR = Bytes.toString(DEFAULT_NAMESPACE_NAME);
/** Backup namespace name. */
public static final byte[] BACKUP_NAMESPACE_NAME = Bytes.toBytes("backup");
public static final String BACKUP_NAMESPACE_NAME_STR = Bytes.toString(BACKUP_NAMESPACE_NAME);

public static final NamespaceDescriptor DEFAULT_NAMESPACE =
NamespaceDescriptor.create(DEFAULT_NAMESPACE_NAME_STR).build();
Expand Down
14 changes: 14 additions & 0 deletions hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public static boolean isMetaTableName(final TableName tn) {
private final byte[] qualifier;
private final String qualifierAsString;
private final boolean systemTable;
private final boolean backupsTable;
private final int hashCode;

/**
Expand Down Expand Up @@ -264,6 +265,10 @@ public boolean isSystemTable() {
return systemTable;
}

public boolean isBackupsTable() {
return backupsTable;
}

@Override
public String toString() {
return nameAsString;
Expand All @@ -287,6 +292,7 @@ private TableName(ByteBuffer namespace, ByteBuffer qualifier) throws IllegalArgu
this.namespace = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME;
this.namespaceAsString = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR;
this.systemTable = false;
this.backupsTable = false;

// The name does not include the namespace when it's the default one.
this.nameAsString = qualifierAsString;
Expand All @@ -296,11 +302,18 @@ private TableName(ByteBuffer namespace, ByteBuffer qualifier) throws IllegalArgu
this.namespace = NamespaceDescriptor.SYSTEM_NAMESPACE_NAME;
this.namespaceAsString = NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR;
this.systemTable = true;
this.backupsTable = false;
} else if (Bytes.equals(NamespaceDescriptor.BACKUP_NAMESPACE_NAME, namespace)) {
this.namespace = NamespaceDescriptor.BACKUP_NAMESPACE_NAME;
this.namespaceAsString = NamespaceDescriptor.BACKUP_NAMESPACE_NAME_STR;
this.systemTable = true;
this.backupsTable = true;
} else {
this.namespace = new byte[namespace.remaining()];
namespace.duplicate().get(this.namespace);
this.namespaceAsString = Bytes.toString(this.namespace);
this.systemTable = false;
this.backupsTable = false;
}
this.nameAsString = namespaceAsString + NAMESPACE_DELIM + qualifierAsString;
this.name = Bytes.toBytes(nameAsString);
Expand All @@ -320,6 +333,7 @@ private TableName(String qualifier) {
this.namespace = NamespaceDescriptor.SYSTEM_NAMESPACE_NAME;
this.namespaceAsString = NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR;
this.systemTable = true;
this.backupsTable = false;

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