BUG-3128: Update DOM RPC concepts 62/50562/1
authorRobert Varga <rovarga@cisco.com>
Tue, 17 Jan 2017 15:44:34 +0000 (16:44 +0100)
committerRobert Varga <rovarga@cisco.com>
Tue, 17 Jan 2017 15:44:34 +0000 (16:44 +0100)
This is the API part of https://git.opendaylight.org/gerrit/50487,
ported back to MD-SAL.

It allows a DOMRpcAvailabilityListener to request filtering of
notifications based on the RPC implementation class.

The other part of it is the ability for DOMRpcImplementation
to advertise its invocation cost -- allowing the RPC router
to make better routing decisions

Change-Id: Icdd36aeea0780bfae5883abd786244a9291b106f
Signed-off-by: Robert Varga <rovarga@cisco.com>
dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMRpcAvailabilityListener.java
dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMRpcImplementation.java

index 307ce6b95c94f042d999261c255b57a43f7e0c04..3c69ed93e2866d22f86f615f3f4f94fc7284223a 100644 (file)
@@ -29,4 +29,17 @@ public interface DOMRpcAvailabilityListener extends EventListener {
      * @param rpcs RPC types which became unavailable
      */
     void onRpcUnavailable(@Nonnull Collection<DOMRpcIdentifier> rpcs);
+
+    /**
+     * Implementation filtering method. This method is useful for forwarding RPC implementations,
+     * which need to ensure they do not re-announce their own implementations. Without this method
+     * a forwarder which registers an implementation would be notified of its own implementation,
+     * potentially re-exporting it as local -- hence creating a forwarding loop.
+     *
+     * @param impl RPC implementation being registered
+     * @return False if the implementation should not be reported, defaults to true.
+     */
+    default boolean acceptsImplementation(final DOMRpcImplementation impl) {
+        return true;
+    }
 }
index 9bb5150467898df0fda4466df31ea6005259c804..7708001551ee96c347c5ad980fdaf582e7c8e3b6 100644 (file)
@@ -29,4 +29,13 @@ public interface DOMRpcImplementation {
      */
     @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException>
         invokeRpc(@Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode<?, ?> input);
+
+    /**
+     * Return the relative invocation cost of this implementation. Default implementation return 0.
+     *
+     * @return Non-negative cost of invoking this implementation.
+     */
+    default long invocationCost() {
+        return 0;
+    }
 }