Skip to content

Commit

Permalink
HBASE-22580 Add a table attribute to make user scan snapshot feature …
Browse files Browse the repository at this point in the history
…configurable for table
  • Loading branch information
mymeiyi committed Jun 25, 2019
1 parent 15ac781 commit fec069d
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,16 @@ public boolean hasFamily(final byte [] familyName) {
return delegatee.hasColumnFamily(familyName);
}

/**
* Check if user scan snapshot enable flag of the table is true. If flag is false then
* SnapshotScannerHDFSAclController won't handle HDFS acls for users with table read permission
* @return true if user scan snapshot is enabled for this table
*/
@Override
public boolean isUserScanSnapshotEnabled() {
return delegatee.isUserScanSnapshotEnabled();
}

/**
* @return Name of this table and then a map of all of the column family
* descriptors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,11 @@ default boolean matchReplicationScope(boolean enabled) {
}
return !enabled;
}

/**
* Check if user scan snapshot enable flag of the table is true. If flag is false then
* SnapshotScannerHDFSAclController won't handle HDFS acls for users with table read permission
* @return true if user scan snapshot is enabled for this table
*/
boolean isUserScanSnapshotEnabled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ public class TableDescriptorBuilder {
private static final Bytes PRIORITY_KEY
= new Bytes(Bytes.toBytes(PRIORITY));

@InterfaceAudience.Private
public static final String USER_SCAN_SNAPSHOT_ENABLED = "USER_SCAN_SNAPSHOT_ENABLED";
private static final Bytes USER_SCAN_SNAPSHOT_ENABLED_KEY =
new Bytes(Bytes.toBytes(USER_SCAN_SNAPSHOT_ENABLED));

/**
* Relative priority of the table used for rpc scheduling
*/
Expand Down Expand Up @@ -537,6 +542,11 @@ public TableDescriptorBuilder setReplicationScope(int scope) {
return this;
}

public TableDescriptorBuilder setUserScanSnapshotEnabled(boolean isEnable) {
desc.setUserScanSnapshotEnabled(isEnable);
return this;
}

public TableDescriptor build() {
return new ModifyableTableDescriptor(desc);
}
Expand Down Expand Up @@ -1074,6 +1084,27 @@ public boolean hasColumnFamily(final byte[] familyName) {
return families.containsKey(familyName);
}

/**
* Setting the user scan snapshot enable flag.
*
* @param isEnabled True if enable user scan snapshot.
* @return the modifyable TD
*/
public ModifyableTableDescriptor setUserScanSnapshotEnabled(boolean isEnabled) {
return setValue(USER_SCAN_SNAPSHOT_ENABLED_KEY, Boolean.toString(isEnabled));
}

/**
* Check if user scan snapshot enable flag of the table is true. If flag is false then
* SnapshotScannerHDFSAclController won't handle HDFS acls for users with table read permission
*
* @return true if user scan snapshot is enabled for this table
*/
@Override
public boolean isUserScanSnapshotEnabled() {
return getOrDefault(USER_SCAN_SNAPSHOT_ENABLED_KEY, Boolean::valueOf, false);
}

/**
* @return Name of this table and then a map of all of the column family descriptors.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,11 @@ public static ListMultimap<String, UserPermission> getNamespacePermissions(Confi
false);
}

public static ListMultimap<String, UserPermission> getGlobalPermissions(Configuration conf)
throws IOException {
return getPermissions(conf, null, null, null, null, null, false);
}

/**
* Reads user permission assignments stored in the <code>l:</code> column family of the first
* table row in <code>_acl_</code>.
Expand Down
Loading

0 comments on commit fec069d

Please sign in to comment.