Class SnapshotScannerHDFSAclHelper
java.lang.Object
org.apache.hadoop.hbase.security.access.SnapshotScannerHDFSAclHelper
- All Implemented Interfaces:
Closeable
,AutoCloseable
A helper to modify or remove HBase granted user default and access HDFS ACLs over hFiles.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static class
Inner class used to describe modify or remove what type of acl entries(ACCESS, DEFAULT, ACCESS_AND_DEFAULT) for files or directories(and child files).(package private) static final class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
private Admin
static final String
static final String
private final org.apache.hadoop.conf.Configuration
private org.apache.hadoop.fs.FileSystem
private static final org.slf4j.Logger
private ExecutorService
static final String
static final String
static final String
static final String
-
Constructor Summary
ConstructorDescriptionSnapshotScannerHDFSAclHelper
(org.apache.hadoop.conf.Configuration configuration, Connection connection) -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.apache.hadoop.fs.permission.AclEntry
boolean
addTableAcl
(TableName tableName, Set<String> users, String operation) Add table user aclsprivate boolean
checkUserPermission
(UserPermission userPermission) void
close()
(package private) boolean
containReadAction
(UserPermission userPermission) (package private) void
createDirIfNotExist
(org.apache.hadoop.fs.Path path) (package private) void
createTableDirectories
(TableName tableName) (package private) void
deleteEmptyDir
(org.apache.hadoop.fs.Path path) (package private) List<org.apache.hadoop.fs.Path>
return paths that user will global permission will visit(package private) List<org.apache.hadoop.fs.Path>
getNamespaceRootPaths
(String namespace) return paths that user will namespace permission will visit(package private) SnapshotScannerHDFSAclHelper.PathHelper
(package private) List<org.apache.hadoop.fs.Path>
getTableRootPaths
(TableName tableName, boolean includeSnapshotPath) return paths that user will table permission will visitprivate List<org.apache.hadoop.fs.Path>
getTableSnapshotPaths
(TableName tableName) Return users with global read permissiongetUsersWithNamespaceReadAction
(String namespace, boolean includeGlobal) Return users with namespace read permissiongetUsersWithReadAction
(org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String, UserPermission> permissionMultimap) getUsersWithTableReadAction
(TableName tableName, boolean includeNamespace, boolean includeGlobal) Return users with table read permissionboolean
Set acl when grant user permissionprivate void
handleGlobalAcl
(Set<String> users, Set<String> skipNamespaces, Set<TableName> skipTables, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType) private void
handleGrantOrRevokeAcl
(UserPermission userPermission, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType, Set<String> skipNamespaces, Set<TableName> skipTables) private CompletableFuture<Void>
private CompletableFuture<Void>
private CompletableFuture<Void>
private void
handleNamespaceAccessAcl
(String namespace, Set<String> users, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType) private void
handleNamespaceAcl
(Set<String> namespaces, Set<String> users, Set<String> skipNamespaces, Set<TableName> skipTables, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType) private void
handleTableAcl
(Set<TableName> tableNames, Set<String> users, Set<String> skipNamespaces, Set<TableName> skipTables, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType) static boolean
isAclSyncToHdfsEnabled
(org.apache.hadoop.conf.Configuration conf) (package private) boolean
isAclSyncToHdfsEnabled
(TableDescriptor tableDescriptor) (package private) boolean
isNotFamilyOrQualifierPermission
(TablePermission tablePermission) boolean
removeNamespaceAccessAcl
(TableName tableName, Set<String> removeUsers, String operation) Remove table access acl from namespace dir when delete tableboolean
removeNamespaceDefaultAcl
(String namespace, Set<String> removeUsers) Remove default acl from namespace archive dir when delete namespaceboolean
removeTableAcl
(TableName tableName, Set<String> users) Remove table acls when modify tableboolean
removeTableDefaultAcl
(TableName tableName, Set<String> removeUsers) Remove default acl from table archive dir when delete tableboolean
Remove acl when grant or revoke user permissionvoid
boolean
snapshotAcl
(SnapshotDescription snapshot) Set acl when take a snapshot
-
Field Details
-
LOG
-
ACL_SYNC_TO_HDFS_ENABLE
- See Also:
-
ACL_SYNC_TO_HDFS_THREAD_NUMBER
- See Also:
-
SNAPSHOT_RESTORE_TMP_DIR
- See Also:
-
SNAPSHOT_RESTORE_TMP_DIR_DEFAULT
- See Also:
-
COMMON_DIRECTORY_PERMISSION
- See Also:
-
COMMON_DIRECTORY_PERMISSION_DEFAULT
- See Also:
-
SNAPSHOT_RESTORE_DIRECTORY_PERMISSION
- See Also:
-
SNAPSHOT_RESTORE_DIRECTORY_PERMISSION_DEFAULT
- See Also:
-
admin
-
conf
-
fs
-
pathHelper
-
pool
-
-
Constructor Details
-
SnapshotScannerHDFSAclHelper
public SnapshotScannerHDFSAclHelper(org.apache.hadoop.conf.Configuration configuration, Connection connection) throws IOException - Throws:
IOException
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
setCommonDirectoryPermission
- Throws:
IOException
-
grantAcl
public boolean grantAcl(UserPermission userPermission, Set<String> skipNamespaces, Set<TableName> skipTables) Set acl when grant user permission- Parameters:
userPermission
- the user and permissionskipNamespaces
- the namespace set to skip set acl because already setskipTables
- the table set to skip set acl because already set- Returns:
- false if an error occurred, otherwise true
-
revokeAcl
public boolean revokeAcl(UserPermission userPermission, Set<String> skipNamespaces, Set<TableName> skipTables) Remove acl when grant or revoke user permission- Parameters:
userPermission
- the user and permissionskipNamespaces
- the namespace set to skip remove aclskipTables
- the table set to skip remove acl- Returns:
- false if an error occurred, otherwise true
-
snapshotAcl
Set acl when take a snapshot- Parameters:
snapshot
- the snapshot desc- Returns:
- false if an error occurred, otherwise true
-
removeNamespaceAccessAcl
public boolean removeNamespaceAccessAcl(TableName tableName, Set<String> removeUsers, String operation) Remove table access acl from namespace dir when delete table- Parameters:
tableName
- the tableremoveUsers
- the users whose access acl will be removed- Returns:
- false if an error occurred, otherwise true
-
removeNamespaceDefaultAcl
Remove default acl from namespace archive dir when delete namespace- Parameters:
namespace
- the namespaceremoveUsers
- the users whose default acl will be removed- Returns:
- false if an error occurred, otherwise true
-
removeTableDefaultAcl
Remove default acl from table archive dir when delete table- Parameters:
tableName
- the table nameremoveUsers
- the users whose default acl will be removed- Returns:
- false if an error occurred, otherwise true
-
addTableAcl
Add table user acls- Parameters:
tableName
- the tableusers
- the table users with READ permission- Returns:
- false if an error occurred, otherwise true
-
removeTableAcl
Remove table acls when modify table- Parameters:
tableName
- the tableusers
- the table users with READ permission- Returns:
- false if an error occurred, otherwise true
-
handleGrantOrRevokeAcl
private void handleGrantOrRevokeAcl(UserPermission userPermission, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType, Set<String> skipNamespaces, Set<TableName> skipTables) throws ExecutionException, InterruptedException, IOException -
handleGlobalAcl
private void handleGlobalAcl(Set<String> users, Set<String> skipNamespaces, Set<TableName> skipTables, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType) throws ExecutionException, InterruptedException, IOException -
handleNamespaceAcl
private void handleNamespaceAcl(Set<String> namespaces, Set<String> users, Set<String> skipNamespaces, Set<TableName> skipTables, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType) throws ExecutionException, InterruptedException, IOException -
handleTableAcl
private void handleTableAcl(Set<TableName> tableNames, Set<String> users, Set<String> skipNamespaces, Set<TableName> skipTables, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType) throws ExecutionException, InterruptedException, IOException -
handleNamespaceAccessAcl
private void handleNamespaceAccessAcl(String namespace, Set<String> users, SnapshotScannerHDFSAclHelper.HDFSAclOperation.OperationType operationType) throws ExecutionException, InterruptedException -
createTableDirectories
- Throws:
IOException
-
getGlobalRootPaths
List<org.apache.hadoop.fs.Path> getGlobalRootPaths()return paths that user will global permission will visit- Returns:
- the path list
-
getNamespaceRootPaths
return paths that user will namespace permission will visit- Parameters:
namespace
- the namespace- Returns:
- the path list
-
getTableRootPaths
List<org.apache.hadoop.fs.Path> getTableRootPaths(TableName tableName, boolean includeSnapshotPath) throws IOException return paths that user will table permission will visit- Parameters:
tableName
- the tableincludeSnapshotPath
- true if return table snapshots paths, otherwise false- Returns:
- the path list
- Throws:
IOException
- if an error occurred
-
getTableSnapshotPaths
private List<org.apache.hadoop.fs.Path> getTableSnapshotPaths(TableName tableName) throws IOException - Throws:
IOException
-
getUsersWithGlobalReadAction
Return users with global read permission- Returns:
- users with global read permission
- Throws:
IOException
- if an error occurred
-
getUsersWithNamespaceReadAction
Set<String> getUsersWithNamespaceReadAction(String namespace, boolean includeGlobal) throws IOException Return users with namespace read permission- Parameters:
namespace
- the namespaceincludeGlobal
- true if include users with global read action- Returns:
- users with namespace read permission
- Throws:
IOException
- if an error occurred
-
getUsersWithTableReadAction
Set<String> getUsersWithTableReadAction(TableName tableName, boolean includeNamespace, boolean includeGlobal) throws IOException Return users with table read permission- Parameters:
tableName
- the tableincludeNamespace
- true if include users with namespace read actionincludeGlobal
- true if include users with global read action- Returns:
- users with table read permission
- Throws:
IOException
- if an error occurred
-
getUsersWithReadAction
private Set<String> getUsersWithReadAction(org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String, UserPermission> permissionMultimap) -
checkUserPermission
-
containReadAction
-
isNotFamilyOrQualifierPermission
-
isAclSyncToHdfsEnabled
-
isAclSyncToHdfsEnabled
-
getPathHelper
-
handleHDFSAcl
-
handleHDFSAclSequential
private CompletableFuture<Void> handleHDFSAclSequential(List<SnapshotScannerHDFSAclHelper.HDFSAclOperation> operations) -
handleHDFSAclParallel
private CompletableFuture<Void> handleHDFSAclParallel(List<SnapshotScannerHDFSAclHelper.HDFSAclOperation> operations) -
aclEntry
-
createDirIfNotExist
- Throws:
IOException
-
deleteEmptyDir
- Throws:
IOException
-