Interface BlockWorker

    • Method Detail

      • abortBlock

        void abortBlock​(long sessionId,
                        long blockId)
                 throws java.io.IOException
        Aborts the temporary block created by the session.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to be aborted
        Throws:
        java.io.IOException
      • commitBlock

        void commitBlock​(long sessionId,
                         long blockId,
                         boolean pinOnCreate)
        Commits a block to Alluxio managed space. The block must be temporary. The block will not be persisted or accessible before commitBlock succeeds.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to commit
        pinOnCreate - whether to pin block on create
      • commitBlockInUfs

        void commitBlockInUfs​(long blockId,
                              long length)
        Commits a block in UFS.
        Parameters:
        blockId - the id of the block to commit
        length - length of the block to commit
      • createBlock

        java.lang.String createBlock​(long sessionId,
                                     long blockId,
                                     int tier,
                                     CreateBlockOptions createBlockOptions)
        Creates a block in Alluxio managed space. Calls createBlockWriter(long, long) to get a writer for writing to the block. The block will be temporary until it is committed by commitBlock(long, long, boolean) . Throws an IllegalArgumentException if the location does not belong to tiered storage.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to create
        tier - the tier to place the new block in BlockStoreLocation.ANY_TIER for any tier
        createBlockOptions - the createBlockOptions
        Returns:
        a string representing the path to the local file
      • getReport

        BlockHeartbeatReport getReport()
        Gets a report for the periodic heartbeat to master. Contains the blocks added since the last heart beat and blocks removed since the last heartbeat.
        Returns:
        a block heartbeat report
      • getStoreMeta

        BlockStoreMeta getStoreMeta()
        Gets the metadata for the entire block store. Contains the block mapping per storage dir and the total capacity and used capacity of each tier. This function is cheap.
        Returns:
        the block store metadata
      • getStoreMetaFull

        BlockStoreMeta getStoreMetaFull()
        Similar as getStoreMeta() except that this also contains full blockId list. This function is expensive.
        Returns:
        the full block store metadata
      • createBlockReader

        BlockReader createBlockReader​(long sessionId,
                                      long blockId,
                                      long offset,
                                      boolean positionShort,
                                      alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options)
                               throws java.io.IOException
        Creates the block reader to read from Alluxio block or UFS block. Owner of this block reader must close it or lock will leak.
        Parameters:
        sessionId - the client session ID
        blockId - the ID of the UFS block to read
        offset - the offset within the block
        positionShort - whether the operation is using positioned read to a small buffer size
        options - the options
        Returns:
        a block reader to read data from
        Throws:
        java.io.IOException - if it fails to get block reader
      • createUfsBlockReader

        BlockReader createUfsBlockReader​(long sessionId,
                                         long blockId,
                                         long offset,
                                         boolean positionShort,
                                         alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options)
                                  throws java.io.IOException
        Creates a block reader to read a UFS block starting from given block offset. Owner of this block reader must close it to cleanup state.
        Parameters:
        sessionId - the client session ID
        blockId - the ID of the UFS block to read
        offset - the offset within the block
        positionShort - whether the operation is using positioned read to a small buffer size
        options - the options
        Returns:
        the block reader instance
        Throws:
        java.io.IOException - if it fails to get block reader
      • removeBlock

        void removeBlock​(long sessionId,
                         long blockId)
                  throws java.io.IOException
        Frees a block from Alluxio managed space.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to be freed
        Throws:
        java.io.IOException
      • freeWorker

        void freeWorker()
                 throws java.io.IOException
        Frees all blocks in the current worker by deleting all block store directories. Whether this method returns successfully or exceptionally, the worker should not be used in any way.
        Throws:
        java.io.IOException - if free fails
      • requestSpace

        void requestSpace​(long sessionId,
                          long blockId,
                          long additionalBytes)
        Request an amount of space for a block in its storage directory. The block must be a temporary block.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to allocate space to
        additionalBytes - the amount of bytes to allocate
      • asyncCache

        @Deprecated
        void asyncCache​(alluxio.grpc.AsyncCacheRequest request)
        Deprecated.
        This method will be deprecated as of v3.0, use cache(alluxio.grpc.CacheRequest)
        Submits the async cache request to async cache manager to execute.
        Parameters:
        request - the async cache request
      • cache

        void cache​(alluxio.grpc.CacheRequest request)
            throws AlluxioException,
                   java.io.IOException
        Submits the cache request to cache manager to execute.
        Parameters:
        request - the cache request
        Throws:
        AlluxioException
        java.io.IOException
      • load

        java.util.concurrent.CompletableFuture<java.util.List<alluxio.grpc.BlockStatus>> load​(java.util.List<alluxio.grpc.Block> fileBlocks,
                                                                                              alluxio.grpc.UfsReadOptions options)
        Load blocks into alluxio.
        Parameters:
        fileBlocks - list of fileBlocks, one file blocks contains blocks belong to one file
        options - read ufs options
        Returns:
        future of load status for failed blocks
      • updatePinList

        void updatePinList​(java.util.Set<java.lang.Long> pinnedInodes)
        Sets the pinlist for the underlying block store.
        Parameters:
        pinnedInodes - a set of pinned inodes
      • getFileInfo

        FileInfo getFileInfo​(long fileId)
                      throws java.io.IOException
        Gets the file information.
        Parameters:
        fileId - the file id
        Returns:
        the file info
        Throws:
        java.io.IOException
      • clearMetrics

        void clearMetrics()
        Clears the worker metrics.
      • getConfiguration

        Configuration getConfiguration​(alluxio.grpc.GetConfigurationPOptions options)
        Parameters:
        options - method options
        Returns:
        configuration information list
      • getWhiteList

        java.util.List<java.lang.String> getWhiteList()
        Returns:
        the white list
      • getBlockStore

        BlockStore getBlockStore()
        Returns:
        the block store
      • getWorkerAddress

        WorkerNetAddress getWorkerAddress()
        Returns:
        the worker address
      • readBlockRemote

        BlockReader readBlockRemote​(long sessionId,
                                    long blockId,
                                    long lockId)
                             throws BlockDoesNotExistException,
                                    InvalidWorkerStateException,
                                    java.io.IOException
        Gets the block reader for the block. This method is only called by a data server.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to read
        lockId - the id of the lock on this block
        Returns:
        the block reader for the block
        Throws:
        BlockDoesNotExistException - if lockId is not found
        InvalidWorkerStateException - if sessionId or blockId is not the same as that in the LockRecord of lockId
        java.io.IOException
      • openUfsBlock

        boolean openUfsBlock​(long sessionId,
                             long blockId,
                             alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options)
                      throws BlockAlreadyExistsException
        Opens a UFS block. It registers the block metadata information to the UFS block store. It throws an UfsBlockAccessTokenUnavailableException if the number of concurrent readers on this block exceeds a threshold.
        Parameters:
        sessionId - the session ID
        blockId - the block ID
        options - the options
        Returns:
        whether the UFS block is successfully opened
        Throws:
        BlockAlreadyExistsException - if the UFS block already exists in the UnderFileSystemBlockStore
      • accessBlock

        void accessBlock​(long sessionId,
                         long blockId)
                  throws BlockDoesNotExistException
        Access the block for a given session. This should be called to update the evictor when necessary.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to access
        Throws:
        BlockDoesNotExistException - this exception is not thrown in the tiered block store implementation
      • readBlock

        java.lang.String readBlock​(long sessionId,
                                   long blockId,
                                   long lockId)
                            throws BlockDoesNotExistException,
                                   InvalidWorkerStateException
        Gets the path to the block file in local storage. The block must be a permanent block, and the caller must first obtain the lock on the block.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to read
        lockId - the id of the lock on this block
        Returns:
        a string representing the path to this block in local storage
        Throws:
        BlockDoesNotExistException - if the blockId cannot be found in committed blocks or lockId cannot be found
        InvalidWorkerStateException - if sessionId or blockId is not the same as that in the LockRecord of lockId
      • unlockBlock

        boolean unlockBlock​(long sessionId,
                            long blockId)
        Releases the lock with the specified session and block id.
        Parameters:
        sessionId - the session id
        blockId - the block id
        Returns:
        false if it fails to unlock due to the lock is not found
      • lockBlock

        long lockBlock​(long sessionId,
                       long blockId)
                throws BlockDoesNotExistException
        Obtains a read lock the block.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to be locked
        Returns:
        the lock id that uniquely identifies the lock obtained
        Throws:
        BlockDoesNotExistException - if blockId cannot be found, for example, evicted already
      • lockBlockNoException

        long lockBlockNoException​(long sessionId,
                                  long blockId)
        Obtains a read lock the block without throwing an exception. If the lock fails, return BlockLockManager#INVALID_LOCK_ID.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to be locked
        Returns:
        the lock id that uniquely identifies the lock obtained or BlockLockManager#INVALID_LOCK_ID if it failed to lock
      • createBlockRemote

        void createBlockRemote​(long sessionId,
                               long blockId,
                               java.lang.String tierAlias,
                               long initialBytes)
                        throws BlockAlreadyExistsException,
                               WorkerOutOfSpaceException,
                               java.io.IOException
        Creates a block. This method is only called from a data server. Calls getTempBlockWriterRemote(long, long) to get a writer for writing to the block. Throws an IllegalArgumentException if the location doens not belong to tiered storage.
        Parameters:
        sessionId - the id of the client
        blockId - the id of the block to be created
        tierAlias - the alias of the tier to place the new block in
        initialBytes - the initial amount of bytes to be allocated
        Throws:
        BlockAlreadyExistsException - if blockId already exists, either temporary or committed, or block in eviction plan already exists
        WorkerOutOfSpaceException - if this Store has no more space than the initialBlockSize
        java.io.IOException
      • readUfsBlock

        BlockReader readUfsBlock​(long sessionId,
                                 long blockId,
                                 long offset)
                          throws BlockDoesNotExistException,
                                 java.io.IOException
        Gets a block reader to read a UFS block. This method is only called by the data server.
        Parameters:
        sessionId - the client session ID
        blockId - the ID of the UFS block to read
        offset - the offset within the block
        Returns:
        the block reader instance
        Throws:
        BlockDoesNotExistException - if the block does not exist in the UFS block store
        java.io.IOException