diff options
author | Dan Timoney <dtimoney@att.com> | 2020-03-25 13:48:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-03-25 13:48:52 +0000 |
commit | 30691263393c3862ed0707220afeb1a9a44d7773 (patch) | |
tree | 58c11a1f3dfaf37d52f5c347d07b269e9124483d /sdnr/wt/netconfnode-state-service/provider | |
parent | e5f9b77e15c14992bfb7771a254b8d0b45c7ea28 (diff) | |
parent | a5e2f5a7f1c71954215615a58c1364c7bfe785bd (diff) |
Merge "fix connection state machine"
Diffstat (limited to 'sdnr/wt/netconfnode-state-service/provider')
2 files changed, 14 insertions, 11 deletions
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<DataTreeModification<Node>> 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<DataTreeModification<Node>> 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<NetconfAccessor> varArgs = ArgumentCaptor.forClass(NetconfAccessor.class); verify(nCL).onEnterConnected(varArgs.capture()); |