com.alibaba.dubbo.rpc.protocol.thrift
Class ThriftCodec

java.lang.Object
  extended by com.alibaba.dubbo.rpc.protocol.thrift.ThriftCodec
All Implemented Interfaces:
Codec

public class ThriftCodec
extends Object
implements Codec

Thrift framed protocol codec.

 |<-                                  message header                                  ->|<- message body ->|
 +----------------+----------------------+------------------+---------------------------+------------------+
 | magic (2 bytes)|message size (4 bytes)|head size(2 bytes)| version (1 byte) | header |   message body   |
 +----------------+----------------------+------------------+---------------------------+------------------+
 |<-                                               message size                                          ->|
 

header fields in version 1

  1. string - service name
  2. long - dubbo request id

Author:
gang.lvg

Field Summary
static short MAGIC
           
static int MESSAGE_HEADER_LENGTH_INDEX
           
static int MESSAGE_LENGTH_INDEX
           
static int MESSAGE_SHORTEST_LENGTH
           
static String NAME
           
static String PARAMETER_CLASS_NAME_GENERATOR
           
static byte VERSION
           
 
Fields inherited from interface com.alibaba.dubbo.remoting.Codec
NEED_MORE_INPUT
 
Constructor Summary
ThriftCodec()
           
 
Method Summary
 Object decode(Channel channel, InputStream input)
          Decode message.
 void encode(Channel channel, OutputStream output, Object message)
          Encode message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_LENGTH_INDEX

public static final int MESSAGE_LENGTH_INDEX
See Also:
Constant Field Values

MESSAGE_HEADER_LENGTH_INDEX

public static final int MESSAGE_HEADER_LENGTH_INDEX
See Also:
Constant Field Values

MESSAGE_SHORTEST_LENGTH

public static final int MESSAGE_SHORTEST_LENGTH
See Also:
Constant Field Values

NAME

public static final String NAME
See Also:
Constant Field Values

PARAMETER_CLASS_NAME_GENERATOR

public static final String PARAMETER_CLASS_NAME_GENERATOR
See Also:
Constant Field Values

VERSION

public static final byte VERSION
See Also:
Constant Field Values

MAGIC

public static final short MAGIC
See Also:
Constant Field Values
Constructor Detail

ThriftCodec

public ThriftCodec()
Method Detail

encode

public void encode(Channel channel,
                   OutputStream output,
                   Object message)
            throws IOException
Description copied from interface: Codec
Encode message.

Specified by:
encode in interface Codec
Parameters:
channel - channel.
output - output stream.
message - message.
Throws:
IOException

decode

public Object decode(Channel channel,
                     InputStream input)
              throws IOException
Description copied from interface: Codec
Decode message.

Specified by:
decode in interface Codec
Parameters:
channel - channel.
input - input stream.
Returns:
message or NEED_MORE_INPUT poison.
Throws:
IOException
See Also:
Codec.NEED_MORE_INPUT


Copyright © 2012 Alibaba. All Rights Reserved.