package org.opendaylight.controller.config.yang.bmp.impl;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.net.InetAddresses;
import io.netty.util.internal.PlatformDependent;
return address.getIpv6Address().getValue();
}
- private Optional<KeyMapping> constructKeys() {
+ private KeyMapping constructKeys() {
final KeyMapping ret = KeyMapping.getKeyMapping();
if (getMonitoredRouter() != null) {
for (final MonitoredRouter mr : getMonitoredRouter()) {
}
}
- return ret.isEmpty() ? Optional.absent() : Optional.of(ret);
+ return ret;
}
@Override
package org.opendaylight.protocol.bmp.impl;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
}
@Override
- public ChannelFuture createClient(final InetSocketAddress address, final BmpSessionListenerFactory slf, final Optional<KeyMapping> keys) {
+ public ChannelFuture createClient(final InetSocketAddress address, final BmpSessionListenerFactory slf, final KeyMapping keys) {
final Bootstrap b = new Bootstrap();
} else {
b.channel(NioSocketChannel.class);
}
- if (keys.isPresent()) {
+ if (!keys.isEmpty()) {
if (Epoll.isAvailable()) {
- b.option(EpollChannelOption.TCP_MD5SIG, keys.get());
+ b.option(EpollChannelOption.TCP_MD5SIG, keys);
} else {
throw new UnsupportedOperationException (Epoll.unavailabilityCause().getCause());
}
}
@Override
- public ChannelFuture createServer(final InetSocketAddress address, final BmpSessionListenerFactory slf, final Optional<KeyMapping> keys) {
+ public ChannelFuture createServer(final InetSocketAddress address, final BmpSessionListenerFactory slf, final KeyMapping keys) {
Preconditions.checkNotNull(address);
Preconditions.checkNotNull(slf);
b.channel(NioServerSocketChannel.class);
}
- if (keys.isPresent()) {
+ if (!keys.isEmpty()) {
if (Epoll.isAvailable()) {
- b.option(EpollChannelOption.TCP_MD5SIG, keys.get());
+ b.option(EpollChannelOption.TCP_MD5SIG, keys);
} else {
throw new UnsupportedOperationException (Epoll.unavailabilityCause().getCause());
}
package org.opendaylight.protocol.bmp.impl.app;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.net.InetAddresses;
import io.netty.channel.Channel;
ret = KeyMapping.getKeyMapping(addr, rfc2385KeyPassword.getValue());
dispatcher.createClient(
Ipv4Util.toInetSocketAddress(mr.getAddress(), mr.getPort()),
- this.sessionManager, Optional.fromNullable(ret));
+ this.sessionManager, ret);
}
}
}
public static BmpMonitoringStation createBmpMonitorInstance(final RIBExtensionConsumerContext ribExtensions, final BmpDispatcher dispatcher,
final DOMDataBroker domDataBroker, final MonitorId monitorId, final InetSocketAddress address,
- final Optional<KeyMapping> keys, final BindingCodecTreeFactory codecFactory, final SchemaContext schemaContext,
+ final KeyMapping keys, final BindingCodecTreeFactory codecFactory, final SchemaContext schemaContext,
final List<MonitoredRouter> mrs ) throws InterruptedException {
Preconditions.checkNotNull(ribExtensions);
Preconditions.checkNotNull(dispatcher);
import static org.opendaylight.protocol.util.CheckUtil.readDataOperational;
import static org.opendaylight.protocol.util.CheckUtil.waitFutureSuccess;
-import com.google.common.base.Optional;
import com.google.common.net.InetAddresses;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
ctx.getBmpMessageRegistry(), new DefaultBmpSessionFactory());
this.bmpApp = BmpMonitoringStationImpl.createBmpMonitorInstance(ribExtension, this.dispatcher, getDomBroker(),
- MONITOR_ID, new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS), MONITOR_LOCAL_PORT), Optional.of(keys),
+ MONITOR_ID, new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS), MONITOR_LOCAL_PORT), keys,
this.mappingService.getCodecFactory(), this.moduleInfoBackedContext.getSchemaContext(), null);
readDataOperational(getDataBroker(), BMP_II, monitor -> {
@Test
public void deploySecondInstance() throws Exception {
final BmpMonitoringStation monitoringStation2 = BmpMonitoringStationImpl.createBmpMonitorInstance(new SimpleRIBExtensionProviderContext(), this.dispatcher, getDomBroker(),
- new MonitorId("monitor2"), new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS_2), MONITOR_LOCAL_PORT), Optional.of(KeyMapping.getKeyMapping()),
+ new MonitorId("monitor2"), new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS_2), MONITOR_LOCAL_PORT), KeyMapping.getKeyMapping(),
this.mappingService.getCodecFactory(), this.moduleInfoBackedContext.getSchemaContext(), null);
readDataOperational(getDataBroker(), BMP_II, monitor -> {
* @param keys RFC2385 key mapping
* @return instance of BmpServer
*/
- ChannelFuture createServer(InetSocketAddress address, BmpSessionListenerFactory slf, Optional<KeyMapping> keys);
+ @Deprecated
+ default ChannelFuture createServer(InetSocketAddress address, BmpSessionListenerFactory slf, Optional<KeyMapping> keys) {
+ if(keys.isPresent()) {
+ return createServer(address, slf, keys.get());
+ }
+ return createServer(address, slf, KeyMapping.getKeyMapping());
+ }
/**
* Creates reconnect clients. Make connection to all active monitored-routers.
* @param keys RFC2385 key mapping
* @return void
*/
- ChannelFuture createClient(InetSocketAddress address, BmpSessionListenerFactory slf, Optional<KeyMapping> keys) ;
+ @Deprecated
+ default ChannelFuture createClient(InetSocketAddress address, BmpSessionListenerFactory slf, Optional<KeyMapping> keys) {
+ if(keys.isPresent()) {
+ return createClient(address, slf, keys.get());
+ }
+ return createClient(address, slf, KeyMapping.getKeyMapping());
+ }
+
+ /**
+ * Creates server. Each server needs three factories to pass their instances to client sessions.
+ *
+ * @param address to be bound with the server
+ * @param slf bmp session listener factory
+ * @param keys RFC2385 key mapping
+ * @return instance of BmpServer
+ */
+ ChannelFuture createServer(InetSocketAddress address, BmpSessionListenerFactory slf, KeyMapping keys);
+
+ /**
+ * Creates reconnect clients. Make connection to all active monitored-routers.
+ *
+ * @param address bmp client to connect to
+ * @param slf bmp session listener factory
+ * @param keys RFC2385 key mapping
+ * @return void
+ */
+ ChannelFuture createClient(InetSocketAddress address, BmpSessionListenerFactory slf, KeyMapping keys) ;
}
*/
package org.opendaylight.protocol.bgp.rib.impl;
+import static org.opendaylight.protocol.concepts.KeyMapping.getKeyMapping;
+
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
@Override
public synchronized Future<BGPSessionImpl> createClient(final InetSocketAddress remoteAddress, final int retryTimer) {
- return createClient(remoteAddress, retryTimer, createClientBootStrap(Optional.absent(), false));
+ return createClient(remoteAddress, retryTimer, createClientBootStrap(getKeyMapping(), false));
}
private synchronized Future<BGPSessionImpl> createClient(final InetSocketAddress remoteAddress,
@VisibleForTesting
public synchronized Future<BGPSessionImpl> createClient(final InetSocketAddress localAddress,
final InetSocketAddress remoteAddress, final int retryTimer, final boolean reuseAddress) {
- final Bootstrap clientBootStrap = createClientBootStrap(Optional.absent(), reuseAddress);
+ final Bootstrap clientBootStrap = createClientBootStrap(getKeyMapping(), reuseAddress);
clientBootStrap.localAddress(localAddress);
return createClient(remoteAddress, retryTimer, clientBootStrap);
}
- private synchronized Bootstrap createClientBootStrap(final Optional<KeyMapping> keys, final boolean reuseAddress) {
+ private synchronized Bootstrap createClientBootStrap(final KeyMapping keys, final boolean reuseAddress) {
final Bootstrap bootstrap = new Bootstrap();
if (Epoll.isAvailable()) {
bootstrap.channel(EpollSocketChannel.class);
} else {
bootstrap.channel(NioSocketChannel.class);
}
- if (keys.isPresent()) {
+ if (!keys.isEmpty()) {
if (Epoll.isAvailable()) {
- bootstrap.option(EpollChannelOption.TCP_MD5SIG, keys.get());
+ bootstrap.option(EpollChannelOption.TCP_MD5SIG, keys);
} else {
throw new UnsupportedOperationException(Epoll.unavailabilityCause().getCause());
}
@Override
public synchronized Future<Void> createReconnectingClient(final InetSocketAddress remoteAddress,
- final int retryTimer, final Optional<KeyMapping> keys) {
+ final int retryTimer, final KeyMapping keys) {
return createReconnectingClient(remoteAddress, retryTimer, keys, null, false);
}
@VisibleForTesting
protected synchronized Future<Void> createReconnectingClient(final InetSocketAddress remoteAddress,
- final int retryTimer, final Optional<KeyMapping> keys, final InetSocketAddress localAddress,
+ final int retryTimer, final KeyMapping keys, final InetSocketAddress localAddress,
final boolean reuseAddress) {
final BGPClientSessionNegotiatorFactory snf = new BGPClientSessionNegotiatorFactory(this.bgpPeerRegistry);
final Bootstrap bootstrap = createClientBootStrap(keys, reuseAddress);
private final BGPDispatcher dispatcher;
private final InetSocketAddress inetAddress;
private final int retryTimer;
- private final Optional<KeyMapping> key;
+ private final KeyMapping keys;
private final WriteConfiguration configurationWriter;
private ClusterSingletonServiceRegistration registration;
private final BGPPeer bgpPeer;
this.dispatcher = rib.getDispatcher();
this.inetAddress = Ipv4Util.toInetSocketAddress(this.neighborAddress, OpenConfigMappingUtil.getPort(neighbor));
this.retryTimer = OpenConfigMappingUtil.getRetryTimer(neighbor);
- this.key = Optional.fromNullable(keyMapping);
+ this.keys = keyMapping;
this.configurationWriter = configurationWriter;
this.serviceGroupIdentifier = rib.getRibIServiceGroupIdentifier();
LOG.info("Peer Singleton Service {} registered", this.serviceGroupIdentifier.getValue());
this.bgpPeer.instantiateServiceInstance();
this.dispatcher.getBGPPeerRegistry().addPeer(this.neighborAddress, this.bgpPeer, this.prefs);
if (this.activeConnection) {
- this.connection = this.dispatcher.createReconnectingClient(this.inetAddress, this.retryTimer, this.key);
+ this.connection = this.dispatcher.createReconnectingClient(this.inetAddress, this.retryTimer, this.keys);
}
}
* @param keys for TCPMD5
* @return Future promising a client session
*/
- Future<Void> createReconnectingClient(InetSocketAddress remoteAddress, int retryTimer, Optional<KeyMapping> keys);
+ @Deprecated
+ default Future<Void> createReconnectingClient(InetSocketAddress remoteAddress, int retryTimer, Optional<KeyMapping> keys) {
+ if(keys.isPresent()) {
+ return createReconnectingClient(remoteAddress, retryTimer, keys.get());
+ }
+ return createReconnectingClient(remoteAddress, retryTimer, KeyMapping.getKeyMapping());
+ }
+
+ /**
+ * Creates Reconnecting client.
+ *
+ * @param remoteAddress remote Peer Address
+ * @param retryTimer Retry timer
+ * @param keys for TCPMD5
+ * @return Future promising a client session
+ */
+ Future<Void> createReconnectingClient(InetSocketAddress remoteAddress, int retryTimer, KeyMapping keys);
/**
* Create new BGP server to accept incoming bgp connections (bound to provided socket localAddress).
import static org.opendaylight.protocol.bgp.rib.impl.CheckUtil.checkIdleState;
import static org.opendaylight.protocol.util.CheckUtil.waitFutureSuccess;
-import com.google.common.base.Optional;
import com.google.common.collect.Sets;
import io.netty.channel.Channel;
import io.netty.util.concurrent.Future;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.State;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
public class BGPDispatcherImplTest extends AbstractBGPDispatcherTest {
public void testCreateReconnectingClient() throws Exception {
final InetSocketAddress serverAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
final Future<Void> future = this.clientDispatcher.createReconnectingClient(serverAddress, RETRY_TIMER,
- Optional.absent(), this.clientAddress, true);
+ KeyMapping.getKeyMapping(), this.clientAddress, true);
final Channel serverChannel = createServer(serverAddress);
Assert.assertEquals(State.UP, this.serverListener.getState());
Assert.assertTrue(serverChannel.isWritable());
import static org.opendaylight.protocol.bgp.rib.impl.AbstractAddPathTest.BGP_ID;
import static org.opendaylight.protocol.util.CheckUtil.readDataOperational;
-import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.util.HexDumpBGPFileParser;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.routes.ipv6.routes.Ipv6Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateAddressFamily;
Mockito.doReturn(GlobalEventExecutor.INSTANCE.newSucceededFuture(null)).when(this.dispatcher)
.createReconnectingClient(Mockito.any(InetSocketAddress.class), Mockito.anyInt(),
- Mockito.any(Optional.class));
+ Mockito.any(KeyMapping.class));
this.ext1 = new SimpleRIBExtensionProviderContext();
this.ext2 = new SimpleRIBExtensionProviderContext();
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
import org.opendaylight.protocol.bgp.rib.impl.stats.rib.impl.BGPRenderStats;
import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.BgpRib;
Mockito.doReturn(new BgpId("127.0.0.1")).when(this.rib).getBgpIdentifier();
Mockito.doReturn(true).when(this.future).cancel(true);
Mockito.doReturn(this.future).when(this.dispatcher)
- .createReconnectingClient(any(InetSocketAddress.class), anyInt(), any(Optional.class));
+ .createReconnectingClient(any(InetSocketAddress.class), anyInt(), any(KeyMapping.class));
Mockito.doReturn(this.dispatcher).when(this.rib).getDispatcher();
Mockito.doReturn(java.util.Optional.of(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)))
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.times;
-import com.google.common.base.Optional;
import java.math.BigDecimal;
import java.net.InetSocketAddress;
import java.util.Collections;
import org.mockito.Mockito;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AddPaths;
Mockito.verify(this.configurationWriter).apply();
Mockito.verify(this.bgpPeerRegistry).addPeer(any(), any(), any());
Mockito.verify(this.dispatcher).createReconnectingClient(any(InetSocketAddress.class),
- anyInt(), any(Optional.class));
+ anyInt(), any(KeyMapping.class));
try {
this.bgpPeer.start(this.rib, neighbor, this.tableTypeRegistry, this.configurationWriter);
}
public static KeyMapping getKeyMapping(@Nonnull final InetAddress inetAddress, @Nullable final String password){
+ final KeyMapping keyMapping = new KeyMapping();
if (!isNullOrEmpty(password)) {
- final KeyMapping keyMapping = new KeyMapping();
keyMapping.put(inetAddress, password.getBytes(StandardCharsets.US_ASCII));
- return keyMapping;
}
- return null;
+ return keyMapping;
}
public static KeyMapping getKeyMapping(){
- final KeyMapping keyMapping = new KeyMapping();
- return keyMapping;
+ return new KeyMapping();
}
}
*/
package org.opendaylight.protocol.pcep;
-import com.google.common.base.Optional;
import io.netty.channel.ChannelFuture;
import java.net.InetSocketAddress;
+import java.util.Optional;
import org.opendaylight.protocol.concepts.KeyMapping;
/**
* @param peerProposal information used in our Open message
* @return instance of PCEPServer
*/
- ChannelFuture createServer(InetSocketAddress address, PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal);
+ ChannelFuture createServer(InetSocketAddress address, PCEPSessionListenerFactory listenerFactory,
+ PCEPPeerProposal peerProposal);
/**
* Creates server. Each server needs three factories to pass their instances to client sessions.
* @param peerProposal information used in our Open message
* @return instance of PCEPServer
*/
- ChannelFuture createServer(InetSocketAddress address, Optional<KeyMapping> keys, PCEPSessionListenerFactory listenerFactory, PCEPPeerProposal peerProposal);
+ @Deprecated
+ default ChannelFuture createServer(InetSocketAddress address, Optional<KeyMapping> keys,
+ PCEPSessionListenerFactory listenerFactory, PCEPPeerProposal peerProposal) {
+ if(keys.isPresent()) {
+ return createServer(address, keys.get(), listenerFactory, peerProposal);
+ }
+ return createServer(address, KeyMapping.getKeyMapping(), listenerFactory, peerProposal);
+ }
+
+ /**
+ * Creates server. Each server needs three factories to pass their instances to client sessions.
+ *
+ * @param address to be bound with the server
+ * @param keys RFC2385 key mapping
+ * @param listenerFactory to create listeners for clients
+ * @param peerProposal information used in our Open message
+ * @return instance of PCEPServer
+ */
+ ChannelFuture createServer(InetSocketAddress address, KeyMapping keys, PCEPSessionListenerFactory listenerFactory,
+ PCEPPeerProposal peerProposal);
PCEPSessionNegotiatorFactory getPCEPSessionNegotiatorFactory();
}
*/
package org.opendaylight.protocol.pcep.impl;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.PooledByteBufAllocator;
private final EventLoopGroup workerGroup;
private final EventExecutor executor;
@GuardedBy("this")
- private Optional<KeyMapping> keys;
+ private KeyMapping keys;
/**
* Creates an instance of PCEPDispatcherImpl, gets the default selector and opens it.
@Override
public final synchronized ChannelFuture createServer(final InetSocketAddress address,
final PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal) {
- return createServer(address, Optional.absent(), listenerFactory, peerProposal);
+ return createServer(address, KeyMapping.getKeyMapping(), listenerFactory, peerProposal);
}
@Override
- public final synchronized ChannelFuture createServer(final InetSocketAddress address, final Optional<KeyMapping> keys,
+ public final synchronized ChannelFuture createServer(final InetSocketAddress address, final KeyMapping keys,
final PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal) {
this.keys = keys;
final ChannelFuture f = b.bind(address);
LOG.debug("Initiated server {} at {}.", f, address);
- this.keys = Optional.absent();
+ this.keys = KeyMapping.getKeyMapping();
return f;
}
} else {
b.channel(NioServerSocketChannel.class);
}
- if (this.keys.isPresent()) {
+ if (!this.keys.isEmpty()) {
if (Epoll.isAvailable()) {
- b.option(EpollChannelOption.TCP_MD5SIG, this.keys.get());
+ b.option(EpollChannelOption.TCP_MD5SIG, this.keys);
} else {
throw new UnsupportedOperationException(Epoll.unavailabilityCause().getCause());
}
@Override
public Future<PCEPSession> createClient(@Nonnull final InetSocketAddress remoteAddress, final long reconnectTime,
@Nonnull final PCEPSessionListenerFactory listenerFactory, @Nonnull final PCEPSessionNegotiatorFactory negotiatorFactory,
- @Nullable final KeyMapping keys, @Nonnull final InetSocketAddress localAddress, @Nonnull final BigInteger dbVersion) {
+ @Nonnull final KeyMapping keys, @Nonnull final InetSocketAddress localAddress, @Nonnull final BigInteger dbVersion) {
final Bootstrap b = new Bootstrap();
b.group(this.workerGroup);
b.localAddress(localAddress);
- final Optional<KeyMapping> optionalKey = Optional.fromNullable(keys);
+ final KeyMapping optionalKey = keys;
setChannelFactory(b, optionalKey);
b.option(ChannelOption.SO_KEEPALIVE, true);
b.option(ChannelOption.SO_REUSEADDR, true);
return promise;
}
- private static void setChannelFactory(final Bootstrap bootstrap, final Optional<KeyMapping> keys) {
+ private static void setChannelFactory(final Bootstrap bootstrap, final KeyMapping keys) {
if (Epoll.isAvailable()) {
bootstrap.channel(EpollSocketChannel.class);
bootstrap.option(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);
} else {
bootstrap.channel(NioSocketChannel.class);
}
- if (keys.isPresent()) {
+ if (!keys.isEmpty()) {
if (Epoll.isAvailable()) {
- bootstrap.option(EpollChannelOption.TCP_MD5SIG, keys.get());
+ bootstrap.option(EpollChannelOption.TCP_MD5SIG, keys);
} else {
throw new UnsupportedOperationException(Epoll.unavailabilityCause().getCause());
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
import org.opendaylight.protocol.pcep.PCEPSession;
@Test
public void testClientReconnect() throws Exception {
final Future<PCEPSession> futureSession = this.dispatcher.createClient(this.serverAddress, 1, new TestingSessionListenerFactory(),
- this.nf, null, this.clientAddress);
+ this.nf, KeyMapping.getKeyMapping(), this.clientAddress);
final TestingSessionListenerFactory slf = new TestingSessionListenerFactory();
final ChannelFuture futureServer = this.pcepDispatcher.createServer(this.serverAddress, slf, null);
waitFutureSuccess(futureServer);
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
import org.opendaylight.protocol.pcep.PCEPPeerProposal;
() -> {
this.pccSessionListener = new PCCSessionListener(1, tunnelManager, false);
return this.pccSessionListener;
- }, snf, null, this.localAddress, dbVersion);
+ }, snf, KeyMapping.getKeyMapping(), this.localAddress, dbVersion);
}
private PCEPSessionNegotiatorFactory<PCEPSessionImpl> getSessionNegotiatorFactory() {
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
.getPortOrDefault(12345));
final InetSocketAddress clientAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
- try (final PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry())) {
- pccDispatcher.createClient(serverAddr, -1, SimpleSessionListener::new, snf, null, clientAddr).get();
+ try (final PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext
+ .getSingletonInstance().getMessageHandlerRegistry())) {
+ pccDispatcher.createClient(serverAddr, -1, SimpleSessionListener::new, snf,
+ KeyMapping.getKeyMapping(), clientAddr).get();
}
}
}
private final InstanceIdentifier<Topology> topology;
private final ServerSessionManager manager;
private final InetSocketAddress address;
- private final Optional<KeyMapping> keys;
+ private final KeyMapping keys;
private final InstructionScheduler scheduler;
private final PCEPTopologyProviderDependenciesProvider dependenciesProvider;
private RoutedRpcRegistration<NetworkTopologyPcepProgrammingService> network;
dependenciesProvider, topology, manager, configDependencies.getSchedulerDependency());
}
- private PCEPTopologyProvider(final InetSocketAddress address, final Optional<KeyMapping> keys,
+ private PCEPTopologyProvider(final InetSocketAddress address, final KeyMapping keys,
final PCEPTopologyProviderDependenciesProvider dependenciesProvider,
final InstanceIdentifier<Topology> topology, final ServerSessionManager manager,
final InstructionScheduler scheduler) {
public final class PCEPTopologyConfigDependencies {
private final InetSocketAddress address;
- private final Optional<KeyMapping> keys;
+ private final KeyMapping keys;
private final InstructionScheduler scheduler;
private final TopologyId topologyId;
private final Optional<PCEPTopologyProviderRuntimeRegistrator> runtime;
private final short rpcTimeout;
- public PCEPTopologyConfigDependencies(final InetSocketAddress address, final Optional<KeyMapping> keys,
+ public PCEPTopologyConfigDependencies(final InetSocketAddress address, final KeyMapping keys,
final InstructionScheduler scheduler, final TopologyId topologyId,
final Optional<PCEPTopologyProviderRuntimeRegistrator> runtime, final short rpcTimeout) {
this.address = checkNotNull(address);
return this.address;
}
- public Optional<KeyMapping> getKeys() {
+ public KeyMapping getKeys() {
return this.keys;
}
}
* The PCEPTopologyDeployer service is managing PcepTopologyProvider
*/
public interface PCEPTopologyDeployer {
+ /**
+ * Creates and register topology provider instance
+ * @param topologyId topology ID
+ * @param inetSocketAddress inetSocketAddress
+ * @param rpcTimeout rpc Timeout
+ * @param keys List of clients password configuration
+ * @param scheduler Instruction Scheduler
+ */
+ @Deprecated
+ default void createTopologyProvider(@Nonnull TopologyId topologyId, @Nonnull InetSocketAddress inetSocketAddress,
+ short rpcTimeout, @Nullable Optional<KeyMapping> keys, @Nonnull InstructionScheduler scheduler,
+ Optional<PCEPTopologyProviderRuntimeRegistrator> runtime) {
+ if(keys.isPresent()) {
+ createTopologyProvider(topologyId, inetSocketAddress, rpcTimeout, keys.get(), scheduler, runtime);
+ }
+ createTopologyProvider(topologyId, inetSocketAddress, rpcTimeout, KeyMapping.getKeyMapping(),
+ scheduler, runtime);
+ }
+
/**
* Creates and register topology provider instance
* @param topologyId topology ID
* @param scheduler Instruction Scheduler
*/
void createTopologyProvider(@Nonnull TopologyId topologyId, @Nonnull InetSocketAddress inetSocketAddress,
- short rpcTimeout, @Nullable Optional<KeyMapping> client, @Nonnull InstructionScheduler scheduler,
+ short rpcTimeout, @Nonnull KeyMapping client, @Nonnull InstructionScheduler scheduler,
Optional<PCEPTopologyProviderRuntimeRegistrator> runtime);
/**
@Override
public synchronized void createTopologyProvider(final TopologyId topologyId,
- final InetSocketAddress inetSocketAddress, final short rpcTimeout, final Optional<KeyMapping> keys,
+ final InetSocketAddress inetSocketAddress, final short rpcTimeout, final KeyMapping keys,
final InstructionScheduler schedulerDependency,
final Optional<PCEPTopologyProviderRuntimeRegistrator> runtime) {
if (this.pcepTopologyServices.containsKey(topologyId)) {
*/
package org.opendaylight.bgpcep.pcep.topology.provider.config;
-import com.google.common.base.Optional;
-import com.google.common.net.InetAddresses;
import java.nio.charset.StandardCharsets;
import java.util.List;
import org.opendaylight.controller.config.yang.pcep.topology.provider.Client;
import org.opendaylight.protocol.concepts.KeyMapping;
-import org.opendaylight.protocol.util.Ipv4Util;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public final class PCEPTopologyProviderUtil {
- private static final Logger LOG = LoggerFactory.getLogger(PCEPTopologyProviderUtil.class);
-
private PCEPTopologyProviderUtil() {
throw new UnsupportedOperationException();
}
- public static Optional<KeyMapping> contructKeys(final List<Client> clients) {
- KeyMapping ret = null;
+ public static KeyMapping contructKeys(final List<Client> clients) {
+ final KeyMapping ret = KeyMapping.getKeyMapping();
- if (clients != null && !clients.isEmpty()) {
- ret = KeyMapping.getKeyMapping();
- for (final Client c : clients) {
- if (c.getAddress() == null) {
- LOG.warn("Client {} does not have an address skipping it", c);
- continue;
- }
- final Rfc2385Key rfc2385KeyPassword = c.getPassword();
- if (rfc2385KeyPassword != null && !rfc2385KeyPassword.getValue().isEmpty()) {
- final String s = Ipv4Util.toStringIP(c.getAddress());
- ret.put(InetAddresses.forString(s), rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));
- }
- }
+ if (clients != null) {
+ clients.stream().filter(client -> client != null && client.getPassword() != null &&
+ !client.getPassword().getValue().isEmpty())
+ .forEach(mr -> {
+ final Rfc2385Key rfc2385KeyPassword = mr.getPassword();
+ ret.put(IetfInetUtil.INSTANCE.inetAddressFor(mr.getAddress()),
+ rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));
+ });
}
- return Optional.fromNullable(ret);
+ return ret;
}
}
JmxAttributeValidationException.checkNotNull(getStatefulPlugin(), IS_NOT_SET, statefulPluginJmxAttribute);
JmxAttributeValidationException.checkNotNull(getRpcTimeout(), IS_NOT_SET, rpcTimeoutJmxAttribute);
- final Optional<KeyMapping> keys = contructKeys(getClient());
- if (keys.isPresent()) {
+ final KeyMapping keys = contructKeys(getClient());
+ if (!keys.isEmpty()) {
JmxAttributeValidationException.checkCondition(Epoll.isAvailable(), NATIVE_TRANSPORT_NOT_AVAILABLE,
clientJmxAttribute);
}
.waitForService(WaitingServiceTracker.FIVE_MINUTES);
final TopologyId topologyID = getTopologyId();
- final com.google.common.base.Optional<KeyMapping> keys = contructKeys(getClient());
+ final KeyMapping keys = contructKeys(getClient());
final InetSocketAddress inetSocketAddress = new InetSocketAddress(listenAddress(), getListenPort().getValue());