From e258e0fef2bc38e35f09354f0fdd5136c69ad1a7 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 26 Mar 2021 08:44:11 +0100 Subject: [PATCH] Remove odl-controller-exp-messagebus 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 --- artifacts/pom.xml | 29 --- docs/pom.xml | 22 -- .../features-controller-experimental/pom.xml | 6 - .../odl-controller-exp-messagebus/pom.xml | 64 ----- .../src/main/feature/feature.xml | 13 - features/pom.xml | 1 - opendaylight/md-sal/messagebus-api/pom.xml | 53 ---- .../src/main/yang/event-aggregator.yang | 131 ---------- .../src/main/yang/event-source.yang | 127 ---------- opendaylight/md-sal/messagebus-impl/pom.xml | 46 ---- .../app/impl/EventSourceRegistrationImpl.java | 37 --- .../messagebus/app/impl/EventSourceTopic.java | 200 --------------- .../app/impl/EventSourceTopology.java | 228 ------------------ .../app/impl/OSGiEventSourceRegistry.java | 61 ----- .../impl/EventSourceRegistrationImplTest.java | 51 ---- .../app/impl/EventSourceTopicTest.java | 125 ---------- .../app/impl/EventSourceTopologyTest.java | 199 --------------- opendaylight/md-sal/messagebus-spi/pom.xml | 43 ---- .../messagebus/spi/EventSource.java | 38 --- .../spi/EventSourceRegistration.java | 20 -- .../messagebus/spi/EventSourceRegistry.java | 25 -- opendaylight/md-sal/messagebus-util/pom.xml | 45 ---- .../app/util/TopicDOMNotification.java | 40 --- .../controller/messagebus/app/util/Util.java | 85 ------- .../app/util/TopicDOMNotificationTest.java | 61 ----- .../messagebus/app/util/UtilTest.java | 93 ------- opendaylight/md-sal/pom.xml | 6 - 27 files changed, 1849 deletions(-) delete mode 100644 features/odl-controller-exp-messagebus/pom.xml delete mode 100644 features/odl-controller-exp-messagebus/src/main/feature/feature.xml delete mode 100644 opendaylight/md-sal/messagebus-api/pom.xml delete mode 100644 opendaylight/md-sal/messagebus-api/src/main/yang/event-aggregator.yang delete mode 100644 opendaylight/md-sal/messagebus-api/src/main/yang/event-source.yang delete mode 100644 opendaylight/md-sal/messagebus-impl/pom.xml delete mode 100644 opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImpl.java delete mode 100644 opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java delete mode 100644 opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java delete mode 100644 opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/OSGiEventSourceRegistry.java delete mode 100644 opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java delete mode 100644 opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java delete mode 100644 opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java delete mode 100644 opendaylight/md-sal/messagebus-spi/pom.xml delete mode 100644 opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSource.java delete mode 100644 opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSourceRegistration.java delete mode 100644 opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSourceRegistry.java delete mode 100644 opendaylight/md-sal/messagebus-util/pom.xml delete mode 100644 opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotification.java delete mode 100644 opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/Util.java delete mode 100644 opendaylight/md-sal/messagebus-util/src/test/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotificationTest.java delete mode 100644 opendaylight/md-sal/messagebus-util/src/test/java/org/opendaylight/controller/messagebus/app/util/UtilTest.java diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 0f012e9f54..af916f3a92 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -194,35 +194,6 @@ runtime - - - org.opendaylight.controller - messagebus-api - ${project.version} - - - org.opendaylight.controller - messagebus-spi - ${project.version} - - - org.opendaylight.controller - messagebus-impl - ${project.version} - - - org.opendaylight.controller - messagebus-util - ${project.version} - - - ${project.groupId} - odl-controller-exp-messagebus - ${project.version} - xml - features - - org.opendaylight.controller.samples diff --git a/docs/pom.xml b/docs/pom.xml index cac81c5cfa..7168d72abb 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -106,24 +106,6 @@ cds-dom-api - - - org.opendaylight.controller - messagebus-api - - - org.opendaylight.controller - messagebus-spi - - - org.opendaylight.controller - messagebus-impl - - - org.opendaylight.controller - messagebus-util - - javax.inject @@ -270,10 +252,6 @@ Akka RAFT implementation org.opendaylight.controller.cluster.raft* - - MD-SAL Message Bus Bridge (experimental) - org.opendaylight.controller.messagebus.*:org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.* - MD-SAL Tracing Utilities org.opendaylight.controller.md.sal.trace.*:org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908* diff --git a/features/features-controller-experimental/pom.xml b/features/features-controller-experimental/pom.xml index 9cab36966e..d0a959543f 100644 --- a/features/features-controller-experimental/pom.xml +++ b/features/features-controller-experimental/pom.xml @@ -35,12 +35,6 @@ - - org.opendaylight.controller - odl-controller-exp-messagebus - xml - features - org.opendaylight.controller odl-controller-exp-netty-config diff --git a/features/odl-controller-exp-messagebus/pom.xml b/features/odl-controller-exp-messagebus/pom.xml deleted file mode 100644 index cd44dedb38..0000000000 --- a/features/odl-controller-exp-messagebus/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.controller - single-feature-parent - 4.0.0-SNAPSHOT - ../single-feature-parent - - - odl-controller-exp-messagebus - feature - OpenDaylight :: Controller :: Experimental :: Message Bus - Experimental Message Bus Collector - - - etc/opendaylight/karaf - - - - - org.opendaylight.controller - odl-mdsal-model-inventory - xml - features - - - org.opendaylight.mdsal.model - odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal - xml - features - - - - org.opendaylight.controller - odl-mdsal-broker - xml - features - - - org.opendaylight.controller - messagebus-api - - - org.opendaylight.controller - messagebus-spi - - - org.opendaylight.controller - messagebus-util - - - org.opendaylight.controller - messagebus-impl - - - diff --git a/features/odl-controller-exp-messagebus/src/main/feature/feature.xml b/features/odl-controller-exp-messagebus/src/main/feature/feature.xml deleted file mode 100644 index c9b88bc8d7..0000000000 --- a/features/odl-controller-exp-messagebus/src/main/feature/feature.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal - - diff --git a/features/pom.xml b/features/pom.xml index 0d8268d564..3651ae28f0 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -35,7 +35,6 @@ features-controller-experimental odl-controller-exp-netty-config - odl-controller-exp-messagebus features-controller-testing diff --git a/opendaylight/md-sal/messagebus-api/pom.xml b/opendaylight/md-sal/messagebus-api/pom.xml deleted file mode 100644 index f349ec180d..0000000000 --- a/opendaylight/md-sal/messagebus-api/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 4.0.0-SNAPSHOT - ../parent - - - messagebus-api - bundle - ${project.artifactId} - - - - org.opendaylight.controller.model - model-inventory - - - org.opendaylight.mdsal.model - yang-ext - - - org.opendaylight.mdsal.model - ietf-topology - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.* - - - - - - 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 deleted file mode 100644 index ad7b573396..0000000000 --- a/opendaylight/md-sal/messagebus-api/src/main/yang/event-aggregator.yang +++ /dev/null @@ -1,131 +0,0 @@ -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 deleted file mode 100644 index c90b26696b..0000000000 --- a/opendaylight/md-sal/messagebus-api/src/main/yang/event-source.yang +++ /dev/null @@ -1,127 +0,0 @@ -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; - } - } -} diff --git a/opendaylight/md-sal/messagebus-impl/pom.xml b/opendaylight/md-sal/messagebus-impl/pom.xml deleted file mode 100644 index 022498f68a..0000000000 --- a/opendaylight/md-sal/messagebus-impl/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 4.0.0-SNAPSHOT - ../parent - - - messagebus-impl - ${project.artifactId} - bundle - - - - org.opendaylight.mdsal - mdsal-binding-api - - - org.opendaylight.controller - messagebus-api - - - org.opendaylight.controller - messagebus-util - - - org.opendaylight.controller - messagebus-spi - - - org.osgi - osgi.cmpn - - - diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImpl.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImpl.java deleted file mode 100644 index 1779ad85f8..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 extends AbstractObjectRegistration - implements EventSourceRegistration { - - 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()); - } -} diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java deleted file mode 100644 index af2099c08d..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * 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, AutoCloseable { - private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(EventSourceTopic.class); - - private final CopyOnWriteArraySet> 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> changes) { - for (DataTreeModification change: changes) { - final DataObjectModification 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 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> future; - try (ReadTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction()) { - future = tx.read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH); - } - - future.addCallback(new FutureCallback>() { - @Override - public void onSuccess(final Optional 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 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(); - } -} diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java deleted file mode 100644 index b22eee233e..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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 EVENT_SOURCE_TOPOLOGY_PATH = - InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, EVENT_SOURCE_TOPOLOGY_KEY); - - private static final InstanceIdentifier TOPOLOGY_TYPE_PATH = EVENT_SOURCE_TOPOLOGY_PATH - .child(TopologyTypes.class).augmentation(TopologyTypes1.class); - - private final Map eventSourceTopicMap = new ConcurrentHashMap<>(); - private final Map routedRpcRegistrations = new ConcurrentHashMap<>(); - - private final DataBroker dataBroker; - private final ObjectRegistration 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 void putData(final LogicalDatastoreType store, - final InstanceIdentifier path, - final T data) { - - final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction(); - tx.mergeParentStructurePut(store, path, data); - tx.commit().addCallback(new FutureCallback() { - @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 void deleteData(final LogicalDatastoreType store, - final InstanceIdentifier path) { - final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction(); - tx.delete(OPERATIONAL, path); - tx.commit().addCallback(new FutureCallback() { - @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 sourcePath) { - final NodeKey nodeKey = sourcePath.getKey(); - final InstanceIdentifier 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 sourcePath) { - final InstanceIdentifier augmentPath = sourcePath.augmentation(Node1.class); - deleteData(OPERATIONAL, augmentPath); - } - - @Override - public ListenableFuture> 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> 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 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 sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey); - final Registration removeRegistration = routedRpcRegistrations.remove(nodeKey); - if (removeRegistration != null) { - removeRegistration.close(); - remove(sourcePath); - } - } - - @Override - public EventSourceRegistration registerEventSource(final T eventSource) { - final EventSourceRegistrationImpl esr = new EventSourceRegistrationImpl<>(eventSource, this); - register(eventSource); - return esr; - } - - DataBroker getDataBroker() { - return dataBroker; - } - - EventSourceService getEventSourceService() { - return eventSourceService; - } - - @VisibleForTesting - Map getRoutedRpcRegistrations() { - return routedRpcRegistrations; - } - - @VisibleForTesting - Map getEventSourceTopicMap() { - return eventSourceTopicMap; - } -} diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/OSGiEventSourceRegistry.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/OSGiEventSourceRegistry.java deleted file mode 100644 index 07e66d247e..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/OSGiEventSourceRegistry.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 EventSourceRegistration 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"); - } -} diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java deleted file mode 100644 index 82ef60db69..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 { - EventSourceRegistrationImplLocal(final EventSource instance, final EventSourceTopology eventSourceTopology) { - super(instance, eventSourceTopology); - } - } - -} diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java deleted file mode 100644 index 6059d9ab4f..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 instanceIdentifierMock = mock(InstanceIdentifier.class); - DataTreeModification mockDataTreeModification = mock(DataTreeModification.class); - DataObjectModification 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)); - } -} diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java deleted file mode 100644 index 2022869ad9..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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 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 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 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 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)); - } -} diff --git a/opendaylight/md-sal/messagebus-spi/pom.xml b/opendaylight/md-sal/messagebus-spi/pom.xml deleted file mode 100644 index ec72892098..0000000000 --- a/opendaylight/md-sal/messagebus-spi/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.controller - mdsal-parent - 4.0.0-SNAPSHOT - ../parent - - - messagebus-spi - ${project.artifactId} - bundle - - - - org.opendaylight.controller - messagebus-api - - - org.opendaylight.yangtools - yang-data-api - - - org.opendaylight.yangtools - yang-model-api - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - diff --git a/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSource.java b/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSource.java deleted file mode 100644 index 6d57b4d95a..0000000000 --- a/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSource.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 getAvailableNotifications(); -} diff --git a/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSourceRegistration.java b/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSourceRegistration.java deleted file mode 100644 index d885461b48..0000000000 --- a/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSourceRegistration.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 extends ObjectRegistration { - @Override - void close(); -} diff --git a/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSourceRegistry.java b/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSourceRegistry.java deleted file mode 100644 index 1d1980fc36..0000000000 --- a/opendaylight/md-sal/messagebus-spi/src/main/java/org/opendaylight/controller/messagebus/spi/EventSourceRegistry.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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()}. - */ - EventSourceRegistration registerEventSource(T eventSource); -} diff --git a/opendaylight/md-sal/messagebus-util/pom.xml b/opendaylight/md-sal/messagebus-util/pom.xml deleted file mode 100644 index 1db9a0697b..0000000000 --- a/opendaylight/md-sal/messagebus-util/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.controller - mdsal-parent - 4.0.0-SNAPSHOT - ../parent - - - messagebus-util - bundle - ${project.artifactId} - - - - org.opendaylight.mdsal - mdsal-binding-api - - - org.opendaylight.mdsal - mdsal-dom-api - - - org.opendaylight.controller - messagebus-api - - - - org.glassfish.jersey.test-framework.providers - jersey-test-framework-provider-grizzly2 - test - - - diff --git a/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotification.java b/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotification.java deleted file mode 100644 index 7afb381eca..0000000000 --- a/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotification.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 + "]"; - } -} diff --git a/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/Util.java b/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/Util.java deleted file mode 100644 index 8546f9a929..0000000000 --- a/opendaylight/md-sal/messagebus-util/src/main/java/org/opendaylight/controller/messagebus/app/util/Util.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 ListenableFuture> 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 expandQname(final List list, final Pattern pattern) { - final List 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(); - } -} diff --git a/opendaylight/md-sal/messagebus-util/src/test/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotificationTest.java b/opendaylight/md-sal/messagebus-util/src/test/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotificationTest.java deleted file mode 100644 index fec1f5eb1d..0000000000 --- a/opendaylight/md-sal/messagebus-util/src/test/java/org/opendaylight/controller/messagebus/app/util/TopicDOMNotificationTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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()); - } -} diff --git a/opendaylight/md-sal/messagebus-util/src/test/java/org/opendaylight/controller/messagebus/app/util/UtilTest.java b/opendaylight/md-sal/messagebus-util/src/test/java/org/opendaylight/controller/messagebus/app/util/UtilTest.java deleted file mode 100644 index 49a994c431..0000000000 --- a/opendaylight/md-sal/messagebus-util/src/test/java/org/opendaylight/controller/messagebus/app/util/UtilTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 rpcResult = Util.resultRpcSuccessFor(expectedResult).get(); - assertEquals(expectedResult, rpcResult.getResult()); - assertTrue(rpcResult.isSuccessful()); - assertTrue(rpcResult.getErrors().isEmpty()); - } - { - final Integer expectedResult = 42; - RpcResult 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 paths = new ArrayList<>(); - final Pattern regexPattern = Pattern.compile(".*"); // match everything - final List matchingPaths = Util.expandQname(paths, regexPattern); - assertTrue(matchingPaths.isEmpty()); - } - - // match no path because of regex pattern - { - final List paths = createSchemaPathList(); - final Pattern regexPattern = Pattern.compile("^@.*"); - final List matchingPaths = Util.expandQname(paths, regexPattern); - assertTrue(matchingPaths.isEmpty()); - } - - // match all paths - { - final List paths = createSchemaPathList(); - final Pattern regexPattern = Pattern.compile(".*"); - final List 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 paths = createSchemaPathList(); - final Pattern regexPattern = Pattern.compile(".*yyy$"); - final List matchingPaths = Util.expandQname(paths, regexPattern); - assertTrue(matchingPaths.contains(paths.get(1))); - assertEquals(1, matchingPaths.size()); - } - } - - private static List 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); - } -} diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 1e663b534d..0f3ad47769 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -54,12 +54,6 @@ sal-remoterpc-connector - - messagebus-api - messagebus-spi - messagebus-impl - messagebus-util - sal-binding-it -- 2.36.6