Use YangInstanceIdentifier.EMPTY
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / CommitTransaction.java
index d7b210fd0307f019b537e6420a5a3001bb8cd234..52ab643ad838987f32e0158811b177bef635023d 100644 (file)
@@ -8,5 +8,37 @@
 
 package org.opendaylight.controller.cluster.datastore.messages;
 
-public class CommitTransaction {
+import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
+import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
+
+public class CommitTransaction extends AbstractThreePhaseCommitMessage {
+    private static final long serialVersionUID = 1L;
+
+    public CommitTransaction() {
+    }
+
+    public CommitTransaction(String transactionID, final short version) {
+        super(transactionID, version);
+    }
+
+    @Deprecated
+    @Override
+    protected Object newLegacySerializedInstance() {
+        return ThreePhaseCommitCohortMessages.CommitTransaction.newBuilder().setTransactionId(
+                getTransactionID()).build();
+    }
+
+    public static CommitTransaction fromSerializable(Object serializable) {
+        if(serializable instanceof CommitTransaction) {
+            return (CommitTransaction)serializable;
+        } else {
+            return new CommitTransaction(((ThreePhaseCommitCohortMessages.CommitTransaction)serializable).
+                    getTransactionId(), DataStoreVersions.LITHIUM_VERSION);
+        }
+    }
+
+    public static boolean isSerializedType(Object message) {
+        return message instanceof CommitTransaction ||
+                message instanceof ThreePhaseCommitCohortMessages.CommitTransaction;
+    }
 }