Package org.apache.hadoop.oncrpc

Examples of org.apache.hadoop.oncrpc.XDR


    return request;
  }

  static XDR write(FileHandle handle, int xid, long offset, int count,
      byte[] data) {
    XDR request = new XDR();
    RpcCall.write(request, xid, Nfs3Constant.PROGRAM, Nfs3Constant.VERSION,
        Nfs3Constant.NFSPROC3_WRITE);

    // credentials
    request.writeInt(0); // auth null
    request.writeInt(0); // length zero
    // verifier
    request.writeInt(0); // auth null
    request.writeInt(0); // length zero
    WRITE3Request write1 = new WRITE3Request(handle, offset, count,
        WriteStableHow.UNSTABLE, ByteBuffer.wrap(data));
    write1.serialize(request);
    return request;
  }
View Full Code Here


      Thread.sleep(1000);
      System.out.println("handle is still null...");
    }
    LOG.info("Send write1 request");

    XDR writeReq;

    writeReq = write(handle, 0x8000005c, 2000, 1000, data3);
    Nfs3Utils.writeChannel(channel, writeReq);
    writeReq = write(handle, 0x8000005d, 1000, 1000, data2);
    Nfs3Utils.writeChannel(channel, writeReq);
View Full Code Here

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
      // Get handle from create response
      ChannelBuffer buf = (ChannelBuffer) e.getMessage();
      XDR rsp = new XDR(buf.array());
      if (rsp.getBytes().length == 0) {
        LOG.info("rsp length is zero, why?");
        return;
      }
      LOG.info("rsp length=" + rsp.getBytes().length);

      RpcReply reply = RpcReply.read(rsp);
      int xid = reply.getXid();
      // Only process the create response
      if (xid != 0x8000004c) {
        return;
      }
      int status = rsp.readInt();
      if (status != Nfs3Status.NFS3_OK) {
        LOG.error("Create failed, status =" + status);
        return;
      }
      LOG.info("Create succeeded");
      rsp.readBoolean(); // value follow
      handle = new FileHandle();
      handle.deserialize(rsp);
      channel = e.getChannel();
    }
View Full Code Here

  public static PortmapMapping mapping(XDR xdr) {
    return PortmapMapping.deserialize(xdr);
  }

  public static XDR create(PortmapMapping mapping) {
    XDR request = new XDR();
    RpcCall.write(request,
        RpcUtil.getNewXid(String.valueOf(RpcProgramPortmap.PROGRAM)),
        RpcProgramPortmap.PROGRAM, RpcProgramPortmap.VERSION,
        Procedure.PMAPPROC_SET.getValue());
    request.writeInt(AuthFlavor.AUTH_NONE.getValue());
    request.writeInt(0);
    request.writeInt(0);
    request.writeInt(0);
    return mapping.serialize(request);
  }
View Full Code Here

 
  @Test
  public void testSerializeDeserialize() {
    // Serialize NfsTime
    NfsTime t1 = new NfsTime(1001);
    XDR xdr = new XDR();
    t1.serialize(xdr);
   
    // Deserialize it back
    NfsTime t2 = NfsTime.deserialize(xdr);
   
View Full Code Here

public class TestFileHandle {
  @Test
  public void testConstructor() {
    FileHandle handle = new FileHandle(1024);
    XDR xdr = new XDR();
    handle.serialize(xdr);
    Assert.assertEquals(handle.getFileId(), 1024);

    // Deserialize it back
    FileHandle handle2 = new FileHandle();
View Full Code Here

    Nfs3 nfs3 = new Nfs3(exports, config);
    nfs3.start(false);

    RpcProgramMountd mountd = (RpcProgramMountd) nfs3.getMountBase()
        .getRpcProgram();
    mountd.nullOp(new XDR(), 1234, InetAddress.getByName("localhost"));
   
    RpcProgramNfs3 nfsd = (RpcProgramNfs3) nfs3.getRpcProgram();
    nfsd.nullProcedure();
   
    cluster.shutdown();
View Full Code Here

    // Make this a method
    RpcCall.write(xdr_out, 0, 100000, 2, procedure);
  }
  static void testGetportMount() {
    XDR xdr_out = new XDR();
    createPortmapXDRheader(xdr_out, 3);
    xdr_out.writeInt(100005);
    xdr_out.writeInt(1);
    xdr_out.writeInt(6);
    xdr_out.writeInt(0);

    XDR request2 = new XDR();
    createPortmapXDRheader(xdr_out, 3);
    request2.writeInt(100005);
    request2.writeInt(1);
    request2.writeInt(6);
    request2.writeInt(0);

    testRequest(xdr_out, request2);
  }
View Full Code Here

    testRequest(xdr_out, request2);
  }
 
  static void testGetport() {
    XDR xdr_out = new XDR();

    createPortmapXDRheader(xdr_out, 3);

    xdr_out.writeInt(100003);
    xdr_out.writeInt(3);
    xdr_out.writeInt(6);
    xdr_out.writeInt(0);

    XDR request2 = new XDR();

    createPortmapXDRheader(xdr_out, 3);
    request2.writeInt(100003);
    request2.writeInt(3);
    request2.writeInt(6);
    request2.writeInt(0);

    testRequest(xdr_out, request2);
  }
View Full Code Here

    testRequest(xdr_out, request2);
  }
 
  static void testDump() {
    XDR xdr_out = new XDR();
    createPortmapXDRheader(xdr_out, 4);
    testRequest(xdr_out, xdr_out);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.oncrpc.XDR

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.