/** * Opens all Block pools on a given volume. * * @param source Source * @param poolIters List of PoolIters to maintain. */ private void openPoolIters(FsVolumeSpi source, List<FsVolumeSpi .BlockIterator> poolIters) { Preconditions.checkNotNull(source); Preconditions.checkNotNull(poolIters); for (String blockPoolID : source.getBlockPoolList()) { poolIters.add(source.newBlockIterator(blockPoolID, "DiskBalancerSource")); } }
/** * Allow the scanner to scan the given block pool. * * @param bpid The block pool id. */ public synchronized void enableBlockPoolId(String bpid) { for (BlockIterator iter : blockIters) { if (iter.getBlockPoolId().equals(bpid)) { LOG.warn("{}: already enabled scanning on block pool {}", this, bpid); return; } } BlockIterator iter = null; try { // Load a block iterator for the next block pool on the volume. iter = volume.loadBlockIterator(bpid, BLOCK_ITERATOR_NAME); LOG.trace("{}: loaded block iterator for {}.", this, bpid); } catch (FileNotFoundException e) { LOG.debug("{}: failed to load block iterator: " + e.getMessage(), this); } catch (IOException e) { LOG.warn("{}: failed to load block iterator.", this, e); } if (iter == null) { iter = volume.newBlockIterator(bpid, BLOCK_ITERATOR_NAME); LOG.trace("{}: created new block iterator for {}.", this, bpid); } iter.setMaxStalenessMs(conf.maxStalenessMs); blockIters.add(iter); notify(); }
/** * Allow the scanner to scan the given block pool. * * @param bpid The block pool id. */ public synchronized void enableBlockPoolId(String bpid) { for (BlockIterator iter : blockIters) { if (iter.getBlockPoolId().equals(bpid)) { LOG.warn("{}: already enabled scanning on block pool {}", this, bpid); return; } } BlockIterator iter = null; try { // Load a block iterator for the next block pool on the volume. iter = volume.loadBlockIterator(bpid, BLOCK_ITERATOR_NAME); LOG.trace("{}: loaded block iterator for {}.", this, bpid); } catch (FileNotFoundException e) { LOG.debug("{}: failed to load block iterator: " + e.getMessage(), this); } catch (IOException e) { LOG.warn("{}: failed to load block iterator.", this, e); } if (iter == null) { iter = volume.newBlockIterator(bpid, BLOCK_ITERATOR_NAME); LOG.trace("{}: created new block iterator for {}.", this, bpid); } iter.setMaxStalenessMs(conf.maxStalenessMs); blockIters.add(iter); notify(); }
/** * Allow the scanner to scan the given block pool. * * @param bpid The block pool id. */ public synchronized void enableBlockPoolId(String bpid) { for (BlockIterator iter : blockIters) { if (iter.getBlockPoolId().equals(bpid)) { LOG.warn("{}: already enabled scanning on block pool {}", this, bpid); return; } } BlockIterator iter = null; try { // Load a block iterator for the next block pool on the volume. iter = volume.loadBlockIterator(bpid, BLOCK_ITERATOR_NAME); LOG.trace("{}: loaded block iterator for {}.", this, bpid); } catch (FileNotFoundException e) { LOG.debug("{}: failed to load block iterator: " + e.getMessage(), this); } catch (IOException e) { LOG.warn("{}: failed to load block iterator.", this, e); } if (iter == null) { iter = volume.newBlockIterator(bpid, BLOCK_ITERATOR_NAME); LOG.trace("{}: created new block iterator for {}.", this, bpid); } iter.setMaxStalenessMs(conf.maxStalenessMs); blockIters.add(iter); notify(); }
BPOfferService bpos[] = ctx.datanode.getAllBpOs(); assertEquals(1, bpos.length); BlockIterator iter = volume.newBlockIterator(ctx.bpids[0], "test"); assertEquals(ctx.bpids[0], iter.getBlockPoolId()); iter.setMaxStalenessMs(maxStaleness);