Add DOM blueprint XML 78/73378/4
authorTom Pantelis <tompantelis@gmail.com>
Sat, 23 Jun 2018 03:38:19 +0000 (23:38 -0400)
committerTom Pantelis <tompantelis@gmail.com>
Sat, 23 Jun 2018 20:44:51 +0000 (16:44 -0400)
In order to start using the mdsal DOM APIs,
we need them advertised.

Change-Id: I4988119c399c5984da0b1c56fc7a2d9704c4e176
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DefaultDOMRpcException.java [new file with mode: 0644]
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouter.java
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRouter.java
dom/mdsal-dom-broker/src/main/resources/org/opendaylight/blueprint/dom-broker.xml [new file with mode: 0644]

diff --git a/dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DefaultDOMRpcException.java b/dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DefaultDOMRpcException.java
new file mode 100644 (file)
index 0000000..4a99b96
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2018 Inocybe Technologies 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.mdsal.dom.api;
+
+/**
+ * Default implementation of DOMRpcException.
+ *
+ * @author Thomas Pantelis
+ */
+public class DefaultDOMRpcException extends DOMRpcException {
+    private static final long serialVersionUID = 1L;
+
+    public DefaultDOMRpcException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
index 78ba3cc19b6b75ac1a7a40396f49d0b2654ec904..e8a307c95841474ed3afdf7e86cd195a40981475 100644 (file)
@@ -105,6 +105,8 @@ public class DOMNotificationRouter implements AutoCloseable, DOMNotificationPubl
 
     public static DOMNotificationRouter create(final int queueDepth, final long spinTime,
             final long parkTime, final TimeUnit unit) {
+        Preconditions.checkArgument(Long.lowestOneBit(queueDepth) == Long.highestOneBit(queueDepth),
+                "Queue depth %s is not power-of-two", queueDepth);
         final ExecutorService executor = Executors.newCachedThreadPool();
         final WaitStrategy strategy = PhasedBackoffWaitStrategy.withLock(spinTime, parkTime, unit);
 
index 492fd4abfbd8854b6a3381d62c24710a178636ef..9dce3e929131b5de63d10ad9a82d51eb51085139 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
 import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.mdsal.dom.spi.AbstractDOMRpcImplementationRegistration;
 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -56,6 +57,14 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP
 
     private volatile DOMRpcRoutingTable routingTable = DOMRpcRoutingTable.EMPTY;
 
+    private ListenerRegistration<?> listenerRegistration;
+
+    public static DOMRpcRouter newInstance(final DOMSchemaService schemaService) {
+        final DOMRpcRouter rpcRouter = new DOMRpcRouter();
+        rpcRouter.listenerRegistration = schemaService.registerSchemaContextListener(rpcRouter);
+        return rpcRouter;
+    }
+
     @Override
     public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
             final T implementation, final DOMRpcIdentifier... rpcs) {
@@ -133,6 +142,10 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP
     @Override
     public void close() {
         listenerNotifier.shutdown();
+
+        if (listenerRegistration != null) {
+            listenerRegistration.close();
+        }
     }
 
     @VisibleForTesting
diff --git a/dom/mdsal-dom-broker/src/main/resources/org/opendaylight/blueprint/dom-broker.xml b/dom/mdsal-dom-broker/src/main/resources/org/opendaylight/blueprint/dom-broker.xml
new file mode 100644 (file)
index 0000000..72e42eb
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+    odl:restart-dependents-on-updates="false">
+
+  <cm:property-placeholder persistent-id="org.opendaylight.mdsal.dom.notification" update-strategy="none">
+    <cm:default-properties>
+      <cm:property name="notification-queue-depth" value="65536"/>
+      <cm:property name="notification-queue-spin" value="0"/>
+      <cm:property name="notification-queue-park" value="0"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
+  <!-- Schema Service -->
+
+  <odl:static-reference id="schemaService" interface="org.opendaylight.mdsal.dom.api.DOMSchemaService"/>
+
+  <!-- DOM Notification Service -->
+
+  <bean id="domNotificationRouter" class="org.opendaylight.mdsal.dom.broker.DOMNotificationRouter"
+          factory-method="create">
+    <argument value="${notification-queue-depth}"/>
+    <argument value="${notification-queue-spin}"/>
+    <argument value="${notification-queue-park}"/>
+    <argument value="MILLISECONDS"/>
+  </bean>
+
+  <service ref="domNotificationRouter" odl:type="default">
+    <interfaces>
+      <value>org.opendaylight.mdsal.dom.api.DOMNotificationService</value>
+      <value>org.opendaylight.mdsal.dom.api.DOMNotificationPublishService</value>
+      <value>org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry</value>
+    </interfaces>
+  </service>
+
+  <!-- DOM RPC Service -->
+
+  <bean id="domRpcRouter" class="org.opendaylight.mdsal.dom.broker.DOMRpcRouter"
+          factory-method="newInstance">
+    <argument ref="schemaService"/>
+  </bean>
+
+  <service ref="domRpcRouter" odl:type="default">
+    <interfaces>
+      <value>org.opendaylight.mdsal.dom.api.DOMRpcService</value>
+      <value>org.opendaylight.mdsal.dom.api.DOMRpcProviderService</value>
+    </interfaces>
+  </service>
+
+  <!-- DOM MountPoint Service -->
+
+  <bean id="domMountPointService" class="org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl"/>
+
+  <service ref="domMountPointService" interface="org.opendaylight.mdsal.dom.api.DOMMountPointService"
+        odl:type="default"/>
+
+  <!-- DOM PingPong Data Broker -->
+
+<!--   <reference id="domDefaultDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker" -->
+<!--       odl:type="default"/> -->
+
+<!--   <bean id="domPingPongDataBroker" class="org.opendaylight.controller.md.sal.dom.broker.impl.PingPongDataBroker"> -->
+<!--     <argument ref="domDefaultDataBroker"/> -->
+<!--   </bean> -->
+
+<!--   <service ref="domPingPongDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker" -->
+<!--       odl:type="pingpong"/> -->
+
+</blueprint>