BUG-8056: make doCommit/finishCommit package-private
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ReadyLocalTransaction.java
index 6d952f9a4a324e05cbfa2b2d5bc87ff49e1d0a14..2664fc17bc879532b783b8df7cb6030b84835039 100644 (file)
@@ -8,26 +8,34 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
 import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 
 /**
  * Message notifying the shard leader to apply modifications which have been
  * prepared locally against its DataTree. This message is not directly serializable,
- * simply because the leader and sender need to be on the same system.
+ * simply because the leader and sender need to be on the same system. When it needs
+ * to be sent out to a remote system, it needs to be intercepted by {@link ReadyLocalTransactionSerializer}
+ * and turned into {@link BatchedModifications}.
  */
 public final class ReadyLocalTransaction {
     private final DataTreeModification modification;
-    private final String transactionID;
+    private final TransactionIdentifier transactionId;
     private final boolean doCommitOnReady;
 
-    public ReadyLocalTransaction(final String transactionID, DataTreeModification modification, boolean doCommitOnReady) {
-        this.transactionID = Preconditions.checkNotNull(transactionID);
+    // The version of the remote system used only when needing to convert to BatchedModifications.
+    private short remoteVersion = DataStoreVersions.CURRENT_VERSION;
+
+    public ReadyLocalTransaction(final TransactionIdentifier transactionId, final DataTreeModification modification,
+            final boolean doCommitOnReady) {
+        this.transactionId = Preconditions.checkNotNull(transactionId);
         this.modification = Preconditions.checkNotNull(modification);
         this.doCommitOnReady = doCommitOnReady;
     }
 
-    public String getTransactionID() {
-        return transactionID;
+    public TransactionIdentifier getTransactionId() {
+        return transactionId;
     }
 
     public DataTreeModification getModification() {
@@ -37,4 +45,12 @@ public final class ReadyLocalTransaction {
     public boolean isDoCommitOnReady() {
         return doCommitOnReady;
     }
+
+    public short getRemoteVersion() {
+        return remoteVersion;
+    }
+
+    public void setRemoteVersion(short remoteVersion) {
+        this.remoteVersion = remoteVersion;
+    }
 }