Package org.apache.avro.ipc

# Class RPCContext

java.lang.Object
org.apache.avro.ipc.RPCContext

public class RPCContext extends Object
This class represents the context of an RPC call or RPC handshake. Designed to provide information to RPC plugin writers, this class encapsulates information about the rpc exchange, including handshake and call metadata. Note: this data includes full copies of the RPC payload, so plugins which store RPCContexts beyond the life of each call should be conscious of memory use.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Exception`
`error`
`protected Map<String,ByteBuffer>`
`requestCallMeta`
`protected Object`
`response`
`protected Map<String,ByteBuffer>`
`responseCallMeta`

## Constructor Summary

Constructors
Constructor
Description
`RPCContext()`

## Method Summary

Modifier and Type
Method
Description
`Exception`
`error()`
The exception generated at the server, or null if no such exception has occurred
`HandshakeRequest`
`getHandshakeRequest()`
Get the handshake request of this RPC.
`HandshakeResponse`
`getHandshakeResponse()`
Get the handshake response of this RPC.
`org.apache.avro.Protocol.Message`
`getMessage()`
Returns the `Protocol.Message` corresponding to this RPC
`List<ByteBuffer>`
`getRequestPayload()`
Returns the serialized payload of the request in this RPC.
`List<ByteBuffer>`
`getResponsePayload()`
Returns the serialized payload of the response in this RPC.
`boolean`
`isError()`
Indicates whether an exception was generated at the server
`Map<String,ByteBuffer>`
`requestCallMeta()`
This is an access method for the per-call state provided by the client to the server.
`Map<String,ByteBuffer>`
`requestHandshakeMeta()`
This is an access method for the handshake state provided by the client to the server.
`Object`
`response()`
The response object generated at the server, if it exists.
`Map<String,ByteBuffer>`
`responseCallMeta()`
This is an access method for the per-call state provided by the server back to the client.
`Map<String,ByteBuffer>`
`responseHandshakeMeta()`
This is an access method for the handshake state provided by the server back to the client
`void`
`setHandshakeRequest(HandshakeRequest handshakeRequest)`
Set the handshake request of this RPC.
`void`
`setHandshakeResponse(HandshakeResponse handshakeResponse)`
Set the handshake response of this RPC.
`void`
`setMessage(org.apache.avro.Protocol.Message message)`
Sets the `Protocol.Message` corresponding to this RPC
`void`
`setRequestPayload(List<ByteBuffer> payload)`
Sets the serialized payload of the request in this RPC.
`void`
`setResponsePayload(List<ByteBuffer> payload)`
Sets the serialized payload of the response in this RPC.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### requestCallMeta

protected Map<String,ByteBuffer> requestCallMeta

### responseCallMeta

protected Map<String,ByteBuffer> responseCallMeta

### response

protected Object response

### error

protected Exception error

## Constructor Details

### RPCContext

public RPCContext()

## Method Details

### setHandshakeRequest

public void setHandshakeRequest(HandshakeRequest handshakeRequest)
Set the handshake request of this RPC.

### getHandshakeRequest

public HandshakeRequest getHandshakeRequest()
Get the handshake request of this RPC.

### setHandshakeResponse

public void setHandshakeResponse(HandshakeResponse handshakeResponse)
Set the handshake response of this RPC.

### getHandshakeResponse

public HandshakeResponse getHandshakeResponse()
Get the handshake response of this RPC.

### requestHandshakeMeta

public Map<String,ByteBuffer> requestHandshakeMeta()
This is an access method for the handshake state provided by the client to the server.

Returns:
  a map representing handshake state from the client to the server

### responseHandshakeMeta

public Map<String,ByteBuffer> responseHandshakeMeta()
This is an access method for the handshake state provided by the server back to the client

Returns:
  a map representing handshake state from the server to the client

### requestCallMeta

public Map<String,ByteBuffer> requestCallMeta()
This is an access method for the per-call state provided by the client to the server.

Returns:
  a map representing per-call state from the client to the server

### responseCallMeta

public Map<String,ByteBuffer> responseCallMeta()
This is an access method for the per-call state provided by the server back to the client.

Returns:
  a map representing per-call state from the server to the client

### response

public Object response()
The response object generated at the server, if it exists. If an exception was generated, this will be null.

Returns:
  the response created by this RPC, no null if an exception was generated

### error

public Exception error()
The exception generated at the server, or null if no such exception has occurred

Returns:
  the exception generated at the server, or null if no such exception

### isError

public boolean isError()
Indicates whether an exception was generated at the server

Returns:
  true is an exception was generated at the server, or false if not

### setMessage

public void setMessage(org.apache.avro.Protocol.Message message)
Sets the `Protocol.Message` corresponding to this RPC

### getMessage

public org.apache.avro.Protocol.Message getMessage()
Returns the `Protocol.Message` corresponding to this RPC

Returns:
  this RPC's `Protocol.Message`

### setRequestPayload

public void setRequestPayload(List<ByteBuffer> payload)
Sets the serialized payload of the request in this RPC. Will not include handshake or meta-data.

### getRequestPayload

public List<ByteBuffer> getRequestPayload()
Returns the serialized payload of the request in this RPC. Will only be generated from a Requestor and will not include handshake or meta-data. If the request payload has not been set yet, returns null.

Returns:
  this RPC's request payload.

### getResponsePayload

public List<ByteBuffer> getResponsePayload()
Returns the serialized payload of the response in this RPC. Will only be generated from a Responder and will not include handshake or meta-data. If the response payload has not been set yet, returns null.

Returns:
  this RPC's response payload.

### setResponsePayload

public void setResponsePayload(List<ByteBuffer> payload)
Sets the serialized payload of the response in this RPC. Will not include handshake or meta-data.