diff options
author | Dan Timoney <dt5972@att.com> | 2018-09-27 19:22:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-27 19:22:22 +0000 |
commit | 99931b9cae6e0e02cf54060ac0f1199aad92537a (patch) | |
tree | 1c9931476d6b591d6b4d628e05b06eedbf351fd9 /restconf-client | |
parent | 2c99dfb113ca8a960b08de00b90165f0c1565836 (diff) | |
parent | c8e5aa9f493ec5f80e4444285816ceed27b1752b (diff) |
Merge "Issue fixes for Restconf discovery node"
Diffstat (limited to 'restconf-client')
5 files changed, 41 insertions, 23 deletions
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java index aae80815..e46e47a9 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java @@ -28,17 +28,18 @@ import org.slf4j.LoggerFactory; import java.util.Map; import static org.onap.ccsdk.sli.plugins.prop.JsonParser.convertToProperties; +import static org.slf4j.LoggerFactory.getLogger; /** * Processes the events from event queue and executes callback DG. */ class EventProcessor implements Runnable { - private static final Logger log = LoggerFactory.getLogger(EventProcessor.class); + + private static final Logger log = getLogger(EventProcessor.class); private RestconfDiscoveryNode node; - private static final String EVENT_SUBSCRIPTION_ID = "ietf-notification:notification" + - ".ietf-yang-push:push-change-update" + - ".subscription-id"; + private static final String EVENT_SUBSCRIPTION_ID = "ietf-restconf:" + + "notification.ietf-yang-push:push-change-update.subscription-id"; public EventProcessor(RestconfDiscoveryNode node) { this.node = node; diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java index f5366a54..111d6284 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -26,7 +26,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -37,12 +36,15 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; +import static org.slf4j.LoggerFactory.getLogger; + /** * Representation of a plugin to subscribe for notification and then * to handle the received notifications. */ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { - private static final Logger log = LoggerFactory.getLogger(RestconfDiscoveryNode.class); + + private static final Logger log = getLogger(RestconfDiscoveryNode.class); private ExecutorService executor = Executors.newCachedThreadPool(); private Map<String, PersistentConnection> runnableInfo = new ConcurrentHashMap<>(); @@ -54,15 +56,19 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { private static final String SUBSCRIBER_ID = "subscriberId"; private static final String RESPONSE_CODE = "response-code"; private static final String RESPONSE_PREFIX = "responsePrefix"; - private static final String OUTPUT_IDENTIFIER = "ietf-subscribed-notifications:output.identifier"; + private static final String OUTPUT_IDENTIFIER = "ietf-subscribed-notif" + + "ications:establish-subscription.output.identifier"; private static final String RESPONSE_CODE_200 = "200"; private static final String SSE_URL = "sseConnectURL"; /** - * Creates an instance of RestconfDiscoveryNode and - * starts processing of event. + * Creates an instance of RestconfDiscoveryNode and starts processing of + * event. + * + * @param r restconf api call node */ - public RestconfDiscoveryNode() { + public RestconfDiscoveryNode(RestconfApiCallNode r) { + this.restconfApiCallNode = r; ExecutorService e = Executors.newFixedThreadPool(20); EventProcessor p = new EventProcessor(this); for (int i = 0; i < 20; ++i) { diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java index 725826bd..1cc6261a 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java @@ -142,7 +142,7 @@ class SvcLogicGraphInfo { SvcLogicStore store = service.getStore(); if (store != null) { - SvcLogicGraph subGraph = store.fetch(module, rpc, version, mode); + SvcLogicGraph subGraph = store.fetch(module, rpc, mode, version); if (subGraph != null) { ctx.setAttribute("subGraph", subGraph.toString()); service.execute(subGraph, ctx); diff --git a/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml b/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml index c8f2dc4c..45c335b1 100755 --- a/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml +++ b/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml @@ -32,7 +32,9 @@ <argument ref="restapiCallNodeProvider"/> </bean> - <bean id="restconfDiscoveryNodeProvider" class="org.onap.ccsdk.sli.plugins.restconfdiscovery.RestconfDiscoveryNode" /> + <bean id="restconfDiscoveryNodeProvider" class="org.onap.ccsdk.sli.plugins.restconfdiscovery.RestconfDiscoveryNode" > + <argument ref="restconfapiCallNodeProvider"/> + </bean> <service ref="restconfapiCallNodeProvider"> <interfaces> diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java index db878f0a..b2094ca7 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java @@ -20,16 +20,19 @@ package org.onap.ccsdk.sli.plugins.restconfdiscovery; -import java.net.URI; -import java.util.HashMap; -import java.util.Map; - import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.media.sse.SseFeature; import org.glassfish.jersey.server.ResourceConfig; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -47,13 +50,15 @@ public class TestRestconfDiscoveryNode { ctx.setAttribute("prop.encoding-json", "encoding-json"); ctx.setAttribute("restapi-result.response-code", "200"); ctx.setAttribute("restapi-result.ietf-subscribed-notifications" + - ":output.identifier", "100"); + ":establish-subscription.output.identifier", + "100"); Map<String, String> p = new HashMap<>(); p.put("sseConnectURL", "http://localhost:8080/events"); p.put("subscriberId", "networkId"); p.put("responsePrefix", "restapi-result"); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); rdn.establishPersistentConnection(p, ctx, "networkId"); Thread.sleep(2000); rdn.deleteSubscription(p, ctx); @@ -75,7 +80,8 @@ public class TestRestconfDiscoveryNode { throws SvcLogicException{ SvcLogicContext ctx = new SvcLogicContext(); Map<String, String> p = new HashMap<>(); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); rdn.establishSubscription(p, ctx); } @@ -84,7 +90,8 @@ public class TestRestconfDiscoveryNode { SvcLogicContext ctx = new SvcLogicContext(); ctx.setAttribute("restapi-result.response-code", "200"); ctx.setAttribute("response-code", "404"); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); assertThat(rdn.getResponseCode("restapi-result", ctx), is("200")); assertThat(rdn.getResponseCode(null, ctx), @@ -95,10 +102,12 @@ public class TestRestconfDiscoveryNode { public void testOutputIdentifier() { SvcLogicContext ctx = new SvcLogicContext(); ctx.setAttribute("restapi-result.ietf-subscribed-notifications:" + - "output.identifier", "89"); - ctx.setAttribute("ietf-subscribed-notifications:output.identifier", + "establish-subscription.output.identifier", "89"); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + ctx.setAttribute("ietf-subscribed-notifications:establish-subscripti" + + "on.output.identifier", "89"); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); assertThat(rdn.getOutputIdentifier("restapi-result", ctx), is("89")); } |