@Override public void close() throws IOException { if (this.volumeReference != null) { volumeReference.close(); } }
ReplicaFileDeleteTask(FsVolumeReference volumeRef, ReplicaInfo replicaToDelete, ExtendedBlock block, String trashDirectory) { this.volumeRef = volumeRef; this.volume = (FsVolumeImpl) volumeRef.getVolume(); this.replicaToDelete = replicaToDelete; this.block = block; this.trashDirectory = trashDirectory; }
private void markHealthy() { synchronized (DatasetVolumeChecker.this) { healthyVolumes.add(reference.getVolume()); } }
@Override public void close() throws IOException { IOException ioe = null; for (FsVolumeReference ref : references) { try { ref.close(); } catch (IOException e) { ioe = e; } } references.clear(); if (ioe != null) { throw ioe; } } }
/** * Get the volume for a given index. */ public FsVolumeSpi get(int index) { return references.get(index).getVolume(); }
/** * Moves a given block from one volume to another volume. This is used by disk * balancer. * * @param block - ExtendedBlock * @param destination - Destination volume * @return Old replica info */ @Override public ReplicaInfo moveBlockAcrossVolumes(ExtendedBlock block, FsVolumeSpi destination) throws IOException { ReplicaInfo replicaInfo = getReplicaInfo(block); if (replicaInfo.getState() != ReplicaState.FINALIZED) { throw new ReplicaNotFoundException( ReplicaNotFoundException.UNFINALIZED_REPLICA + block); } FsVolumeReference volumeRef = null; try (AutoCloseableLock lock = datasetLock.acquire()) { volumeRef = destination.obtainReference(); } try { moveBlock(block, replicaInfo, volumeRef); } finally { if (volumeRef != null) { volumeRef.close(); } } return replicaInfo; }
private void markFailed() { synchronized (DatasetVolumeChecker.this) { failedVolumes.add(reference.getVolume()); } }
@Override public void close() throws IOException { if (this.volumeReference != null) { volumeReference.close(); } }
@Override public FsVolumeSpi next() { int refIdx = idx++; return references.get(refIdx).getVolume(); }
@Override public void close() throws IOException { if (this.volumeReference != null) { volumeReference.close(); } }
@Override public void onFailure(@Nonnull Throwable t) { Throwable exception = (t instanceof ExecutionException) ? t.getCause() : t; LOG.warn("Exception running disk checks against volume " + reference.getVolume(), exception); markFailed(); cleanup(); }
} finally { if (volumeRef != null) { volumeRef.close();
/** * Create a new temporary replica of replicaInfo object in specified volume. * * @param block - Extended Block * @param replicaInfo - ReplicaInfo * @param volumeRef - Volume Ref - Closed by caller. * @return newReplicaInfo new replica object created in specified volume. * @throws IOException */ @VisibleForTesting ReplicaInfo copyReplicaToVolume(ExtendedBlock block, ReplicaInfo replicaInfo, FsVolumeReference volumeRef) throws IOException { FsVolumeImpl targetVolume = (FsVolumeImpl) volumeRef.getVolume(); // Copy files to temp dir first ReplicaInfo newReplicaInfo = targetVolume.moveBlockToTmpLocation(block, replicaInfo, smallBufferSize, conf); return newReplicaInfo; }
@Test public void testReleaseVolumeRefIfNoBlockScanner() throws IOException { FsVolumeList volumeList = new FsVolumeList( Collections.<VolumeFailureInfo>emptyList(), null, blockChooser); File volDir = new File(baseDir, "volume-0"); volDir.mkdirs(); FsVolumeImpl volume = new FsVolumeImpl(dataset, "storage-id", volDir, conf, StorageType.DEFAULT); FsVolumeReference ref = volume.obtainReference(); volumeList.addVolume(ref); try { ref.close(); fail("Should throw exception because the reference is closed in " + "VolumeList#addVolume()."); } catch (IllegalStateException e) { } }
@Override public void onSuccess(@Nonnull VolumeCheckResult result) { switch(result) { case HEALTHY: case DEGRADED: LOG.debug("Volume {} is {}.", reference.getVolume(), result); markHealthy(); break; case FAILED: LOG.warn("Volume {} detected as being unhealthy", reference.getVolume()); markFailed(); break; default: LOG.error("Unexpected health check result {} for volume {}", result, reference.getVolume()); markHealthy(); break; } cleanup(); }
public void dropCacheBehindReads(String identifier, long offset, long len, int flags) throws NativeIOException { assert this.dataInFd != null : "null dataInFd!"; fileIoProvider.posixFadvise(getVolumeRef().getVolume(), identifier, dataInFd, offset, len, flags); }
/** * Delete the block file and meta file from the disk asynchronously, adjust * dfsUsed statistics accordingly. */ void deleteAsync(FsVolumeReference volumeRef, ReplicaInfo replicaToDelete, ExtendedBlock block, String trashDirectory) { LOG.info("Scheduling " + block.getLocalBlock() + " replica " + replicaToDelete + " for deletion"); ReplicaFileDeleteTask deletionTask = new ReplicaFileDeleteTask( volumeRef, replicaToDelete, block, trashDirectory); execute(((FsVolumeImpl) volumeRef.getVolume()), deletionTask); }
/** * Asynchronously lazy persist the block from the RamDisk to Disk. */ void submitLazyPersistTask(String bpId, long blockId, long genStamp, long creationTime, ReplicaInfo replica, FsVolumeReference target) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("LazyWriter schedule async task to persist RamDisk block pool id: " + bpId + " block id: " + blockId); } ReplicaLazyPersistTask lazyPersistTask = new ReplicaLazyPersistTask( bpId, blockId, genStamp, creationTime, replica, target); FsVolumeImpl volume = (FsVolumeImpl)target.getVolume(); execute(volume.getStorageID(), lazyPersistTask); }