use of alluxio.worker.block.io.BlockWriter in project alluxio by Alluxio.
the class TieredBlockStoreTestUtils method createTempBlock.
/**
* Makes a temp block of a given size in {@link StorageDir}.
*
* @param sessionId session who caches the data
* @param blockId id of the cached block
* @param bytes size of the block in bytes
* @param dir the {@link StorageDir} the block resides in
* @return the temp block meta
* @throws Exception when fail to create this block
*/
public static TempBlockMeta createTempBlock(long sessionId, long blockId, long bytes, StorageDir dir) throws Exception {
// prepare temp block
TempBlockMeta tempBlockMeta = new TempBlockMeta(sessionId, blockId, bytes, dir);
dir.addTempBlockMeta(tempBlockMeta);
// write data
FileUtils.createFile(tempBlockMeta.getPath());
BlockWriter writer = new LocalFileBlockWriter(tempBlockMeta.getPath());
writer.append(BufferUtils.getIncreasingByteBuffer(Ints.checkedCast(bytes)));
writer.close();
return tempBlockMeta;
}
Aggregations