Class LocalFileRoleAccessor
- java.lang.Object
-
- org.apache.iotdb.commons.auth.role.LocalFileRoleAccessor
-
- All Implemented Interfaces:
IRoleAccessor,SnapshotProcessor
public class LocalFileRoleAccessor extends java.lang.Object implements IRoleAccessor
This class store each role in a separate sequential file. Role file schema : Int32 role name size Utf-8 role name bytes Int32 seriesPath privilege number n Int32 seriesPath[1] size Utf-8 seriesPath[1] bytes Int32 privilege num k1 Int32 privilege[1][1] Int32 privilege[1][2] ... Int32 privilege[1][k1] Int32 seriesPath[2] size Utf-8 seriesPath[2] bytes Int32 privilege num yk2 Int32 privilege[2][1] Int32 privilege[2][2] ... Int32 privilege[2][k2] ... Int32 seriesPath[n] size Utf-8 seriesPath[n] bytes Int32 privilege num kn Int32 privilege[n][1] Int32 privilege[n][2] ... Int32 privilege[n][kn]
-
-
Constructor Summary
Constructors Constructor Description LocalFileRoleAccessor(java.lang.String roleDirPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandeleteRole(java.lang.String rolename)Delete a role's in lower storage.java.util.List<java.lang.String>listAllRoles()List all roles in this database.RoleloadRole(java.lang.String rolename)Deserialize a role from lower storage.voidprocessLoadSnapshot(java.io.File snapshotDir)Load snapshotbooleanprocessTakeSnapshot(java.io.File snapshotDir)Take snapshotvoidreset()Re-initialize this object.voidsaveRole(Role role)Serialize the role object to lower storage.
-
-
-
Method Detail
-
loadRole
public Role loadRole(java.lang.String rolename) throws java.io.IOException
Description copied from interface:IRoleAccessorDeserialize a role from lower storage.- Specified by:
loadRolein interfaceIRoleAccessor- Parameters:
rolename- The name of the role to be deserialized.- Returns:
- The role object or null if no such role.
- Throws:
java.io.IOException- if IOException is raised when interacting with lower storage.
-
saveRole
public void saveRole(Role role) throws java.io.IOException
Description copied from interface:IRoleAccessorSerialize the role object to lower storage.- Specified by:
saveRolein interfaceIRoleAccessor- Parameters:
role- The role object that is to be saved.- Throws:
java.io.IOException- if IOException is raised when interacting with lower storage.
-
deleteRole
public boolean deleteRole(java.lang.String rolename) throws java.io.IOExceptionDescription copied from interface:IRoleAccessorDelete a role's in lower storage.- Specified by:
deleteRolein interfaceIRoleAccessor- Parameters:
rolename- The name of the role to be deleted.- Returns:
- True if the role is successfully deleted, false if the role does not exists.
- Throws:
java.io.IOException- if IOException is raised when interacting with lower storage.
-
listAllRoles
public java.util.List<java.lang.String> listAllRoles()
Description copied from interface:IRoleAccessorList all roles in this database.- Specified by:
listAllRolesin interfaceIRoleAccessor- Returns:
- A list contains all names of the roles.
-
processTakeSnapshot
public boolean processTakeSnapshot(java.io.File snapshotDir) throws org.apache.thrift.TException, java.io.IOExceptionDescription copied from interface:SnapshotProcessorTake snapshot- Specified by:
processTakeSnapshotin interfaceSnapshotProcessor- Parameters:
snapshotDir- Where snapshot files are stored.- Returns:
- Whether the snapshot is successfully executed
- Throws:
org.apache.thrift.TException- Exception occurred during the thrift serialize structjava.io.IOException- Exception related to file read and write
-
processLoadSnapshot
public void processLoadSnapshot(java.io.File snapshotDir) throws org.apache.thrift.TException, java.io.IOExceptionDescription copied from interface:SnapshotProcessorLoad snapshot- Specified by:
processLoadSnapshotin interfaceSnapshotProcessor- Parameters:
snapshotDir- Load snapshot from here- Throws:
org.apache.thrift.TException- Exception occurred during the thrift deserialize structjava.io.IOException- Exception related to file read and write
-
reset
public void reset()
Description copied from interface:IRoleAccessorRe-initialize this object.- Specified by:
resetin interfaceIRoleAccessor
-
-