Eliminate PCEPSessionNegotiatorFactoryDependencies 28/104028/3
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 15 Jan 2023 17:48:22 +0000 (18:48 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 15 Jan 2023 22:02:26 +0000 (23:02 +0100)
This is a completely useless construct, just adding overhead and
indirection. This converges argument knowledge, so that we actually
can peel them further.

Change-Id: I4a2c48830086087cdb225fcd399b6b01bde29ecc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 files changed:
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPDispatcher.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactory.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactoryDependencies.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiatorFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/DefaultPCEPSessionNegotiatorFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPDispatcherImpl.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPDispatcherImplTest.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/protocol/PCCDispatcherImpl.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/PCCDispatcherImplTest.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/PCCMockCommon.java
pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/Main.java
pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestToolPCEPNegotiatorDependencies.java [deleted file]
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPSessionNegotiatorFactoryDependenciesImpl.java [deleted file]
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPTopologyProvider.java

index b43e1c5ce7bc7ac9b3f330617985ed6fdd363b01..8babcac7f2375c665d143636332c79cb0c9d3e02 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.pcep;
 import io.netty.channel.ChannelFuture;
 import java.net.InetSocketAddress;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.protocol.concepts.KeyMapping;
 
 /**
@@ -23,10 +24,11 @@ public interface PCEPDispatcher {
      * @param tcpKeys RFC2385 TCP-MD5 keys
      * @param registry a message registry
      * @param negotiatorFactory a negotiation factory
-     * @param negotiatorDependencies PCEPSessionNegotiatorFactoryDependencies
+     * @param listenerFactory {@link PCEPSessionListenerFactory} to create listeners for clients
+     * @param peerProposal optional information used in our Open message
      * @return A future completing when the PCEP server is created
      */
     @NonNull ChannelFuture createServer(@NonNull InetSocketAddress listenAddress, @NonNull KeyMapping tcpKeys,
         @NonNull MessageRegistry registry, @NonNull PCEPSessionNegotiatorFactory negotiatorFactory,
-        @NonNull PCEPSessionNegotiatorFactoryDependencies negotiatorDependencies);
+        @NonNull PCEPSessionListenerFactory listenerFactory, @Nullable PCEPPeerProposal peerProposal);
 }
index 4171610404b8cdbc4f1c022f325a2edd3cb607e7..482e136677197d6d53a7ce419682cbda491b58bf 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.pcep;
 import io.netty.channel.Channel;
 import io.netty.util.concurrent.Promise;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 
 /**
  * Factory for creating PCEP session negotiator.
@@ -18,12 +19,10 @@ public interface PCEPSessionNegotiatorFactory {
     /**
      * Creates PCEPSessionNegotiator instance for income attributes.
      *
-     * @param sessionNegotiatorDependencies contains PCEPSessionNegotiator dependencies
-     * @param channel                       session channel
-     * @param promise                       session promise
+     * @param channel session channel
+     * @param promise session promise
      * @return PCEPSessionNegotiator instance
      */
-    @NonNull SessionNegotiator getSessionNegotiator(
-            @NonNull PCEPSessionNegotiatorFactoryDependencies sessionNegotiatorDependencies,
-            @NonNull Channel channel, @NonNull Promise<PCEPSession> promise);
+    @NonNull SessionNegotiator getSessionNegotiator(@NonNull Channel channel, @NonNull Promise<PCEPSession> promise,
+            @NonNull PCEPSessionListenerFactory listenerFactory, @Nullable PCEPPeerProposal peerProposal);
 }
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactoryDependencies.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactoryDependencies.java
deleted file mode 100644 (file)
index e7c48c9..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * Contains required dependencies for create SessionNegotiator.
- */
-public interface PCEPSessionNegotiatorFactoryDependencies {
-    /**
-     * ListenerFactory to create listeners for clients.
-     *
-     * @return ListenerFactory
-     */
-    @NonNull PCEPSessionListenerFactory getListenerFactory();
-
-    /**
-     * PeerProposal information used in our Open message.
-     *
-     * @return peerProposal null by default since its not mandatory. Otherwise method should be override it.
-     */
-    default @Nullable PCEPPeerProposal getPeerProposal() {
-        return null;
-    }
-}
index 392de1ca122383c585b00db8d622ee3028b4d0da..31f423c3e921560ff943317918ee2e2e1b4bf0dc 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.protocol.pcep.impl;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.primitives.UnsignedBytes;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFutureListener;
@@ -14,9 +16,12 @@ import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
 import java.util.Comparator;
 import java.util.concurrent.ExecutionException;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSession;
