X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fconcepts%2FMessage.java;h=1d198fc8a9c9f8039b9f5cc6955e3a37230f0d98;hp=87b0e6ef345d8ad0c142fd6259d0ab0b1a5f2b67;hb=598f290a8c88342f16379842ab7e4915e9fcea6c;hpb=e4959b48fbe437645fff11374ff7fe3fd200932e 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 87b0e6ef34..1d198fc8a9 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 @@ -7,14 +7,15 @@ */ package org.opendaylight.controller.cluster.access.concepts; +import static com.google.common.base.Verify.verifyNotNull; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; import java.io.Serializable; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.concepts.WritableIdentifier; @@ -23,21 +24,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,28 +56,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 @NonNull ABIVersion version; private final long sequence; - private final ABIVersion version; - private final long retry; + private final @NonNull T target; - private Message(final ABIVersion version, final T target, final long sequence, final long retry) { - this.target = Preconditions.checkNotNull(target); - this.version = Preconditions.checkNotNull(version); + private Message(final ABIVersion version, final T target, final long sequence) { + this.target = requireNonNull(target); + this.version = requireNonNull(version); this.sequence = sequence; - this.retry = retry; } - Message(final T target, final long sequence, final long retry) { - this(ABIVersion.current(), target, sequence, retry); + Message(final T target, final long sequence) { + this(ABIVersion.current(), target, sequence); } Message(final C msg, final ABIVersion version) { - this(version, msg.getTarget(), msg.getSequence(), msg.getRetry()); - } - - Message(final C msg, final long retry) { - this(msg.getVersion(), msg.getTarget(), msg.getSequence(), retry); + this(version, msg.getTarget(), msg.getSequence()); } /** @@ -79,55 +80,46 @@ public abstract class Message externalizableProxy(@Nonnull ABIVersion version); + abstract @NonNull AbstractMessageProxy externalizableProxy(@NonNull ABIVersion reqVersion); protected final Object writeReplace() { return externalizableProxy(version);