Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
IDIEP-9
AuthorPavel Tupitsyn
SponsorPavel Tupitsyn
Created20-NOV-2017
Status
Status
colourGreyGreen
titleDRAFTCOMPLETED


Table of Contents

Info

This page includes low-level protocol documentation that might be outdated and is not maintained. Refer to the official protocol documentation here: https://apacheignite.readme.io/docs/binary-client-protocol

Motivation

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

...

NameType CodeSize (bytes)
byte11
short22
int34
long48
float54
double68
char72
bool81
string94 bytes length + length * 2Utf8 byte count + Utf8 bytes
UUID (Guid)1016
date118 (milliseconds from 1 Jan 1970)
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. Nulls (byte 101) are allowed.
UUID (Guid) array214 bytes length + length * 16. Nulls (byte 101) are allowed.
date array224 bytes length + length * 8. Nulls (byte 101) are allowed.
object array234 bytes length + 4 bytes element type id + variable size binary objects
map254 bytes length + byte type (1 = HASH_MAP, 2 = LINKED_HASH_MAP) + length * (BinaryObject + BinaryObject)
NULL1010

...

Header
byteObject type code, always 103
byteVersion, always 1
shortFlags, USER_TYPE = 1, HAS_SCHEMA = 2
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
intSchema offset from the header start, position where fields end
BinaryObject * nFields
(int + int) * nSchema, fieldId (Java-style hash of field name) + offset (from header start)

 

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

Wrapped Binary Objects

One ore more binary objects can be wrapped in an array. This allows reading, storing, passing and writing objects efficiently without understanding their contents, performing simple byte copy.

All cache operations return complex objects inside a wrapper (but not primitives).

byteType code, always 27
intByte array size
n bytesPayload
intOffset of the object within array (array can contain an object graph, this offset points to the root object)

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 Length is omitted in all message descriptions below for brevity.

...

Response
BinaryObjectvalue

 

Cache flags

GET and all other cache operations include flags byte.

1KEEP_BINARY

Indicates wether IgniteCache.withKeepBinary should be called on the server side.

This flag has effect only for OP_QUERY_SCAN when Java filter is used.

Other operations ignore the flag and call withKeepBinary anyway.

 

 

OP_OP_CACHE_GET_ALL = 1003

Retrieves multiple values from cache given multiple keys. 

...

Request
intCache ID: Java-style hash code of the cache name
Response
CacheConfigurationSee below

Cache configuration is sent and received by server in the following format:

Response
CacheConfigurationSee below

Cache configuration is sent by server in the following format:

CacheConfiguration
intLength of the configuration, in bytes
intCacheAtomicityMode, TRANSACTIONAL = 0, ATOMIC = 1
intBackups
intCacheMode, LOCAL = 0, REPLICATED = 1, PARTITIONED = 2
boolCopyOnRead
stringDataRegionName
boolEagerTtl
boolStatisticsEnabled
stringGroupName
longDefaultLockTimeout (milliseconds)
intMaxConcurrentAsyncOperations
intMaxQueryIterators
stringName
boolIsOnheapcacheEnabled
intPartitionLossPolicy, READ_ONLY_SAFE = 0, READ_ONLY_ALL = 1, READ_WRITE_SAFE = 2, READ_WRITE_ALL = 3, IGNORE = 4
intQueryDetailMetricsSize
intQueryParallelism
boolReadFromBackup
intRebalanceBatchSize
longRebalanceBatchesPrefetchCount
longRebalanceDelay (milliseconds)
intRebalanceMode, SYNC = 0, ASYNC = 1, NONE = 2
intRebalanceOrder
longRebalanceThrottle (milliseconds)
longRebalanceTimeout (milliseconds)
boolSqlEscapeAll
intSqlIndexInlineMaxSize
stringSqlSchema
intWriteSynchronizationMode, FULL_SYNC = 0, FULL_ASYNC = 1, PRIMARY_SYNC = 2
intCacheKeyConfiguration count
CacheKeyConfiguration * count
CacheKeyConfiguration
stringType name
stringAffinity key field name
intQueryEntity count
QueryEntity * count
QueryEntity
stringKey type name
stringValue type name
stringTable name
stringKey field name
stringValue field name
intQueryField count
QueryField * count
QueryField
stringName
stringType name
boolIs key field
boolIs NotNull constraint field
intAlias count
(string + string) * countField name aliases
intQueryIndex count
QueryIndex * count
QueryIndex
stringIndex name
byteIndex type, SORTED = 0, FULLTEXT = 1, GEOSPATIAL = 2
intInline size
intField count
(string + bool) * countFields (name + IsDescensing)


 

OP_CACHE_CREATE_WITH_CONFIGURATION = 1053

