Added custom transport implementaion (for Catalyst Transport) for all copycat specific communication
Change-Id: I801d973b7c3412f6a8efcec77fe73fc480b2ce6e
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
new file mode 100644
index 0000000..4c69605
--- /dev/null
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/CopycatTransport.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.primitives.impl;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.store.cluster.messaging.MessagingService;
+
+import io.atomix.catalyst.transport.Client;
+import io.atomix.catalyst.transport.Server;
+import io.atomix.catalyst.transport.Transport;
+
+/**
+ * Custom {@link Transport transport} for Copycat interactions
+ * built on top of {@link MessagingService}.
+ *
+ * @see CopycatTransportServer
+ * @see CopycatTransportClient
+ */
+public class CopycatTransport implements Transport {
+
+ /**
+ * Transport Mode.
+ */
+ public enum Mode {
+ /**
+ * Signifies transport for client -> server interaction.
+ */
+ CLIENT,
+
+ /**
+ * Signified transport for server -> server interaction.
+ */
+ SERVER
+ }
+
+ private final Mode mode;
+ private final String clusterName;
+ private final MessagingService messagingService;
+
+ public CopycatTransport(Mode mode, String clusterName, MessagingService messagingService) {
+ this.mode = checkNotNull(mode);
+ this.clusterName = checkNotNull(clusterName);
+ this.messagingService = checkNotNull(messagingService);
+ }
+
+ @Override
+ public Client client() {
+ return new CopycatTransportClient(clusterName,
+ messagingService,
+ mode);
+ }
+
+ @Override
+ public Server server() {
+ return new CopycatTransportServer(clusterName,
+ messagingService);
+ }
+}