BUG-8402: fix sequencing with read/exists requests
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / IncrementTransactionSequenceRequestProxyV1.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.access.commands;
9
10 import akka.actor.ActorRef;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
15 import org.opendaylight.yangtools.concepts.WritableObjects;
16
17 final class IncrementTransactionSequenceRequestProxyV1
18         extends AbstractTransactionRequestProxy<IncrementTransactionSequenceRequest> {
19     private long increment;
20
21     // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
22     // be able to create instances via reflection.
23     @SuppressWarnings("checkstyle:RedundantModifier")
24     public IncrementTransactionSequenceRequestProxyV1() {
25         // For Externalizable
26     }
27
28     IncrementTransactionSequenceRequestProxyV1(final IncrementTransactionSequenceRequest request) {
29         super(request);
30         this.increment = request.getIncrement();
31     }
32
33     @Override
34     public void writeExternal(final ObjectOutput out) throws IOException {
35         super.writeExternal(out);
36         WritableObjects.writeLong(out, increment);
37     }
38
39     @Override
40     public void readExternal(final ObjectInput in) throws ClassNotFoundException, IOException {
41         super.readExternal(in);
42         increment = WritableObjects.readLong(in);
43     }
44
45     @Override
46     protected IncrementTransactionSequenceRequest createRequest(final TransactionIdentifier target, final long sequence,
47             final ActorRef replyToActor) {
48         return new IncrementTransactionSequenceRequest(target, sequence, replyToActor, increment);
49     }
50 }