+import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
 import org.opendaylight.protocol.pcep.SessionNegotiator;
 import org.opendaylight.protocol.pcep.impl.PCEPPeerRegistry.SessionReference;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
@@ -36,34 +41,34 @@ public abstract class AbstractPCEPSessionNegotiatorFactory implements PCEPSessio
     /**
      * Create a new negotiator. This method needs to be implemented by subclasses to actually provide a negotiator.
      *
-     * @param snd       PCEP Session Negotiator dependencies
-     * @param promise   Session promise to be completed by the negotiator
-     * @param channel   Associated channel
-     * @param sessionId Session ID assigned to the resulting session
+     * @param promise         Session promise to be completed by the negotiator
+     * @param channel         Associated channel
+     * @param sessionId       Session ID assigned to the resulting session
+     * @param listenerFactory {@link PCEPSessionListenerFactory} to create listeners for clients
+     * @param peerProposal    optional information used in our Open message
      * @return a PCEP session negotiator
      */
-    protected abstract AbstractPCEPSessionNegotiator createNegotiator(
-            PCEPSessionNegotiatorFactoryDependencies snd,
-            Promise<PCEPSession> promise,
-            Channel channel, Uint8 sessionId);
+    protected abstract AbstractPCEPSessionNegotiator createNegotiator(Promise<PCEPSession> promise, Channel channel,
+        Uint8 sessionId, PCEPSessionListenerFactory listenerFactory, @Nullable PCEPPeerProposal peerProposal);
 
     @Override
-    public final SessionNegotiator getSessionNegotiator(final PCEPSessionNegotiatorFactoryDependencies dependencies,
-            final Channel channel, final Promise<PCEPSession> promise) {
-
+    public final SessionNegotiator getSessionNegotiator(final Channel channel, final Promise<PCEPSession> promise,
+            final PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal) {
         LOG.debug("Instantiating bootstrap negotiator for channel {}", channel);
-        return new BootstrapSessionNegotiator(channel, promise, dependencies);
+        return new BootstrapSessionNegotiator(channel, promise, listenerFactory, peerProposal);
     }
 
     private final class BootstrapSessionNegotiator extends AbstractSessionNegotiator {
         private static final Comparator<byte[]> COMPARATOR = UnsignedBytes.lexicographicalComparator();
 
-        private final PCEPSessionNegotiatorFactoryDependencies nfd;
+        private final @NonNull PCEPSessionListenerFactory listenerFactory;
+        private final @Nullable PCEPPeerProposal peerProposal;
 
         BootstrapSessionNegotiator(final Channel channel, final Promise<PCEPSession> promise,
-                final PCEPSessionNegotiatorFactoryDependencies dependencies) {
+                final PCEPSessionListenerFactory listenerFactory, final @Nullable PCEPPeerProposal peerProposal) {
             super(promise, channel);
-            nfd = dependencies;
+            this.listenerFactory = requireNonNull(listenerFactory);
+            this.peerProposal = peerProposal;
         }
 
         @Override
@@ -100,7 +105,7 @@ public abstract class AbstractPCEPSessionNegotiatorFactory implements PCEPSessio
                 }
 
                 final Uint8 sessionId = sessionRegistry.nextSession(clientAddress);
-                final AbstractPCEPSessionNegotiator n = createNegotiator(nfd, promise, channel, sessionId);
+                final var negotiator = createNegotiator(promise, channel, sessionId, listenerFactory, peerProposal);
 
                 sessionRegistry.putSessionReference(clientAddress, new SessionReference() {
                     @Override
@@ -125,8 +130,8 @@ public abstract class AbstractPCEPSessionNegotiatorFactory implements PCEPSessio
                 });
 
                 LOG.info("Replacing bootstrap negotiator for channel {}", channel);
-                channel.pipeline().replace(this, "negotiator", n);
-                n.startNegotiation();
+                channel.pipeline().replace(this, "negotiator", negotiator);
+                negotiator.startNegotiation();
             }
         }
 
index f836fb67e8ff8734f4695593fc5c189ff6a3569f..bdcfdb39af9306003ea682db74cbff86f1210cf7 100644 (file)
@@ -15,8 +15,9 @@ import java.net.InetSocketAddress;
 import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.protocol.pcep.PCEPCapability;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSession;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
