private DataNodeVolumeMetrics getVolumeMetrics(final FsVolumeSpi volume) { if (isEnabled) { if (volume != null) { return volume.getMetrics(); } } return null; } }
long getRemaining() throws IOException { long remaining = 0L; for (FsVolumeSpi vol : volumes) { try (FsVolumeReference ref = vol.obtainReference()) { remaining += vol.getAvailable(); } catch (ClosedChannelException e) { // ignore } } return remaining; }
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; }
/** * @return the FileInputStream for the meta data of the given block. * @throws FileNotFoundException * if the file not found. * @throws ClassCastException * if the underlying input stream is not a FileInputStream. */ public static FileInputStream getMetaDataInputStream( ExtendedBlock b, FsDatasetSpi<?> data) throws IOException { final LengthInputStream lin = data.getMetaDataInputStream(b); if (lin == null) { throw new FileNotFoundException("Meta file for " + b + " not found."); } return (FileInputStream)lin.getWrappedStream(); } }
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); }
/** * Get the storageUuid of the volume that stores this replica. */ @Override public String getStorageUuid() { return volume.getStorageID(); }
/** @return is writing to a transient storage? */ public boolean isTransientStorage() { return volume.isTransientStorage(); }
@Override public void close() throws IOException { if (this.volumeReference != null) { volumeReference.close(); } }
@Override // InterDatanodeProtocol public ReplicaRecoveryInfo initReplicaRecovery(RecoveringBlock rBlock) throws IOException { return data.initReplicaRecovery(rBlock); }
/** Cleanup a partial block * if this write is for a replication request (and not from a client) */ private void cleanupBlock() throws IOException { if (isDatanode) { datanode.data.unfinalizeBlock(block); } }
InputStream getBlockInputStream(ExtendedBlock block, long seekOffset) throws IOException { return datanode.data.getBlockInputStream(block, seekOffset); }
/** * Adjust the file pointer in the local meta file so that the last checksum * will be overwritten. */ private void adjustCrcFilePosition() throws IOException { streams.flushDataOut(); if (checksumOut != null) { checksumOut.flush(); } // rollback the position of the meta file datanode.data.adjustCrcChannelPosition(block, streams, checksumSize); }
@Override public IOException call() { try { data.addVolume(location, nsInfos); } catch (IOException e) { return e; } return null; } }));
@Override // ReplicaInPipeline public void setBytesAcked(long bytesAcked) { long newBytesAcked = bytesAcked - this.bytesAcked; this.bytesAcked = bytesAcked; // Once bytes are ACK'ed we can release equivalent space from the // volume's reservedForRbw count. We could have released it as soon // as the write-to-disk completed but that would be inefficient. getVolume().releaseReservedSpace(newBytesAcked); bytesReserved -= newBytesAcked; }
/** * Get the {@link FileIoProvider} for disk IO operations. */ public FileIoProvider getFileIoProvider() { // In tests and when invoked via FsDatasetUtil#computeChecksum, the // target volume for this replica may be unknown and hence null. // Use the DEFAULT_FILE_IO_PROVIDER with no-op hooks. return (volume != null) ? volume.getFileIoProvider() : DEFAULT_FILE_IO_PROVIDER; }
@Override public Iterator<FsVolumeSpi> iterator() { return new FsVolumeSpiIterator(references); }
AvailableSpaceVolumeChoosingPolicy(Random random) { this.random = random; initLocks(); }
/** * Get the volume for a given index. */ public FsVolumeSpi get(int index) { return references.get(index).getVolume(); }
@Override public String toString() { return "VolumeScanner(" + volume + ", " + volume.getStorageID() + ")"; }
@Override public boolean isOnTransientStorage() { return volume.isTransientStorage(); }