Search in sources :

Example 1 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class PortmapRequest method create.

public static XDR create(PortmapMapping mapping, boolean set) {
    XDR request = new XDR();
    int procedure = set ? RpcProgramPortmap.PMAPPROC_SET : RpcProgramPortmap.PMAPPROC_UNSET;
    RpcCall call = RpcCall.getInstance(RpcUtil.getNewXid(String.valueOf(RpcProgramPortmap.PROGRAM)), RpcProgramPortmap.PROGRAM, RpcProgramPortmap.VERSION, procedure, new CredentialsNone(), new VerifierNone());
    call.write(request);
    return mapping.serialize(request);
}
Also used : RpcCall(org.apache.hadoop.oncrpc.RpcCall) XDR(org.apache.hadoop.oncrpc.XDR) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) CredentialsNone(org.apache.hadoop.oncrpc.security.CredentialsNone)

Example 2 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class RpcProgram method sendRejectedReply.

protected static void sendRejectedReply(RpcCall call, SocketAddress remoteAddress, ChannelHandlerContext ctx) {
    XDR out = new XDR();
    RpcDeniedReply reply = new RpcDeniedReply(call.getXid(), RpcReply.ReplyState.MSG_DENIED, RpcDeniedReply.RejectState.AUTH_ERROR, new VerifierNone());
    reply.write(out);
    ChannelBuffer buf = ChannelBuffers.wrappedBuffer(out.asReadOnlyWrap().buffer());
    RpcResponse rsp = new RpcResponse(buf, remoteAddress);
    RpcUtil.sendRpcResponse(ctx, rsp);
}
Also used : VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 3 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class RpcProgramMountd method handleInternal.

@Override
public void handleInternal(ChannelHandlerContext ctx, RpcInfo info) {
    RpcCall rpcCall = (RpcCall) info.header();
    final MNTPROC mntproc = MNTPROC.fromValue(rpcCall.getProcedure());
    int xid = rpcCall.getXid();
    byte[] data = new byte[info.data().readableBytes()];
    info.data().readBytes(data);
    XDR xdr = new XDR(data);
    XDR out = new XDR();
    InetAddress client = ((InetSocketAddress) info.remoteAddress()).getAddress();
    if (mntproc == MNTPROC.NULL) {
        out = nullOp(out, xid, client);
    } else if (mntproc == MNTPROC.MNT) {
        // Only do port monitoring for MNT
        if (!doPortMonitoring(info.remoteAddress())) {
            out = MountResponse.writeMNTResponse(Nfs3Status.NFS3ERR_ACCES, out, xid, null);
        } else {
            out = mnt(xdr, out, xid, client);
        }
    } else if (mntproc == MNTPROC.DUMP) {
        out = dump(out, xid, client);
    } else if (mntproc == MNTPROC.UMNT) {
        out = umnt(xdr, out, xid, client);
    } else if (mntproc == MNTPROC.UMNTALL) {
        umntall(out, xid, client);
    } else if (mntproc == MNTPROC.EXPORT) {
        // Currently only support one NFS export
        List<NfsExports> hostsMatchers = new ArrayList<NfsExports>();
        if (hostsMatcher != null) {
            hostsMatchers.add(hostsMatcher);
            out = MountResponse.writeExportList(out, xid, exports, hostsMatchers);
        } else {
            // This means there are no valid exports provided.
            RpcAcceptedReply.getInstance(xid, RpcAcceptedReply.AcceptState.PROC_UNAVAIL, new VerifierNone()).write(out);
        }
    } else {
        // Invalid procedure
        RpcAcceptedReply.getInstance(xid, RpcAcceptedReply.AcceptState.PROC_UNAVAIL, new VerifierNone()).write(out);
    }
    ChannelBuffer buf = ChannelBuffers.wrappedBuffer(out.asReadOnlyWrap().buffer());
    RpcResponse rsp = new RpcResponse(buf, info.remoteAddress());
    RpcUtil.sendRpcResponse(ctx, rsp);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) XDR(org.apache.hadoop.oncrpc.XDR) RpcResponse(org.apache.hadoop.oncrpc.RpcResponse) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) RpcCall(org.apache.hadoop.oncrpc.RpcCall) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) NfsExports(org.apache.hadoop.nfs.NfsExports) ArrayList(java.util.ArrayList) List(java.util.List) InetAddress(java.net.InetAddress)

Example 4 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class RpcProgramMountd method umnt.

@Override
public XDR umnt(XDR xdr, XDR out, int xid, InetAddress client) {
    String path = xdr.readString();
    if (LOG.isDebugEnabled()) {
        LOG.debug("MOUNT UMNT path: " + path + " client: " + client);
    }
    String host = client.getHostName();
    mounts.remove(new MountEntry(host, path));
    RpcAcceptedReply.getAcceptInstance(xid, new VerifierNone()).write(out);
    return out;
}
Also used : MountEntry(org.apache.hadoop.mount.MountEntry) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone)

Example 5 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class WriteManager method handleWrite.

