2 * Copyright (c) 2015 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.datastore.messages;
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
12 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
13 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
16 * Message notifying the shard leader to apply modifications which have been
17 * prepared locally against its DataTree. This message is not directly serializable,
18 * simply because the leader and sender need to be on the same system. When it needs
19 * to be sent out to a remote system, it needs to be intercepted by {@link ReadyLocalTransactionSerializer}
20 * and turned into {@link BatchedModifications}.
22 public final class ReadyLocalTransaction {
23 private final DataTreeModification modification;
24 private final TransactionIdentifier transactionId;
25 private final boolean doCommitOnReady;
27 // The version of the remote system used only when needing to convert to BatchedModifications.
28 private short remoteVersion = DataStoreVersions.CURRENT_VERSION;
30 public ReadyLocalTransaction(final TransactionIdentifier transactionId, final DataTreeModification modification,
31 final boolean doCommitOnReady) {
32 this.transactionId = Preconditions.checkNotNull(transactionId);
33 this.modification = Preconditions.checkNotNull(modification);
34 this.doCommitOnReady = doCommitOnReady;
37 public TransactionIdentifier getTransactionId() {
41 public DataTreeModification getModification() {
45 public boolean isDoCommitOnReady() {
46 return doCommitOnReady;
49 public short getRemoteVersion() {
53 public void setRemoteVersion(short remoteVersion) {
54 this.remoteVersion = remoteVersion;