Serialization/Deserialization and a host of other fixes
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ReadyTransactionReply.java
index 32d31bf84db44e87a4ebbbd6328c97c3898fd9ae..5273dc247925608326f9756e5dcbb061b106e5e2 100644 (file)
@@ -9,8 +9,11 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
 import akka.actor.ActorPath;
 package org.opendaylight.controller.cluster.datastore.messages;
 
 import akka.actor.ActorPath;
+import akka.actor.ActorSystem;
+import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
 
-public class ReadyTransactionReply {
+public class ReadyTransactionReply implements SerializableMessage {
+  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadyTransactionReply.class;
   private final ActorPath cohortPath;
 
   public ReadyTransactionReply(ActorPath cohortPath) {
   private final ActorPath cohortPath;
 
   public ReadyTransactionReply(ActorPath cohortPath) {
@@ -21,4 +24,16 @@ public class ReadyTransactionReply {
   public ActorPath getCohortPath() {
     return cohortPath;
   }
   public ActorPath getCohortPath() {
     return cohortPath;
   }
+
+  @Override
+  public ShardTransactionMessages.ReadyTransactionReply toSerializable() {
+    return ShardTransactionMessages.ReadyTransactionReply.newBuilder()
+        .setActorPath(cohortPath.toString()).build();
+  }
+
+  public static ReadyTransactionReply fromSerializable(ActorSystem actorSystem,Object serializable){
+    ShardTransactionMessages.ReadyTransactionReply o = (ShardTransactionMessages.ReadyTransactionReply) serializable;
+    return new ReadyTransactionReply(
+        actorSystem.actorFor(o.getActorPath()).path());
+  }
 }
 }