void handleWrite(DFSClient dfsClient, WRITE3Request request, Channel channel, int xid, Nfs3FileAttributes preOpAttr) throws IOException {
    int count = request.getCount();
    byte[] data = request.getData().array();
    if (data.length < count) {
        WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_INVAL);
        Nfs3Utils.writeChannel(channel, response.serialize(new XDR(), xid, new VerifierNone()), xid);
        return;
    }
    FileHandle handle = request.getHandle();
    if (LOG.isDebugEnabled()) {
        LOG.debug("handleWrite " + request);
    }
    // Check if there is a stream to write
    FileHandle fileHandle = request.getHandle();
    OpenFileCtx openFileCtx = fileContextCache.get(fileHandle);
    if (openFileCtx == null) {
        LOG.info("No opened stream for fileId: " + fileHandle.getFileId());
        String fileIdPath = Nfs3Utils.getFileIdPath(fileHandle.getFileId());
        HdfsDataOutputStream fos = null;
        Nfs3FileAttributes latestAttr = null;
        try {
            int bufferSize = config.getInt(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY, CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT);
            fos = dfsClient.append(fileIdPath, bufferSize, EnumSet.of(CreateFlag.APPEND), null, null);
            latestAttr = Nfs3Utils.getFileAttr(dfsClient, fileIdPath, iug);
        } catch (RemoteException e) {
            IOException io = e.unwrapRemoteException();
            if (io instanceof AlreadyBeingCreatedException) {
                LOG.warn("Can't append file: " + fileIdPath + ". Possibly the file is being closed. Drop the request: " + request + ", wait for the client to retry...");
                return;
            }
            throw e;
        } catch (IOException e) {
            LOG.error("Can't append to file: " + fileIdPath, e);
            if (fos != null) {
                fos.close();
            }
            WccData fileWcc = new WccData(Nfs3Utils.getWccAttr(preOpAttr), preOpAttr);
            WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO, fileWcc, count, request.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
            Nfs3Utils.writeChannel(channel, response.serialize(new XDR(), xid, new VerifierNone()), xid);
            return;
        }
        // Add open stream
        String writeDumpDir = config.get(NfsConfigKeys.DFS_NFS_FILE_DUMP_DIR_KEY, NfsConfigKeys.DFS_NFS_FILE_DUMP_DIR_DEFAULT);
        openFileCtx = new OpenFileCtx(fos, latestAttr, writeDumpDir + "/" + fileHandle.getFileId(), dfsClient, iug, aixCompatMode, config);
        if (!addOpenFileStream(fileHandle, openFileCtx)) {
            LOG.info("Can't add new stream. Close it. Tell client to retry.");
            try {
                fos.close();
            } catch (IOException e) {
                LOG.error("Can't close stream for fileId: " + handle.getFileId(), e);
            }
            // Notify client to retry
            WccData fileWcc = new WccData(latestAttr.getWccAttr(), latestAttr);
            WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_JUKEBOX, fileWcc, 0, request.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
            Nfs3Utils.writeChannel(channel, response.serialize(new XDR(), xid, new VerifierNone()), xid);
            return;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("Opened stream for appending file: " + fileHandle.getFileId());
        }
    }
    // Add write into the async job queue
    openFileCtx.receivedNewWrite(dfsClient, request, channel, xid, asyncDataService, iug);
    return;
}
Also used : WccData(org.apache.hadoop.nfs.nfs3.response.WccData) AlreadyBeingCreatedException(org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException) FileHandle(org.apache.hadoop.nfs.nfs3.FileHandle) XDR(org.apache.hadoop.oncrpc.XDR) Nfs3FileAttributes(org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes) IOException(java.io.IOException) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) HdfsDataOutputStream(org.apache.hadoop.hdfs.client.HdfsDataOutputStream) WRITE3Response(org.apache.hadoop.nfs.nfs3.response.WRITE3Response) RemoteException(org.apache.hadoop.ipc.RemoteException)

Aggregations

VerifierNone (org.apache.hadoop.oncrpc.security.VerifierNone)21 XDR (org.apache.hadoop.oncrpc.XDR)15 WccData (org.apache.hadoop.nfs.nfs3.response.WccData)8 WRITE3Response (org.apache.hadoop.nfs.nfs3.response.WRITE3Response)6 IOException (java.io.IOException)5 CredentialsNone (org.apache.hadoop.oncrpc.security.CredentialsNone)5 Test (org.junit.Test)5 FileHandle (org.apache.hadoop.nfs.nfs3.FileHandle)4 RpcCall (org.apache.hadoop.oncrpc.RpcCall)4 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)4 WriteStableHow (org.apache.hadoop.nfs.nfs3.Nfs3Constant.WriteStableHow)3 WccAttr (org.apache.hadoop.nfs.nfs3.response.WccAttr)3 RpcResponse (org.apache.hadoop.oncrpc.RpcResponse)3 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 Nfs3FileAttributes (org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes)2 COMMIT3Response (org.apache.hadoop.nfs.nfs3.response.COMMIT3Response)2 Credentials (org.apache.hadoop.oncrpc.security.Credentials)2 Verifier (org.apache.hadoop.oncrpc.security.Verifier)2 File (java.io.File)1