Use partitionId instead of clusterName in CopycatTransport

Change-Id: I8e7ab3863a36944ac9e48e187037fb43695ebde3
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransport.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransport.java
index 2634288..ddec252 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransport.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransport.java
@@ -17,6 +17,7 @@
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import org.onosproject.cluster.PartitionId;
 import org.onosproject.store.cluster.messaging.MessagingService;
 
 import io.atomix.catalyst.transport.Client;
@@ -48,25 +49,25 @@
     }
 
     private final Mode mode;
-    private final String clusterName;
+    private final PartitionId partitionId;
     private final MessagingService messagingService;
 
-    public CopycatTransport(Mode mode, String clusterName, MessagingService messagingService) {
+    public CopycatTransport(Mode mode, PartitionId partitionId, MessagingService messagingService) {
         this.mode = checkNotNull(mode);
-        this.clusterName = checkNotNull(clusterName);
+        this.partitionId = checkNotNull(partitionId);
         this.messagingService = checkNotNull(messagingService);
     }
 
     @Override
     public Client client() {
-        return new CopycatTransportClient(clusterName,
+        return new CopycatTransportClient(partitionId,
                                           messagingService,
                                           mode);
     }
 
     @Override
     public Server server() {
-        return new CopycatTransportServer(clusterName,
+        return new CopycatTransportServer(partitionId,
                                           messagingService);
     }
 }
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportClient.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportClient.java
index 390cde3..96729c7 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportClient.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportClient.java
@@ -19,7 +19,9 @@
 
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
+
 import org.apache.commons.lang.math.RandomUtils;
+import org.onosproject.cluster.PartitionId;
 import org.onosproject.store.cluster.messaging.MessagingService;
 
 import com.google.common.collect.Sets;
@@ -34,13 +36,13 @@
  */
 public class CopycatTransportClient implements Client {
 
-    private final String clusterName;
+    private final PartitionId partitionId;
     private final MessagingService messagingService;
     private final CopycatTransport.Mode mode;
     private final Set<CopycatTransportConnection> connections = Sets.newConcurrentHashSet();
 
-    CopycatTransportClient(String clusterName, MessagingService messagingService, CopycatTransport.Mode mode) {
-        this.clusterName = checkNotNull(clusterName);
+    CopycatTransportClient(PartitionId partitionId, MessagingService messagingService, CopycatTransport.Mode mode) {
+        this.partitionId = checkNotNull(partitionId);
         this.messagingService = checkNotNull(messagingService);
         this.mode = checkNotNull(mode);
     }
@@ -51,7 +53,7 @@
         CopycatTransportConnection connection = new CopycatTransportConnection(
                 nextConnectionId(),
                 CopycatTransport.Mode.CLIENT,
-                clusterName,
+                partitionId,
                 remoteAddress,
                 messagingService,
                 context);
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportConnection.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportConnection.java
index 58928b3..3c5b649 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportConnection.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportConnection.java
@@ -32,6 +32,7 @@
 import org.apache.commons.io.IOUtils;
 import org.onlab.packet.IpAddress;
 import org.onlab.util.Tools;
+import org.onosproject.cluster.PartitionId;
 import org.onosproject.store.cluster.messaging.Endpoint;
 import org.onosproject.store.cluster.messaging.MessagingService;
 
@@ -77,7 +78,7 @@
 
     CopycatTransportConnection(long connectionId,
             CopycatTransport.Mode mode,
-            String clusterName,
+            PartitionId partitionId,
             Address address,
             MessagingService messagingService,
             ThreadContext context) {
@@ -86,11 +87,11 @@
         this.remoteAddress = checkNotNull(address);
         this.messagingService = checkNotNull(messagingService);
         if (mode == CopycatTransport.Mode.CLIENT) {
-            this.outboundMessageSubject = String.format("onos-copycat-%s", clusterName);
-            this.inboundMessageSubject = String.format("onos-copycat-%s-%d", clusterName, connectionId);
+            this.outboundMessageSubject = String.format("onos-copycat-%s", partitionId);
+            this.inboundMessageSubject = String.format("onos-copycat-%s-%d", partitionId, connectionId);
         } else {
-            this.outboundMessageSubject = String.format("onos-copycat-%s-%d", clusterName, connectionId);
-            this.inboundMessageSubject = String.format("onos-copycat-%s", clusterName);
+            this.outboundMessageSubject = String.format("onos-copycat-%s-%d", partitionId, connectionId);
+            this.inboundMessageSubject = String.format("onos-copycat-%s", partitionId);
         }
         this.context = checkNotNull(context);
     }
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportServer.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportServer.java
index 7dfc59b..9a1959a 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportServer.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransportServer.java
@@ -29,6 +29,7 @@
 
 import org.apache.commons.io.IOUtils;
 import org.onlab.util.Tools;
+import org.onosproject.cluster.PartitionId;
 import org.onosproject.store.cluster.messaging.MessagingService;
 
 import com.google.common.collect.Maps;
@@ -46,15 +47,15 @@
 
     private final AtomicBoolean listening = new AtomicBoolean(false);
     private CompletableFuture<Void> listenFuture = new CompletableFuture<>();
-    private final String clusterName;
+    private final PartitionId partitionId;
     private final MessagingService messagingService;
     private final String messageSubject;
     private final Map<Long, CopycatTransportConnection> connections = Maps.newConcurrentMap();
 
-    CopycatTransportServer(String clusterName, MessagingService messagingService) {
-        this.clusterName = checkNotNull(clusterName);
+    CopycatTransportServer(PartitionId partitionId, MessagingService messagingService) {
+        this.partitionId = checkNotNull(partitionId);
         this.messagingService = checkNotNull(messagingService);
-        this.messageSubject = String.format("onos-copycat-%s", clusterName);
+        this.messageSubject = String.format("onos-copycat-%s", partitionId);
     }
 
     @Override
@@ -78,7 +79,7 @@
                     newConnection.set(true);
                     return new CopycatTransportConnection(connectionId,
                             CopycatTransport.Mode.SERVER,
-                            clusterName,
+                            partitionId,
                             senderAddress,
                             messagingService,
                             getOrCreateContext(context));
@@ -114,6 +115,6 @@
         if (context != null) {
             return context;
         }
-        return new SingleThreadContext("copycat-transport-server-" + clusterName, parentContext.serializer().clone());
+        return new SingleThreadContext("copycat-transport-server-" + partitionId, parentContext.serializer().clone());
     }
 }