Hi All,

I’m writing an Opendaylight application which receives RPCs and then uses 
Apache’s HttpClient library to grab some data to return in the RPC output.

However, whenever I make reference to Request.Get(), the RPC call fails with a 
501 Not Implemented HTTP response code and an error message:
{
  "errors": {
    "error": [
      {
        "error-type": "application",
        "error-tag": "operation-not-supported",
        "error-message": "No implementation of RPC 
AbsoluteSchemaPath{path=[(urn:opendaylight:params:xml:ns:yang:rpc-bug?revision=2015-01-05)noop]}
 available"
      }
    ]
  }
}

Notice how above I said “make reference”, and not call. That’s because this bug 
appears even when the method which calls Request.Get() is NOT CALLED. It 
appears even when you reference Request.Get() in another class which itself is 
not referenced nor instantiated (check out the bug2 branch for this variant).

Since I’m sure you’re now thinking that this is outright impossible, I’ve 
generated a new ODL project using the startup archetype, and implemented a 
minimal noop RPC to demonstrate this issue.

You can clone it here: https://github.com/tjlevine/rpc-bug

Here’s how to demonstrate the bug:
1) First, build the master branch. I used the following command: mvn clean 
install -DskipTests -Dmaven.javadoc.skip
2) Run karaf
3) Once the controller has come up, run the following cURL command:

curl -i -XPOST -H 'Authorization: Basic YWRtaW46YWRtaW4=' -H 'Content-Type: 
application/json' -d '{"input": {}}' 
'http://localhost:8181/restconf/operations/rpc-bug:noop'

4) Notice that we get a 200 return code, and no content. The RPC was successful:

HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1glywbxn7t6mh1396kszy7jkdi;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Wed, 
10-Aug-2016 02:11:24 GMT
Content-Type: application/yang.operation+json
Content-Length: 0
Server: Jetty(8.1.17.v20150415)

5) Now go checkout the branch called “bug”
6) Rebuild and run karaf again
7) Once the controller comes up, run the curl command above once again.
8) Notice that we get a 501 Not Implemented return code, and the error message 
which appears above:

HTTP/1.1 501 Not Implemented
Set-Cookie: JSESSIONID=14dvnl6re3iwcpstpdv707169;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Wed, 
10-Aug-2016 02:17:44 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(8.1.17.v20150415)

{"errors":{"error":[{"error-type":"application","error-tag":"operation-not-supported","error-message":"No
 implementation of RPC 
AbsoluteSchemaPath{path=[(urn:opendaylight:params:xml:ns:yang:rpc-bug?revision=2015-01-05)noop]}
 available"}]}}

9) Now go look at the diff between the master and the bug branches (I’ll save 
you the trouble, it’s right here):

tylevine@TYLEVINE-M-X247:~/src/odl/rpc-bug (bug) $ git diff master..bug
diff --git a/impl/pom.xml b/impl/pom.xml
index 3e95e92..f91e77a 100644
--- a/impl/pom.xml
+++ b/impl/pom.xml
@@ -29,6 +29,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <version>${project.version}</version>
     </dependency>

+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient-osgi</artifactId>
+      <version>4.5.2</version>
+    </dependency>
+
     <!-- Testing Dependencies -->
     <dependency>
       <groupId>junit</groupId>
diff --git a/impl/src/main/java/org/opendaylight/impl/RpcBugProvider.java 
b/impl/src/main/java/org/opendaylight/impl/RpcBugProvider.java
index d89311a..a3243ed 100644
--- a/impl/src/main/java/org/opendaylight/impl/RpcBugProvider.java
+++ b/impl/src/main/java/org/opendaylight/impl/RpcBugProvider.java
@@ -8,6 +8,7 @@
 package org.opendaylight.impl;

 import java.util.concurrent.Future;
+import org.apache.http.client.fluent.Request;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import 
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpc.bug.rev150105.NoopInput;
@@ -30,9 +31,12 @@ public class RpcBugProvider {
         rpcProviderRegistry.addRpcImplementation(RpcBugService.class, new 
RpcBugService() {
             @Override
             public Future<RpcResult<NoopOutput>> noop(NoopInput input) {
-
                 return RpcResultBuilder.<NoopOutput>success().buildFuture();
             }
+
+            private void notCalled() {
+                Request.Get("http://google.com";);
+            }
         });
     }

Now I hope you believe what I say is true :)

This leads me to a few questions:

  1.  Can you reproduce this? I have reproduced this on my local machine as 
well as in a VM running ubuntu 16.04.
  2.  Is this actually a bug? Or is there something I’m missing here that leads 
this to be a desired behavior?
  3.  If this is a bug, is it a bug in Apache’s http client library or in 
MDSAL’s RPC implementation?
  4.  What is the root cause of this rather unusual problem (speculation here 
is acceptable)? Is there any workaround that would allow me to use Apache’s 
http client and MDSAL RPCs in the same project?

Thanks as always,
Tyler Levine
_______________________________________________
controller-dev mailing list
controller-dev@lists.opendaylight.org
https://lists.opendaylight.org/mailman/listinfo/controller-dev
  • [controller-dev... Tyler Levine (tylevine)

Reply via email to