From 8e4f48115539cf45bb3ad0f1dcd96539314eff5d Mon Sep 17 00:00:00 2001 From: Michael Dürre Date: Wed, 25 Mar 2020 08:35:03 +0100 Subject: fix connection state machine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed state handlers for netconf nodes Issue-ID: SDNC-1134 Signed-off-by: Michael Dürre Change-Id: Ibd63e84e4cc891a03ef5bd499760804a8cb89e93 (cherry picked from commit a5e2f5a7f1c71954215615a58c1364c7bfe785bd) --- .../model/src/main/yang/netconfnode-state.yang | 94 ++++++++++++++++++++++ .../src/main/yang/netconfnodestateservice.yang | 64 --------------- .../impl/NetconfNodeStateServiceImpl.java | 21 ++--- .../test/TestNetconfNodeStateService.java | 4 +- 4 files changed, 108 insertions(+), 75 deletions(-) create mode 100644 sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnode-state.yang delete mode 100644 sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnodestateservice.yang (limited to 'sdnr/wt/netconfnode-state-service') diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnode-state.yang b/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnode-state.yang new file mode 100644 index 000000000..cd6c92e31 --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnode-state.yang @@ -0,0 +1,94 @@ +module netconfnode-state { + + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:netconfnode-state"; + prefix netconfnode-state; + + import data-provider { + prefix data-provider; + } + + organization + "highstreet technologies GmbH"; + contact + "Web: + ONAP: "; + + description + "netconfnode-state-service Api Module + + Copyright 2019 highstreet technologies GmbH Intellectual Property. + All rights reserved. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2019-10-11 { + description + "Initial revision"; + reference + "https://jira.onap.org/browse/SDNC-877"; + } + + container fault-notification { + description + "Handle fault problem notification of a network-element"; + uses data-provider:object-change-reference; + uses data-provider:fault; + } + container attribute-change-notification { + description + "Handle attribute change notification of a network-element"; + uses data-provider:object-change-reference; + uses data-provider:attribute-change; + } + + rpc push-fault-notification { + description + "Forward fault problem notification of a network-element"; + input { + uses data-provider:object-change-reference; + uses data-provider:fault; + } + } + + rpc push-attribute-change-notification { + description + "Forward attribute change notification of a network-element"; + input { + uses data-provider:object-change-reference; + uses data-provider:attribute-change; + } + } + + rpc get-status { + description + "Returns status information"; + output { + list status { + key "key"; + leaf key { + type string; + description + "A unique identifier for the status."; + } + leaf value { + type string; + description + "The value corresponding to the key."; + } + description + "Provides a key value list with status information"; + } + } + } +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnodestateservice.yang b/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnodestateservice.yang deleted file mode 100644 index 737f858de..000000000 --- a/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnodestateservice.yang +++ /dev/null @@ -1,64 +0,0 @@ -module netconfnode-state { - - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:netconfnode-state"; - prefix "netconfnode-state"; - - import data-provider { prefix "data-provider"; } - - description - "sdnr-wt-netconfnode-state-service Api Module"; - - revision "2019-10-11" { - description - "Initial revision"; - } - - container fault-notification { - description - "Handle fault problem notification of a network-element"; - uses data-provider:object-change-reference; - uses data-provider:fault; - } - container attribute-change-notification { - description - "Handle attribute change notification of a network-element"; - uses data-provider:object-change-reference; - uses data-provider:attribute-change; - } - rpc push-fault-notification { - description - "Forward fault problem notification of a network-element"; - input { - uses data-provider:object-change-reference; - uses data-provider:fault; - } - } - rpc push-attribute-change-notification { - description - "Forward attribute change notification of a network-element"; - input { - uses data-provider:object-change-reference; - uses data-provider:attribute-change; - } - } - - rpc get-status { - description - "Returns status information"; - - output { - list status { - description "Provides a key value list with status information"; - key key; - leaf key { - type string; - } - leaf value { - type string; - } - } - } - } -} - diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java index 041ab9a23..adced6b33 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java @@ -460,7 +460,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc // enterConnected state.after == connected // => Here create or update by checking root.getDataBefore() != null - boolean connectedBefore, connectedAfter; + boolean connectedBefore, connectedAfter, created=false; NetconfNode nNodeAfter = getNetconfNode(root.getDataAfter()); connectedAfter = isConnected(nNodeAfter); if (root.getDataBefore() != null) { @@ -470,6 +470,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc } else { // It is a create connectedBefore = false; + created = true; } LOG.info( @@ -477,14 +478,16 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc nodeId, connectedBefore, connectedAfter, getClusteredConnectionStatus(nNodeAfter), isCluster); + if(created) { + netconfNodeStateListenerList.forEach(item -> { + try { + item.onCreated(nodeId, nNodeAfter); + } catch (Exception e) { + LOG.info("Exception during onCreated listener call", e); + } + }); + } if (!connectedBefore && connectedAfter) { - netconfNodeStateListenerList.forEach(item -> { - try { - item.onCreated(nodeId, nNodeAfter); - } catch (Exception e) { - LOG.info("Exception during onCreated listener call", e); - } - }); enterConnectedState(nodeId, nNodeAfter); } else { LOG.debug("State change {} {}", connectedBefore, connectedAfter); @@ -534,7 +537,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc @Override public void onDataTreeChanged(@NonNull Collection> changes) { LOG.info("L1 TreeChange enter changes:{}", changes.size()); - onDataTreeChangedHandler(changes); + new Thread( () -> onDataTreeChangedHandler(changes)).start(); LOG.info("L1 TreeChange leave"); } } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java index 372d41225..5427c0339 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java @@ -179,7 +179,7 @@ public class TestNetconfNodeStateService { @SuppressWarnings("unchecked") @Test - public void test5OnConnect() { + public void test5OnConnect() throws InterruptedException { System.out.println("Test5: On Connect"); NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder(); netconfNodeBuilder.setConnectionStatus(ConnectionStatus.Connected); @@ -208,7 +208,7 @@ public class TestNetconfNodeStateService { Collection> changes = Arrays.asList(ntn); dataBrokerNetconf.sendClusteredChanges(changes); dataBrokerNetconf.sendChanges(changes); - + Thread.sleep(300); //verify that it was called one time and nodeId is the expected ArgumentCaptor varArgs = ArgumentCaptor.forClass(NetconfAccessor.class); verify(nCL).onEnterConnected(varArgs.capture()); -- cgit 1.2.3-korg