Search in sources :

Example 11 with Slot

use of org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot in project hadoop by apache.

the class TestEnhancedByteBufferAccess method waitForReplicaAnchorStatus.

private void waitForReplicaAnchorStatus(final ShortCircuitCache cache, final ExtendedBlock block, final boolean expectedIsAnchorable, final boolean expectedIsAnchored, final int expectedOutstandingMmaps) throws Exception {
    GenericTestUtils.waitFor(new Supplier<Boolean>() {

        @Override
        public Boolean get() {
            final MutableBoolean result = new MutableBoolean(false);
            cache.accept(new CacheVisitor() {

                @Override
                public void visit(int numOutstandingMmaps, Map<ExtendedBlockId, ShortCircuitReplica> replicas, Map<ExtendedBlockId, InvalidToken> failedLoads, LinkedMap evictable, LinkedMap evictableMmapped) {
                    Assert.assertEquals(expectedOutstandingMmaps, numOutstandingMmaps);
                    ShortCircuitReplica replica = replicas.get(ExtendedBlockId.fromExtendedBlock(block));
                    Assert.assertNotNull(replica);
                    Slot slot = replica.getSlot();
                    if ((expectedIsAnchorable != slot.isAnchorable()) || (expectedIsAnchored != slot.isAnchored())) {
                        LOG.info("replica " + replica + " has isAnchorable = " + slot.isAnchorable() + ", isAnchored = " + slot.isAnchored() + ".  Waiting for isAnchorable = " + expectedIsAnchorable + ", isAnchored = " + expectedIsAnchored);
                        return;
                    }
                    result.setValue(true);
                }
            });
            return result.toBoolean();
        }
    }, 10, 60000);
}
Also used : ShortCircuitReplica(org.apache.hadoop.hdfs.shortcircuit.ShortCircuitReplica) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean) CacheVisitor(org.apache.hadoop.hdfs.shortcircuit.ShortCircuitCache.CacheVisitor) Slot(org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean) Map(java.util.Map) LinkedMap(org.apache.commons.collections.map.LinkedMap) LinkedMap(org.apache.commons.collections.map.LinkedMap)

Aggregations

Slot (org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot)11 MutableBoolean (org.apache.commons.lang.mutable.MutableBoolean)4 IOException (java.io.IOException)3 ExtendedBlockId (org.apache.hadoop.hdfs.ExtendedBlockId)3 CacheVisitor (org.apache.hadoop.hdfs.shortcircuit.ShortCircuitCache.CacheVisitor)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 Configuration (org.apache.hadoop.conf.Configuration)2 InvalidRequestException (org.apache.hadoop.fs.InvalidRequestException)2 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)2 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)2 DomainPeer (org.apache.hadoop.hdfs.net.DomainPeer)2 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)2 DatanodeInfoBuilder (org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder)2 PerDatanodeVisitorInfo (org.apache.hadoop.hdfs.shortcircuit.DfsClientShmManager.PerDatanodeVisitorInfo)2 Visitor (org.apache.hadoop.hdfs.shortcircuit.DfsClientShmManager.Visitor)2 ShmId (org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.ShmId)2 TemporarySocketDirectory (org.apache.hadoop.net.unix.TemporarySocketDirectory)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1