@Test public void testPrepareDirectory() throws Exception { File[] dirs = new File[3]; for (int i = 0; i < dirs.length; i++) { dirs[i] = tempFolder.newFolder(); } MmapChunkAllocator allocator = new MmapChunkAllocator(10240, dirs, new Configuration()); for (File dir : dirs) { Assert.assertTrue(new File(dir, MmapChunkAllocator.MMAP_DIR).exists()); } allocator.close(); }
@Override public void close() { if (!isClosed.compareAndSet(false, true)) { return; } for (Tuple2<RandomAccessFile, MappedByteBuffer> tuple : memoryMappedFiles) { PlatformDependent.freeDirectBuffer(tuple.f1); IOUtils.closeQuietly(tuple.f0); } removeCandidateDirectory(candidateDirectories); }
MmapChunkAllocator implements ChunkAllocator { @Override public void close() { if (!isClosed.compareAndSet(false, true)) { return; } for (Tuple2<RandomAccessFile, MappedByteBuffer> tuple : memoryMappedFiles) { PlatformDependent.freeDirectBuffer(tuple.f1); IOUtils.closeQuietly(tuple.f0); } removeCandidateDirectory(candidateDirectories); } }
MmapChunkAllocator implements ChunkAllocator { @Override public void close() { if (!isClosed.compareAndSet(false, true)) { return; } for (Tuple2<RandomAccessFile, MappedByteBuffer> tuple : memoryMappedFiles) { PlatformDependent.freeDirectBuffer(tuple.f1); IOUtils.closeQuietly(tuple.f0); } removeCandidateDirectory(candidateDirectories); } MmapChunkAllocator(int chunkSize, File[] localDirs, Configuration configuration); }
MmapChunkAllocator implements ChunkAllocator { @Override public void close() { if (!isClosed.compareAndSet(false, true)) { return; } for (Tuple2<RandomAccessFile, MappedByteBuffer> tuple : memoryMappedFiles) { PlatformDependent.freeDirectBuffer(tuple.f1); IOUtils.closeQuietly(tuple.f0); } removeCandidateDirectory(candidateDirectories); } MmapChunkAllocator(int chunkSize, File[] localDirs, Configuration configuration); @Override Chunk createChunk(int chunkId, AllocateStrategy allocateStrategy); @Override void close(); }
MmapChunkAllocator implements ChunkAllocator { @Override public void close() { if (!isClosed.compareAndSet(false, true)) { return; } for (Tuple2<RandomAccessFile, MappedByteBuffer> tuple : memoryMappedFiles) { PlatformDependent.freeDirectBuffer(tuple.f1); IOUtils.closeQuietly(tuple.f0); } removeCandidateDirectory(candidateDirectories); } MmapChunkAllocator(int chunkSize, File[] localDirs, Configuration configuration); @Override Chunk createChunk(int chunkId, AllocateStrategy allocateStrategy); @Override void close(); static final String MMAP_DIR; }