/** * Get the storageUuid of the volume that stores this replica. */ @Override public String getStorageUuid() { return volume.getStorageID(); }
@Override public String toString() { return "VolumeScanner(" + volume + ", " + volume.getStorageID() + ")"; }
/** * Stops and removes a volume scanner.<p/> * * This function will block until the volume scanner has stopped. * * @param volume The volume to remove. */ public synchronized void removeVolumeScanner(FsVolumeSpi volume) { if (!isEnabled()) { LOG.debug("Not removing volume scanner for {}, because the block " + "scanner is disabled.", volume.getStorageID()); return; } VolumeScanner scanner = scanners.get(volume.getStorageID()); if (scanner == null) { LOG.warn("No scanner found to remove for volumeId {}", volume.getStorageID()); return; } LOG.info("Removing scanner for volume {} (StorageID {})", volume, volume.getStorageID()); scanner.shutdown(); scanners.remove(volume.getStorageID()); Uninterruptibles.joinUninterruptibly(scanner, 5, TimeUnit.MINUTES); }
public void printStats(StringBuilder p) { p.append(String.format("Block scanner information for volume %s with base" + " path %s%n", volume.getStorageID(), volume)); synchronized (stats) { p.append(String.format("Bytes verified in last hour : %57d%n",
return; VolumeScanner scanner = scanners.get(volume.getStorageID()); if (scanner != null) { LOG.error("Already have a scanner for volume {}.", volume, volume.getStorageID()); scanner = new VolumeScanner(conf, datanode, ref); scanner.start(); scanners.put(volume.getStorageID(), scanner); success = true; } finally {
private void reportBadBlock(final BPOfferService bpos, final ExtendedBlock block, final String msg) { FsVolumeSpi volume = getFSDataset().getVolume(block); if (volume == null) { LOG.warn("Cannot find FsVolumeSpi to report bad block: " + block); return; } bpos.reportBadBlocks( block, volume.getStorageID(), volume.getStorageType()); LOG.warn(msg); }
/** * Report a bad block which is hosted on the local DN. * * @param block the bad block which is hosted on the local DN * @param volume the volume that block is stored in and the volume * must not be null * @throws IOException */ public void reportBadBlocks(ExtendedBlock block, FsVolumeSpi volume) throws IOException { BPOfferService bpos = getBPOSForBlock(block); bpos.reportBadBlocks( block, volume.getStorageID(), volume.getStorageType()); }
/** * Get FsVolume by volume UUID. * @param fsDataset * @param volUuid * @return FsVolumeSpi */ private static FsVolumeSpi getFsVolume(final FsDatasetSpi<?> fsDataset, final String volUuid) { FsVolumeSpi fsVolume = null; try (FsVolumeReferences volumeReferences = fsDataset.getFsVolumeReferences()) { for (int i = 0; i < volumeReferences.size(); i++) { if (volumeReferences.get(i).getStorageID().equals(volUuid)) { fsVolume = volumeReferences.get(i); break; } } } catch (IOException e) { LOG.warn("Disk Balancer - Error when closing volume references: ", e); } return fsVolume; }
/** * Returns volume UUID to volume base path map. * * @return Map * @throws DiskBalancerException */ private Map<String, String> getStorageIDToVolumeBasePathMap() throws DiskBalancerException { Map<String, String> storageIDToVolBasePathMap = new HashMap<>(); FsDatasetSpi.FsVolumeReferences references; try { try(AutoCloseableLock lock = this.dataset.acquireDatasetLock()) { references = this.dataset.getFsVolumeReferences(); for (int ndx = 0; ndx < references.size(); ndx++) { FsVolumeSpi vol = references.get(ndx); storageIDToVolBasePathMap.put(vol.getStorageID(), vol.getBaseURI().getPath()); } references.close(); } } catch (IOException ex) { LOG.error("Disk Balancer - Internal Error.", ex); throw new DiskBalancerException("Internal error", ex, DiskBalancerException.Result.INTERNAL_ERROR); } return storageIDToVolBasePathMap; }
curVolumes = volumes.getVolumes(); for (FsVolumeSpi v : curVolumes) { builders.put(v.getStorageID(), BlockListAsLongs.builder(maxDataLength)); continue; String volStorageID = b.getVolume().getStorageID(); if (!builders.containsKey(volStorageID)) { if (!missingVolumesReported.contains(volStorageID)) {
FsVolumeSpi fsVolumeSpi = volumes.get(index); LOG.error("Error compiling report for the volume, StorageId: " + fsVolumeSpi.getStorageID(), ex);
LOG.error("BlockSender.sendChunks() exception: ", e); datanode.getBlockScanner().markSuspectBlock( ris.getVolumeRef().getVolume().getStorageID(), block);
/** * Get the storageUuid of the volume that stores this replica. */ @Override public String getStorageUuid() { return volume.getStorageID(); }
blockScanner.markSuspectBlock(data.getVolume(b).getStorageID(), b);
expireOldScannedBytesRecords(monotonicMs); if (!calculateShouldScan(volume.getStorageID(), conf.targetBytesPerSec, scannedBytesSum, startMinute, curMinute)) {
@Override public String toString() { return "VolumeScanner(" + volume.getBasePath() + ", " + volume.getStorageID() + ")"; }
@Override public String toString() { return "VolumeScanner(" + volume.getBasePath() + ", " + volume.getStorageID() + ")"; }
private void reportBadBlock(final BPOfferService bpos, final ExtendedBlock block, final String msg) { FsVolumeSpi volume = getFSDataset().getVolume(block); if (volume == null) { LOG.warn("Cannot find FsVolumeSpi to report bad block: " + block); return; } bpos.reportBadBlocks( block, volume.getStorageID(), volume.getStorageType()); LOG.warn(msg); }
static Info getInfo(FsVolumeSpi volume) { Info newInfo = new Info(); Info prevInfo = infos. putIfAbsent(volume.getStorageID(), newInfo); return prevInfo == null ? newInfo : prevInfo; }
@Before public void startCluster() throws IOException { conf = new HdfsConfiguration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(DN_COUNT).build(); singletonNn = cluster.getNameNode(); singletonDn = cluster.getDataNodes().get(0); bpos = singletonDn.getAllBpOs()[0]; actor = bpos.getBPServiceActors().get(0); storageUuid = singletonDn.getFSDataset().getVolumes().get(0).getStorageID(); }