public BlockScanner(DataNode datanode, Configuration conf) { this.datanode = datanode; this.conf = new Conf(conf); if (isEnabled()) { LOG.info("Initialized block scanner with targetBytesPerSec {}", this.conf.targetBytesPerSec); } else { LOG.info("Disabled block scanner."); } }
/** * Mark a block as "suspect." * * This means that we should try to rescan it soon. Note that the * VolumeScanner keeps a list of recently suspicious blocks, which * it uses to avoid rescanning the same block over and over in a short * time frame. * * @param storageId The ID of the storage where the block replica * is being stored. * @param block The block's ID and block pool id. */ synchronized void markSuspectBlock(String storageId, ExtendedBlock block) { if (!isEnabled()) { LOG.debug("Not scanning suspicious block {} on {}, because the block " + "scanner is disabled.", block, storageId); return; } VolumeScanner scanner = scanners.get(storageId); if (scanner == null) { // This could happen if the volume is in the process of being removed. // The removal process shuts down the VolumeScanner, but the volume // object stays around as long as there are references to it (which // should not be that long.) LOG.info("Not scanning suspicious block {} on {}, because there is no " + "volume scanner for that storageId.", block, storageId); return; } scanner.markSuspectBlock(block); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); DataNode datanode = (DataNode) getServletContext().getAttribute("datanode"); BlockScanner blockScanner = datanode.getBlockScanner(); StringBuilder buffer = new StringBuilder(8 * 1024); if (!blockScanner.isEnabled()) { LOG.warn("Periodic block scanner is not running"); buffer.append("Periodic block scanner is not running. " + "Please check the datanode log if this is unexpected."); } else { buffer.append("Block Scanner Statistics\n\n"); blockScanner.printStats(buffer); } String resp = buffer.toString(); LOG.trace("Returned Servlet info {}", resp); response.getWriter().write(resp); } }
/** * 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); }
try { FsVolumeSpi volume = ref.getVolume(); if (!isEnabled()) { LOG.debug("Not adding volume scanner for {}, because the block " + "scanner is disabled.", volume);
public BlockScanner(DataNode datanode, Configuration conf) { this.datanode = datanode; this.conf = new Conf(conf); if (isEnabled()) { LOG.info("Initialized block scanner with targetBytesPerSec {}", this.conf.targetBytesPerSec); } else { LOG.info("Disabled block scanner."); } }
/** * Mark a block as "suspect." * * This means that we should try to rescan it soon. Note that the * VolumeScanner keeps a list of recently suspicious blocks, which * it uses to avoid rescanning the same block over and over in a short * time frame. * * @param storageId The ID of the storage where the block replica * is being stored. * @param block The block's ID and block pool id. */ synchronized void markSuspectBlock(String storageId, ExtendedBlock block) { if (!isEnabled()) { LOG.debug("Not scanning suspicious block {} on {}, because the block " + "scanner is disabled.", block, storageId); return; } VolumeScanner scanner = scanners.get(storageId); if (scanner == null) { // This could happen if the volume is in the process of being removed. // The removal process shuts down the VolumeScanner, but the volume // object stays around as long as there are references to it (which // should not be that long.) LOG.info("Not scanning suspicious block {} on {}, because there is no " + "volume scanner for that storageId.", block, storageId); return; } scanner.markSuspectBlock(block); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); DataNode datanode = (DataNode) getServletContext().getAttribute("datanode"); BlockScanner blockScanner = datanode.getBlockScanner(); StringBuilder buffer = new StringBuilder(8 * 1024); if (!blockScanner.isEnabled()) { LOG.warn("Periodic block scanner is not running"); buffer.append("Periodic block scanner is not running. " + "Please check the datanode log if this is unexpected."); } else { buffer.append("Block Scanner Statistics\n\n"); blockScanner.printStats(buffer); } String resp = buffer.toString(); LOG.trace("Returned Servlet info {}", resp); response.getWriter().write(resp); } }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); DataNode datanode = (DataNode) getServletContext().getAttribute("datanode"); BlockScanner blockScanner = datanode.getBlockScanner(); StringBuilder buffer = new StringBuilder(8 * 1024); if (!blockScanner.isEnabled()) { LOG.warn("Periodic block scanner is not running"); buffer.append("Periodic block scanner is not running. " + "Please check the datanode log if this is unexpected."); } else { buffer.append("Block Scanner Statistics\n\n"); blockScanner.printStats(buffer); } String resp = buffer.toString(); LOG.trace("Returned Servlet info {}", resp); response.getWriter().write(resp); } }
public BlockScanner(DataNode datanode, Configuration conf) { this.datanode = datanode; this.conf = new Conf(conf); if (isEnabled()) { LOG.info("Initialized block scanner with targetBytesPerSec {}", this.conf.targetBytesPerSec); } else { LOG.info("Disabled block scanner."); } }
/** * Mark a block as "suspect." * * This means that we should try to rescan it soon. Note that the * VolumeScanner keeps a list of recently suspicious blocks, which * it uses to avoid rescanning the same block over and over in a short * time frame. * * @param storageId The ID of the storage where the block replica * is being stored. * @param block The block's ID and block pool id. */ synchronized void markSuspectBlock(String storageId, ExtendedBlock block) { if (!isEnabled()) { LOG.debug("Not scanning suspicious block {} on {}, because the block " + "scanner is disabled.", block, storageId); return; } VolumeScanner scanner = scanners.get(storageId); if (scanner == null) { // This could happen if the volume is in the process of being removed. // The removal process shuts down the VolumeScanner, but the volume // object stays around as long as there are references to it (which // should not be that long.) LOG.info("Not scanning suspicious block {} on {}, because there is no " + "volume scanner for that storageId.", block, storageId); return; } scanner.markSuspectBlock(block); }
/** * 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.getBasePath(), volume.getStorageID()); scanner.shutdown(); scanners.remove(volume.getStorageID()); Uninterruptibles.joinUninterruptibly(scanner, 5, TimeUnit.MINUTES); }
try { FsVolumeSpi volume = ref.getVolume(); if (!isEnabled()) { LOG.debug("Not adding volume scanner for {}, because the block " + "scanner is disabled.", volume.getBasePath());
/** * 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.getBasePath(), volume.getStorageID()); scanner.shutdown(); scanners.remove(volume.getStorageID()); Uninterruptibles.joinUninterruptibly(scanner, 5, TimeUnit.MINUTES); }
@Test(timeout=60000) public void testDisableVolumeScanner() throws Exception { Configuration conf = new Configuration(); disableBlockScanner(conf); TestContext ctx = new TestContext(conf, 1); try { Assert.assertFalse(ctx.datanode.getBlockScanner().isEnabled()); } finally { ctx.close(); } }
Mockito.when(mockScanner.isEnabled()).thenReturn(false); dn0.setBlockScanner(mockScanner); Path filePath = new Path("test.dat");
try { FsVolumeSpi volume = ref.getVolume(); if (!isEnabled()) { LOG.debug("Not adding volume scanner for {}, because the block " + "scanner is disabled.", volume.getBasePath());