- protected void customizeBootstrap(final Bootstrap b) {
- if (this.keys != null && !this.keys.isEmpty()) {
- if (this.cf == null) {
- throw new UnsupportedOperationException("No key access instance available, cannot use key mapping");
- }
- b.channelFactory(this.cf);
- b.option(MD5ChannelOption.TCP_MD5SIG, this.keys);
- }
+ @VisibleForTesting
+ protected synchronized Future<Void> createReconnectingClient(final InetSocketAddress remoteAddress, final BGPPeerRegistry peerRegistry,
+ final int retryTimer, final Optional<KeyMapping> keys, final InetSocketAddress localAddress, final boolean reuseAddress) {
+ final BGPClientSessionNegotiatorFactory snf = new BGPClientSessionNegotiatorFactory(peerRegistry);
+ final Bootstrap bootstrap = createClientBootStrap(keys, reuseAddress);
+ bootstrap.localAddress(localAddress);
+ final BGPReconnectPromise reconnectPromise = new BGPReconnectPromise(GlobalEventExecutor.INSTANCE, remoteAddress,
+ retryTimer, bootstrap, peerRegistry, BGPChannel.createChannelPipelineInitializer(this.handlerFactory, snf));
+ reconnectPromise.connect();
+ return reconnectPromise;
+ }