@Test public void commitBlock() throws Exception { TieredBlockStoreTestUtils.createTempBlock(SESSION_ID1, TEMP_BLOCK_ID, BLOCK_SIZE, mTestDir1); assertFalse(mBlockStore.hasBlockMeta(TEMP_BLOCK_ID)); mBlockStore.commitBlock(SESSION_ID1, TEMP_BLOCK_ID, false); assertTrue(mBlockStore.hasBlockMeta(TEMP_BLOCK_ID)); assertFalse( FileUtils.exists(TempBlockMeta.tempPath(mTestDir1, SESSION_ID1, TEMP_BLOCK_ID))); assertTrue(FileUtils.exists(TempBlockMeta.commitPath(mTestDir1, TEMP_BLOCK_ID))); }
@Override public void commitBlock(long sessionId, long blockId, boolean pinOnCreate) throws BlockAlreadyExistsException, InvalidWorkerStateException, BlockDoesNotExistException, IOException { LOG.debug("commitBlock: sessionId={}, blockId={}, pinOnCreate={}", sessionId, blockId, pinOnCreate); long lockId = mLockManager.lockBlock(sessionId, blockId, BlockLockType.WRITE); try { BlockStoreLocation loc = commitBlockInternal(sessionId, blockId, pinOnCreate); synchronized (mBlockStoreEventListeners) { for (BlockStoreEventListener listener : mBlockStoreEventListeners) { listener.onCommitBlock(sessionId, blockId, loc); } } } finally { mLockManager.unlockBlock(lockId); } }
TieredBlockStore implements BlockStore { @Override public void commitBlock(long sessionId, long blockId, boolean pinOnCreate) throws BlockAlreadyExistsException, InvalidWorkerStateException, BlockDoesNotExistException, IOException { LOG.debug("commitBlock: sessionId={}, blockId={}, pinOnCreate={}", sessionId, blockId, pinOnCreate); long lockId = mLockManager.lockBlock(sessionId, blockId, BlockLockType.WRITE); try { BlockStoreLocation loc = commitBlockInternal(sessionId, blockId, pinOnCreate); synchronized (mBlockStoreEventListeners) { for (BlockStoreEventListener listener : mBlockStoreEventListeners) { listener.onCommitBlock(sessionId, blockId, loc); } } } finally { mLockManager.unlockBlock(lockId); } } }
TieredBlockStore implements BlockStore { @Override public void commitBlock(long sessionId, long blockId, boolean pinOnCreate) throws BlockAlreadyExistsException, InvalidWorkerStateException, BlockDoesNotExistException, IOException { LOG.debug("commitBlock: sessionId={}, blockId={}, pinOnCreate={}", sessionId, blockId, pinOnCreate); long lockId = mLockManager.lockBlock(sessionId, blockId, BlockLockType.WRITE); try { BlockStoreLocation loc = commitBlockInternal(sessionId, blockId, pinOnCreate); synchronized (mBlockStoreEventListeners) { for (BlockStoreEventListener listener : mBlockStoreEventListeners) { listener.onCommitBlock(sessionId, blockId, loc); } } } finally { mLockManager.unlockBlock(lockId); } } TieredBlockStore(); }
TieredBlockStore implements BlockStore { @Override public void commitBlock(long sessionId, long blockId, boolean pinOnCreate) throws BlockAlreadyExistsException, InvalidWorkerStateException, BlockDoesNotExistException, IOException { LOG.debug("commitBlock: sessionId={}, blockId={}, pinOnCreate={}", sessionId, blockId, pinOnCreate); long lockId = mLockManager.lockBlock(sessionId, blockId, BlockLockType.WRITE); try { BlockStoreLocation loc = commitBlockInternal(sessionId, blockId, pinOnCreate); synchronized (mBlockStoreEventListeners) { for (BlockStoreEventListener listener : mBlockStoreEventListeners) { listener.onCommitBlock(sessionId, blockId, loc); } } } finally { mLockManager.unlockBlock(lockId); } } TieredBlockStore(); @Override long lockBlock(long sessionId, long blockId); @Override long lockBlockNoException(long sessionId, long blockId); @Override void unlockBlock(long lockId); @Override boolean unlockBlock(long sessionId, long blockId); @Override BlockWriter getBlockWriter(long sessionId, long blockId); @Override BlockReader getBlockReader(long sessionId, long blockId, long lockId); @Override TempBlockMeta createBlock(long sessionId, long blockId, AllocateOptions options); @Override BlockMeta getVolatileBlockMeta(long blockId); @Override BlockMeta getBlockMeta(long sessionId, long blockId, long lockId); @Override TempBlockMeta getTempBlockMeta(long sessionId, long blockId); @Override void commitBlock(long sessionId, long blockId, boolean pinOnCreate); @Override long commitBlockLocked(long sessionId, long blockId, boolean pinOnCreate); @Override void abortBlock(long sessionId, long blockId); @Override void requestSpace(long sessionId, long blockId, long additionalBytes); @Override void moveBlock(long sessionId, long blockId, AllocateOptions moveOptions); @Override void moveBlock(long sessionId, long blockId, BlockStoreLocation oldLocation,
      AllocateOptions moveOptions); @Override void removeBlock(long sessionId, long blockId); @Override void removeBlock(long sessionId, long blockId, BlockStoreLocation location); @Override void accessBlock(long sessionId, long blockId); @Override synchronized void freeSpace(long sessionId, long minContiguousBytes,
      long minAvailableBytes, BlockStoreLocation location); @Override void cleanupSession(long sessionId); @Override boolean hasBlockMeta(long blockId); @Override BlockStoreMeta getBlockStoreMeta(); @Override BlockStoreMeta getBlockStoreMetaFull(); @Override void registerBlockStoreEventListener(BlockStoreEventListener listener); @Override void updatePinnedInodes(Set<Long> inodes); @Override boolean checkStorage(); void removeDir(StorageDir dir); @Override void close(); }
