Introduce message bus models 29/15029/5
authorRobert Varga <rovarga@cisco.com>
Sat, 7 Feb 2015 20:12:07 +0000 (21:12 +0100)
committerRobert Varga <rovarga@cisco.com>
Wed, 18 Feb 2015 12:41:09 +0000 (13:41 +0100)
This patch introduces the basic mechanics for integrating various event
sources across MD-SAL, effectively forming a message bus.

Change-Id: I5cbaf9c0975f38c3e3c05ab9862aacf20d2b57c6
Signed-off-by: Robert Gallas <rgallas@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/messagebus-api/pom.xml [new file with mode: 0644]
opendaylight/md-sal/messagebus-api/src/main/yang/event-aggregator.yang [new file with mode: 0644]
opendaylight/md-sal/messagebus-api/src/main/yang/event-source.yang [new file with mode: 0644]
opendaylight/md-sal/pom.xml

diff --git a/opendaylight/md-sal/messagebus-api/pom.xml b/opendaylight/md-sal/messagebus-api/pom.xml
new file mode 100644 (file)
index 0000000..542308a
--- /dev/null
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>message-bus-api</artifactId>
+    <name>${project.artifactId}</name>
+
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-inventory</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.model</groupId>
+            <artifactId>yang-ext</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.model</groupId>
+            <artifactId>ietf-topology</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <codeGenerators>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>${project.build.directory}/generated-sources/sal</outputBaseDir>
+                                </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
+                                    <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
+                                    <additionalConfiguration>
+                                        <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
+                                    </additionalConfiguration>
+                                </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>target/site/models</outputBaseDir>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.8</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${project.build.directory}/generated-sources/config</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.*</Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/opendaylight/md-sal/messagebus-api/src/main/yang/event-aggregator.yang b/opendaylight/md-sal/messagebus-api/src/main/yang/event-aggregator.yang
new file mode 100644 (file)
index 0000000..ad7b573
--- /dev/null
@@ -0,0 +1,131 @@
+module event-aggregator {
+    // FIXME: this module needs to be split up to concepts and API
+    //        as the concepts are shared with the other model in this
+    //        package.
+    yang-version 1;
+    namespace "urn:cisco:params:xml:ns:yang:messagebus:eventaggregator";
+    prefix "eventaggregator";
+
+    organization "Cisco Systems, Inc.";
+    contact "Robert Gallas";
+
+    description
+        "Module implementing message but RPC.
+
+        Copyright (c)2014 Cisco Systems, Inc. All rights reserved.
+
+        This program and the accompanying materials are made available
+        under the terms of the Eclipse Public License v1.0 which
+        accompanies this distribution, and is available at
+        http://www.eclipse.org/legal/epl-v10.html";
+
+    revision "2014-12-02" {
+        description "Initial revision";
+    }
+
+    typedef pattern {
+        type string {
+            length 1..max;
+        }
+
+        // FIXME: make this a regular expression
+        description "A match pattern. Specifically this is a wildcard pattern.";
+    }
+
+    typedef notification-pattern {
+        type pattern;
+        description
+            "Pattern for matching candidate notification types. This pattern is to be
+            applied against the concatenation of the namespace of the module which
+            defines that particular notification, followed by a single colon, and
+            then followed by notification identifier, as supplied in the argument to
+            the notification statement.";
+    }
+
+    typedef topic-id {
+        type string {
+            length 1..max;
+        }
+        description
+            "A topic identifier. It uniquely defines a topic as seen by the the user
+            of this model's RPCs";
+    }
+
+    // FIXME: we would really like to share instances here, but that requires some sort
+    //        of sane reference counting. The reason for sharing is the data path part
+    //        of notification delivery -- multiple creators of topics can still share
+    //        a single data path.
+    rpc create-topic {
+        description
+            "Create a new topic. A topic is an aggregation of several notification
+            types from a set of nodes. Each successful invocation results in a unique
+            topic being created. The caller is responsible for removing the topic
+            once it is no longer needed.";
+
+        input {
+            leaf notification-pattern {
+                type notification-pattern;
+                mandatory true;
+                description
+                    "Pattern matching notification which should be forwarded into this
+                    topic.";
+            }
+
+            leaf node-id-pattern {
+                type pattern;
+                mandatory true;
+                description
+                    "Pattern for matching candidate event source nodes when looking
+                    for contributors to the topic. The pattern will be applied against
+                    /network-topology/topology/node/node-id";
+            }
+        }
+
+        output {
+            leaf topic-id {
+                type topic-id;
+                mandatory true;
+            }
+        }
+    }
+
+    rpc destroy-topic {
+        description
+            "Destroy a topic. No further messages will be delivered to it.";
+
+        input {
+            leaf topic-id {
+                type topic-id;
+                mandatory true;
+            }
+        }
+    }
+
+    notification topic-notification {
+        description
+            "Notification of an event occuring on a particular node. This notification
+            acts as an encapsulation for the event being delivered.";
+
+        leaf topic-id {
+            type topic-id;
+            mandatory true;
+            description
+                "Topic to which this event is being delivered.";
+        }
+
+        leaf node-id {
+            // FIXME: should be topology node ID
+            type string;
+            mandatory true;
+            description
+                "Node ID of the node which generated the event.";
+        }
+
+        anyxml payload {
+            mandatory true;
+            description
+                "Encapsulated notification. The format is the XML representation of
+                a notification according to RFC6020 section 7.14.2.";
+        }
+    }
+}
diff --git a/opendaylight/md-sal/messagebus-api/src/main/yang/event-source.yang b/opendaylight/md-sal/messagebus-api/src/main/yang/event-source.yang
new file mode 100644 (file)
index 0000000..5dd416c
--- /dev/null
@@ -0,0 +1,85 @@
+module event-source {
+    yang-version 1;
+    namespace "urn:cisco:params:xml:ns:yang:messagebus:eventsource";
+    prefix "eventsource";
+
+    import event-aggregator { prefix aggr; }
+    import network-topology { prefix nt; revision-date "2013-10-21"; }
+    import opendaylight-inventory {prefix inv; revision-date "2013-08-19"; }
+    import yang-ext {prefix ext; revision-date "2013-07-09"; }
+
+    organization "Cisco Systems, Inc.";
+    contact "Robert Gallas";
+
+    description
+        "Base model for a topology where individual nodes can produce events.
+
+        Module implementing event source topology and encapped notification.
+
+        Copyright (c)2014 Cisco Systems, Inc. All rights reserved.
+
+        This program and the accompanying materials are made available
+        under the terms of the Eclipse Public License v1.0 which
+        accompanies this distribution, and is available at
+        http://www.eclipse.org/legal/epl-v10.html";
+
+    revision "2014-12-02" {
+        description "first revision";
+    }
+
+    // FIXME: expand this
+    typedef join-topic-status {
+        type enumeration {
+            enum up;
+            enum down;
+        }
+        description "Object status";
+    }
+
+    // FIXME: migrate to topology
+    typedef node-ref {
+        type leafref {
+            path "/inv:nodes/inv:node/inv:id";
+        }
+    }
+
+    grouping topology-event-source-type {
+        container topology-event-source {
+            presence "indicates an event source-aware topology";
+        }
+    }
+
+    rpc join-topic {
+        input {
+            leaf node {
+               ext:context-reference "inv:node-context";
+               type "instance-identifier";
+            }
+            leaf topic-id {
+                type aggr:topic-id;
+                description "in current implementation notification-pattern is defined by topic-id.
+                             By persisting topic definition we could omit notification-pattern";
+            }
+            leaf notification-pattern {
+                type aggr:notification-pattern;
+            }
+        }
+
+        output {
+            leaf status {
+                type join-topic-status;
+            }
+        }
+    }
+
+    augment "/nt:network-topology/nt:topology/nt:topology-types" {
+        uses topology-event-source-type;
+    }
+
+    augment "/nt:network-topology/nt:topology/nt:node" {
+        when "../../nt:topology-types/topology-event-source";
+        leaf event-source-node {
+            type node-ref;
+        }
+    }
+}
index 1743b62180a8519afcaddaf892c499a11ad9778e..3151380647e22113b5a72f1dc5a090b7ffde13a8 100644 (file)
@@ -90,6 +90,9 @@
 
     <!-- Clustering -->
     <module>sal-remoterpc-connector</module>
+
+    <!-- Message Bus -->
+    <module>messagebus-api</module>
   </modules>
 
   <build>