Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

IDIEP-76
Author
Sponsor
Created

  

Status

Status
colourGreen
titleACtIVE


Table of Contents

Motivation

Thin client protocol will be the primary way to interact with Ignite 3.0 from code.

Description

Adapt Ignite 2.x protocol for Ignite 3.0. The main differences are:

TCP Socket

  • Every Ignite node listens on a TCP port. Thin client implementations connect to any node in the cluster (possibly multiple nodes) through a 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 are needed.
  • Netty is used on the server for network IO.

Data Format

MsgPack is used for data serialization (uses big-endian byte order).

Data Types Mapping

Ignite data types defined in IEP-54 map to MsgPack data types the following way:

...

"Extension X" is a MsgPack extension type (up to 128 extension types are allowed).

Integer data types, varint encoding

MsgPack provides multiple data types for integer values. When encoding a value, the smallest data type for that value is picked automatically.

"int" is used below to denote int format family. Values such as payload size, request ID, error codes, are encoded this way - using variable number of bytes based on the value.

Message format

All messages, requests and responses, except handshake, start with a 4-byte message length (excluding the length itself).

...

4 bytes Length of Payload
...Payload

Tuple serialization

  • This IEP covers Table API - Ignite#tables(), which is the only public API available at the moment.
  • Table API operates on tuples (Tuple and TupleBuilder interfaces).
  • Tuple is a set of key-value pairs - column name and value.
  • Values can be of basic types described above and in IEP-54, according to the table schema. 
  • Table schema can evolve over time, columns get added and removed. Ignite tracks the evolution with incrementing integer schema version.
  • All schema versions are stored by Ignite. It is possible to retrieve the set of columns for any version.

...

