Slice front-end request messages
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / ModifyTransactionRequest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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 com.google.common.annotations.Beta;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.collect.ImmutableList;
14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15 import java.util.List;
16 import java.util.Optional;
17 import org.opendaylight.controller.cluster.access.ABIVersion;
18 import org.opendaylight.controller.cluster.access.concepts.SliceableMessage;
19 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
20
21 /**
22  * A transaction request to apply a particular set of operations on top of the current transaction. This message is
23  * used to also finish a transaction by specifying a {@link PersistenceProtocol}.
24  *
25  * @author Robert Varga
26  */
27 @Beta
28 public final class ModifyTransactionRequest extends TransactionRequest<ModifyTransactionRequest>
29         implements SliceableMessage {
30     private static final long serialVersionUID = 1L;
31
32     @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
33             + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
34             + "aren't serialized. FindBugs does not recognize this.")
35     private final List<TransactionModification> modifications;
36     private final PersistenceProtocol protocol;
37
38     ModifyTransactionRequest(final TransactionIdentifier target, final long sequence, final ActorRef replyTo,
39         final List<TransactionModification> modifications, final PersistenceProtocol protocol) {
40         super(target, sequence, replyTo);
41         this.modifications = ImmutableList.copyOf(modifications);
42         this.protocol = protocol;
43     }
44
45     public Optional<PersistenceProtocol> getPersistenceProtocol() {
46         return Optional.ofNullable(protocol);
47     }
48
49     public List<TransactionModification> getModifications() {
50         return modifications;
51     }
52
53     @Override
54     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
55         return super.addToStringAttributes(toStringHelper).add("modifications", modifications.size())
56                 .add("protocol", protocol);
57     }
58
59     @Override
60     protected ModifyTransactionRequestProxyV1 externalizableProxy(final ABIVersion version) {
61         return new ModifyTransactionRequestProxyV1(this);
62     }
63
64     @Override
65     protected ModifyTransactionRequest cloneAsVersion(final ABIVersion version) {
66         return this;
67     }
68 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.