You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 27 Next »

 

Introduction

Geode is a reliable distributed data management tool. There is a demand to access Geode from various programming languages. But the existing client-server protocol is too complex to understand, and it’s not even documented. That establishes the need for a new client-server protocol.


Protocol Terms

  Any binary protocol will require following things

 
  1. Version: This indicates the API version.

  2. Request Type: This indicates API needs to invoke.

  3. Correlation Id: This helps to relate request-response.

  4. Object Type: What is the type of serialized object.

  5. Response Type: It indicates whether resposne is partial or complete.

  6. Error Handling: It indicates the problem with API invocation.

  7. Streaming support: To support the large response or continuous response.

  8. Request Format: Api request and response.

  9. Byte Order(Big Endian)

  10. Request: It indicates client's message

  11. Response: It indicates server's message.

  12. Message: Bytes which contains defined format.

Connect 

The new protocol will be integrated with current Geode server. The new client driver can connect with Geode server by sending byte “110”.

Request Type

Following table contains the request type and its corresponding id. RequestTypeId would recognize the API, which client want to invoke on the server. The request format will contain the 2-bytes(int16) for request type id. It will be marked as requestTypeId in request format.

RequestTypeRequestTypeId
MetaDataConfigRequestType1
AuthenticationRequestType 2
PutRequestType 3
GetRequestType 4
PutAllRequestType 5
GetAllRequestType 6
FunctionRequestType 7
CreateRequestType 8
InvalidateRequestType 9
DestroyRequestType 10
KeySetRequestType 11
ValuesRequestType 12
EntrySetRequestType 13
ContainsValueForKeyRequestType 14
ContainsKeyRequestType 15
ContainsValueRequestType 16
RemoveAllRequestType 17
SizeRequestType 18
PutIfAbsentRequestType 19
RemoveIfValueIsSameRequestType 20
ReplaceIfValueIsSameRequestType 21
ReplaceIfValueExistType 22

API Version

API version will be associated with request api. The request fromat will contain 1-byte for version. It will be marked as apiVerision in request format. Its current value will be 1.


Correlation Id

The purpose of correlation id to match the request and its corresponding response. The request format will contain the 4-bytes(int32) for correlation Id. It will be marked as correlationId in request format. 

Object Type

We will support all the object types which Geode understands. This would include all the java primitive types, an array of primitive types, collections, java serialization, data serializable, pdx serialization and custom user data serializers. For the purpose of the request format, we would distinguish key type and value type.

ObjectKeyType

Geode supports only few object types as the region Key. The region key will be marked as KeyObject in the request format.

ObjectValueType

All the supported Geode types can be defined as the region value. In the request format the region value will be marked as ValueObject. The ValueObject will contain the serialized bytes. We will have ability to send those bytes in chunk.

ResponseType

ReponseType will indicate that whether the response is partial or complete. A client can process a partial response.  Response with FullResponse type id will indicate the completion of that request. 

The response format will contain the 2-bytes(int16) for response type. It will be marked as FullResponse or PartialResponse in the response format.

ResponseTypeResponseTypeId
FullResponse1
PartialResponse2

 

Error Codes

Error codes indicate the issue with the invocation of API at the server. We have following error code for various issues at the server. The response format will contain the 2-bytes(int16) for error codes. It will be marked as ErrorCode in the response format.

 

Exception TypeErrorCode
AUTHENICATION_REQUIRED_EXCEPTION 1
AUTHORIZATION_FAILED_EXCEPTION 2
AUTHETICATIONFAILED_EXCEPTION 3
BUCKET_MOVED_EXCEPTION 4
SERIALIZATION_EXCEPTION 5
INTERRUPTED_EXCEPTION 6
ILLEGAL_ARGUMNET_EXCEPTION 7
ILLEGAL_STATE_EXCEPTION 8
TIMEOUT_EXCEPTION 9
CACHE_WRITER_EXCEPTION 10
REGION_EXIST_EXCEPTION 11
REGION_NOT_EXIST_EXCEPTION 12
LEASE_EXPIRED_EXCEPTION 13
CACHE_LOADER_EXCEPTION 14
REGION_DESTROYED_EXCEPTION 15
ENTRY_DESTROYED_EXCEPTION 16
ENTRY_NOT_FOUND_EXCEPTION 17
FUNCTION_NOT_FOUND_EXCEPTION 18
FUNCTION_ATTRIBUTE_MISMATCH_EXCEPTION 19
FUNCTION_EXECUTION_EXCEPTION 20
CONCURRENT_MODIFICATION_EXCEPTION 21
UNKNOWN_EXCEPTION 22
CLASS_CAST_EXCEPTION 23
GEODE_IO_EXCEPTION 24
NULL_POINTER_EXCEPTION 25
ENTRY_EXIST_EXCEPTION 26
DISK_ACCESS_EXCEPTION 27
QUERY_EXCEPTION 28
CACHE_CLOSED_EXCEPTION 29
MESSAGE_FORMAT_EXCEPTION 30
CACHE_LISTENER_EXCEPTION 31
CQ_EXCEPTION 32
CQ_CLOSED_EXCEPTION 33
CQ_QUERY_EXCEPTION 34
CQ_EXIST_EXCEPTION 35
CQ_INVALID_EXCEPTION 36
INVALID_DELTA_EXCEPTION 37
TRANSACTION_EXCEPTION 38
TRANSACTION_DATA_NODE_DEPARTED_EXCEPTION 39
TRANSACTION_REBALANCED_EXCEPTION 40
COMMIT_CONFLICT_EXCEPTION 41
PUTALL_PARTIAL_RESULT_EXCEPTION 42


Message(Framing) 

A message is series of bytes which contains request or response. If the message is large, then we need to divide the message into small messages. Then message can be sent in following way.

Message --> MessageHeader (Request | Response)
MessageHeader --> defined below
Request --> defined below
Response --> defined below

 

MessageHeader

MessageHeader --> Size PartialMessage CorrelationId
Size --> int32 (Size of request or response)
PartialMessage --> boolean (isMessageCompleted)
CorrelationId -->int32( to co-relate request and response)

 

Request Format

Request --> RequestType Version hasMetaData [MetaData] RequestAPI
RequestType --> RequestTypeId
version --> int16 (api version)
hasMetaData --> boolean (if there is any meta data associated with this request)
MetaData --> optional

RequestAPI --> (PutRequest | GetRequest | PutAllRequest | GetAllRequest)

 

Response Format

Response --> (ResponseTypeId | ErrorCode) hasMetaData [MetaData] APIResponse
ResponseTypeId --> int16(codes defined above)
ErrorCode --> int16 (codes defined above)
hasMetaData --> boolean (if there is any meta data associated with this request)
MetaData --> Optional
APIResponse –> (PutResponse | GetResponse | PutAlLRequest | GetAllRequest)

 

ValueObject

ValueObject --> Serializedbytes
Serializedbytes --> SerializedBytesHeader PartialSerializedBytes [SerializedBytesHeader PartialSerializedBytes]
SerializedBytesHeader --> Size isPartialBytes
Size --> int (Number of serialized bytes)
isPartialBytes --> boolean

ProtocolTypes

 

APIS

GetRequestResponse

PutRequestResponse

GetAllRequestResponse

PutAllRequestResponse

MetaData

Examples

 

  • No labels