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%2FCreateTransactionReply.java;h=73b33d7fe27b0c4336be0bc79b63c6296cd4b211;hb=8ec73bf853a9b6708b455c0321a585992e02b125;hp=096d131d5a5517821ae2e228aa4c4332315a37a9;hpb=ed693440aa741fee9b94447f8404d89b4020f616;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java index 096d131d5a..73b33d7fe2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransactionReply.java @@ -8,16 +8,22 @@ package org.opendaylight.controller.cluster.datastore.messages; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; -public class CreateTransactionReply implements SerializableMessage { +public class CreateTransactionReply extends VersionedExternalizableMessage { + private static final long serialVersionUID = 1L; - public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CreateTransactionReply.class; - private final String transactionPath; - private final String transactionId; + private String transactionPath; + private String transactionId; - public CreateTransactionReply(String transactionPath, - String transactionId) { + public CreateTransactionReply() { + } + + public CreateTransactionReply(final String transactionPath, final String transactionId, final short version) { + super(version); this.transactionPath = transactionPath; this.transactionId = transactionId; } @@ -30,16 +36,48 @@ public class CreateTransactionReply implements SerializableMessage { return transactionId; } - public Object toSerializable(){ - return ShardTransactionMessages.CreateTransactionReply.newBuilder() - .setTransactionActorPath(transactionPath) - .setTransactionId(transactionId) - .build(); + @Override + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + super.readExternal(in); + transactionId = in.readUTF(); + transactionPath = in.readUTF(); } - public static CreateTransactionReply fromSerializable(Object serializable){ - ShardTransactionMessages.CreateTransactionReply o = (ShardTransactionMessages.CreateTransactionReply) serializable; - return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId()); + @Override + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal(out); + out.writeUTF(transactionId); + out.writeUTF(transactionPath); } + @Deprecated + @Override + protected Object newLegacySerializedInstance() { + return ShardTransactionMessages.CreateTransactionReply.newBuilder().setTransactionActorPath(transactionPath) + .setTransactionId(transactionId).setMessageVersion(getVersion()).build(); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("CreateTransactionReply [transactionPath=").append(transactionPath).append(", transactionId=") + .append(transactionId).append(", version=").append(getVersion()).append("]"); + return builder.toString(); + } + + public static CreateTransactionReply fromSerializable(Object serializable) { + if(serializable instanceof CreateTransactionReply) { + return (CreateTransactionReply)serializable; + } else { + ShardTransactionMessages.CreateTransactionReply o = + (ShardTransactionMessages.CreateTransactionReply) serializable; + return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId(), + (short)o.getMessageVersion()); + } + } + + public static boolean isSerializedType(Object message) { + return message instanceof CreateTransactionReply || + message instanceof ShardTransactionMessages.CreateTransactionReply; + } }