Example usage for org.apache.hadoop.hdfs.shortcircuit ShortCircuitReplicaInfo getInvalidTokenException

List of usage examples for org.apache.hadoop.hdfs.shortcircuit ShortCircuitReplicaInfo getInvalidTokenException

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.shortcircuit ShortCircuitReplicaInfo getInvalidTokenException.

Prototype

public InvalidToken getInvalidTokenException() 

Source Link

Usage

From source file:BlockReaderFactory.java

License:Apache License

private BlockReader getBlockReaderLocal() throws InvalidToken {
    if (LOG.isTraceEnabled()) {
        LOG.trace(this + ": trying to construct a BlockReaderLocal " + "for short-circuit reads.");
    }/*from w  w w  .j a va 2s  .  c  om*/
    if (pathInfo == null) {
        pathInfo = clientContext.getDomainSocketFactory().getPathInfo(inetSocketAddress, conf);
    }
    if (!pathInfo.getPathState().getUsableForShortCircuit()) {
        PerformanceAdvisory.LOG.debug(this + ": " + pathInfo + " is not "
                + "usable for short circuit; giving up on BlockReaderLocal.");
        return null;
    }
    ShortCircuitCache cache = clientContext.getShortCircuitCache();
    ExtendedBlockId key = new ExtendedBlockId(block.getBlockId(), block.getBlockPoolId());
    ShortCircuitReplicaInfo info = cache.fetchOrCreate(key, this);
    InvalidToken exc = info.getInvalidTokenException();
    if (exc != null) {
        if (LOG.isTraceEnabled()) {
            LOG.trace(this + ": got InvalidToken exception while trying to " + "construct BlockReaderLocal via "
                    + pathInfo.getPath());
        }
        throw exc;
    }
    if (info.getReplica() == null) {
        if (LOG.isTraceEnabled()) {
            PerformanceAdvisory.LOG.debug(this + ": failed to get " + "ShortCircuitReplica. Cannot construct "
                    + "BlockReaderLocal via " + pathInfo.getPath());
        }
        return null;
    }
    return new BlockReaderLocal.Builder(conf).setFilename(fileName).setBlock(block).setStartOffset(startOffset)
            .setShortCircuitReplica(info.getReplica()).setVerifyChecksum(verifyChecksum)
            .setCachingStrategy(cachingStrategy).setStorageType(storageType).build();
}