Example usage for org.apache.hadoop.hdfs.server.protocol DatanodeRegistration getXferAddr

List of usage examples for org.apache.hadoop.hdfs.server.protocol DatanodeRegistration getXferAddr

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.protocol DatanodeRegistration getXferAddr.

Prototype

public String getXferAddr() 

Source Link

Usage

From source file:com.mellanox.r4h.DataXceiverBase.java

License:Apache License

private boolean checkAccess(final boolean reply, final ExtendedBlock blk, final Token<BlockTokenIdentifier> t,
        final Op op, final BlockTokenSecretManager.AccessMode mode, final Msg msg) throws IOException {
    if (dnBridge.isBlockTokenEnabled()) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Checking block access token for block '" + blk.getBlockId() + "' with mode '" + mode
                    + "'");
        }//from  w  w w.  ja  va2s . c om
        try {
            dnBridge.getBlockPoolTokenSecretManager().checkAccess(t, null, blk, mode);
        } catch (InvalidToken e) {
            if (reply) {
                final OutputStream replyOut = new ByteBufferOutputStream(msg.getOut());
                BlockOpResponseProto.Builder resp = BlockOpResponseProto.newBuilder()
                        .setStatus(ERROR_ACCESS_TOKEN);
                if (mode == BlockTokenSecretManager.AccessMode.WRITE) {
                    DatanodeRegistration dnR = dnBridge.getDNRegistrationForBP(blk.getBlockPoolId());
                    // NB: Unconditionally using the xfer addr w/o hostname
                    resp.setFirstBadLink(dnR.getXferAddr());
                }
                resp.build().writeDelimitedTo(replyOut);
                replyOut.flush();
                spw.queueAsyncReply(DataXceiverBase.this, msg, onFlightMsgs, true);
            }
            LOG.error("Block token verification failed: op=" + op + ", serverSession=" + serverSession
                    + ", message=" + e.getLocalizedMessage());
            return false;// FAILED
        }
    }
    return true; // SUCCESS
}