Table of Contents
...
Protocol negotiation
In order to fit into the existing Geode client/server infrastructure, we will be leveraging the current Geode "cache server" component. It accepts an initial byte that tells it what type of client is connecting to the server and how the client should be handled. A client using the new protocol can connect with the Geode server by sending a protocol byte. Initially, we will support the following two protocols:
...
We may add additional protocol definitions here to indicate the use of an alternative serialization mechanism. For instance bytes 112 & 113 might indicate the but require the server to use Protobuf for serialization of client/server messages. How we handle other serialization libraries will be addressed when the pluggable-serialization architecture is roughed out.
Protocol FieldDefinitions
API Id
The ApiId recognizes the API, a client wants to invoke on the server. The request format will contain the 2-byte(int16) for API id. It will be marked as ApiId in the request format.
API Version
API version will be associated with the request API. The request format will contain a 1-byte(int8) for the version. It will be marked as ApiVersion in the 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 the request and response format. The client needs to send correlation id with the request and server will send the same id with the response.
Object Type
We will support all the object types which Geode understands. This would include all the primitive java types, an array of primitive types, collections, java serialization, data serializable, PDX serialization and custom user data serializers. The client needs to serialize objects as described here. This might be extended as part of making the Geode storage format pluggable.
ObjectKeyType
Geode supports only few object types as the region Key. The region key will be marked as Key in the request format. the client needs to serialize key as described here.
ResponseType
The Response Type indicates whether the response is partial or complete. The response with the FullResponse type id indicates the completion of that request. And the response with PartialResponse type id indicates the response is partial. The response format will contain the 2-bytes(int16) for response type. It will be marked as ResponseTypeId in the response format.
ResponseType | ResponseTypeId |
---|---|
FullResponse | 1 |
PartialResponse | 2 |
Error Codes
The Error codes indicate the issue with the invocation of API at the server. We have defined the error code for various issues here. The response format will contain the 2-bytes(int16) for error codes. It will be marked as ErrorCode in the response format.
Data Type Definitions
The protocol descriptions use the following types. These may be mapped to a pluggable serialization description language but their native serialization is described here. The native serialization uses network byte order ("big-endian").
Type | Number Of Bytes | Value | SerializedBytes |
---|---|---|---|
boolean | Fixed = 1 | true | 0x01 |
boolean | Fixed = 1 | false | 0x00 |
int8 | Fixed = 1 | 1 | 0x01 |
int16 | Fixed = 2 | 1 | 0x00 0x01 |
int32 | Fixed = 4 | 1 | 0x00 0x00 0x00 0x01 |
int64 | Fixed = 8 | 1 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 |
String(modified UTF 8 ) | Variable
| "Geode" | 0x00 0x05 (length) 0x47 0x65 0x6f 0x64 0x65 (utf encoding) |
byte[] | Variable
| {1,2} | 0x00 0x02 (length) 0x01 0x02 |
bytes | Variable: series of bytes containing a serialized value. |
Field Definitions
Understanding the message definitions it is advised that one references the Protocol Field Definitions page and Supported Data Type Definitions.
Message Definition
A message is a series of bytes which contains the request or response. If the message is large, then we will have provision to divide the message into small messages. In that case, client/server needs to collect all messages to parse the request/response.
...
ResponseHeader => ResponseTypeId | ErrorCode | Description | |
---|---|---|
ResponseTypeId | fixedSize = 2 bytes, type = int16 | The ResponeTypeId corresponding to either a Full or Partial message |
ErrorCode | fixedSize = 2 bytes, type = int16 | When there is error response will have error message(String) for itThe error code for the error that occurred. A list of error codes can be found on the page Error Codes |
ErrorResponse
The server will raise the error when it failed to execute API request from the client. The error code and message should help the client to diagnose the issue.
ErrorResponse => errorMessage | Description | |
---|---|---|
errorMessage | variable size, type = String | The errorMessageerror message |
Value
The Value is serialized bytes for the Geode region value. It contains value header and series of bytes. Using value header, we can send a big serialized object in more than one chunk.
...