2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.access.commands;
10 import akka.actor.ActorRef;
11 import com.google.common.collect.ImmutableList;
12 import com.google.common.primitives.UnsignedLong;
13 import java.io.IOException;
14 import java.io.ObjectInput;
15 import java.io.ObjectOutput;
16 import java.io.Serial;
17 import java.util.List;
18 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
19 import org.opendaylight.yangtools.concepts.WritableObjects;
22 * Externalizable proxy for use with {@link SkipTransactionsRequest}. It implements the initial
23 * (Phosphorus SR1) serialization format.
25 final class SkipTransactionsRequestV1 extends AbstractTransactionRequestProxy<SkipTransactionsRequest> {
27 private static final long serialVersionUID = -7493419007644462643L;
29 private List<UnsignedLong> others;
31 // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
32 // be able to create instances via reflection.
33 @SuppressWarnings("checkstyle:RedundantModifier")
34 public SkipTransactionsRequestV1() {
38 SkipTransactionsRequestV1(final SkipTransactionsRequest request) {
40 others = request.getOthers();
44 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
45 super.readExternal(in);
47 final int size = in.readInt();
48 final var builder = ImmutableList.<UnsignedLong>builderWithExpectedSize(size);
51 builder.add(UnsignedLong.fromLongBits(WritableObjects.readLong(in)));
56 for (; idx < size; idx += 2) {
57 final byte hdr = WritableObjects.readLongHeader(in);
58 builder.add(UnsignedLong.fromLongBits(WritableObjects.readFirstLong(in, hdr)));
59 builder.add(UnsignedLong.fromLongBits(WritableObjects.readSecondLong(in, hdr)));
61 others = builder.build();
65 public void writeExternal(final ObjectOutput out) throws IOException {
66 super.writeExternal(out);
68 final int size = others.size();
73 WritableObjects.writeLong(out, others.get(0).longValue());
78 for (; idx < size; idx += 2) {
79 WritableObjects.writeLongs(out, others.get(idx).longValue(), others.get(idx + 1).longValue());
84 protected SkipTransactionsRequest createRequest(final TransactionIdentifier target, final long sequence,
85 final ActorRef replyToActor) {
86 return new SkipTransactionsRequest(target, sequence, replyToActor, others);