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

Compare with Current View Page History

« Previous Version 20 Next »

IDIEP-9
AuthorPavel Tupitsyn
SponsorPavel Tupitsyn
Created20-NOV-2017
StatusDRAFT


Motivation

Implement thin Ignite client in any programming language / platform using a well-defined binary connectiona protocol.

"Thin" here means that we do not start an Ignite node in order to communicate with the cluster, we do not implement discovery/communication spi logic, as opposed to currently available Ignite Client Mode.

Description

TCP Socket

Every Ignite node listens on a TCP port. Thin client implementations connect to any node in the cluster through TCP socket and perform Ignite operations using a well-defined binary protocol.

Server-side connection parameters are defined in ClientConnectorConfiguration class. Default port is 10800. Connector is enabled by default, no configuration changes needed.

Data Format

Byte order is little-endian. Strings are UTF-8 with int prefix (no null terminator). All data types in this proposal are Java-like (byte = 8 bits, short = 2 bytes, int = 4 bytes, long = 8 bytes).

Binary Objects

User data, such as cache keys and values, is represented in Ignite Binary Object format. Binary Object can be a primitive (predefined type) or a complex object.

Primitives (predefined types)

Primitives are represented as a type code + value:

byteType code
...Value

Available primitives are listed below:

NameType CodeSize (bytes)
byte11
short22
int34
long48
float54
double68
char72
bool81
string94 bytes length + length * 2
UUID (Guid)108
date118
byte array124 bytes length + length
short array134 bytes length + length * 2
int array144 bytes length + length * 4
long array154 bytes length + length * 8
float array164 bytes length + length * 4
double array174 bytes length + length * 8
char array184 bytes length + length * 2
bool array194 bytes length + length
string array204 bytes length + variable length strings, see above
UUID (Guid) array214 bytes length + length * 8
date array224 bytes length + length * 8
NULL1010


Complex Objects

Complex objects consist of a 24-byte header and a set of fields (key-value pairs).

Header
byteObject type code, always 103
byteVersion, always 1
shortFlags, see below
intType id, Java-style hash code of the type name
intHash code, Java-style hash of contents without header, necessary for comparisons
intLength, including header
intSchema Id, see below
intSchemaOffset, see below

 

Message format

All messages, request and response, including handshake, start with int message length (excluding these first 4 bytes). E.g. empty message would be represented by 4 zero bytes.

intLength of Payload
...Payload

Length is omitted in all message descriptions below for brevity.

Handshake

The first message upon connection establishment must be a handshake. Handshake ensures that client and server versions are compatible.

Request
byteHandshake code, always 1
shortVersion major
shortVersion minor
shortVersion patch
byte

Client code, always 2

Response (success)
byteSuccess flag, 1
Response (failure)
byteSuccess flag, 0
shortServer version major
shortServer version minor
shortServer version patch
stringError message

Client Operations

 Upon successful handshake client can start performing operations by sending a request with specific op code. Each operation has it's own request and response format, with a common header.

Request
shortOperation code
longRequest id, generated by client and returned as-is in response
...Operation-specific data
Response
longRequest id (see above)
intStatus code (0 for success, otherwise error code)
stringError message (present only when status is not 0)
...Operation-specific data

Operation codes and request ids are omitted everywhere below for brevity.


OP_CACHE_GET = 1

Request
int
Cache ID: Java-style hash code of the cache name
byteflags
BinaryObjectkey
Response
BinaryObjectvalue

 

OP_CACHE_GET_ALL = 12

 

Request
int
Cache ID: Java-style hash code of the cache name
byteflags
intkey count
BinaryObject * countkeys
Response
intresult count
(BinaryObject + BinaryObject) * countResulting key-value pairs. Keys that are not present in the cache are not included.

 

OP_CACHE_PUT = 4 

Request
int
Cache ID: Java-style hash code of the cache name
byteflags
BinaryObjectkey
BinaryObjectvalue

 

OP_CACHE_PUT_ALL = 20

Request
int
Cache ID: Java-style hash code of the cache name
byteflags
intKey-value pair count
(BinaryObject + BinaryObject) * countKey-value pairs



OP_CACHE_CONTAINS_KEY = 10

Request
int
Cache ID: Java-style hash code of the cache name
byteflags
BinaryObjectkey
Response
boolTrue when key is present, false otherwise

 

OP_CACHE_CONTAINS_KEYS = 11

Request
int
Cache ID: Java-style hash code of the cache name
byteflags
intkey count
BinaryObject * countkeys
Response
boolTrue when keys are present, false otherwise

 

 

Message Exchange Example

Let's see how request and response would look for a cache.get operation for integer key and value:

TODO

Discussion Links

http://apache-ignite-developers.2346864.n4.nabble.com/Thin-client-protocol-message-format-td20300.html

Reference Links

Similar protocols from other vendors:

Tickets

See "thin client" component in JIRA

type key summary assignee reporter priority status resolution created updated due

JQL and issue key arguments for this macro require at least one Jira application link to be configured

  • No labels