@Override public StorageResource allocateResource() throws Exception { StorageResource resource = null; if (allocatedSize < RdmaConstants.STORAGE_RDMA_STORAGE_LIMIT){ //mmap buffer int fileId = fileCount++; String dataFilePath = dataDirPath + "/" + fileId; RandomAccessFile dataFile = new RandomAccessFile(dataFilePath, "rw"); if (!RdmaConstants.STORAGE_RDMA_PERSISTENT){ dataFile.setLength(RdmaConstants.STORAGE_RDMA_ALLOCATION_SIZE); } FileChannel dataChannel = dataFile.getChannel(); ByteBuffer dataBuffer = dataChannel.map(MapMode.READ_WRITE, 0, RdmaConstants.STORAGE_RDMA_ALLOCATION_SIZE); dataFile.close(); dataChannel.close(); //register buffer allocatedSize += dataBuffer.capacity(); IbvMr mr = datanodeServerEndpoint.registerMemory(dataBuffer).execute().free().getMr(); //create resource resource = StorageResource.createResource(mr.getAddr(), mr.getLength(), mr.getLkey()); } return resource; }