@Override void addBlockPool(String bpid, Configuration conf) throws IOException { addBlockPool(bpid, conf, null); }
/** * @param volumeURI URI of the volume * @param blockURI URI of the block * @return true if the {@code blockURI} can belong to the volume or both URIs * are null. */ @VisibleForTesting public static boolean containsBlock(URI volumeURI, URI blockURI) { if (volumeURI == null && blockURI == null){ return true; } if (volumeURI == null || blockURI == null) { return false; } volumeURI = getAbsoluteURI(volumeURI); blockURI = getAbsoluteURI(blockURI); return !volumeURI.relativize(blockURI).equals(blockURI); }
@Override public long getAvailable() throws IOException { long remaining = getCapacity() - getDfsUsed(); // do not report less than 0 remaining space for PROVIDED storage // to prevent marking it as over capacity on NN if (remaining < 0L) { LOG.warn("Volume {} has less than 0 available space", this); return 0L; } return remaining; }
return; Path blockPrefixPath = new Path(providedVolume.getBaseURI()); for (FileRegion region : reader) { if (containsBlock(providedVolume.baseURI, region.getProvidedStorageLocation().getPath().toUri())) { String blockSuffix = getSuffix(blockPrefixPath, new Path(region.getProvidedStorageLocation().getPath().toUri())); PathHandle pathHandle = null;
@Override boolean isBPDirEmpty(String bpid) throws IOException { return getProvidedBlockPoolSlice(bpid).isEmpty(); }
@Override void addBlockPool(String bpid, Configuration conf, Timer timer) throws IOException { LOG.info("Adding block pool " + bpid + " to volume with id " + getStorageID()); ProvidedBlockPoolSlice bp; bp = new ProvidedBlockPoolSlice(bpid, this, conf); bpSlices.put(bpid, bp); }
@Override public long getCapacity() { try { // default to whatever is the space used! return getDfsUsed(); } catch (IOException e) { LOG.warn("Exception when trying to get capacity of ProvidedVolume: {}", e); } return 0L; }
@Override public long getDfsUsed() throws IOException { long dfsUsed = 0; synchronized(getDataset()) { for(ProvidedBlockPoolSlice s : bpSlices.values()) { dfsUsed += s.getDfsUsed(); } } return dfsUsed; }
FsVolumeImpl build() throws IOException { if (sd.getStorageLocation().getStorageType() == StorageType.PROVIDED) { return new ProvidedVolumeImpl(dataset, storageID, sd, fileIoProvider != null ? fileIoProvider : new FileIoProvider(null, null), conf); } if (null == usage) { // set usage unless overridden by unit tests usage = new DF(sd.getCurrentDir().getParentFile(), conf); } return new FsVolumeImpl( dataset, storageID, sd, fileIoProvider != null ? fileIoProvider : new FileIoProvider(null, null), conf, usage); } }
@Override void getVolumeMap(String bpid, ReplicaMap volumeMap, final RamDiskReplicaTracker ramDiskReplicaMap) throws IOException { getProvidedBlockPoolSlice(bpid).fetchVolumeMap(volumeMap, ramDiskReplicaMap, remoteFS); }
public void load() throws IOException { // on load, we just rewind the iterator for provided volumes. rewind(); LOG.trace("load({}, {}): loaded iterator {}: {}", getStorageID(), bpid, name, WRITER.writeValueAsString(state)); } }
@VisibleForTesting BlockAliasMap<FileRegion> getFileRegionProvider(String bpid) throws IOException { return getProvidedBlockPoolSlice(bpid).getBlockAliasMap(); }
@Override long getBlockPoolUsed(String bpid) throws IOException { return getProvidedBlockPoolSlice(bpid).getDfsUsed(); }
@VisibleForTesting BlockAliasMap<FileRegion> getBlockFormat(String bpid) throws IOException { return getProvidedBlockPoolSlice(bpid).getBlockAliasMap(); }