BGPCEP-758: Use random ip for Pcc mock tests
[bgpcep.git] / pcep / pcc-mock / src / main / java / org / opendaylight / protocol / pcep / pcc / mock / PCCsBuilder.java
index e43b7b9c6b243999b09dde7cba2553346c1eaf9e..e93f54bd12c8000a2a8a8a46bcb3d989257031cc 100644 (file)
@@ -17,7 +17,6 @@ import java.math.BigInteger;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.protocol.concepts.KeyMapping;
@@ -51,10 +50,10 @@ final class PCCsBuilder {
     private final Timer timer = new HashedWheelTimer();
     private PCCDispatcherImpl pccDispatcher;
 
-    PCCsBuilder(final int lsps, final boolean pcError, final int pccCount, @Nonnull final InetSocketAddress localAddress,
-        @Nonnull final List<InetSocketAddress> remoteAddress, final short keepAlive, final short deadTimer,
-        @Nullable final String password, final long reconnectTime, final int redelegationTimeout, final int stateTimeout,
-        @Nonnull final PCEPCapability pcepCapabilities) {
+    PCCsBuilder(final int lsps, final boolean pcError, final int pccCount,
+            @Nonnull final InetSocketAddress localAddress, @Nonnull final List<InetSocketAddress> remoteAddress,
+            final short keepAlive, final short deadTimer, @Nullable final String password, final long reconnectTime,
+            final int redelegationTimeout, final int stateTimeout, @Nonnull final PCEPCapability pcepCapabilities) {
         this.lsps = lsps;
         this.pcError = pcError;
         this.pccCount = pccCount;
@@ -70,8 +69,7 @@ final class PCCsBuilder {
         startActivators();
     }
 
-    void createPCCs(final BigInteger initialDBVersion, final Optional<TimerHandler> timerHandler)
-        throws InterruptedException, ExecutionException {
+    void createPCCs(final BigInteger initialDBVersion, final Optional<TimerHandler> timerHandler) {
         InetAddress currentAddress = this.localAddress.getAddress();
         this.pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance()
                 .getMessageHandlerRegistry());
@@ -81,18 +79,19 @@ final class PCCsBuilder {
         for (int i = 0; i < this.pccCount; i++) {
             final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(this.lsps, currentAddress,
                 this.redelegationTimeout, this.stateTimeout, this.timer, timerHandler);
-            createPCC(new InetSocketAddress(currentAddress, this.localAddress.getPort()), tunnelManager, initialDBVersion);
+            createPCC(new InetSocketAddress(currentAddress, this.localAddress.getPort()), tunnelManager,
+                    initialDBVersion);
             currentAddress = InetAddresses.increment(currentAddress);
         }
     }
 
-    private void createPCC(@Nonnull final InetSocketAddress localAddress, @Nonnull final PCCTunnelManager tunnelManager,
-        final BigInteger initialDBVersion) throws InterruptedException, ExecutionException {
+    private void createPCC(@Nonnull final InetSocketAddress plocalAddress,
+            final PCCTunnelManager tunnelManager, final BigInteger initialDBVersion) {
         final PCEPSessionNegotiatorFactory<PCEPSessionImpl> snf = getSessionNegotiatorFactory();
         for (final InetSocketAddress pceAddress : this.remoteAddress) {
             this.pccDispatcher.createClient(pceAddress, this.reconnectTime, () -> new PCCSessionListener(
-                    this.remoteAddress.indexOf(pceAddress), tunnelManager, this.pcError), snf,
-                KeyMapping.getKeyMapping(pceAddress.getAddress(), this.password), localAddress, initialDBVersion);
+                            this.remoteAddress.indexOf(pceAddress), tunnelManager, this.pcError), snf,
+                    KeyMapping.getKeyMapping(pceAddress.getAddress(), this.password), plocalAddress, initialDBVersion);
         }
     }