Creates cache with provided configuration. Throws an exception if the name is already in use. 

Request
intLength of the configuration, in bytes
shortNumber of configuration properties
(short + ...) * nConfiguration property data

Any number of configuration properties can be provided. Name is required.

Cache configuration data is specified in key-value form, where key is `short` property id and value is property-specific data. Table below describes all available properties.

 

Length of the configuration, in bytes
Property codeProperty typeDescription
2
CacheConfiguration
intintCacheAtomicityMode, TRANSACTIONAL = 0, ATOMIC = 1
3intBackups
1intCacheMode, LOCAL = 0, REPLICATED = 1, PARTITIONED = 2
5boolCopyOnRead
100stringDataRegionName
405boolEagerTtl
406boolStatisticsEnabled
400stringGroupName
bool402invalidatelongDefaultLockTimeout (milliseconds)
403intMaxConcurrentAsyncOperations
206intMaxQueryIterators
0stringName
101boolIsOnheapcacheEnabled
404intPartitionLossPolicy, READ_ONLY_SAFE = 0, READ_ONLY_ALL = 1, READ_WRITE_SAFE = 2, READ_WRITE_ALL = 3, IGNORE = 4
202intQueryDetailMetricsSize
201intQueryParallelism
6boolReadFromBackup
303intRebalanceBatchSize
304longRebalanceBatchesPrefetchCount
301longRebalanceDelay (milliseconds)
300intRebalanceMode, SYNC = 0, ASYNC = 1, NONE = 2
305intRebalanceOrder
306longRebalanceThrottle (milliseconds)
302longRebalanceTimeout (milliseconds)
205boolSqlEscapeAll
204intSqlIndexInlineMaxSize
203stringSqlSchema
4intWriteSynchronizationMode, FULL_SYNC = 0, FULL_ASYNC = 1, PRIMARY_SYNC = 2
401int + CacheKeyConfiguration * count

CacheKeyConfiguration

*

count

CacheKeyConfiguration
stringType name
stringAffinity key field name
200int + QueryEntity countQueryEntity * count
QueryEntity
stringKey type name
stringValue type name
stringTable name
stringKey field name
stringValue field name
intQueryField count
QueryField * count
QueryField
stringName
stringType name
boolIs key field
boolIs NotNull constraint field
intAlias count
(string + string) * countField name aliases
intQueryIndex count
QueryIndex * count
QueryIndex
stringIndex name
byteIndex type, SORTED = 0, FULLTEXT = 1, GEOSPATIAL = 2
intInline size
intField count
(string + bool) * countFields (name + IsDescensing)

...

OP_CACHE_CREATE_WITH_CONFIGURATION = 1053

Creates cache with provided configuration. Throws an exception if the name is already in use. 

Request
CacheConfigurationCache config (see format above)




Empty response.


 

OP_CACHE_GET_OR_CREATE_WITH_CONFIGURATION = 1054

Creates cache with provided configuration. Does nothing if the name is already in use.  

Request
CacheConfigurationCache config (see format above)

 Same request format as above. Empty response.


 

 

OP_QUERY_SQL = 2002

Performs SQL query. 

...

Response
bool

False: binary type does not exist, response end.

True: binary type exists, response as follows.

intType id
stringType name
stringAffinity key field name
intBinaryField count
BinaryField * count
BinaryField
stringField name
intType id
intField id
boolIs enum
int (if isEnum)Enum field count
(string + int) * count (if isEnum)Enum values
intSchema count
(int + int[](schema id) + int (field count) + int (field id) * n) * countBinary schemas, set of (schemaId + fieldIds) pairs

...

Request
intType id
stringType name
stringAffinity key field name
intBinaryField count
BinaryField * count
BinaryField
stringField name
intType id
intField id
boolIs enum
int (if isEnum)Enum field count
(string + int) * count (if isEnum)Enum values
intSchema count
(int (schema id) + int (field count) + int [](field id) * n) * countBinary schemas, set of (schemaId + fieldIds) pairs

...

Request
intCache ID: Java-style hash code of the cache name
BinaryObjectFilter object
byte (if filter object is not null)Filter platform, JAVA = 1, DOTNET = 2, CPP = 3
intCursor page size
intPartition to query (negative to query entire cache)
boolLocal flag
cache)
boolLocal flag
Response
longCursor id
intRow count for the first page
(Object + Object) * countCache entries, key + value

bool

Indicates whether more results are available to be fetched with OP_QUERY_SCAN_CURSOR_GET_PAGE
Response
longCursor id

 


OP_QUERY_SCAN_CURSOR_GET_PAGE = 2001

...

Tickets

See "thin client" component in JIRA

...