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

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

public class ThriftCodec
extends Object
implements Codec2

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.alibaba.dubbo.remoting.Codec2
Codec2.DecodeResult
 
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
           
 
Constructor Summary
ThriftCodec()
           
 
Method Summary
 Object decode(Channel channel, ChannelBuffer buffer)
           
 void encode(Channel channel, ChannelBuffer buffer, Object 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,
                   ChannelBuffer buffer,
                   Object message)
            throws IOException
Specified by:
encode in interface Codec2
Throws:
IOException

decode

public Object decode(Channel channel,
                     ChannelBuffer buffer)
              throws IOException
Specified by:
decode in interface Codec2
Throws:
IOException


Copyright © 2012–2017 Alibaba. All rights reserved.