- private class BootstrapConnectListener implements ChannelFutureListener {
- @Override
- public void operationComplete(final ChannelFuture cf) {
- synchronized (NetconfSessionPromise.this) {
-
- LOG.debug("Promise {} connection resolved", NetconfSessionPromise.this);
-
- // Triggered when a connection attempt is resolved.
- Preconditions.checkState(NetconfSessionPromise.this.pending.equals(cf));
-
- /*
- * The promise we gave out could have been cancelled,
- * which cascades to the connect getting cancelled,
- * but there is a slight race window, where the connect
- * is already resolved, but the listener has not yet
- * been notified -- cancellation at that point won't
- * stop the notification arriving, so we have to close
- * the race here.
- */
- if (isCancelled()) {
- if (cf.isSuccess()) {
- LOG.debug("Closing channel for cancelled promise {}", NetconfSessionPromise.this);
- cf.channel().close();
- }
- return;
- }
-
- if (cf.isSuccess()) {
- LOG.debug("Promise {} connection successful", NetconfSessionPromise.this);
- return;
- }
-
- LOG.debug("Attempt to connect to {} failed", NetconfSessionPromise.this.address, cf.cause());
-
- final Future<Void> rf = NetconfSessionPromise.this.strategy.scheduleReconnect(cf.cause());
- rf.addListener(new ReconnectingStrategyListener());
- NetconfSessionPromise.this.pending = rf;
+ // Triggered when a connection attempt is resolved.
+ private synchronized void channelConnectComplete(final ChannelFuture cf) {
+ LOG.debug("Promise {} connection resolved", this);
+ checkState(pending.equals(cf));
+
+ /*
+ * The promise we gave out could have been cancelled,
+ * which cascades to the connect getting cancelled,
+ * but there is a slight race window, where the connect
+ * is already resolved, but the listener has not yet
+ * been notified -- cancellation at that point won't
+ * stop the notification arriving, so we have to close
+ * the race here.
+ */
+ if (isCancelled()) {
+ if (cf.isSuccess()) {
+ LOG.debug("Closing channel for cancelled promise {}", this);
+ cf.channel().close();