@Test public void releaseAccess() throws Exception { UnderFileSystemBlockStore blockStore = new UnderFileSystemBlockStore(mAlluxioBlockStore, mUfsManager); for (int i = 0; i < 5; i++) { assertTrue(blockStore.acquireAccess(i + 1, BLOCK_ID, mOpenUfsBlockOptions)); blockStore.releaseAccess(i + 1, BLOCK_ID); } assertTrue(blockStore.acquireAccess(6, BLOCK_ID, mOpenUfsBlockOptions)); }
public void releaseAccess(long sessionId, long blockId) { try (LockResource lr = new LockResource(mLock)) { Key key = new Key(sessionId, blockId); if (!mBlocks.containsKey(key)) { LOG.warn("Key (block ID: {}, session ID {}) is not found when releasing the UFS block.", blockId, sessionId); } mBlocks.remove(key); Set<Long> blockIds = mSessionIdToBlockIds.get(sessionId); if (blockIds != null) { blockIds.remove(blockId); if (blockIds.isEmpty()) { mSessionIdToBlockIds.remove(sessionId); } } Set<Long> sessionIds = mBlockIdToSessionIds.get(blockId); if (sessionIds != null) { sessionIds.remove(sessionId); if (sessionIds.isEmpty()) { mBlockIdToSessionIds.remove(blockId); } } } }
UnderFileSystemBlockStore implements SessionCleanable { public void releaseAccess(long sessionId, long blockId) { try (LockResource lr = new LockResource(mLock)) { Key key = new Key(sessionId, blockId); if (!mBlocks.containsKey(key)) { LOG.warn("Key (block ID: {}, session ID {}) is not found when releasing the UFS block.", blockId, sessionId); } mBlocks.remove(key); Set<Long> blockIds = mSessionIdToBlockIds.get(sessionId); if (blockIds != null) { blockIds.remove(blockId); if (blockIds.isEmpty()) { mSessionIdToBlockIds.remove(sessionId); } } Set<Long> sessionIds = mBlockIdToSessionIds.get(blockId); if (sessionIds != null) { sessionIds.remove(sessionId); if (sessionIds.isEmpty()) { mBlockIdToSessionIds.remove(blockId); } } } } }
UnderFileSystemBlockStore implements SessionCleanable { public void releaseAccess(long sessionId, long blockId) { try (LockResource lr = new LockResource(mLock)) { Key key = new Key(sessionId, blockId); if (!mBlocks.containsKey(key)) { LOG.warn("Key (block ID: {}, session ID {}) is not found when releasing the UFS block.", blockId, sessionId); } mBlocks.remove(key); Set<Long> blockIds = mSessionIdToBlockIds.get(sessionId); if (blockIds != null) { blockIds.remove(blockId); if (blockIds.isEmpty()) { mSessionIdToBlockIds.remove(sessionId); } } Set<Long> sessionIds = mBlockIdToSessionIds.get(blockId); if (sessionIds != null) { sessionIds.remove(sessionId); if (sessionIds.isEmpty()) { mBlockIdToSessionIds.remove(blockId); } } } } UnderFileSystemBlockStore(BlockStore localBlockStore, UfsManager ufsManager); }
UnderFileSystemBlockStore implements SessionCleanable { public void releaseAccess(long sessionId, long blockId) { try (LockResource lr = new LockResource(mLock)) { Key key = new Key(sessionId, blockId); if (!mBlocks.containsKey(key)) { LOG.warn("Key (block ID: {}, session ID {}) is not found when releasing the UFS block.", blockId, sessionId); } mBlocks.remove(key); Set<Long> blockIds = mSessionIdToBlockIds.get(sessionId); if (blockIds != null) { blockIds.remove(blockId); if (blockIds.isEmpty()) { mSessionIdToBlockIds.remove(sessionId); } } Set<Long> sessionIds = mBlockIdToSessionIds.get(blockId); if (sessionIds != null) { sessionIds.remove(sessionId); if (sessionIds.isEmpty()) { mBlockIdToSessionIds.remove(blockId); } } } } UnderFileSystemBlockStore(BlockStore localBlockStore, UfsManager ufsManager); boolean acquireAccess(long sessionId, long blockId, Protocol.OpenUfsBlockOptions options); void closeReaderOrWriter(long sessionId, long blockId); void releaseAccess(long sessionId, long blockId); @Override void cleanupSession(long sessionId); BlockReader getBlockReader(final long sessionId, long blockId, long offset,
      boolean positionShort); }
UnderFileSystemBlockStore implements SessionCleanable { public void releaseAccess(long sessionId, long blockId) { try (LockResource lr = new LockResource(mLock)) { Key key = new Key(sessionId, blockId); if (!mBlocks.containsKey(key)) { LOG.warn("Key (block ID: {}, session ID {}) is not found when releasing the UFS block.", blockId, sessionId); } mBlocks.remove(key); Set<Long> blockIds = mSessionIdToBlockIds.get(sessionId); if (blockIds != null) { blockIds.remove(blockId); if (blockIds.isEmpty()) { mSessionIdToBlockIds.remove(sessionId); } } Set<Long> sessionIds = mBlockIdToSessionIds.get(blockId); if (sessionIds != null) { sessionIds.remove(sessionId); if (sessionIds.isEmpty()) { mBlockIdToSessionIds.remove(blockId); } } } } UnderFileSystemBlockStore(BlockStore localBlockStore, UfsManager ufsManager); boolean acquireAccess(long sessionId, long blockId, Protocol.OpenUfsBlockOptions options); void closeReaderOrWriter(long sessionId, long blockId); void releaseAccess(long sessionId, long blockId); @Override void cleanupSession(long sessionId); BlockReader getBlockReader(final long sessionId, long blockId, long offset,
      boolean positionShort);  }