/** Return the total number of insufficient redundancy blocks. */ synchronized int size() { int size = 0; for (int i = 0; i < LEVEL; i++) { size += priorityQueues.get(i).size(); } return size; }
/** * Return the number of insufficiently redundant blocks excluding corrupt * blocks. */ synchronized int getLowRedundancyBlockCount() { int size = 0; for (int i = 0; i < LEVEL; i++) { if (i != QUEUE_WITH_CORRUPT_BLOCKS) { size += priorityQueues.get(i).size(); } } return size; }
/** Return the number of corrupt blocks */ synchronized int getCorruptBlockSize() { return priorityQueues.get(QUEUE_WITH_CORRUPT_BLOCKS).size(); }
/** @return the number of leases currently in the system */ public synchronized int countLease() {return sortedLeases.size();}
/** Return the total number of under replication blocks */ synchronized int size() { int size = 0; for (int i = 0; i < LEVEL; i++) { size += priorityQueues.get(i).size(); } return size; }
/** get the number of under replicated blocks with equal or higher priority */ synchronized int getSize( int priority ) { int size = 0; for (int i=priority; i<LEVEL; i++) { size += priorityQueues.get(i).size(); } return size; }
/** Return the number of under replication blocks excluding corrupt blocks */ synchronized int getUnderReplicatedBlockCount() { int size = 0; for (int i = 0; i < LEVEL; i++) { if (i != QUEUE_WITH_CORRUPT_BLOCKS) { size += priorityQueues.get(i).size(); } } return size; }
/** Return the number of under replication blocks excluding corrupt blocks */ synchronized int getUnderReplicatedBlockCount() { int size = 0; for (int i = 0; i < LEVEL; i++) { if (i != QUEUE_WITH_CORRUPT_BLOCKS) { size += priorityQueues.get(i).size(); } } return size; }
synchronized int getNonCorruptUnderReplicatedBlocksCount() { int size = 0; for (int i=0; i<QUEUE_WITH_CORRUPT_BLOCKS; i++) { size += priorityQueues.get(i).size(); } return size; }
/** Return the total number of under replication blocks */ synchronized int size() { int size = 0; for (int i = 0; i < LEVEL; i++) { size += priorityQueues.get(i).size(); } return size; }
/** Return the number of corrupt blocks */ synchronized int getCorruptBlocksCount() { return priorityQueues.get(QUEUE_WITH_CORRUPT_BLOCKS).size(); }
/** Return the number of corrupt blocks */ synchronized int getCorruptBlockSize() { return priorityQueues.get(QUEUE_WITH_CORRUPT_BLOCKS).size(); }
/** Return the number of corrupt blocks */ synchronized int getCorruptBlockSize() { return priorityQueues.get(QUEUE_WITH_CORRUPT_BLOCKS).size(); }
/** Return the number of under replication blocks of priority */ synchronized int size( int priority) { if (priority < 0 || priority >= LEVEL) { throw new IllegalArgumentException("Unsupported priority: " + priority); } return priorityQueues.get(priority).size(); }
private synchronized long getEarliestScanTime() { if ( blockInfoSet.size() > 0 ) { return blockInfoSet.first().lastScanTime; } return Long.MAX_VALUE; }
private synchronized boolean isFirstBlockProcessed() { if (blockInfoSet.size() > 0 ) { long blockId = blockInfoSet.first().block.getBlockId(); if (processedBlocks.contains(blockId)) { return true; } } return false; }
private void verifyFirstBlock() { BlockScanInfo block = null; synchronized (this) { if ( blockInfoSet.size() > 0 ) { block = blockInfoSet.first(); } } if ( block != null ) { verifyBlock(block); processedBlocks.add(block.block.getBlockId()); } }
@Test public void testOneElementBasic() { LOG.info("Test one element basic"); set.add(list.get(0)); // set should be non-empty assertEquals(1, set.size()); assertFalse(set.isEmpty()); // iterator should have next Iterator<Integer> iter = set.iterator(); assertTrue(iter.hasNext()); // iterator should not have next assertEquals(list.get(0), iter.next()); assertFalse(iter.hasNext()); LOG.info("Test one element basic - DONE"); }
@Test public void testEmptyBasic() { LOG.info("Test empty basic"); Iterator<Integer> iter = set.iterator(); // iterator should not have next assertFalse(iter.hasNext()); assertEquals(0, set.size()); assertTrue(set.isEmpty()); // poll should return nothing assertNull(set.pollFirst()); assertEquals(0, set.pollAll().size()); assertEquals(0, set.pollN(10).size()); LOG.info("Test empty - DONE"); }
@Test public void testPollAll() { LOG.info("Test poll all"); for (Integer i : list) { assertTrue(set.add(i)); } // remove all elements by polling while (set.pollFirst() != null); assertEquals(0, set.size()); assertTrue(set.isEmpty()); // the deleted elements should not be there for (int i = 0; i < NUM; i++) { assertFalse(set.contains(list.get(i))); } Iterator<Integer> iter = set.iterator(); assertFalse(iter.hasNext()); LOG.info("Test poll all - DONE"); }