Code Block
languagejava
titleTuple serialization (pseudocode)
for (Column col : tuple) {
	switch (col.type().spec()) {
    	case BYTE:
        	packer.packByte(tuple.byteValue(col.name()));
	        break;
	    case SHORT:
...

Key tuples

Key tuples are tuples with key columns only. Key columns always come first in the schema. So if there are 2 key columns, first two values of the tuple is the key.

Null vs NoValue

Ignite Table API handles "column set to null" (1) and "column not set" (2) differently.

...

NoValue custom protocol type reflects this distinction.

Handshake


Request
4 bytesMagic number 49 47 4E 49, or "IGNI". Helps to identify misconfigured SSL or other apps probing the port.
intPayload length
intVersion major
intVersion minor
intVersion patch
intClient code (1 for JDBC, 2 for general-purpose client)
binFeatures (bitmask)
map (string → any)Extensions (auth, attributes, etc). Server can skip unknown extension data (when client is newer).

...

Response
4 bytesMagic number 49 47 4E 49, or "IGNI". Helps to identify misconfigured SSL or different server on the port.
intPayload length
intServer version major
intServer version minor
intServer version patch
intError code (0 for success)
stringError message (when error code is not 0)
intWhen error code is 0: Server idle timeout
stringWhen error code is 0: Server node id
string When error code is 0: Server node name (consistent id)
binWhen error code is 0: Server features (bitmask)
map (string → any)When error code is 0: Extensions (auth, attributes, etc). Client can skip unknown extension data (when server is newer).

Client Operations

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

...

Request or response without operation-specific data is called basic request or basic response below.

Notifications

Clients should expect notification messages at any moment after the successful handshake.

...

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

TABLES_GET = 3

Basic request.

Response
map (UUID -> string)map of table ids and names

Note: tables can only be created/deleted with SQL, there are no TABLE_CREATE or TABLE_DROP operations.

TABLE_GET = 4

Request
stringtable name


Response
UUID or niltable ID or null when a table with the given name does not exist

SCHEMAS_GET = 5

Request
UUIDtable ID
arr or nilschema IDs, or null to get latest

...

Response
map (int → array (array))Map from schema ID to columns. Column is represented by an array of values for: name, type, isKey, isNullable. The array can contain extra data in future for additional properties.

TUPLE_UPSERT = 10

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for all columns in given schema (nil when value is missing for a column)

...

  • If columns don't match, request the latest schema and try again.
  • If the latest schema still does not match, and live schema is enabled, use TUPLE_UPSERT_SCHEMALESS

TUPLE_GET = 12

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for key columns (in schema order)

...

Clients should retrieve schemas with SCHEMAS_GET and cache them per table.

TUPLE_UPSERT_ALL = 13

Request
UUIDtable ID
int or niltransaction ID
intschema ID
introw count
valuesrows with values for all columns in given schema (nil when value is missing for a column)

Basic response.

TUPLE_GET_ALL = 15

Request
UUIDtable ID
int or niltransaction ID
intschema ID, or nil when result set is empty
introw count
valuesarray of rows with values for key columns (in schema order)

...

Response
intschema ID (for all tuples in response)
introw count
valuesrows with values in schema order

TUPLE_GET_AND_UPSERT = 16

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for all columns in given schema (nil when value is missing for a column)

...

Response
int or nilschema id for the current tuple, or nil when there is no matching record
valuesvalues for value columns in schema order

TUPLE_INSERT = 18

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for all columns in given schema (nil when value is missing for a column)

...

Response
boolInsert result

TUPLE_INSERT_ALL = 20

Request
UUIDtable ID
int or niltransaction ID
intschema ID
introw count
valuesrows with values for all columns in given schema (nil when value is missing for a column)

...

Response
intschema id, or nil when no rows were skipped
intskipped row count
valuesskipped rows (values in schema order)

TUPLE_REPLACE = 22

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for all columns in given schema (nil when value is missing for a column)

...

Response
boolReplace result

TUPLE_REPLACE_EXACT = 24

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesoldRec: values for all columns in given schema (nil when value is missing for a column)
valuesnewRec: values for all columns in given schema (nil when value is missing for a column)

...

Response
boolReplace result

TUPLE_GET_AND_REPLACE = 26

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for all columns in given schema (nil when value is missing for a column)

...

Response
int or nilschema id for the current tuple, or nil when there is no matching record
valuesvalues for value columns in schema order

TUPLE_DELETE = 28

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for key columns in given schema

...

Response
boolDelete result

TUPLE_DELETE_ALL = 29

Request
UUIDtable ID
int or niltransaction ID
intschema ID
introw count
valuesrows with values for key columns in a given schema

...

Response
intschema id, or nil when no rows were skipped
intskipped row count
valuesskipped rows (values for key columns in schema order)


TUPLE_DELETE_EXACT = 30

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for all columns in given schema (nil when value is missing for a column)

...

Response
boolDelete result

TUPLE_DELETE_ALL_EXACT = 31

Request
UUIDtable ID
int or niltransaction ID
intschema ID
introw count
valuesrows with values for all columns in given schema (nil when value is missing for a column)

...

Response
intschema id, or nil when no rows were skipped
intskipped row count
valuesskipped rows (values for key columns in schema order)

TUPLE_GET_AND_DELETE = 32

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for all columns in given schema (nil when value is missing for a column)

...

Response
int or nilschema id for the current tuple, or nil when there is no matching record
valuesvalues for value columns in schema order, when schema id is not null

TUPLE_CONTAINS_KEY = 33

Request
UUIDtable ID
int or niltransaction ID
intschema ID
valuesvalues for key columns

...

Response
boolwhether a tuple with the given key exists

TX_BEGIN = 43

Request
boolRead-only tx flag
longObservable timestamp (value from server - see standard response header)

...

Response
intTransaction ID

TX_COMMIT = 44

Request
intTransaction ID

Basic response

TX_ROLLBACK = 45

Request
intTransaction ID

Basic response

Risks and Assumptions

  • This IEP covers handshake and Tables API, which is the only public API available at the moment.
  • Invoke API is out of scope: code deployment and processor serialization should be designed separately.

Discussion Links

Reference Links

Tickets

Jira
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
maximumIssues20
jqlQuerylabels=iep-76
serverId5aa69414-a9e9-3523-82ec-879b028fb15b