+import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPTimerProposal;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionTimers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionTls;
@@ -50,13 +51,10 @@ public final class DefaultPCEPSessionNegotiatorFactory extends AbstractPCEPSessi
     }
 
     @Override
-    protected AbstractPCEPSessionNegotiator createNegotiator(
-            final PCEPSessionNegotiatorFactoryDependencies sessionNegotiatorDependencies,
-            final Promise<PCEPSession> promise,
-            final Channel channel,
-            final Uint8 sessionId) {
+    protected AbstractPCEPSessionNegotiator createNegotiator(final Promise<PCEPSession> promise, final Channel channel,
+            final Uint8 sessionId, final PCEPSessionListenerFactory listenerFactory,
+            final PCEPPeerProposal peerProposal) {
         final var address = (InetSocketAddress) channel.remoteAddress();
-        final var peerProposal = sessionNegotiatorDependencies.getPeerProposal();
 
         final var builder = new TlvsBuilder();
         for (final var capability : capabilities) {
@@ -67,8 +65,8 @@ public final class DefaultPCEPSessionNegotiatorFactory extends AbstractPCEPSessi
             peerProposal.setPeerSpecificProposal(address, builder);
         }
 
-        return new DefaultPCEPSessionNegotiator(promise, channel,
-            sessionNegotiatorDependencies.getListenerFactory().getSessionListener(), sessionId, new OpenBuilder()
+        return new DefaultPCEPSessionNegotiator(promise, channel, listenerFactory.getSessionListener(), sessionId,
+            new OpenBuilder()
                 .setSessionId(sessionId)
                 .setKeepalive(timers.keepAlive())
                 .setDeadTimer(timers.deadTimer())
index 4330a7cf9ec926229af5f8acaad861735ade6b72..39791d0d02dcb075d29bd18e3697490ae388f760 100644 (file)
@@ -39,9 +39,10 @@ import org.kohsuke.MetaInfServices;
 import org.opendaylight.protocol.concepts.KeyMapping;
 import org.opendaylight.protocol.pcep.MessageRegistry;
 import org.opendaylight.protocol.pcep.PCEPDispatcher;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSession;
+import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
@@ -110,14 +111,14 @@ public class PCEPDispatcherImpl implements PCEPDispatcher, AutoCloseable {
     @Override
     public final synchronized ChannelFuture createServer(final InetSocketAddress listenAddress,
             final KeyMapping tcpKeys, final MessageRegistry registry,
-            final PCEPSessionNegotiatorFactory negotiatorFactory,
-            final PCEPSessionNegotiatorFactoryDependencies negotiatorDependencies) {
+            final PCEPSessionNegotiatorFactory negotiatorFactory, final PCEPSessionListenerFactory listenerFactory,
+            final PCEPPeerProposal peerProposal) {
         final var hf = new PCEPHandlerFactory(registry);
 
         final ChannelPipelineInitializer initializer = (ch, promise) -> {
             ch.pipeline().addLast(hf.getDecoders());
             ch.pipeline().addLast("negotiator",
-                negotiatorFactory.getSessionNegotiator(negotiatorDependencies, ch, promise));
+                negotiatorFactory.getSessionNegotiator(ch, promise, listenerFactory, peerProposal));
             ch.pipeline().addLast(hf.getEncoders());
         };
 
index a6571a81ff3fdecc4cf40f05f829bb4b677039c6..e37c3e6840e193737ccef4dafa4c1dcf35ac9937 100644 (file)
@@ -49,7 +49,6 @@ import org.opendaylight.protocol.pcep.MessageRegistry;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
 import org.opendaylight.protocol.pcep.PCEPTimerProposal;
 import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
 import org.opendaylight.protocol.util.InetSocketAddressUtil;
@@ -69,8 +68,6 @@ public class PCEPDispatcherImplTest {
     @Mock
     private Channel mockChannel;
     @Mock
-    private PCEPSessionNegotiatorFactoryDependencies negotiatorDependencies;
-    @Mock
     private PCEPSessionListenerFactory listenerFactory;
 
     private MessageRegistry msgReg;
@@ -86,8 +83,6 @@ public class PCEPDispatcherImplTest {
 
         dispatcher = new PCEPDispatcherImpl();
 
-        doReturn(null).when(negotiatorDependencies).getPeerProposal();
-
         final PCEPDispatcherImpl dispatcher2 = new PCEPDispatcherImpl();
         disp2Spy = spy(dispatcher2);
 
@@ -107,10 +102,9 @@ public class PCEPDispatcherImplTest {
         final InetSocketAddress clientAddr1 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
         final InetSocketAddress clientAddr2 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
 
-        doReturn(listenerFactory).when(negotiatorDependencies).getListenerFactory();
         doReturn(new SimpleSessionListener()).when(listenerFactory).getSessionListener();
         final ChannelFuture futureChannel = dispatcher.createServer(serverAddr, KeyMapping.of(), msgReg,
-            negotiatorFactory, negotiatorDependencies);
+            negotiatorFactory, listenerFactory, null);
         futureChannel.sync();
 
         try (var session1 = (PCEPSessionImpl) pccMock.createClient(clientAddr1,
@@ -138,10 +132,9 @@ public class PCEPDispatcherImplTest {
         final InetSocketAddress serverAddr = new InetSocketAddress("0.0.0.0", port);
         final InetSocketAddress clientAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
 
-        doReturn(listenerFactory).when(negotiatorDependencies).getListenerFactory();
         doReturn(new SimpleSessionListener()).when(listenerFactory).getSessionListener();
 
-        dispatcher.createServer(serverAddr, KeyMapping.of(), msgReg, negotiatorFactory, negotiatorDependencies)
+        dispatcher.createServer(serverAddr, KeyMapping.of(), msgReg, negotiatorFactory, listenerFactory, null)
             .sync();
         final Future<PCEPSession> futureClient = pccMock.createClient(clientAddr, RETRY_TIMER, CONNECT_TIMEOUT,
                 SimpleSessionListener::new);
@@ -163,10 +156,9 @@ public class PCEPDispatcherImplTest {
         final int port = InetSocketAddressUtil.getRandomPort();
         final InetSocketAddress clientAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
 
-        doReturn(listenerFactory).when(negotiatorDependencies).getListenerFactory();
         doReturn(new SimpleSessionListener()).when(listenerFactory).getSessionListener();
         dispatcher.createServer(new InetSocketAddress("0.0.0.0", port), KeyMapping.of(), msgReg, negotiatorFactory,
-            negotiatorDependencies).sync();
+            listenerFactory, null).sync();
         final PCEPSessionImpl session1 = (PCEPSessionImpl) pccMock.createClient(clientAddr,
                 RETRY_TIMER, CONNECT_TIMEOUT, SimpleSessionListener::new).get();
 
@@ -194,7 +186,7 @@ public class PCEPDispatcherImplTest {
             clientAddr2.getAddress(), "CLIENT2_ADDRESS"));
 
         final ChannelFuture futureChannel = disp2Spy.createServer(new InetSocketAddress("0.0.0.0", port),
-            keys, msgReg, negotiatorFactory, negotiatorDependencies).sync();
+            keys, msgReg, negotiatorFactory, null, null).sync();
         verify(disp2Spy).createServerBootstrap(any(PCEPDispatcherImpl.ChannelPipelineInitializer.class), same(keys));
     }
 
@@ -216,8 +208,8 @@ public class PCEPDispatcherImplTest {
                 final int connectTimeout, final PCEPSessionListenerFactory listenerFactory) {
             return createClient(address, retryTimer, connectTimeout, (ch, promise) -> {
                 ch.pipeline().addLast(factory.getDecoders());
-                ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(
-                    () -> listenerFactory, ch, promise));
+                ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(ch, promise, listenerFactory,
+                    null));
                 ch.pipeline().addLast(factory.getEncoders());
             });
         }
index ebd93e3352054908f3dbe173a429b1997a872cbc..0a29ab8c0b898b31d3054ebe4eebce8c99e6408b 100755 (executable)
@@ -28,11 +28,9 @@ import java.util.concurrent.ExecutionException;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.protocol.concepts.KeyMapping;
 import org.opendaylight.protocol.pcep.MessageRegistry;
-import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
 import org.opendaylight.protocol.pcep.impl.PCEPHandlerFactory;
 import org.opendaylight.protocol.pcep.pcc.mock.api.PCCDispatcher;
 import org.opendaylight.yangtools.yang.common.Uint64;
@@ -84,18 +82,8 @@ public final class PCCDispatcherImpl implements PCCDispatcher, AutoCloseable {
             @Override
             protected void initChannel(final SocketChannel ch) {
                 ch.pipeline().addLast(factory.getDecoders());
-                ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(
-                        new PCEPSessionNegotiatorFactoryDependencies() {
-                            @Override
-                            public PCEPSessionListenerFactory getListenerFactory() {
-                                return listenerFactory;
-                            }
-
-                            @Override
-                            public PCEPPeerProposal getPeerProposal() {
-                                return new PCCPeerProposal(dbVersion);
-                            }
-                        }, ch, promise));
+                ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(ch, promise, listenerFactory,
+                    new PCCPeerProposal(dbVersion)));
                 ch.pipeline().addLast(factory.getEncoders());
                 ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
                     @Override
index 42a111cb22505d0b118f38890d24ac12e02057ad..65965f93b388c8c8f587037644237c8960f208ea 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.protocol.pcep.pcc.mock;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doReturn;
 import static org.opendaylight.protocol.pcep.pcc.mock.PCCMockCommon.checkSessionListenerNotNull;
 
 import io.netty.channel.Channel;
@@ -21,12 +20,10 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.protocol.concepts.KeyMapping;
 import org.opendaylight.protocol.pcep.MessageRegistry;
 import org.opendaylight.protocol.pcep.PCEPSession;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
 import org.opendaylight.protocol.pcep.PCEPTimerProposal;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
@@ -47,9 +44,6 @@ public class PCCDispatcherImplTest {
     private InetSocketAddress clientAddress;
     private MessageRegistry registry;
 
-    @Mock
-    PCEPSessionNegotiatorFactoryDependencies negotiatorDependencies;
-
     @Before
     public void setUp() {
         registry = new DefaultPCEPExtensionConsumerContext().getMessageHandlerRegistry();
@@ -58,7 +52,6 @@ public class PCCDispatcherImplTest {
         pcepDispatcher = new PCEPDispatcherImpl();
         serverAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
         clientAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
-        doReturn(null).when(negotiatorDependencies).getPeerProposal();
     }
 
     @After
@@ -72,10 +65,9 @@ public class PCCDispatcherImplTest {
         final Future<PCEPSession> futureSession = dispatcher.createClient(serverAddress, 1,
             new TestingSessionListenerFactory(), nf, KeyMapping.of(), clientAddress);
         final TestingSessionListenerFactory slf = new TestingSessionListenerFactory();
-        doReturn(slf).when(negotiatorDependencies).getListenerFactory();
 
         final ChannelFuture futureServer = pcepDispatcher.createServer(serverAddress, KeyMapping.of(), registry, nf,
-            negotiatorDependencies);
+            slf, null);
         futureServer.sync();
         final Channel channel = futureServer.channel();
         assertNotNull(futureSession.get());
@@ -89,9 +81,8 @@ public class PCCDispatcherImplTest {
         pcepDispatcher = new PCEPDispatcherImpl();
 
         final TestingSessionListenerFactory slf2 = new TestingSessionListenerFactory();
-        doReturn(slf2).when(negotiatorDependencies).getListenerFactory();
         final ChannelFuture future2 = pcepDispatcher.createServer(serverAddress, KeyMapping.of(), registry, nf,
-            negotiatorDependencies);
+            slf2, null);
         future2.sync();
         final Channel channel2 = future2.channel();
         final TestingSessionListener sl2 = checkSessionListenerNotNull(slf2,
index 7af2785186ce88a0b6cddcea3b51fd74d81556d4..ba7ba9040aa46e29b135d2eaf46790d458f0913d 100644 (file)
@@ -35,9 +35,7 @@ import org.opendaylight.protocol.pcep.MessageRegistry;
 import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSession;
-import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
 import org.opendaylight.protocol.pcep.PCEPTimerProposal;
 import org.opendaylight.protocol.pcep.ietf.stateful.StatefulActivator;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
@@ -130,7 +128,7 @@ public abstract class PCCMockCommon {
         optimizationsActivator.start(extensionProvider);
 
         final ChannelFuture future = pceDispatcher.createServer(serverAddress2, KeyMapping.of(), messageRegistry,
-            negotiatorFactory, new NegotiatorDependencies(factory, peerProposal));
+            negotiatorFactory, factory, peerProposal);
         waitFutureSuccess(future);
         return future.channel();
     }
@@ -231,25 +229,4 @@ public abstract class PCCMockCommon {
     TestingSessionListener getListener(final TestingSessionListenerFactory factory) {
         return checkSessionListenerNotNull(factory, localAddress.getHostString());
     }
-
-    private static class NegotiatorDependencies implements PCEPSessionNegotiatorFactoryDependencies {
-        private final TestingSessionListenerFactory listenerFactory;
-        private final PCEPPeerProposal peerProposal;
-
-        NegotiatorDependencies(final TestingSessionListenerFactory listenerFactory,
-                final PCEPPeerProposal peerProposal) {
-            this.listenerFactory = listenerFactory;
-            this.peerProposal = peerProposal;
-        }
-
-        @Override
-        public PCEPSessionListenerFactory getListenerFactory() {
-            return listenerFactory;
-        }
-
-        @Override
-        public PCEPPeerProposal getPeerProposal() {
-            return peerProposal;
-        }
-    }
 }
index 86b7f95fa05c893c1771e340d25bf45060f506bb..36fac50824f490f3f4bc0c6d6f1a1b16c8c4d83a 100644 (file)
@@ -127,6 +127,6 @@ public final class Main {
         dispatcher.createServer(address, KeyMapping.of(), handlerRegistry,
             new DefaultPCEPSessionNegotiatorFactory(new PCEPTimerProposal(keepAliveValue, deadTimerValue),
                 List.of(new PCEPStatefulCapability(stateful, active, instant, false, false, false, false)),
-                maxUnknownMessages, null), new TestToolPCEPNegotiatorDependencies()).get();
+                maxUnknownMessages, null), new TestingSessionListenerFactory(), null).get();
     }
 }
diff --git a/pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestToolPCEPNegotiatorDependencies.java b/pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestToolPCEPNegotiatorDependencies.java
deleted file mode 100644 (file)
index 756e8cb..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.testtool;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
-
-public final class TestToolPCEPNegotiatorDependencies implements PCEPSessionNegotiatorFactoryDependencies {
-    private final @NonNull PCEPSessionListenerFactory listenerFactory = new TestingSessionListenerFactory();
-
-    @Override
-    public PCEPSessionListenerFactory getListenerFactory() {
-        return listenerFactory;
-    }
-}
diff --git a/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPSessionNegotiatorFactoryDependenciesImpl.java b/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPSessionNegotiatorFactoryDependenciesImpl.java
deleted file mode 100644 (file)
index 1596c39..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.bgpcep.pcep.topology.provider;
-
-import static java.util.Objects.requireNonNull;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.protocol.pcep.PCEPPeerProposal;
-import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
-
-final class PCEPSessionNegotiatorFactoryDependenciesImpl implements PCEPSessionNegotiatorFactoryDependencies {
-    private final @NonNull PCEPSessionListenerFactory listenerFactory;
-    private final @NonNull PCEPPeerProposal peerProposal;
-
-    PCEPSessionNegotiatorFactoryDependenciesImpl(final PCEPSessionListenerFactory listenerFactory,
-            final PCEPPeerProposal peerProposal) {
-        this.listenerFactory = requireNonNull(listenerFactory);
-        this.peerProposal = requireNonNull(peerProposal);
-    }
-
-    @Override
-    public PCEPSessionListenerFactory getListenerFactory() {
-        return listenerFactory;
-    }
-
-    @Override
-    public PCEPPeerProposal getPeerProposal() {
-        return peerProposal;
-    }
-}
index 4dc8565a04eab34356cc7f3dddcdf2d2afa3db2c..32c3bb10f73657f3ce2145cdabc994a5ecfd231e 100644 (file)
@@ -227,8 +227,7 @@ final class PCEPTopologyProvider extends DefaultTopologyReference {
         final var channelFuture = dependencies.getPCEPDispatcher().createServer(currentConfig.getAddress(),
             currentConfig.getKeys(), dependencies.getMessageRegistry(),
             new DefaultPCEPSessionNegotiatorFactory(currentConfig.getTimerProposal(), dependencies.getCapabilities(),
-                currentConfig.getMaxUnknownMessages(), currentConfig.getTls()),
-            new PCEPSessionNegotiatorFactoryDependenciesImpl(manager, proposal));
+                currentConfig.getMaxUnknownMessages(), currentConfig.getTls()), manager, proposal);
         channelFuture.addListener(ignored -> enableRPCs(future, channelFuture));
     }