Messagebus bridge is an unfinished concept, which was never productized.
It was deprecated in previous release, now we remove it.
JIRA: YANGTOOLS-1974
Change-Id: I8d544f8edf54bcacfb36419badb5003976e6b409
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
<scope>runtime</scope>
</dependency>
- <!-- MessageBus -->
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-spi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-util</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-controller-exp-messagebus</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
-
<!-- Clustering system test support -->
<dependency>
<groupId>org.opendaylight.controller.samples</groupId>
<artifactId>cds-dom-api</artifactId>
</dependency>
- <!-- MessageBus -->
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-util</artifactId>
- </dependency>
-
<!-- Third-party dependencies -->
<dependency>
<groupId>javax.inject</groupId>
<title>Akka RAFT implementation</title>
<packages>org.opendaylight.controller.cluster.raft*</packages>
</group>
- <group>
- <title>MD-SAL Message Bus Bridge (experimental)</title>
- <packages>org.opendaylight.controller.messagebus.*:org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.*</packages>
- </group>
<group>
<title>MD-SAL Tracing Utilities</title>
<packages>org.opendaylight.controller.md.sal.trace.*:org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908*</packages>
</dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-controller-exp-messagebus</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>odl-controller-exp-netty-config</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2016, 2017 Red Hat, Inc. and others.
-
- 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>single-feature-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../single-feature-parent</relativePath>
- </parent>
-
- <artifactId>odl-controller-exp-messagebus</artifactId>
- <packaging>feature</packaging>
- <name>OpenDaylight :: Controller :: Experimental :: Message Bus</name>
- <description>Experimental Message Bus Collector</description>
-
- <properties>
- <config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-model-inventory</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-broker</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-impl</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2020 PANTHEON.tech, s.r.o. and others.
-
- 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
- -->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-controller-exp-messagebus-${project.version}">
- <feature name="odl-controller-exp-messagebus" version="${project.version}">
- <feature version="[7,8)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
- </feature>
-</features>
<!-- Experimental features -->
<module>features-controller-experimental</module>
<module>odl-controller-exp-netty-config</module>
- <module>odl-controller-exp-messagebus</module>
<!-- CSIT features -->
<module>features-controller-testing</module>
+++ /dev/null
-<?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>mdsal-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <artifactId>messagebus-api</artifactId>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-inventory</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>yang-ext</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-topology</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <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>
+++ /dev/null
-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.";
- }
- }
-}
+++ /dev/null
-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
- + add rpc dis-join-topic
- + add notification event-source-status-notification";
- }
-
- // 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";
- }
- }
-
- typedef event-source-status {
- type enumeration {
- enum active;
- enum inactive;
- enum deactive;
- }
- description "Status of event source
- - active: event source is publishing notification,
- - inactive: event source stopped publishing of notifications temporarily
- - deactive: event source stopped publishing of notifications permanently" ;
- }
-
- 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;
- }
- }
- }
-
- rpc dis-join-topic {
- input {
- leaf node {
- ext:context-reference "inv:node-context";
- type "instance-identifier";
- }
- leaf topic-id {
- type aggr:topic-id;
- mandatory true;
- description "identifier of topic to be disjoin";
- }
- }
-
- }
-
- notification event-source-status-notification {
-
- description
- "Notification of change event source status.";
-
- leaf status {
- type event-source-status;
- mandatory true;
- description "Current status of event source.";
- }
-
- }
-
- 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;
- }
- }
-}
+++ /dev/null
-<?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>mdsal-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <artifactId>messagebus-impl</artifactId>
- <name>${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import org.opendaylight.controller.messagebus.spi.EventSource;
-import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-
-@Deprecated(forRemoval = true)
-class EventSourceRegistrationImpl<T extends EventSource> extends AbstractObjectRegistration<T>
- implements EventSourceRegistration<T> {
-
- private final EventSourceTopology eventSourceTopology;
-
- /**
- * Constructor.
- *
- * @param instance of EventSource that has been registered by
- * {@link EventSourceRegistryImpl#registerEventSource(Node, EventSource)}
- */
- EventSourceRegistrationImpl(final T instance, final EventSourceTopology eventSourceTopology) {
- super(instance);
- this.eventSourceTopology = requireNonNull(eventSourceTopology);
- }
-
- @Override
- protected void removeRegistration() {
- this.eventSourceTopology.unRegister(getInstance());
- }
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Collection;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.ExecutionException;
-import java.util.regex.Pattern;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicOutput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public final class EventSourceTopic implements DataTreeChangeListener<Node>, AutoCloseable {
- private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(EventSourceTopic.class);
-
- private final CopyOnWriteArraySet<InstanceIdentifier<?>> joinedEventSources = new CopyOnWriteArraySet<>();
- private final NotificationPattern notificationPattern;
- private final EventSourceService sourceService;
- private final Pattern nodeIdPattern;
- private final TopicId topicId;
- private ListenerRegistration<?> listenerRegistration;
-
- public static EventSourceTopic create(final NotificationPattern notificationPattern,
- final String nodeIdRegexPattern, final EventSourceTopology eventSourceTopology) {
- final EventSourceTopic est = new EventSourceTopic(notificationPattern, nodeIdRegexPattern,
- eventSourceTopology.getEventSourceService());
- est.registerListner(eventSourceTopology);
- est.notifyExistingNodes(eventSourceTopology);
- return est;
- }
-
- private EventSourceTopic(final NotificationPattern notificationPattern, final String nodeIdRegexPattern,
- final EventSourceService sourceService) {
- this.notificationPattern = requireNonNull(notificationPattern);
- this.sourceService = requireNonNull(sourceService);
- this.nodeIdPattern = Pattern.compile(nodeIdRegexPattern);
- this.topicId = new TopicId(getUUIDIdent());
- this.listenerRegistration = null;
- LOG.info("EventSourceTopic created - topicId {}", topicId.getValue());
- }
-
- public TopicId getTopicId() {
- return topicId;
- }
-
- @Override
- public void onDataTreeChanged(final Collection<DataTreeModification<Node>> changes) {
- for (DataTreeModification<Node> change: changes) {
- final DataObjectModification<Node> rootNode = change.getRootNode();
- switch (rootNode.getModificationType()) {
- case WRITE:
- case SUBTREE_MODIFIED:
- final Node node = rootNode.getDataAfter();
- if (getNodeIdRegexPattern().matcher(node.getNodeId().getValue()).matches()) {
- notifyNode(change.getRootPath().getRootIdentifier());
- }
- break;
- default:
- break;
- }
- }
- }
-
- public void notifyNode(final InstanceIdentifier<?> nodeId) {
- LOG.debug("Notify node: {}", nodeId);
- try {
- final RpcResult<JoinTopicOutput> rpcResultJoinTopic =
- sourceService.joinTopic(getJoinTopicInputArgument(nodeId)).get();
- if (!rpcResultJoinTopic.isSuccessful()) {
- for (final RpcError err : rpcResultJoinTopic.getErrors()) {
- LOG.error("Can not join topic: [{}] on node: [{}]. Error: {}", getTopicId().getValue(),
- nodeId.toString(), err.toString());
- }
- } else {
- joinedEventSources.add(nodeId);
- }
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Could not invoke join topic for node {}", nodeId);
- }
- }
-
- private void notifyExistingNodes(final EventSourceTopology eventSourceTopology) {
- LOG.debug("Notify existing nodes");
- final Pattern nodeRegex = this.nodeIdPattern;
-
- final FluentFuture<Optional<Topology>> future;
- try (ReadTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction()) {
- future = tx.read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
- }
-
- future.addCallback(new FutureCallback<Optional<Topology>>() {
- @Override
- public void onSuccess(final Optional<Topology> data) {
- if (data.isPresent()) {
- for (final Node node : data.get().nonnullNode().values()) {
- if (nodeRegex.matcher(node.getNodeId().getValue()).matches()) {
- notifyNode(EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, node.key()));
- }
- }
- }
- }
-
- @Override
- public void onFailure(final Throwable ex) {
- LOG.error("Can not notify existing nodes", ex);
- }
- }, MoreExecutors.directExecutor());
- }
-
- private JoinTopicInput getJoinTopicInputArgument(final InstanceIdentifier<?> path) {
- final NodeRef nodeRef = new NodeRef(path);
- final JoinTopicInput jti =
- new JoinTopicInputBuilder()
- .setNode(nodeRef.getValue())
- .setTopicId(topicId)
- .setNotificationPattern(notificationPattern)
- .build();
- return jti;
- }
-
- public Pattern getNodeIdRegexPattern() {
- return nodeIdPattern;
- }
-
- private DisJoinTopicInput getDisJoinTopicInputArgument(final InstanceIdentifier<?> eventSourceNodeId) {
- final NodeRef nodeRef = new NodeRef(eventSourceNodeId);
- final DisJoinTopicInput dji = new DisJoinTopicInputBuilder()
- .setNode(nodeRef.getValue())
- .setTopicId(topicId)
- .build();
- return dji;
- }
-
- private void registerListner(final EventSourceTopology eventSourceTopology) {
- this.listenerRegistration = eventSourceTopology.getDataBroker().registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
- EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class)), this);
- }
-
- @Override
- public void close() {
- if (this.listenerRegistration != null) {
- this.listenerRegistration.close();
- }
- for (final InstanceIdentifier<?> eventSourceNodeId : joinedEventSources) {
- try {
- final RpcResult<DisJoinTopicOutput> result = sourceService
- .disJoinTopic(getDisJoinTopicInputArgument(eventSourceNodeId)).get();
- if (result.isSuccessful() == false) {
- for (final RpcError err : result.getErrors()) {
- LOG.error("Can not destroy topic: [{}] on node: [{}]. Error: {}", getTopicId().getValue(),
- eventSourceNodeId, err.toString());
- }
- }
- } catch (InterruptedException | ExecutionException ex) {
- LOG.error("Can not close event source topic / destroy topic {} on node {}.", this.topicId.getValue(),
- eventSourceNodeId, ex);
- }
- }
- joinedEventSources.clear();
- }
-
- private static String getUUIDIdent() {
- final UUID uuid = UUID.randomUUID();
- return uuid.toString();
- }
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.impl;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Collections;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.controller.messagebus.app.util.Util;
-import org.opendaylight.controller.messagebus.spi.EventSource;
-import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
-import org.opendaylight.controller.messagebus.spi.EventSourceRegistry;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicInput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicOutput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicOutput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.EventAggregatorService;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.Node1;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.Node1Builder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.TopologyTypes1;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.TopologyTypes1Builder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.topology.event.source.type.TopologyEventSource;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.topology.event.source.type.TopologyEventSourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public class EventSourceTopology implements EventAggregatorService, EventSourceRegistry {
- private static final Logger LOG = LoggerFactory.getLogger(EventSourceTopology.class);
-
- private static final String TOPOLOGY_ID = "EVENT-SOURCE-TOPOLOGY" ;
- private static final TopologyKey EVENT_SOURCE_TOPOLOGY_KEY = new TopologyKey(new TopologyId(TOPOLOGY_ID));
- private static final LogicalDatastoreType OPERATIONAL = LogicalDatastoreType.OPERATIONAL;
-
- static final InstanceIdentifier<Topology> EVENT_SOURCE_TOPOLOGY_PATH =
- InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, EVENT_SOURCE_TOPOLOGY_KEY);
-
- private static final InstanceIdentifier<TopologyTypes1> TOPOLOGY_TYPE_PATH = EVENT_SOURCE_TOPOLOGY_PATH
- .child(TopologyTypes.class).augmentation(TopologyTypes1.class);
-
- private final Map<TopicId, EventSourceTopic> eventSourceTopicMap = new ConcurrentHashMap<>();
- private final Map<NodeKey, Registration> routedRpcRegistrations = new ConcurrentHashMap<>();
-
- private final DataBroker dataBroker;
- private final ObjectRegistration<EventSourceTopology> aggregatorRpcReg;
- private final EventSourceService eventSourceService;
- private final RpcProviderService rpcRegistry;
-
- public EventSourceTopology(final DataBroker dataBroker, final RpcProviderService providerService,
- final RpcConsumerRegistry rpcService) {
-
- this.dataBroker = dataBroker;
- this.rpcRegistry = providerService;
- aggregatorRpcReg = providerService.registerRpcImplementation(EventAggregatorService.class, this);
- eventSourceService = rpcService.getRpcService(EventSourceService.class);
-
- final TopologyEventSource topologySource = new TopologyEventSourceBuilder().build();
- final TopologyTypes1 topologyTypeAugment =
- new TopologyTypes1Builder().setTopologyEventSource(topologySource).build();
- putData(OPERATIONAL, TOPOLOGY_TYPE_PATH, topologyTypeAugment);
- LOG.info("EventSourceRegistry has been initialized");
- }
-
- private <T extends DataObject> void putData(final LogicalDatastoreType store,
- final InstanceIdentifier<T> path,
- final T data) {
-
- final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
- tx.mergeParentStructurePut(store, path, data);
- tx.commit().addCallback(new FutureCallback<CommitInfo>() {
- @Override
- public void onSuccess(final CommitInfo result) {
- LOG.trace("Data has put into datastore {} {}", store, path);
- }
-
- @Override
- public void onFailure(final Throwable ex) {
- LOG.error("Can not put data into datastore [store: {}] [path: {}]", store, path, ex);
- }
- }, MoreExecutors.directExecutor());
- }
-
- private <T extends DataObject> void deleteData(final LogicalDatastoreType store,
- final InstanceIdentifier<T> path) {
- final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
- tx.delete(OPERATIONAL, path);
- tx.commit().addCallback(new FutureCallback<CommitInfo>() {
- @Override
- public void onSuccess(final CommitInfo result) {
- LOG.trace("Data has deleted from datastore {} {}", store, path);
- }
-
- @Override
- public void onFailure(final Throwable ex) {
- LOG.error("Can not delete data from datastore [store: {}] [path: {}]", store, path, ex);
- }
- }, MoreExecutors.directExecutor());
- }
-
- private void insert(final KeyedInstanceIdentifier<Node, NodeKey> sourcePath) {
- final NodeKey nodeKey = sourcePath.getKey();
- final InstanceIdentifier<Node1> augmentPath = sourcePath.augmentation(Node1.class);
- final Node1 nodeAgument = new Node1Builder().setEventSourceNode(
- new NodeId(nodeKey.getNodeId().getValue())).build();
- putData(OPERATIONAL, augmentPath, nodeAgument);
- }
-
- private void remove(final KeyedInstanceIdentifier<Node, NodeKey> sourcePath) {
- final InstanceIdentifier<Node1> augmentPath = sourcePath.augmentation(Node1.class);
- deleteData(OPERATIONAL, augmentPath);
- }
-
- @Override
- public ListenableFuture<RpcResult<CreateTopicOutput>> createTopic(final CreateTopicInput input) {
- LOG.debug("Received Topic creation request: NotificationPattern -> {}, NodeIdPattern -> {}",
- input.getNotificationPattern(),
- input.getNodeIdPattern());
-
- final NotificationPattern notificationPattern = new NotificationPattern(input.getNotificationPattern());
- //FIXME: do not use Util.wildcardToRegex - NodeIdPatter should be regex
- final String nodeIdPattern = input.getNodeIdPattern().getValue();
- final EventSourceTopic eventSourceTopic = EventSourceTopic.create(notificationPattern, nodeIdPattern, this);
-
- eventSourceTopicMap.put(eventSourceTopic.getTopicId(), eventSourceTopic);
-
- final CreateTopicOutput cto = new CreateTopicOutputBuilder()
- .setTopicId(eventSourceTopic.getTopicId())
- .build();
-
- LOG.info("Topic has been created: NotificationPattern -> {}, NodeIdPattern -> {}",
- input.getNotificationPattern(),
- input.getNodeIdPattern());
-
- return Util.resultRpcSuccessFor(cto);
- }
-
- @Override
- public ListenableFuture<RpcResult<DestroyTopicOutput>> destroyTopic(final DestroyTopicInput input) {
- final EventSourceTopic topicToDestroy = eventSourceTopicMap.remove(input.getTopicId());
- if (topicToDestroy != null) {
- topicToDestroy.close();
- }
- return Util.resultRpcSuccessFor(new DestroyTopicOutputBuilder().build());
- }
-
- @Override
- public void close() {
- aggregatorRpcReg.close();
- eventSourceTopicMap.values().forEach(EventSourceTopic::close);
- }
-
- public void register(final EventSource eventSource) {
- final NodeKey nodeKey = eventSource.getSourceNodeKey();
- final KeyedInstanceIdentifier<Node, NodeKey> sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey);
- final Registration reg = rpcRegistry.registerRpcImplementation(EventSourceService.class, eventSource,
- Collections.singleton(sourcePath));
- routedRpcRegistrations.put(nodeKey, reg);
- insert(sourcePath);
- }
-
- public void unRegister(final EventSource eventSource) {
- final NodeKey nodeKey = eventSource.getSourceNodeKey();
- final KeyedInstanceIdentifier<Node, NodeKey> sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey);
- final Registration removeRegistration = routedRpcRegistrations.remove(nodeKey);
- if (removeRegistration != null) {
- removeRegistration.close();
- remove(sourcePath);
- }
- }
-
- @Override
- public <T extends EventSource> EventSourceRegistration<T> registerEventSource(final T eventSource) {
- final EventSourceRegistrationImpl<T> esr = new EventSourceRegistrationImpl<>(eventSource, this);
- register(eventSource);
- return esr;
- }
-
- DataBroker getDataBroker() {
- return dataBroker;
- }
-
- EventSourceService getEventSourceService() {
- return eventSourceService;
- }
-
- @VisibleForTesting
- Map<NodeKey, Registration> getRoutedRpcRegistrations() {
- return routedRpcRegistrations;
- }
-
- @VisibleForTesting
- Map<TopicId, EventSourceTopic> getEventSourceTopicMap() {
- return eventSourceTopicMap;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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
- */
-package org.opendaylight.controller.messagebus.app.impl;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.controller.messagebus.spi.EventSource;
-import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
-import org.opendaylight.controller.messagebus.spi.EventSourceRegistry;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Beta
-@Component(immediate = true)
-@Deprecated(forRemoval = true)
-public final class OSGiEventSourceRegistry implements EventSourceRegistry {
- private static final Logger LOG = LoggerFactory.getLogger(OSGiEventSourceRegistry.class);
-
- @Reference
- DataBroker dataBroker;
- @Reference
- RpcConsumerRegistry rpcConsumerRegistry;
- @Reference
- RpcProviderService rpcProviderService;
-
- private EventSourceTopology delegate;
-
- @Override
- public <T extends EventSource> EventSourceRegistration<T> registerEventSource(final T eventSource) {
- return delegate.registerEventSource(eventSource);
- }
-
- @Override
- public void close() {
- // Intentiational no-op
- }
-
- @Activate
- void activate() {
- delegate = new EventSourceTopology(dataBroker, rpcProviderService, rpcConsumerRegistry);
- LOG.info("Event Source Registry started");
- }
-
- @Deactivate
- void deactivate() {
- LOG.info("Event Source Registry stopping");
- delegate.close();
- LOG.info("Event Source Registry stopped");
- }
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.impl;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.messagebus.spi.EventSource;
-
-@Deprecated(forRemoval = true)
-public class EventSourceRegistrationImplTest {
-
- EventSourceRegistrationImplLocal eventSourceRegistrationImplLocal;
- EventSourceTopology eventSourceTopologyMock;
-
- @BeforeClass
- public static void initTestClass() {
- }
-
- @Before
- public void setUp() {
- EventSource eventSourceMock = mock(EventSource.class);
- eventSourceTopologyMock = mock(EventSourceTopology.class);
- eventSourceRegistrationImplLocal = new EventSourceRegistrationImplLocal(eventSourceMock,
- eventSourceTopologyMock);
- }
-
- @Test
- public void removeRegistrationTest() {
- eventSourceRegistrationImplLocal.removeRegistration();
- verify(eventSourceTopologyMock, times(1)).unRegister(any(EventSource.class));
- }
-
-
- private class EventSourceRegistrationImplLocal extends EventSourceRegistrationImpl<EventSource> {
- EventSourceRegistrationImplLocal(final EventSource instance, final EventSourceTopology eventSourceTopology) {
- super(instance, eventSourceTopology);
- }
- }
-
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Collections;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicStatus;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-@Deprecated(forRemoval = true)
-public class EventSourceTopicTest {
-
- EventSourceTopic eventSourceTopic;
- DataBroker dataBrokerMock;
- EventSourceService eventSourceServiceMock;
- EventSourceTopology eventSourceTopologyMock;
-
- @BeforeClass
- public static void initTestClass() {
- }
-
- @Before
- public void setUp() {
- final NotificationPattern notificationPattern = new NotificationPattern("value1");
- eventSourceServiceMock = mock(EventSourceService.class);
- doReturn(RpcResultBuilder.success(new JoinTopicOutputBuilder().setStatus(JoinTopicStatus.Up).build())
- .buildFuture()).when(eventSourceServiceMock).joinTopic(any(JoinTopicInput.class));
-
- eventSourceTopologyMock = mock(EventSourceTopology.class);
- dataBrokerMock = mock(DataBroker.class);
- doReturn(eventSourceServiceMock).when(eventSourceTopologyMock).getEventSourceService();
- doReturn(dataBrokerMock).when(eventSourceTopologyMock).getDataBroker();
-
- WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
- doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
- doNothing().when(writeTransactionMock).mergeParentStructurePut(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class), any(DataObject.class));
- FluentFuture checkedFutureWriteMock = mock(FluentFuture.class);
- doReturn(checkedFutureWriteMock).when(writeTransactionMock).commit();
-
- ReadTransaction readOnlyTransactionMock = mock(ReadTransaction.class);
- doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
- FluentFuture checkedFutureReadMock = mock(FluentFuture.class);
- doReturn(checkedFutureReadMock).when(readOnlyTransactionMock).read(LogicalDatastoreType.OPERATIONAL,
- EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
- eventSourceTopic = EventSourceTopic.create(notificationPattern, "nodeIdPattern1", eventSourceTopologyMock);
- }
-
- @Test
- public void createModuleTest() {
- assertNotNull("Instance has not been created correctly.", eventSourceTopic);
- }
-
- @Test
- public void getTopicIdTest() {
- assertNotNull("Topic has not been created correctly.", eventSourceTopic.getTopicId());
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void onDataTreeChangedTest() {
- InstanceIdentifier<Node> instanceIdentifierMock = mock(InstanceIdentifier.class);
- DataTreeModification<Node> mockDataTreeModification = mock(DataTreeModification.class);
- DataObjectModification<Node> mockModification = mock(DataObjectModification.class);
- doReturn(mockModification).when(mockDataTreeModification).getRootNode();
- doReturn(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifierMock))
- .when(mockDataTreeModification).getRootPath();
- doReturn(DataObjectModification.ModificationType.WRITE).when(mockModification).getModificationType();
-
- Node dataObjectNodeMock = mock(Node.class);
- doReturn(getNodeKey("testNodeId01")).when(dataObjectNodeMock).key();
- NodeId nodeIdMock = mock(NodeId.class);
- doReturn(nodeIdMock).when(dataObjectNodeMock).getNodeId();
- doReturn("nodeIdPattern1").when(nodeIdMock).getValue();
-
- doReturn(dataObjectNodeMock).when(mockModification).getDataAfter();
-
- eventSourceTopic.onDataTreeChanged(Collections.singletonList(mockDataTreeModification));
- verify(dataObjectNodeMock).getNodeId();
- verify(nodeIdMock).getValue();
- }
-
- @Test
- public void notifyNodeTest() {
- InstanceIdentifier instanceIdentifierMock = mock(InstanceIdentifier.class);
- eventSourceTopic.notifyNode(instanceIdentifierMock);
- verify(eventSourceServiceMock, times(1)).joinTopic(any(JoinTopicInput.class));
- }
-
- public NodeKey getNodeKey(final String nodeId) {
- return new NodeKey(new NodeId(nodeId));
- }
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.messagebus.spi.EventSource;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicInput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInput;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.EventAggregatorService;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-public class EventSourceTopologyTest {
-
- EventSourceTopology eventSourceTopology;
- DataBroker dataBrokerMock;
- RpcProviderService rpcProviderRegistryMock;
- RpcConsumerRegistry rpcServiceMock;
- CreateTopicInput createTopicInputMock;
- ListenerRegistration<?> listenerRegistrationMock;
- ObjectRegistration<EventAggregatorService> aggregatorRpcReg;
-
- @Before
- public void setUp() {
- dataBrokerMock = mock(DataBroker.class);
- rpcProviderRegistryMock = mock(RpcProviderService.class);
- rpcServiceMock = mock(RpcConsumerRegistry.class);
- }
-
- @Test
- public void constructorTest() {
- constructorTestHelper();
- eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock, rpcServiceMock);
- assertNotNull("Instance has not been created correctly.", eventSourceTopology);
- }
-
- private void constructorTestHelper() {
- aggregatorRpcReg = mock(ObjectRegistration.class);
- EventSourceService eventSourceService = mock(EventSourceService.class);
- doReturn(aggregatorRpcReg).when(rpcProviderRegistryMock).registerRpcImplementation(
- eq(EventAggregatorService.class), any(EventSourceTopology.class));
- doReturn(eventSourceService).when(rpcServiceMock).getRpcService(EventSourceService.class);
- WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
- doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
- doNothing().when(writeTransactionMock).mergeParentStructurePut(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class), any(DataObject.class));
- FluentFuture checkedFutureMock = mock(FluentFuture.class);
- doReturn(checkedFutureMock).when(writeTransactionMock).commit();
- }
-
- @Test
- public void createTopicTest() throws Exception {
- topicTestHelper();
- assertNotNull("Topic has not been created correctly.", eventSourceTopology.createTopic(createTopicInputMock));
- }
-
- @Test
- public void destroyTopicTest() throws Exception {
- topicTestHelper();
- TopicId topicId = new TopicId("topic-id-007");
- Map<TopicId, EventSourceTopic> localMap = eventSourceTopology.getEventSourceTopicMap();
- EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"),
- "pattern", eventSourceTopology);
- localMap.put(topicId, eventSourceTopic);
- DestroyTopicInput input = new DestroyTopicInputBuilder().setTopicId(topicId).build();
- eventSourceTopology.destroyTopic(input);
- verify(listenerRegistrationMock, times(1)).close();
- }
-
- private void topicTestHelper() throws Exception {
- constructorTestHelper();
- createTopicInputMock = mock(CreateTopicInput.class);
- eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock, rpcServiceMock);
-
- NotificationPattern notificationPattern = new NotificationPattern("value1");
- doReturn(notificationPattern).when(createTopicInputMock).getNotificationPattern();
- Pattern pattern = new Pattern("valuePattern1");
- doReturn(pattern).when(createTopicInputMock).getNodeIdPattern();
-
- listenerRegistrationMock = mock(ListenerRegistration.class);
- doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataTreeChangeListener(
- any(DataTreeIdentifier.class), any(EventSourceTopic.class));
-
- ReadTransaction readOnlyTransactionMock = mock(ReadTransaction.class);
- doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
-
- FluentFuture checkedFutureMock = mock(FluentFuture.class);
- doReturn(checkedFutureMock).when(readOnlyTransactionMock).read(eq(LogicalDatastoreType.OPERATIONAL),
- any(InstanceIdentifier.class));
- Topology topologyMock = mock(Topology.class);
- doReturn(Optional.of(topologyMock)).when(checkedFutureMock).get();
-
- final NodeKey nodeKey = new NodeKey(new NodeId("nodeIdValue1"));
- final Node node = new NodeBuilder().withKey(nodeKey).build();
- doReturn(Map.of(nodeKey, node)).when(topologyMock).getNode();
- }
-
- @Test
- public void closeTest() throws Exception {
- constructorTestHelper();
- topicTestHelper();
- Map<TopicId, EventSourceTopic> localMap = eventSourceTopology.getEventSourceTopicMap();
- TopicId topicIdMock = mock(TopicId.class);
- EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"),
- "pattern", eventSourceTopology);
- localMap.put(topicIdMock, eventSourceTopic);
- eventSourceTopology.close();
- verify(aggregatorRpcReg, times(1)).close();
- verify(listenerRegistrationMock, times(1)).close();
- }
-
- @Test
- public void registerTest() throws Exception {
- topicTestHelper();
- Node nodeMock = mock(Node.class);
- EventSource eventSourceMock = mock(EventSource.class);
- NodeId nodeId = new NodeId("nodeIdValue1");
- NodeKey nodeKey = new NodeKey(nodeId);
- doReturn(nodeKey).when(nodeMock).key();
- doReturn(nodeKey).when(eventSourceMock).getSourceNodeKey();
- ObjectRegistration routedRpcRegistrationMock = mock(ObjectRegistration.class);
- doReturn(routedRpcRegistrationMock).when(rpcProviderRegistryMock).registerRpcImplementation(
- eq(EventSourceService.class), eq(eventSourceMock), any(Set.class));
- eventSourceTopology.register(eventSourceMock);
- verify(rpcProviderRegistryMock, times(1)).registerRpcImplementation(eq(EventSourceService.class),
- eq(eventSourceMock), any(Set.class));
- }
-
- @Test
- public void unregisterTest() throws Exception {
- topicTestHelper();
- EventSource eventSourceMock = mock(EventSource.class);
- NodeId nodeId = new NodeId("nodeIdValue1");
- NodeKey nodeKey = new NodeKey(nodeId);
- Map<NodeKey, Registration> localMap = eventSourceTopology.getRoutedRpcRegistrations();
- NodeKey nodeKeyMock = mock(NodeKey.class);
- doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey();
- ObjectRegistration routedRpcRegistrationMock = mock(ObjectRegistration.class);
- localMap.put(nodeKeyMock, routedRpcRegistrationMock);
- eventSourceTopology.unRegister(eventSourceMock);
- verify(routedRpcRegistrationMock, times(1)).close();
- }
-
- @Test
- public void registerEventSourceTest() throws Exception {
- topicTestHelper();
- Node nodeMock = mock(Node.class);
- EventSource eventSourceMock = mock(EventSource.class);
- NodeId nodeId = new NodeId("nodeIdValue1");
- NodeKey nodeKey = new NodeKey(nodeId);
- doReturn(nodeKey).when(nodeMock).key();
- doReturn(nodeKey).when(eventSourceMock).getSourceNodeKey();
- ObjectRegistration routedRpcRegistrationMock = mock(ObjectRegistration.class);
- doReturn(routedRpcRegistrationMock).when(rpcProviderRegistryMock)
- .registerRpcImplementation(eq(EventSourceService.class), eq(eventSourceMock), any(Set.class));
- assertNotNull("Return value has not been created correctly.",
- eventSourceTopology.registerEventSource(eventSourceMock));
- }
-}
+++ /dev/null
-<?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>mdsal-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <artifactId>messagebus-spi</artifactId>
- <name>${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-api</artifactId>
- </dependency>
- </dependencies>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-</project>
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.spi;
-
-import java.util.List;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Event source is a node in topology which is able to produce notifications.
- * To register event source you use {@link EventSourceRegistry#registerEventSource(EventSource)}.
- * EventSourceRegistry will request registered event source to publish notifications
- * whenever EventSourceRegistry has been asked to publish a certain type of notifications.
- * EventSourceRegistry will call method JoinTopic to request EventSource to publish notification.
- * Event source must implement method JoinTopic (from superinterface {@link EventSourceService}).
- */
-@Deprecated(forRemoval = true)
-public interface EventSource extends EventSourceService, AutoCloseable {
- /**
- * Identifier of node associated with event source.
- *
- * @return instance of NodeKey
- */
- NodeKey getSourceNodeKey();
-
- /**
- * List the types of notifications which source can produce.
- *
- * @return list of available notification
- */
- List<SchemaPath> getAvailableNotifications();
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.spi;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-
-/**
- * Instance of EventSourceRegistration is returned by {@link EventSourceRegistry#registerEventSource(EventSource)}
- * and it is used to unregister EventSource.
- */
-@Deprecated(forRemoval = true)
-public interface EventSourceRegistration<T extends EventSource> extends ObjectRegistration<T> {
- @Override
- void close();
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.spi;
-
-/**
- * EventSourceRegistry is used to register {@link EventSource}.
- */
-@Deprecated(forRemoval = true)
-public interface EventSourceRegistry extends AutoCloseable {
-
- /**
- * Registers the given EventSource for public consumption. The EventSource is
- * associated with the node identified via {@link EventSource#getSourceNodeKey}.
- *
- * @param eventSource the EventSource instance to register
- * @return an EventSourceRegistration instance that is used to unregister the EventSource
- * via {@link EventSourceRegistration#close()}.
- */
- <T extends EventSource> EventSourceRegistration<T> registerEventSource(T eventSource);
-}
+++ /dev/null
-<?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>mdsal-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <artifactId>messagebus-util</artifactId>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>messagebus-api</artifactId>
- </dependency>
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>org.glassfish.jersey.test-framework.providers</groupId>
- <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.util;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.dom.api.DOMNotification;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicNotification;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
-
-@Deprecated(forRemoval = true)
-public class TopicDOMNotification implements DOMNotification {
- private static final @NonNull Absolute TOPIC_NOTIFICATION_ID = Absolute.of(TopicNotification.QNAME);
-
- private final ContainerNode body;
-
- public TopicDOMNotification(final ContainerNode body) {
- this.body = body;
- }
-
- @Override
- public Absolute getType() {
- return TOPIC_NOTIFICATION_ID;
- }
-
- @Override
- public ContainerNode getBody() {
- return body;
- }
-
- @Override
- public String toString() {
- return "TopicDOMNotification [body=" + body + "]";
- }
-}
+++ /dev/null
-/*
- * 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
- */
-
-package org.opendaylight.controller.messagebus.app.util;
-
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-public final class Util {
- private Util() {
- }
-
- public static <T> ListenableFuture<RpcResult<T>> resultRpcSuccessFor(final T output) {
- return Futures.immediateFuture(RpcResultBuilder.success(output).build());
- }
-
- /**
- * Method filters qnames based on wildcard strings.
- *
- * @param list list of SchemaPaths
- * @param pattern matching pattern
- * @return list of filtered qnames
- */
- public static List<SchemaPath> expandQname(final List<SchemaPath> list, final Pattern pattern) {
- final List<SchemaPath> matchingQnames = new ArrayList<>();
-
- for (final SchemaPath notification : list) {
- final String namespace = notification.getLastComponent().getNamespace().toString();
- if (pattern.matcher(namespace).matches()) {
- matchingQnames.add(notification);
- }
- }
- return matchingQnames;
- }
-
- /**
- * CREDIT to http://www.rgagnon.com/javadetails/java-0515.html.
- */
- public static String wildcardToRegex(final String wildcard) {
- final StringBuilder s = new StringBuilder(wildcard.length());
- s.append('^');
- for (final char c : wildcard.toCharArray()) {
- switch (c) {
- case '*':
- s.append(".*");
- break;
- case '?':
- s.append('.');
- break;
- // escape special regexp-characters
- case '(':
- case ')':
- case '[':
- case ']':
- case '$':
- case '^':
- case '.':
- case '{':
- case '}':
- case '|':
- case '\\':
- s.append("\\");
- s.append(c);
- break;
- default:
- s.append(c);
- break;
- }
- }
- s.append('$');
- return s.toString();
- }
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicNotification;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
-
-@Deprecated(forRemoval = true)
-public class TopicDOMNotificationTest {
-
- private static final String CONTAINER_NODE_BODY_MOCK_TO_STRING = "containerNodeBodyMock";
- ContainerNode containerNodeBodyMock;
- TopicDOMNotification topicDOMNotification;
-
- @BeforeClass
- public static void initTestClass() {
- }
-
- @Before
- public void setUp() {
- containerNodeBodyMock = mock(ContainerNode.class);
- doReturn(CONTAINER_NODE_BODY_MOCK_TO_STRING).when(containerNodeBodyMock).toString();
- topicDOMNotification = new TopicDOMNotification(containerNodeBodyMock);
- }
-
- @Test
- public void constructorTest() {
- assertNotNull("Instance has not been created correctly.", topicDOMNotification);
- }
-
- @Test
- public void getTypeTest() {
- assertEquals("Type has not been created correctly.", Absolute.of(TopicNotification.QNAME),
- topicDOMNotification.getType());
- }
-
- @Test
- public void getBodyTest() {
- assertEquals("String has not been created correctly.", containerNodeBodyMock, topicDOMNotification.getBody());
- }
-
- @Test
- public void getToStringTest() {
- String bodyString = "TopicDOMNotification [body=" + CONTAINER_NODE_BODY_MOCK_TO_STRING + "]";
- assertEquals("String has not been created correctly.", bodyString, topicDOMNotification.toString());
- }
-}
+++ /dev/null
-/*
- * 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
- */
-package org.opendaylight.controller.messagebus.app.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Pattern;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Unit tests for Util.
- *
- * @author ppalmar
- */
-@Deprecated(forRemoval = true)
-public class UtilTest {
-
- @Test
- public void testResultFor() throws Exception {
- {
- final String expectedResult = "dummy string";
- RpcResult<String> rpcResult = Util.resultRpcSuccessFor(expectedResult).get();
- assertEquals(expectedResult, rpcResult.getResult());
- assertTrue(rpcResult.isSuccessful());
- assertTrue(rpcResult.getErrors().isEmpty());
- }
- {
- final Integer expectedResult = 42;
- RpcResult<Integer> rpcResult = Util.resultRpcSuccessFor(expectedResult).get();
- assertEquals(expectedResult, rpcResult.getResult());
- assertTrue(rpcResult.isSuccessful());
- assertTrue(rpcResult.getErrors().isEmpty());
- }
- }
-
- @Test
- public void testExpandQname() {
- // match no path because the list of the allowed paths is empty
- {
- final List<SchemaPath> paths = new ArrayList<>();
- final Pattern regexPattern = Pattern.compile(".*"); // match everything
- final List<SchemaPath> matchingPaths = Util.expandQname(paths, regexPattern);
- assertTrue(matchingPaths.isEmpty());
- }
-
- // match no path because of regex pattern
- {
- final List<SchemaPath> paths = createSchemaPathList();
- final Pattern regexPattern = Pattern.compile("^@.*");
- final List<SchemaPath> matchingPaths = Util.expandQname(paths, regexPattern);
- assertTrue(matchingPaths.isEmpty());
- }
-
- // match all paths
- {
- final List<SchemaPath> paths = createSchemaPathList();
- final Pattern regexPattern = Pattern.compile(".*");
- final List<SchemaPath> matchingPaths = Util.expandQname(paths, regexPattern);
- assertTrue(matchingPaths.contains(paths.get(0)));
- assertTrue(matchingPaths.contains(paths.get(1)));
- assertEquals(paths.size(), matchingPaths.size());
- }
-
- // match one path only
- {
- final List<SchemaPath> paths = createSchemaPathList();
- final Pattern regexPattern = Pattern.compile(".*yyy$");
- final List<SchemaPath> matchingPaths = Util.expandQname(paths, regexPattern);
- assertTrue(matchingPaths.contains(paths.get(1)));
- assertEquals(1, matchingPaths.size());
- }
- }
-
- private static List<SchemaPath> createSchemaPathList() {
- final QName qname1 = QName.create("urn:odl:xxx", "2015-01-01", "localName");
- final QName qname2 = QName.create("urn:odl:yyy", "2015-01-01", "localName");
- final SchemaPath path1 = SchemaPath.create(true, qname1);
- final SchemaPath path2 = SchemaPath.create(true, qname2);
- return Arrays.asList(path1, path2);
- }
-}
<!-- Clustering -->
<module>sal-remoterpc-connector</module>
- <!-- Message Bus -->
- <module>messagebus-api</module>
- <module>messagebus-spi</module>
- <module>messagebus-impl</module>
- <module>messagebus-util</module>
-
<!-- PAX EXAM ITs -->
<module>sal-binding-it</module>