From 754c972d1788febb1439567247d8e4a82f82c595 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Thu, 19 Mar 2015 18:16:49 +0100 Subject: [PATCH] BUG-2739 Fix concurrent metadata cleanup for netconf-connector When deleting/closing a netconf-connector, the cleanup came from 2-3 places and was not properly synchronized resulting in failed transaction with metadata still present Change-Id: I91f1c8bf3d5d24cc2cf4fdb02fb1f5cc3f8a8796 Signed-off-by: Maros Marsalek --- .../connect/netconf/listener/NetconfDeviceCommunicator.java | 5 ++--- .../sal/connect/netconf/sal/NetconfDeviceSalFacade.java | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java index ce5aa79af0..4f2f6ab38e 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java @@ -110,7 +110,7 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener, @Override public void operationComplete(Future future) throws Exception { - if (!future.isSuccess()) { + if (!future.isSuccess() && !future.isCancelled()) { logger.debug("{}: Connection failed", id, future.cause()); NetconfDeviceCommunicator.this.remoteDevice.onRemoteSessionFailed(future.cause()); } @@ -197,9 +197,8 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener, // Disconnect from device if(session != null) { session.close(); + // tear down not necessary, called indirectly by above close } - - tearDown(id + ": Netconf session closed"); } @Override diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java index ad16532bad..11f82c02bf 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java @@ -73,14 +73,14 @@ public final class NetconfDeviceSalFacade implements AutoCloseable, RemoteDevice } @Override - public void onDeviceFailed(final Throwable throwable) { + public synchronized void onDeviceFailed(final Throwable throwable) { salProvider.getTopologyDatastoreAdapter().setDeviceAsFailed(throwable); salProvider.getMountInstance().onDeviceDisconnected(); salProvider.getMountInstance().onTopologyDeviceDisconnected(); } @Override - public void close() { + public synchronized void close() { for (final AutoCloseable reg : Lists.reverse(salRegistrations)) { closeGracefully(reg); } -- 2.36.6