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%2Fcommands%2FSkipTransactionsRequest.java;fp=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fcommands%2FSkipTransactionsRequest.java;h=54fdfc581a7d0b4c595b66853bc9be589c1dce2d;hb=d92bd0e575983b3d6a09a73089ef8f9c62f94eaa;hp=3b97bb98170c762a7a5d70bf1df0300f30b60510;hpb=e085f22bb1934959f9d6f7f4368c1afe964b1e07;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/SkipTransactionsRequest.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/SkipTransactionsRequest.java index 3b97bb9817..54fdfc581a 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/SkipTransactionsRequest.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/SkipTransactionsRequest.java @@ -11,12 +11,15 @@ import akka.actor.ActorRef; import com.google.common.base.MoreObjects.ToStringHelper; import com.google.common.collect.ImmutableList; import com.google.common.primitives.UnsignedLong; -import java.io.Serial; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.util.Collection; import java.util.List; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; +import org.opendaylight.yangtools.concepts.WritableObjects; /** * Request to skip a number of {@link TransactionIdentifier}s within a {code local history}. This request is essentially @@ -28,7 +31,50 @@ import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier * explicitly retired and are guaranteed to never be used by the frontend. */ public final class SkipTransactionsRequest extends TransactionRequest { - @Serial + interface SerialForm extends TransactionRequest.SerialForm { + @Override + default SkipTransactionsRequest readExternal(final ObjectInput in, final TransactionIdentifier target, + final long sequence, final ActorRef replyTo) throws IOException { + final int size = in.readInt(); + final var builder = ImmutableList.builderWithExpectedSize(size); + int idx; + if (size % 2 != 0) { + builder.add(UnsignedLong.fromLongBits(WritableObjects.readLong(in))); + idx = 1; + } else { + idx = 0; + } + for (; idx < size; idx += 2) { + final byte hdr = WritableObjects.readLongHeader(in); + builder.add(UnsignedLong.fromLongBits(WritableObjects.readFirstLong(in, hdr))); + builder.add(UnsignedLong.fromLongBits(WritableObjects.readSecondLong(in, hdr))); + } + + return new SkipTransactionsRequest(target, sequence, replyTo, builder.build()); + } + + @Override + default void writeExternal(final ObjectOutput out, final SkipTransactionsRequest msg) throws IOException { + TransactionRequest.SerialForm.super.writeExternal(out, msg); + + final var others = msg.others; + final int size = others.size(); + out.writeInt(size); + + int idx; + if (size % 2 != 0) { + WritableObjects.writeLong(out, others.get(0).longValue()); + idx = 1; + } else { + idx = 0; + } + for (; idx < size; idx += 2) { + WritableObjects.writeLongs(out, others.get(idx).longValue(), others.get(idx + 1).longValue()); + } + } + } + + @java.io.Serial private static final long serialVersionUID = 1L; // Note: UnsignedLong is arbitrary, yang.common.Uint64 would work just as well, we really want an immutable @@ -41,6 +87,11 @@ public final class SkipTransactionsRequest extends TransactionRequest