Versions Compared

Key

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

Goal is a communication protocol that able to work between nodes with different Ignite versions.

Prerequisites:

  1. It is proposed to

...

  1. provide compatibility between versions that differ by 1 minor version, for example between 2.20.X

...

  1. and 2.19.X (but not between 2.20.X and 2.18.X).
  2. Peers are aware of messages schemas (Message class). Older versions aren't aware of new fields only.
  3. Schema changes are rare.
  4. Code changes should be minimal.

Communication protocol

Communication protocol consist of 2 parts:

...

Code Block
languagejava
titleMyMessage
@Since(version = "2.19.0")
public class MyMessage {
    private int id;
    
    @Until(version = "2.20.0")
    private String rmFld;

    @Since(version = "2.20.0")
    private String newFld;

    // Generated code from the schema ^.

    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer, IgniteProductVersion destVer) {
        if (destVer.lessThan(2, 19, 0))
            throw new IgniteException("Must not send the message to destination node");

        if (!writer.writeString(id))
            return false;

        if (destVer.lessThan(2, 20, 0)) {
            if (!writer.writeString(rmFld))
                return false;
        }

        if (destVer.greaterThanEqual(2, 20, 0)) {
            if (!writer.writeString(newFld))
                return false;
        }

        return true;
    }

    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader, IgniteProductVersion srcVer) {
        id = reader.readString();

        if (srcVer.greaterThanEqual(2, 20, 0))
            newFld = reader.readString();
        else
            newFld = null;

        return true;
    }
}

...