From: Tomas Olvecky Date: Mon, 14 Apr 2014 08:22:26 +0000 (+0200) Subject: Resolve Bug:713 - Open snapshot only once per session. X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~229^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=90eec30ff127328e9945a097eb251b7afa54b93c Resolve Bug:713 - Open snapshot only once per session. Rework NetconfOperationServiceSnapshot lifecycle: Open it when session negotiator is requested, thus at entry point where both hello message and session listener is created. Close the snapshot when NetconfSessionListener receives down/terminated event. Change-Id: Id491110524ab635e552a49f48e4938dd7113d8bf Signed-off-by: Tomas Olvecky --- diff --git a/opendaylight/netconf/netconf-impl/pom.xml b/opendaylight/netconf/netconf-impl/pom.xml index b8b3028708..4e78b2e4d6 100644 --- a/opendaylight/netconf/netconf-impl/pom.xml +++ b/opendaylight/netconf/netconf-impl/pom.xml @@ -157,6 +157,14 @@ org.apache.maven.plugins maven-jar-plugin 2.4 + + + package + + test-jar + + + diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java index ee9009762e..130818b12a 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java @@ -12,13 +12,12 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.EventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.util.concurrent.Promise; - -import java.net.InetSocketAddress; - import org.opendaylight.controller.netconf.impl.util.DeserializerExceptionHandler; import org.opendaylight.controller.netconf.util.AbstractChannelInitializer; import org.opendaylight.protocol.framework.AbstractDispatcher; +import java.net.InetSocketAddress; + public class NetconfServerDispatcher extends AbstractDispatcher { private final ServerChannelInitializer initializer; @@ -44,12 +43,11 @@ public class NetconfServerDispatcher extends AbstractDispatcher promise) { - ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR, negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise)); + ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR, + negotiatorFactory.getSessionNegotiator(null, ch, promise)); } } diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java index a44b7a799d..86cfac0b60 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java @@ -33,10 +33,13 @@ public class NetconfServerSessionListener implements NetconfSessionListener { - private final NetconfOperationProvider netconfOperationProvider; - private final DefaultCommitNotificationProducer commitNotifier; - - private final SessionIdProvider idProvider; - private final SessionMonitoringService monitor; + private final NetconfOperationServiceSnapshot netconfOperationServiceSnapshot; + private final CapabilityProvider capabilityProvider; + + public NetconfServerSessionListenerFactory(DefaultCommitNotificationProducer commitNotifier, + SessionMonitoringService monitor, + NetconfOperationServiceSnapshot netconfOperationServiceSnapshot, + CapabilityProvider capabilityProvider) { - public NetconfServerSessionListenerFactory(NetconfOperationProvider netconfOperationProvider, - DefaultCommitNotificationProducer commitNotifier, - SessionIdProvider idProvider, SessionMonitoringService monitor) { - this.netconfOperationProvider = netconfOperationProvider; this.commitNotifier = commitNotifier; - this.idProvider = idProvider; this.monitor = monitor; + this.netconfOperationServiceSnapshot = netconfOperationServiceSnapshot; + this.capabilityProvider = capabilityProvider; } @Override public NetconfServerSessionListener getSessionListener() { - NetconfOperationServiceSnapshot netconfOperationServiceSnapshot = netconfOperationProvider.getSnapshot( - getNetconfSessionIdForReporting(idProvider.getCurrentSessionId())); - - CapabilityProvider capabilityProvider = new CapabilityProviderImpl(netconfOperationServiceSnapshot); - NetconfOperationRouter operationRouter = NetconfOperationRouterImpl.createOperationRouter( - netconfOperationServiceSnapshot, capabilityProvider, - commitNotifier); - - return new NetconfServerSessionListener(operationRouter, monitor); + netconfOperationServiceSnapshot, capabilityProvider, commitNotifier); + return new NetconfServerSessionListener(operationRouter, monitor, netconfOperationServiceSnapshot); } } diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiator.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiator.java index f8024922cf..5c389fa966 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiator.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiator.java @@ -8,8 +8,10 @@ package org.opendaylight.controller.netconf.impl; -import java.net.InetSocketAddress; - +import com.google.common.base.Optional; +import io.netty.channel.Channel; +import io.netty.util.Timer; +import io.netty.util.concurrent.Promise; import org.opendaylight.controller.netconf.api.NetconfServerSessionPreferences; import org.opendaylight.controller.netconf.util.AbstractNetconfSessionNegotiator; import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage; @@ -17,11 +19,7 @@ import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAddi import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Optional; - -import io.netty.channel.Channel; -import io.netty.util.Timer; -import io.netty.util.concurrent.Promise; +import java.net.InetSocketAddress; public class NetconfServerSessionNegotiator extends AbstractNetconfSessionNegotiator { @@ -52,4 +50,4 @@ public class NetconfServerSessionNegotiator extends return new NetconfServerSession(sessionListener, channel, getSessionPreferences().getSessionId(), parsedHeader); } - } +} diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiatorFactory.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiatorFactory.java index b3fa3467ad..6fce8d333a 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiatorFactory.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiatorFactory.java @@ -14,7 +14,9 @@ import io.netty.util.Timer; import io.netty.util.concurrent.Promise; import org.opendaylight.controller.netconf.api.NetconfServerSessionPreferences; import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider; +import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider; +import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot; import org.opendaylight.controller.netconf.util.NetconfUtil; import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage; import org.opendaylight.controller.netconf.util.xml.XMLNetconfUtil; @@ -43,13 +45,18 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF private final SessionIdProvider idProvider; private final NetconfOperationProvider netconfOperationProvider; private final long connectionTimeoutMillis; + private final DefaultCommitNotificationProducer commitNotificationProducer; + private final SessionMonitoringService monitoringService; public NetconfServerSessionNegotiatorFactory(Timer timer, NetconfOperationProvider netconfOperationProvider, - SessionIdProvider idProvider, long connectionTimeoutMillis) { + SessionIdProvider idProvider, long connectionTimeoutMillis, + DefaultCommitNotificationProducer commitNot, SessionMonitoringService monitoringService) { this.timer = timer; this.netconfOperationProvider = netconfOperationProvider; this.idProvider = idProvider; this.connectionTimeoutMillis = connectionTimeoutMillis; + this.commitNotificationProducer = commitNot; + this.monitoringService = monitoringService; } private static Document loadHelloMessageTemplate() { @@ -60,13 +67,30 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF return NetconfUtil.createMessage(resourceAsStream).getDocument(); } + /** + * + * @param defunctSessionListenerFactory will not be taken into account as session listener factory can + * only be created after snapshot is opened, thus this method constructs + * proper session listener factory. + * @param channel Underlying channel + * @param promise Promise to be notified + * @return session negotiator + */ @Override - public SessionNegotiator getSessionNegotiator(SessionListenerFactory sessionListenerFactory, Channel channel, - Promise promise) { + public SessionNegotiator getSessionNegotiator(SessionListenerFactory defunctSessionListenerFactory, + Channel channel, Promise promise) { long sessionId = idProvider.getNextSessionId(); + NetconfOperationServiceSnapshot netconfOperationServiceSnapshot = netconfOperationProvider.openSnapshot( + getNetconfSessionIdForReporting(sessionId)); + CapabilityProvider capabilityProvider = new CapabilityProviderImpl(netconfOperationServiceSnapshot); + + NetconfServerSessionPreferences proposal = new NetconfServerSessionPreferences( + createHelloMessage(sessionId, capabilityProvider), sessionId); + + NetconfServerSessionListenerFactory sessionListenerFactory = new NetconfServerSessionListenerFactory( + commitNotificationProducer, monitoringService, + netconfOperationServiceSnapshot, capabilityProvider); - NetconfServerSessionPreferences proposal = new NetconfServerSessionPreferences(createHelloMessage(sessionId), - sessionId); return new NetconfServerSessionNegotiator(proposal, promise, channel, timer, sessionListenerFactory.getSessionListener(), connectionTimeoutMillis); } @@ -76,7 +100,7 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF private static final XPathExpression capabilitiesXPath = XMLNetconfUtil .compileXPath("/netconf:hello/netconf:capabilities"); - private NetconfHelloMessage createHelloMessage(long sessionId) { + private NetconfHelloMessage createHelloMessage(long sessionId, CapabilityProvider capabilityProvider) { Document helloMessageTemplate = getHelloTemplateClone(); // change session ID @@ -88,9 +112,6 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF final Element capabilitiesElement = (Element) XmlUtil.evaluateXPath(capabilitiesXPath, helloMessageTemplate, XPathConstants.NODE); - CapabilityProvider capabilityProvider = new CapabilityProviderImpl(netconfOperationProvider.getSnapshot( - getNetconfSessionIdForReporting(sessionId))); - for (String capability : capabilityProvider.getCapabilities()) { final Element capabilityElement = helloMessageTemplate.createElement(XmlNetconfConstants.CAPABILITY); capabilityElement.setTextContent(capability); diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivator.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivator.java index 04eda09287..bbd07e42bf 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivator.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivator.java @@ -9,13 +9,12 @@ package org.opendaylight.controller.netconf.impl.osgi; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.util.HashedWheelTimer; -import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider; import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService; import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer; import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher; -import org.opendaylight.controller.netconf.impl.NetconfServerSessionListenerFactory; import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory; import org.opendaylight.controller.netconf.impl.SessionIdProvider; +import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider; import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -50,20 +49,19 @@ public class NetconfImplActivator implements BundleActivator { SessionIdProvider idProvider = new SessionIdProvider(); timer = new HashedWheelTimer(); long connectionTimeoutMillis = NetconfConfigUtil.extractTimeoutMillis(context); - NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory( - timer, factoriesListener, idProvider, connectionTimeoutMillis); + commitNot = new DefaultCommitNotificationProducer(ManagementFactory.getPlatformMBeanServer()); - NetconfMonitoringServiceImpl monitoringService = startMonitoringService(context, factoriesListener); + SessionMonitoringService monitoringService = startMonitoringService(context, factoriesListener); - NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory( - factoriesListener, commitNot, idProvider, monitoringService); + NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory( + timer, factoriesListener, idProvider, connectionTimeoutMillis, commitNot, monitoringService); eventLoopGroup = new NioEventLoopGroup(); NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer( - serverNegotiatorFactory, listenerFactory); + serverNegotiatorFactory); NetconfServerDispatcher dispatch = new NetconfServerDispatcher(serverChannelInitializer, eventLoopGroup, eventLoopGroup); logger.info("Starting TCP netconf server at {}", address); diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfMonitoringServiceImpl.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfMonitoringServiceImpl.java index f9b0a128e0..a7560fadb6 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfMonitoringServiceImpl.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfMonitoringServiceImpl.java @@ -70,7 +70,7 @@ public class NetconfMonitoringServiceImpl implements NetconfMonitoringService, S @Override public Schemas getSchemas() { // capabilities should be split from operations (it will allow to move getSchema operation to monitoring module) - try (NetconfOperationServiceSnapshot snapshot = netconfOperationProvider.getSnapshot("netconf-monitoring")) { + try (NetconfOperationServiceSnapshot snapshot = netconfOperationProvider.openSnapshot("netconf-monitoring")) { return transformSchemas(snapshot.getServices()); } catch (RuntimeException e) { throw e; diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryListenerImpl.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryListenerImpl.java index 28bc2da778..63cd0baf34 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryListenerImpl.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryListenerImpl.java @@ -28,7 +28,7 @@ public class NetconfOperationServiceFactoryListenerImpl implements NetconfOperat } @Override - public synchronized NetconfOperationServiceSnapshotImpl getSnapshot(String sessionIdForReporting) { + public synchronized NetconfOperationServiceSnapshotImpl openSnapshot(String sessionIdForReporting) { return new NetconfOperationServiceSnapshotImpl(allFactories, sessionIdForReporting); } diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java index 82e8caef3a..db5a359d7a 100644 --- a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java +++ b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java @@ -18,7 +18,6 @@ import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.client.test.TestingNetconfClient; @@ -53,7 +52,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doNothing; -import static org.mockito.MockitoAnnotations.initMocks; +import static org.mockito.Mockito.mock; public class ConcurrentClientsTest { @@ -68,14 +67,20 @@ public class ConcurrentClientsTest { private DefaultCommitNotificationProducer commitNot; private NetconfServerDispatcher dispatch; - @Mock - private SessionMonitoringService monitoring; + HashedWheelTimer hashedWheelTimer; + public static SessionMonitoringService createMockedMonitoringService() { + SessionMonitoringService monitoring = mock(SessionMonitoringService.class); + doNothing().when(monitoring).onSessionUp(any(NetconfServerSession.class)); + doNothing().when(monitoring).onSessionDown(any(NetconfServerSession.class)); + return monitoring; + } + @Before public void setUp() throws Exception { - initMocks(this); + nettyGroup = new NioEventLoopGroup(); NetconfHelloMessageAdditionalHeader additionalHeader = new NetconfHelloMessageAdditionalHeader("uname", "10.10.10.1", "830", "tcp", "client"); netconfClientDispatcher = new NetconfClientDispatcher( nettyGroup, nettyGroup, additionalHeader, 5000); @@ -86,16 +91,13 @@ public class ConcurrentClientsTest { SessionIdProvider idProvider = new SessionIdProvider(); hashedWheelTimer = new HashedWheelTimer(); NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory( - hashedWheelTimer, factoriesListener, idProvider, 5000); + hashedWheelTimer, factoriesListener, idProvider, 5000, commitNot, createMockedMonitoringService()); commitNot = new DefaultCommitNotificationProducer(ManagementFactory.getPlatformMBeanServer()); - doNothing().when(monitoring).onSessionUp(any(NetconfServerSession.class)); - doNothing().when(monitoring).onSessionDown(any(NetconfServerSession.class)); - NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory( - factoriesListener, commitNot, idProvider, monitoring); - NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory, listenerFactory); + + NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory); dispatch = new NetconfServerDispatcher(serverChannelInitializer, nettyGroup, nettyGroup); ChannelFuture s = dispatch.createServer(netconfAddress); diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfDispatcherImplTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfDispatcherImplTest.java index b60f4e3d82..42bd033c71 100644 --- a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfDispatcherImplTest.java +++ b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfDispatcherImplTest.java @@ -27,6 +27,7 @@ public class NetconfDispatcherImplTest { private DefaultCommitNotificationProducer commitNot; private HashedWheelTimer hashedWheelTimer; + @Before public void setUp() throws Exception { nettyGroup = new NioEventLoopGroup(); @@ -38,11 +39,9 @@ public class NetconfDispatcherImplTest { SessionIdProvider idProvider = new SessionIdProvider(); hashedWheelTimer = new HashedWheelTimer(); NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory( - hashedWheelTimer, factoriesListener, idProvider, 5000); + hashedWheelTimer, factoriesListener, idProvider, 5000, commitNot, ConcurrentClientsTest.createMockedMonitoringService()); - NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory( - factoriesListener, commitNot, idProvider, null); - NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory, listenerFactory); + NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory); dispatch = new NetconfServerDispatcher( serverChannelInitializer, nettyGroup, nettyGroup); diff --git a/opendaylight/netconf/netconf-it/pom.xml b/opendaylight/netconf/netconf-it/pom.xml index 68fd34e135..3ca79be9d9 100644 --- a/opendaylight/netconf/netconf-it/pom.xml +++ b/opendaylight/netconf/netconf-it/pom.xml @@ -74,6 +74,12 @@ netconf-impl test + + ${project.groupId} + netconf-impl + test + test-jar + ${project.groupId} netconf-monitoring diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/AbstractNetconfConfigTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/AbstractNetconfConfigTest.java index b261218bf1..b81f950cb3 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/AbstractNetconfConfigTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/AbstractNetconfConfigTest.java @@ -15,7 +15,6 @@ import org.junit.Before; import org.opendaylight.controller.config.manager.impl.AbstractConfigTest; import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer; import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher; -import org.opendaylight.controller.netconf.impl.NetconfServerSessionListenerFactory; import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory; import org.opendaylight.controller.netconf.impl.SessionIdProvider; import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl; @@ -39,14 +38,10 @@ public class AbstractNetconfConfigTest extends AbstractConfigTest { SessionIdProvider idProvider = new SessionIdProvider(); NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory( - hashedWheelTimer, factoriesListener, idProvider, 5000); - - NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory( - factoriesListener, commitNotifier, idProvider, - sessionMonitoringService); + hashedWheelTimer, factoriesListener, idProvider, 5000, commitNotifier, sessionMonitoringService); NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer( - serverNegotiatorFactory, listenerFactory); + serverNegotiatorFactory); return new NetconfServerDispatcher(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup); } diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java index f61a28c2ab..fc1c73f7b0 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java @@ -186,7 +186,7 @@ public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest { doReturn(caps).when(service).getCapabilities(); Set services = Sets.newHashSet(service); doReturn(services).when(snap).getServices(); - doReturn(snap).when(factoriesListener).getSnapshot(anyString()); + doReturn(snap).when(factoriesListener).openSnapshot(anyString()); return factoriesListener; } diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java index a1892dbb0b..ae4a9bf4b2 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java @@ -121,7 +121,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest { NetconfOperationProvider netconfOperationProvider = mock(NetconfOperationProvider.class); NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class); doReturn(Collections.emptySet()).when(snap).getServices(); - doReturn(snap).when(netconfOperationProvider).getSnapshot(anyString()); + doReturn(snap).when(netconfOperationProvider).openSnapshot(anyString()); return new NetconfMonitoringServiceImpl(netconfOperationProvider); } diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java index 5805e0afd1..e36261c6eb 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java @@ -219,7 +219,7 @@ public class NetconfMonitoringITTest extends AbstractNetconfConfigTest { doReturn(caps).when(service).getCapabilities(); Set services = Sets.newHashSet(service); doReturn(services).when(snap).getServices(); - doReturn(snap).when(factoriesListener).getSnapshot(anyString()); + doReturn(snap).when(factoriesListener).openSnapshot(anyString()); return factoriesListener; } diff --git a/opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/NetconfOperationProvider.java b/opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/NetconfOperationProvider.java index c72c39c30c..f5c50f8167 100644 --- a/opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/NetconfOperationProvider.java +++ b/opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/NetconfOperationProvider.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.netconf.mapping.api; public interface NetconfOperationProvider { - NetconfOperationServiceSnapshot getSnapshot(String sessionIdForReporting); + NetconfOperationServiceSnapshot openSnapshot(String sessionIdForReporting); public static class NetconfOperationProviderUtil { diff --git a/opendaylight/netconf/pom.xml b/opendaylight/netconf/pom.xml index 9a71c47193..ab71180ba9 100644 --- a/opendaylight/netconf/pom.xml +++ b/opendaylight/netconf/pom.xml @@ -137,6 +137,12 @@ netconf-impl ${netconf.version} + + ${project.groupId} + netconf-impl + ${netconf.version} + test-jar + ${project.groupId} netconf-monitoring