Versions Compared

Key

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

...

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;

    @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;
    }
}

Introduce Communication Protocol Version (ProtoVer) that depends on changes in the parts:

  • Version is Major.Minor, initial 1.0.
  • Minor version is upgraded by adding new fields in any Message. Version is updated along with a commit that introduce a change.
  • Major version is upgraded by breaking changes in protocol (changes in handshake or ser/des algorithm, adding new Message).

Rules to support compatibility:


Rules to describe Message (must be automated and validated):

  1. Do not remove Message class or Message fields, but annotate it with @Until
  2. Do not change types or order of fields.
  3. New fields must be annotated with @Since. All such fields must be optional, default value is null. Handling the nulls is care of Message consumer on the reader side.

Removing annotated entities is allowed after current version is greater than (@Until + 1) or (@Since + 1).

Transport compatibility 

  1. Changes to communication transport must be tracked with FeatureTable
  2. Every such a feature must be annotated with @Since Ignite version. This is required to track all affected places, and for removing the compatible code after Ignite version becomes greater than (@Since + 1)
  3. It's prohibited to remove fields, change types of fields in Messages. Only adding new fields is allowed.
  4. Breaking changes are introduced as communication features (FeatureTable).Every communication feature must be declared with @since Ignite version.
  5. Ignite release must disable a communication feature with Ignite node with (@since - 1) version. 

    1. On release Ignite should check the @since version and notify release manager to drop support of old versions.

...