org.apache.hadoop.oncrpc
Class XDR

java.lang.Object
  extended by org.apache.hadoop.oncrpc.XDR

public final class XDR
extends Object

Utility class for building XDR messages based on RFC 4506. Key points of the format:


Nested Class Summary
static class XDR.State
           
 
Constructor Summary
XDR()
           
XDR(byte[] src)
          Wraps a byte array as a read-only XDR message.
XDR(ByteBuffer buf, XDR.State state)
           
XDR(int initialCapacity)
          Construct a new XDR message buffer.
 
Method Summary
 XDR asReadOnlyWrap()
           
 ByteBuffer buffer()
           
static int fragmentSize(byte[] mark)
           
 byte[] getBytes()
           
static boolean isLastFragment(byte[] mark)
           
 boolean readBoolean()
           
 byte[] readFixedOpaque(int size)
           
 long readHyper()
           
 int readInt()
           
 String readString()
           
 byte[] readVariableOpaque()
           
 int size()
           
static boolean verifyLength(XDR xdr, int len)
          check if the rest of data has more than len bytes
 void writeBoolean(boolean v)
           
 void writeFixedOpaque(byte[] src)
           
 void writeFixedOpaque(byte[] src, int length)
           
 void writeInt(int v)
           
 void writeLongAsHyper(long v)
           
static org.jboss.netty.buffer.ChannelBuffer writeMessageTcp(XDR request, boolean last)
          Write an XDR message to a TCP ChannelBuffer
static org.jboss.netty.buffer.ChannelBuffer writeMessageUdp(XDR response)
          Write an XDR message to a UDP ChannelBuffer
 void writeString(String s)
           
 void writeVariableOpaque(byte[] src)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XDR

public XDR(int initialCapacity)
Construct a new XDR message buffer.

Parameters:
initialCapacity - the initial capacity of the buffer.

XDR

public XDR()

XDR

public XDR(ByteBuffer buf,
           XDR.State state)

XDR

public XDR(byte[] src)
Wraps a byte array as a read-only XDR message. There's no copy involved, thus it is the client's responsibility to ensure that the byte array remains unmodified when using the XDR object.

Parameters:
src - the byte array to be wrapped.
Method Detail

asReadOnlyWrap

public XDR asReadOnlyWrap()

buffer

public ByteBuffer buffer()

size

public int size()

readInt

public int readInt()

writeInt

public void writeInt(int v)

readBoolean

public boolean readBoolean()

writeBoolean

public void writeBoolean(boolean v)

readHyper

public long readHyper()

writeLongAsHyper

public void writeLongAsHyper(long v)

readFixedOpaque

public byte[] readFixedOpaque(int size)

writeFixedOpaque

public void writeFixedOpaque(byte[] src,
                             int length)

writeFixedOpaque

public void writeFixedOpaque(byte[] src)

readVariableOpaque

public byte[] readVariableOpaque()

writeVariableOpaque

public void writeVariableOpaque(byte[] src)

readString

public String readString()

writeString

public void writeString(String s)

verifyLength

public static boolean verifyLength(XDR xdr,
                                   int len)
check if the rest of data has more than len bytes


writeMessageTcp

public static org.jboss.netty.buffer.ChannelBuffer writeMessageTcp(XDR request,
                                                                   boolean last)
Write an XDR message to a TCP ChannelBuffer


writeMessageUdp

public static org.jboss.netty.buffer.ChannelBuffer writeMessageUdp(XDR response)
Write an XDR message to a UDP ChannelBuffer


fragmentSize

public static int fragmentSize(byte[] mark)

isLastFragment

public static boolean isLastFragment(byte[] mark)

getBytes

public byte[] getBytes()


Copyright © 2014 Apache Software Foundation. All Rights Reserved.