org.apache.avro.ipc
Class Responder

java.lang.Object
  extended by org.apache.avro.ipc.Responder
Direct Known Subclasses:
GenericResponder

public abstract class Responder
extends Object

Base class for the server side of a protocol interaction.


Field Summary
protected  List<RPCPlugin> rpcMetaPlugins
           
 
Constructor Summary
protected Responder(Protocol local)
           
 
Method Summary
 void addRPCPlugin(RPCPlugin plugin)
          Adds a new plugin to manipulate per-call metadata.
 Protocol getLocal()
          Return the local protocol.
static Protocol getRemote()
          Return the remote protocol.
abstract  Object readRequest(Schema actual, Schema expected, Decoder in)
          Reads a request message.
 List<ByteBuffer> respond(List<ByteBuffer> buffers)
          Called by a server to deserialize a request, compute and serialize a response or error.
 List<ByteBuffer> respond(List<ByteBuffer> buffers, Transceiver connection)
          Called by a server to deserialize a request, compute and serialize a response or error.
abstract  Object respond(Protocol.Message message, Object request)
          Computes the response for a message.
abstract  void writeError(Schema schema, Object error, Encoder out)
          Writes an error message.
abstract  void writeResponse(Schema schema, Object response, Encoder out)
          Writes a response message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rpcMetaPlugins

protected final List<RPCPlugin> rpcMetaPlugins
Constructor Detail

Responder

protected Responder(Protocol local)
Method Detail

getRemote

public static Protocol getRemote()
Return the remote protocol. Accesses a ThreadLocal that's set around calls to respond(Protocol.Message, Object).


getLocal

public Protocol getLocal()
Return the local protocol.


addRPCPlugin

public void addRPCPlugin(RPCPlugin plugin)
Adds a new plugin to manipulate per-call metadata. Plugins are executed in the order that they are added.

Parameters:
plugin - a plugin that will manipulate RPC metadata

respond

public List<ByteBuffer> respond(List<ByteBuffer> buffers)
                         throws IOException
Called by a server to deserialize a request, compute and serialize a response or error.

Throws:
IOException

respond

public List<ByteBuffer> respond(List<ByteBuffer> buffers,
                                Transceiver connection)
                         throws IOException
Called by a server to deserialize a request, compute and serialize a response or error. Transciever is used by connection-based servers to track handshake status of connection.

Throws:
IOException

respond

public abstract Object respond(Protocol.Message message,
                               Object request)
                        throws Exception
Computes the response for a message.

Throws:
Exception

readRequest

public abstract Object readRequest(Schema actual,
                                   Schema expected,
                                   Decoder in)
                            throws IOException
Reads a request message.

Throws:
IOException

writeResponse

public abstract void writeResponse(Schema schema,
                                   Object response,
                                   Encoder out)
                            throws IOException
Writes a response message.

Throws:
IOException

writeError

public abstract void writeError(Schema schema,
                                Object error,
                                Encoder out)
                         throws IOException
Writes an error message.

Throws:
IOException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.