2 * Copyright (c) 2017 Pantheon Technologies, 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 static com.google.common.base.Preconditions.checkArgument;
12 import akka.actor.ActorRef;
13 import java.io.IOException;
14 import java.io.ObjectInput;
15 import java.io.ObjectOutput;
16 import org.opendaylight.controller.cluster.access.ABIVersion;
17 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
18 import org.opendaylight.yangtools.concepts.WritableObjects;
21 * A blank transaction request. This is used to provide backfill requests in converted retransmit scenarios, such as
22 * when a initial request to a transaction (such as a {@link ReadTransactionRequest}) is satisfied by the backend
23 * before the need to replay the transaction to a different remote backend.
25 public final class IncrementTransactionSequenceRequest extends
26 AbstractReadTransactionRequest<IncrementTransactionSequenceRequest> {
27 interface SerialForm extends AbstractReadTransactionRequest.SerialForm<IncrementTransactionSequenceRequest> {
29 default void writeExternal(final ObjectOutput out, final IncrementTransactionSequenceRequest msg)
31 AbstractReadTransactionRequest.SerialForm.super.writeExternal(out, msg);
32 WritableObjects.writeLong(out, msg.getIncrement());
36 default IncrementTransactionSequenceRequest readExternal(final ObjectInput in,
37 final TransactionIdentifier target, final long sequence, final ActorRef replyTo,
38 final boolean snapshotOnly) throws IOException {
39 return new IncrementTransactionSequenceRequest(target, sequence, replyTo, snapshotOnly,
40 WritableObjects.readLong(in));
45 private static final long serialVersionUID = 1L;
47 private final long increment;
49 public IncrementTransactionSequenceRequest(final IncrementTransactionSequenceRequest request,
50 final ABIVersion version) {
51 super(request, version);
52 increment = request.increment;
55 public IncrementTransactionSequenceRequest(final TransactionIdentifier identifier, final long sequence,
56 final ActorRef replyTo, final boolean snapshotOnly, final long increment) {
57 super(identifier, sequence, replyTo, snapshotOnly);
58 checkArgument(increment >= 0, "Unexpected increment %s", increment);
59 this.increment = increment;
63 * Return the sequence increment beyond this request's sequence.
65 * @return Sequence increment, guaranteed to be non-negative.
67 public long getIncrement() {
72 protected SerialForm externalizableProxy(final ABIVersion version) {
73 return ABIVersion.MAGNESIUM.lt(version) ? new ITSR(this) : new IncrementTransactionSequenceRequestProxyV1(this);
77 protected IncrementTransactionSequenceRequest cloneAsVersion(final ABIVersion targetVersion) {
78 return new IncrementTransactionSequenceRequest(this, targetVersion);