2 * Copyright (c) 2016 Cisco Systems, Inc. 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.annotations.Beta;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.base.Preconditions;
14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15 import javax.annotation.Nonnull;
16 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
20 * Request to commit a local transaction. Since local transactions do not introduce state on the backend until they
21 * are ready, this message carries a complete set of modifications.
23 * @author Robert Varga
26 public final class CommitLocalTransactionRequest
27 extends AbstractLocalTransactionRequest<CommitLocalTransactionRequest> {
28 private static final long serialVersionUID = 1L;
30 @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
31 + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
32 + "aren't serialized. FindBugs does not recognize this.")
33 private final DataTreeModification mod;
34 private final boolean coordinated;
36 public CommitLocalTransactionRequest(@Nonnull final TransactionIdentifier identifier, final long sequence,
37 @Nonnull final ActorRef replyTo, @Nonnull final DataTreeModification mod, final boolean coordinated) {
38 super(identifier, sequence, replyTo);
39 this.mod = Preconditions.checkNotNull(mod);
40 this.coordinated = coordinated;
43 public DataTreeModification getModification() {
48 * Indicate if this is a coordinated, multi-backend request. If this method returns true, the backend must
49 * act as a cohort participating in the three-phase commit (3PC) protocol to commit this transaction. If this
50 * method returns false, the backend should proceed to commit the transaction and respond once the commit completes
51 * or fails to complete.
53 * @return Indication of coordinated commit.
55 public boolean isCoordinated() {
60 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
61 return super.addToStringAttributes(toStringHelper).add("coordinated", coordinated);