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.util.List;
17 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
18 import org.opendaylight.yangtools.concepts.WritableObjects;
21 * Externalizable proxy for use with {@link SkipTransactionsRequest}. It implements the initial
22 * (Phosphorus SR1) serialization format.
24 final class SkipTransactionsRequestV1 extends AbstractTransactionRequestProxy<SkipTransactionsRequest> {
25 private List<UnsignedLong> others;
27 // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
28 // be able to create instances via reflection.
29 @SuppressWarnings("checkstyle:RedundantModifier")
30 public SkipTransactionsRequestV1() {
34 SkipTransactionsRequestV1(final SkipTransactionsRequest request) {
36 others = request.getOthers();
40 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
41 super.readExternal(in);
43 final int size = in.readInt();
44 final var builder = ImmutableList.<UnsignedLong>builderWithExpectedSize(size);
47 builder.add(UnsignedLong.fromLongBits(WritableObjects.readLong(in)));
52 for (; idx < size; idx += 2) {
53 final byte hdr = WritableObjects.readLongHeader(in);
54 builder.add(UnsignedLong.fromLongBits(WritableObjects.readFirstLong(in, hdr)));
55 builder.add(UnsignedLong.fromLongBits(WritableObjects.readSecondLong(in, hdr)));
57 others = builder.build();
61 public void writeExternal(final ObjectOutput out) throws IOException {
62 super.writeExternal(out);
64 final int size = others.size();
69 WritableObjects.writeLong(out, others.get(0).longValue());
74 for (; idx < size; idx += 2) {
75 WritableObjects.writeLongs(out, others.get(idx).longValue(), others.get(idx + 1).longValue());
80 protected SkipTransactionsRequest createRequest(final TransactionIdentifier target, final long sequence,
81 final ActorRef replyToActor) {
82 return new SkipTransactionsRequest(target, sequence, replyToActor, others);