Class 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
      boolean deleteRole​(java.lang.String rolename)
      Delete a role's in lower storage.
      java.util.List<java.lang.String> listAllRoles()
      List all roles in this database.
      Role loadRole​(java.lang.String rolename)
      Deserialize a role from lower storage.
      void processLoadSnapshot​(java.io.File snapshotDir)
      Load snapshot
      boolean processTakeSnapshot​(java.io.File snapshotDir)
      Take snapshot
      void reset()
      Re-initialize this object.
      void saveRole​(Role role)
      Serialize the role object to lower storage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocalFileRoleAccessor

        public LocalFileRoleAccessor​(java.lang.String roleDirPath)
    • Method Detail

      • loadRole

        public Role loadRole​(java.lang.String rolename)
                      throws java.io.IOException
        Description copied from interface: IRoleAccessor
        Deserialize a role from lower storage.
        Specified by:
        loadRole in interface IRoleAccessor
        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: IRoleAccessor
        Serialize the role object to lower storage.
        Specified by:
        saveRole in interface IRoleAccessor
        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.IOException
        Description copied from interface: IRoleAccessor
        Delete a role's in lower storage.
        Specified by:
        deleteRole in interface IRoleAccessor
        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: IRoleAccessor
        List all roles in this database.
        Specified by:
        listAllRoles in interface IRoleAccessor
        Returns:
        A list contains all names of the roles.
      • processTakeSnapshot

        public boolean processTakeSnapshot​(java.io.File snapshotDir)
                                    throws org.apache.thrift.TException,
                                           java.io.IOException
        Description copied from interface: SnapshotProcessor
        Take snapshot
        Specified by:
        processTakeSnapshot in interface SnapshotProcessor
        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 struct
        java.io.IOException - Exception related to file read and write
      • processLoadSnapshot

        public void processLoadSnapshot​(java.io.File snapshotDir)
                                 throws org.apache.thrift.TException,
                                        java.io.IOException
        Description copied from interface: SnapshotProcessor
        Load snapshot
        Specified by:
        processLoadSnapshot in interface SnapshotProcessor
        Parameters:
        snapshotDir - Load snapshot from here
        Throws:
        org.apache.thrift.TException - Exception occurred during the thrift deserialize struct
        java.io.IOException - Exception related to file read and write
      • reset

        public void reset()
        Description copied from interface: IRoleAccessor
        Re-initialize this object.
        Specified by:
        reset in interface IRoleAccessor