BUG-5280: use MemberName instead of String
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / entityownership / EntityOwnershipShardCommitCoordinator.java
index 172849c9535e574ff3181e94304f7d4694aaf6ce..9cbcbf9dea73c0750ea51603eee701db6ec42cfb 100644 (file)
@@ -13,6 +13,7 @@ import akka.actor.Status.Failure;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Queue;
+import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
@@ -28,29 +29,34 @@ import scala.concurrent.duration.FiniteDuration;
  * @author Thomas Pantelis
  */
 class EntityOwnershipShardCommitCoordinator {
-    private static final Object COMMIT_RETRY_MESSAGE = "entityCommitRetry";
+    private static final Object COMMIT_RETRY_MESSAGE = new Object() {
+        @Override
+        public String toString() {
+            return "entityCommitRetry";
+        }
+    };
 
     private final Logger log;
     private int transactionIDCounter = 0;
-    private final String localMemberName;
+    private final MemberName localMemberName;
     private final Queue<Modification> pendingModifications = new LinkedList<>();
     private BatchedModifications inflightCommit;
     private Cancellable retryCommitSchedule;
 
-    EntityOwnershipShardCommitCoordinator(String localMemberName, Logger log) {
+    EntityOwnershipShardCommitCoordinator(MemberName localMemberName, Logger log) {
         this.localMemberName = localMemberName;
         this.log = log;
     }
 
     boolean handleMessage(Object message, EntityOwnershipShard shard) {
         boolean handled = true;
-        if(CommitTransactionReply.SERIALIZABLE_CLASS.isInstance(message)) {
+        if(CommitTransactionReply.isSerializedType(message)) {
             // Successful reply from a local commit.
             inflightCommitSucceeded(shard);
         } else if(message instanceof akka.actor.Status.Failure) {
             // Failure reply from a local commit.
             inflightCommitFailure(((Failure)message).cause(), shard);
-        } else if(message.equals(COMMIT_RETRY_MESSAGE)) {
+        } else if(COMMIT_RETRY_MESSAGE.equals(message)) {
             retryInflightCommit(shard);
         } else {
             handled = false;