Example usage for org.apache.hadoop.util PerformanceAdvisory LOG

List of usage examples for org.apache.hadoop.util PerformanceAdvisory LOG

Introduction

In this page you can find the example usage for org.apache.hadoop.util PerformanceAdvisory LOG.

Prototype

Logger LOG

To view the source code for org.apache.hadoop.util PerformanceAdvisory LOG.

Click Source Link

Usage

From source file:BlockReaderFactory.java

License:Apache License

/**
 * Get {@link BlockReaderLocalLegacy} for short circuited local reads.
 * This block reader implements the path-based style of local reads
 * first introduced in HDFS-2246.//  w w  w  .  j av  a2s. c o m
 */
private BlockReader getLegacyBlockReaderLocal() throws IOException {
    if (LOG.isTraceEnabled()) {
        LOG.trace(this + ": trying to construct BlockReaderLocalLegacy");
    }
    if (!DFSClient.isLocalAddress(inetSocketAddress)) {
        if (LOG.isTraceEnabled()) {
            LOG.trace(this + ": can't construct BlockReaderLocalLegacy because " + "the address "
                    + inetSocketAddress + " is not local");
        }
        return null;
    }
    if (clientContext.getDisableLegacyBlockReaderLocal()) {
        PerformanceAdvisory.LOG.debug(this + ": can't construct " + "BlockReaderLocalLegacy because "
                + "disableLegacyBlockReaderLocal is set.");
        return null;
    }
    IOException ioe = null;
    try {
        return BlockReaderLocalLegacy.newBlockReader(conf, userGroupInformation, configuration, fileName, block,
                token, datanode, startOffset, length, storageType);
    } catch (RemoteException remoteException) {
        ioe = remoteException.unwrapRemoteException(InvalidToken.class, AccessControlException.class);
    } catch (IOException e) {
        ioe = e;
    }
    if ((!(ioe instanceof AccessControlException)) && isSecurityException(ioe)) {
        // Handle security exceptions.
        // We do not handle AccessControlException here, since
        // BlockReaderLocalLegacy#newBlockReader uses that exception to indicate
        // that the user is not in dfs.block.local-path-access.user, a condition
        // which requires us to disable legacy SCR.
        throw ioe;
    }
    LOG.warn(this + ": error creating legacy BlockReaderLocal.  " + "Disabling legacy local reads.", ioe);
    clientContext.setDisableLegacyBlockReaderLocal();
    return null;
}

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  v  a  2  s.  co  m
    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();
}

From source file:BlockReaderFactory.java

License:Apache License

/**
 * Get a RemoteBlockReader that communicates over a UNIX domain socket.
 *
 * @return The new BlockReader, or null if we failed to create the block
 * reader.//from   w w w.  ja va  2s  .com
 *
 * @throws InvalidToken    If the block token was invalid.
 * Potentially other security-related execptions.
 */
private BlockReader getRemoteBlockReaderFromDomain() throws IOException {
    if (pathInfo == null) {
        pathInfo = clientContext.getDomainSocketFactory().getPathInfo(inetSocketAddress, conf);
    }
    if (!pathInfo.getPathState().getUsableForDataTransfer()) {
        PerformanceAdvisory.LOG.debug(this + ": not trying to create a "
                + "remote block reader because the UNIX domain socket at " + pathInfo + " is not usable.");
        return null;
    }
    if (LOG.isTraceEnabled()) {
        LOG.trace(this + ": trying to create a remote block reader from the " + "UNIX domain socket at "
                + pathInfo.getPath());
    }

    while (true) {
        BlockReaderPeer curPeer = nextDomainPeer();
        if (curPeer == null)
            break;
        if (curPeer.fromCache)
            remainingCacheTries--;
        DomainPeer peer = (DomainPeer) curPeer.peer;
        BlockReader blockReader = null;
        try {
            blockReader = getRemoteBlockReader(peer);
            return blockReader;
        } catch (IOException ioe) {
            IOUtils.cleanup(LOG, peer);
            if (isSecurityException(ioe)) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace(this + ": got security exception while constructing "
                            + "a remote block reader from the unix domain socket at " + pathInfo.getPath(),
                            ioe);
                }
                throw ioe;
            }
            if (curPeer.fromCache) {
                // Handle an I/O error we got when using a cached peer.  These are
                // considered less serious, because the underlying socket may be stale.
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Closed potentially stale domain peer " + peer, ioe);
                }
            } else {
                // Handle an I/O error we got when using a newly created domain peer.
                // We temporarily disable the domain socket path for a few minutes in
                // this case, to prevent wasting more time on it.
                LOG.warn("I/O error constructing remote block reader.  Disabling " + "domain socket "
                        + peer.getDomainSocket(), ioe);
                clientContext.getDomainSocketFactory().disableDomainSocketPath(pathInfo.getPath());
                return null;
            }
        } finally {
            if (blockReader == null) {
                IOUtils.cleanup(LOG, peer);
            }
        }
    }
    return null;
}