From 206b6688f5be750d1c66c7e6d5fd1d62511db2af Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Wed, 23 Oct 2013 19:54:35 +0200 Subject: [PATCH] Added skeletons for ZeroMQ APIs for Binding Aware ZeroMQ Connector Change-Id: I92c91af2c23d9f9d351a16b9d200e02d6ede2f52 Signed-off-by: Tony Tkacik --- opendaylight/md-sal/sal-connector-api/pom.xml | 5 +- .../connector/api/BindingAwareRpcRouter.java | 114 ++++++++++++++++++ .../api/BindingAwareZeroMqRpcRouter.java | 31 +++++ .../sal/connector/api/RpcRouter.java | 46 +++++++ 4 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java create mode 100644 opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareZeroMqRpcRouter.java create mode 100644 opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java diff --git a/opendaylight/md-sal/sal-connector-api/pom.xml b/opendaylight/md-sal/sal-connector-api/pom.xml index 3be5b82806..daeda3da6f 100644 --- a/opendaylight/md-sal/sal-connector-api/pom.xml +++ b/opendaylight/md-sal/sal-connector-api/pom.xml @@ -27,7 +27,10 @@ org.opendaylight.yangtools yang-model-api - + + org.opendaylight.yangtools + yang-binding + bundle diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java new file mode 100644 index 0000000000..11df1ff9c6 --- /dev/null +++ b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java @@ -0,0 +1,114 @@ +package org.opendaylight.controller.sal.connector.api; + +import java.util.concurrent.Future; + +import org.opendaylight.yangtools.concepts.Immutable; + +public interface BindingAwareRpcRouter extends RpcRouter { + + @Override + public Future> sendRpc( + RpcRequest input); + + class BindingAwareRequest implements RpcRequest, Immutable { + + private final BindingAwareRouteIdentifier routingInformation; + private final byte[] payload; + + public BindingAwareRequest(BindingAwareRouteIdentifier routingInformation, byte[] payload) { + super(); + this.routingInformation = routingInformation; + this.payload = payload; + } + + public BindingAwareRouteIdentifier getRoutingInformation() { + return this.routingInformation; + } + + @Override + public byte[] getPayload() { + return payload; + } + } + + class BindingAwareRouteIdentifier implements RouteIdentifier, Immutable { + + private final String type; + private final String route; + private final String content; + + public BindingAwareRouteIdentifier(String type, String route, String content) { + super(); + this.type = type; + this.route = route; + this.content = content; + } + + /** + * Java class name of Rpc Context + * + * + */ + @Override + public String getContext() { + return this.content; + } + + /** + * String representation of route e.g. node-id + * + */ + @Override + public String getRoute() { + return this.route; + } + + /** + * Java class name of Rpc Type e.g org.opendaylight.AddFlowInput + * + */ + @Override + public String getType() { + return this.type; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((content == null) ? 0 : content.hashCode()); + result = prime * result + ((route == null) ? 0 : route.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BindingAwareRouteIdentifier other = (BindingAwareRouteIdentifier) obj; + if (content == null) { + if (other.content != null) + return false; + } else if (!content.equals(other.content)) + return false; + if (route == null) { + if (other.route != null) + return false; + } else if (!route.equals(other.route)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; + } + + } + +} diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareZeroMqRpcRouter.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareZeroMqRpcRouter.java new file mode 100644 index 0000000000..1a360ad052 --- /dev/null +++ b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareZeroMqRpcRouter.java @@ -0,0 +1,31 @@ +package org.opendaylight.controller.sal.connector.api; + +import java.util.concurrent.Future; + +public class BindingAwareZeroMqRpcRouter implements BindingAwareRpcRouter { + + BindingAwareRpcRouter mdSalRouter; + + public BindingAwareRpcRouter getMdSalRouter() { + return mdSalRouter; + } + + + public void setMdSalRouter(BindingAwareRpcRouter mdSalRouter) { + this.mdSalRouter = mdSalRouter; + } + + + @Override + public Future> sendRpc(RpcRequest input) { + // Write message down to the wire + return null; + } + + // Receiver part - invoked when request is received and deserialized + private Future> receivedRequest(RpcRequest input) { + + return mdSalRouter.sendRpc(input); + } + +} diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java new file mode 100644 index 0000000000..4807c4e200 --- /dev/null +++ b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java @@ -0,0 +1,46 @@ +package org.opendaylight.controller.sal.connector.api; + +import java.util.concurrent.Future; + +/** + * + * @author ttkacik + * + * @param Routing Context Identifier + * @param Route Type + * @param Rpc Type + * @param Data Type + */ +public interface RpcRouter { + + + + Future> sendRpc(RpcRequest input); + + + /** + * + * @author + * + * @param Routing Context Identifier + * @param Route Type + * @param Rpc Type + * @param Data Type + */ + public interface RpcRequest { + + RouteIdentifier getRoutingInformation(); + D getPayload(); + } + + public interface RouteIdentifier { + + C getContext(); // defines a routing table (e.g. NodeContext) + R getRoute(); // e.g. (node identity) + T getType(); // rpc type + } + + public interface RpcReply { + D getPayload(); + } +} -- 2.36.6