Fix issues with LeastLoadedCandidateSelectionStrategy
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / AbortTransaction.java
index 4cf713a0b3efa0a16aa68a9230af81bf568aa0ad..ed4519b83acbfb6c573cc35a5352e9570787ff68 100644 (file)
@@ -8,5 +8,37 @@
 
 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);
+    }
+
+    @Deprecated
+    @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;
+    }
 }