X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fconcepts%2FMessage.java;h=8788c0df989e248d1eddad1be62b16a46237644a;hb=cd2a6fa0d8fa6281be28d3c7b9828ecf4e932811;hp=5070b7cf71ef518b6387415f78b3d58bd40b897e;hpb=c9d61ee66367d819319bb8ccfa9f9b0555264d86;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Message.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Message.java index 5070b7cf71..8788c0df98 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Message.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Message.java @@ -23,21 +23,26 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier; * An abstract concept of a Message. This class cannot be instantiated directly, use its specializations {@link Request} * and {@link Response}. * + *

* Messages have a target and a sequence number. Sequence numbers are expected to be assigned monotonically on a * per-target basis, hence two targets can observe the same sequence number. * + *

* This class includes explicit versioning for forward- and backward- compatibility of serialization format. This is * achieved by using the serialization proxy pattern. Subclasses are in complete control of what proxy is used to * serialize a particular object on the wire. This class can serve as an explicit version marker, hence no further * action is necessary in the deserialization path. * + *

* For the serialization path an explicit call from the user is required to select the appropriate serialization * version. This is done via {@link #toVersion(ABIVersion)} method, which should return a copy of this object with * the requested ABI version recorded and should return the appropriate serialization proxy. * + *

* This workflow allows least disturbance across ABI versions, as all messages not affected by a ABI version bump * will remain working with the same serialization format for the new ABI version. * + *

* Note that this class specifies the {@link Immutable} contract, which means that all subclasses must follow this API * contract. * @@ -50,20 +55,23 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier; public abstract class Message> implements Immutable, Serializable { private static final long serialVersionUID = 1L; - private final T target; + private final ABIVersion version; + private final long sequence; + private final T target; - private Message(final ABIVersion version, final T target) { + private Message(final ABIVersion version, final T target, final long sequence) { this.target = Preconditions.checkNotNull(target); this.version = Preconditions.checkNotNull(version); + this.sequence = sequence; } - Message(final T target) { - this(ABIVersion.current(), target); + Message(final T target, final long sequence) { + this(ABIVersion.current(), target, sequence); } Message(final C msg, final ABIVersion version) { - this(version, msg.getTarget()); + this(version, msg.getTarget(), msg.getSequence()); } /** @@ -71,11 +79,22 @@ public abstract class Message externalizableProxy(@Nonnull ABIVersion version); + @Nonnull + abstract AbstractMessageProxy externalizableProxy(@Nonnull ABIVersion reqVersion); protected final Object writeReplace() { return externalizableProxy(version);