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