X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmessages%2FCanCommitTransaction.java;h=e0bf4489b48e9a151313d29617472fb1fbe9e3f1;hb=8ec73bf853a9b6708b455c0321a585992e02b125;hp=2c032aff65ea569567b09595f76b9b52a1108124;hpb=6d73d16b194435ea1ea783a37d1b51fc1f558a1f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java index 2c032aff65..e0bf4489b4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java @@ -8,13 +8,37 @@ package org.opendaylight.controller.cluster.datastore.messages; +import org.opendaylight.controller.cluster.datastore.DataStoreVersions; import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages; -public class CanCommitTransaction implements SerializableMessage { - public static Class SERIALIZABLE_CLASS = ThreePhaseCommitCohortMessages.CanCommitTransaction.class; +public class CanCommitTransaction extends AbstractThreePhaseCommitMessage { + private static final long serialVersionUID = 1L; - @Override - public Object toSerializable() { - return ThreePhaseCommitCohortMessages.CanCommitTransaction.newBuilder().build(); - } + public CanCommitTransaction() { + } + + public CanCommitTransaction(String transactionID, final short version) { + super(transactionID, version); + } + + @Deprecated + @Override + protected Object newLegacySerializedInstance() { + return ThreePhaseCommitCohortMessages.CanCommitTransaction.newBuilder(). + setTransactionId(getTransactionID()).build(); + } + + public static CanCommitTransaction fromSerializable(Object serializable) { + if(serializable instanceof CanCommitTransaction) { + return (CanCommitTransaction)serializable; + } else { + return new CanCommitTransaction(((ThreePhaseCommitCohortMessages.CanCommitTransaction)serializable). + getTransactionId(), DataStoreVersions.LITHIUM_VERSION); + } + } + + public static boolean isSerializedType(Object message) { + return message instanceof CanCommitTransaction || + message instanceof ThreePhaseCommitCohortMessages.CanCommitTransaction; + } }