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 javax.annotation.Nonnull;
15 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
19 * Request to commit a local transaction. Since local transactions do not introduce state on the backend until they
20 * are ready, this message carries a complete set of modifications.
22 * @author Robert Varga
25 public final class CommitLocalTransactionRequest
26 extends AbstractLocalTransactionRequest<CommitLocalTransactionRequest> {
27 private static final long serialVersionUID = 1L;
28 private final DataTreeModification mod;
29 private final boolean coordinated;
31 public CommitLocalTransactionRequest(@Nonnull final TransactionIdentifier identifier,
32 @Nonnull final ActorRef replyTo, @Nonnull final DataTreeModification mod, final boolean coordinated) {
33 super(identifier, 0, replyTo);
34 this.mod = Preconditions.checkNotNull(mod);
35 this.coordinated = coordinated;
38 public DataTreeModification getModification() {
43 * Indicate if this is a coordinated, multi-backend request. If this method returns true, the backend must
44 * act as a cohort participating in the three-phase commit (3PC) protocol to commit this transaction. If this
45 * method returns false, the backend should proceed to commit the transaction and respond once the commit completes
46 * or fails to complete.
48 * @return Indication of coordinated commit.
50 public boolean isCoordinated() {
55 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
56 return super.addToStringAttributes(toStringHelper).add("coordinated", coordinated);