TieredBlockStore implements BlockStore { @Override public void commitBlock(long sessionId, long blockId, boolean pinOnCreate) throws BlockAlreadyExistsException, InvalidWorkerStateException, BlockDoesNotExistException, IOException { LOG.debug("commitBlock: sessionId={}, blockId={}, pinOnCreate={}", sessionId, blockId, pinOnCreate); long lockId = mLockManager.lockBlock(sessionId, blockId, BlockLockType.WRITE); try { BlockStoreLocation loc = commitBlockInternal(sessionId, blockId, pinOnCreate); synchronized (mBlockStoreEventListeners) { for (BlockStoreEventListener listener : mBlockStoreEventListeners) { listener.onCommitBlock(sessionId, blockId, loc); } } } finally { mLockManager.unlockBlock(lockId); } } TieredBlockStore(); @Override long lockBlock(long sessionId, long blockId); @Override long lockBlockNoException(long sessionId, long blockId); @Override void unlockBlock(long lockId); @Override boolean unlockBlock(long sessionId, long blockId); @Override BlockWriter getBlockWriter(long sessionId, long blockId); @Override BlockReader getBlockReader(long sessionId, long blockId, long lockId); @Override TempBlockMeta createBlock(long sessionId, long blockId, AllocateOptions options); @Override BlockMeta getVolatileBlockMeta(long blockId); @Override BlockMeta getBlockMeta(long sessionId, long blockId, long lockId); @Override TempBlockMeta getTempBlockMeta(long sessionId, long blockId); @Override void commitBlock(long sessionId, long blockId, boolean pinOnCreate); @Override long commitBlockLocked(long sessionId, long blockId, boolean pinOnCreate); @Override void abortBlock(long sessionId, long blockId); @Override void requestSpace(long sessionId, long blockId, long additionalBytes); @Override void moveBlock(long sessionId, long blockId, AllocateOptions moveOptions); @Override void moveBlock(long sessionId, long blockId, BlockStoreLocation oldLocation,
      AllocateOptions moveOptions); @Override void removeBlock(long sessionId, long blockId); @Override void removeBlock(long sessionId, long blockId, BlockStoreLocation location); @Override void accessBlock(long sessionId, long blockId); @Override synchronized void freeSpace(long sessionId, long minContiguousBytes,
      long minAvailableBytes, BlockStoreLocation location); @Override void cleanupSession(long sessionId); @Override boolean hasBlockMeta(long blockId); @Override BlockStoreMeta getBlockStoreMeta(); @Override BlockStoreMeta getBlockStoreMetaFull(); @Override void registerBlockStoreEventListener(BlockStoreEventListener listener); @Override void updatePinnedInodes(Set<Long> inodes); @Override boolean checkStorage(); void removeDir(StorageDir dir); @Override void close();  }