Will be called when new channels in the token network are detected.
        If the minimum number of channels was not yet established, it will try
        to open new channels.

        If the connection manager has no funds, this is a noop.
334535
def retry_connect(self):
        
        with self.lock:
            if self._funds_remaining > 0 and not self._leaving_state:
                self._open_channels()
1022907
private void maybeShutdownNowSubchannels() {
    if (shutdownNowed) {
      for (InternalSubchannel subchannel : subchannels) {
        subchannel.shutdownNow(SHUTDOWN_NOW_STATUS);
      }
      for (OobChannel oobChannel : oobChannels) {
        oobChannel.getInternalSubchannel().shutdownNow(SHUTDOWN_NOW_STATUS);
      }
    }
  }
356668
def new_connection_status(self, conn_status):
        """"""
        if conn_status.status == CONNECTION_STATUS_CONNECTED:
            self._mz.update_members()
        if (conn_status.status == CONNECTION_STATUS_DISCONNECTED or
                conn_status.status == CONNECTION_STATUS_LOST):
            self._mz.reset_members()
1285683
protected boolean setChannel(final Channel newChannel) {
        if(newChannel == null) {
            return false;
        }
        synchronized (lock) {
            if(state != State.OPEN || channel != null) {
                return false;
            }
            this.channel = newChannel;
            this.channel.addCloseHandler(new CloseHandler<Channel>() {
                @Override
                public void handleClose(final Channel closed, final IOException exception) {
                    synchronized (lock) {
                        if(FutureManagementChannel.this.channel == closed) {
                            FutureManagementChannel.this.channel = null;
                        }
                        lock.notifyAll();
                    }
                }
            });
            lock.notifyAll();
            return true;
        }
    }
1295919
def open_channel(self):
        
        logger.debug('Creating new channel')
        self._connection.channel(on_open_callback=self.on_channel_open)
466375
protected void maybeSignalForMoreConnections(ConnectionPartition connectionPartition) {

		if (!connectionPartition.isUnableToCreateMoreTransactions() 
				&& !this.poolShuttingDown &&
				connectionPartition.getAvailableConnections()*100/connectionPartition.getMaxConnections() <= this.poolAvailabilityThreshold){
			connectionPartition.getPoolWatchThreadSignalQueue().offer(new Object()); // item being pushed is not important.
		}
	}
1321951
def on_channel_open(self, channel):
        
        self._logger.debug('Channel opened')
        self._channel = channel
        self._channel.parent_client = self
        self.add_on_channel_close_callback()
        self.setup_exchange(self._exchange)
1163413
def closed(self, block_identifier: BlockSpecification) -> bool:
        
        return self.token_network.channel_is_closed(
            participant1=self.participant1,
            participant2=self.participant2,
            block_identifier=block_identifier,
            channel_identifier=self.channel_identifier,
        )
363559
def _connection_handler(self, event_name, data, channel_name):
        
        if channel_name in self.channels:
            self.channels[channel_name]._handle_event(event_name, data)
382684
@Override
    public void openChannel(FutureCallback<Channel> callback) throws IllegalStateException {
        assertOpen();

        ChannelFuture future = this.bootstrap.clone().register();
        future.addListener(new NetworkManagerChannelFutureCallback(callback));
    }
349214
@Handler(channels = NetworkChannel.class)
    public void onIoError(IOError event) throws IOException {
        for (Channel channel : event.channels()) {
            if (channel instanceof TcpChannel) {
                // Error while using established network connection
                TcpChannel netConnChannel = (TcpChannel) channel;
                Optional<WebAppMsgChannel> appChannel
                    = netConnChannel.associated(WebAppMsgChannel.class);
                if (appChannel.isPresent()) {
                    // Error while using a network connection
                    appChannel.get().handleIoError(event, netConnChannel);
                    continue;
                }
                // Just in case...
                pooled.remove(netConnChannel.remoteAddress(), netConnChannel);
                continue;
            }
            // Error while trying to establish the network connection
            if (event.event() instanceof OpenTcpConnection) {
                OpenTcpConnection connEvent
                    = (OpenTcpConnection) event.event();
                Optional<Set<WebAppMsgChannel>> erroneous;
                synchronized (connecting) {
                    erroneous = Optional
                        .ofNullable(connecting.get(connEvent.address()));
                    connecting.remove(connEvent.address());
                }
                erroneous.ifPresent(set -> {
                    for (WebAppMsgChannel chann : set) {
                        chann.openError(event);
                    }
                });
            }
        }
    }
463787
def opened(self, block_identifier: BlockSpecification) -> bool:
        
        return self.token_network.channel_is_opened(
            participant1=self.participant1,
            participant2=self.participant2,
            block_identifier=block_identifier,
            channel_identifier=self.channel_identifier,
        )
683838
def on_open(self, websocket):
        ''''''
        LOGGER.info('New websocket opened. Add client to %s on "%s" channel',
                    self.pubsub, self.channel)
        self.pubsub.add_client(self.client(websocket, self.channel))
1007369
protected void maybeSignalForMoreConnections(ThriftConnectionPartition<T> connectionPartition) {
		if (!connectionPartition.isUnableToCreateMoreTransactions() && !this.poolShuttingDown
				&& connectionPartition.getAvailableConnections() * 100
						/ connectionPartition.getMaxConnections() <= this.poolAvailabilityThreshold) {
			connectionPartition.getPoolWatchThreadSignalQueue().offer(new Object());
		}
	}
1068325
private void resubscribeChannels() throws InterruptedException, BitfinexClientException {
		final Map<Integer, ChannelCallbackHandler> oldChannelIdSymbolMap = new HashMap<>();

		synchronized (channelIdToHandlerMap) {
			oldChannelIdSymbolMap.putAll(channelIdToHandlerMap);
			channelIdToHandlerMap.clear();
			channelIdToHandlerMap.notifyAll();
			
			// Implicit channel account info channel
			channelIdToHandlerMap.put(ACCCOUNT_INFO_CHANNEL, oldChannelIdSymbolMap.get(ACCCOUNT_INFO_CHANNEL));
		}
		
		// Resubscribe channels
		for(final ChannelCallbackHandler handler : oldChannelIdSymbolMap.values()) {
			final BitfinexStreamSymbol symbol = handler.getSymbol();
			if(symbol instanceof BitfinexTickerSymbol) {
				sendCommand(new SubscribeTickerCommand((BitfinexTickerSymbol) symbol));
			} else if(symbol instanceof BitfinexExecutedTradeSymbol) {
				sendCommand(new SubscribeTradesCommand((BitfinexExecutedTradeSymbol) symbol));
			} else if(symbol instanceof BitfinexCandlestickSymbol) {
				sendCommand(new SubscribeCandlesCommand((BitfinexCandlestickSymbol) symbol));
			} else if(symbol instanceof BitfinexOrderBookSymbol) {
				sendCommand(new SubscribeOrderbookCommand((BitfinexOrderBookSymbol) symbol));
			} else if(symbol instanceof BitfinexAccountSymbol) {
				// This symbol does not need to be resubscribed
			} else {
				logger.error("Unknown stream symbol: {}", symbol);
			}
		}
		
		waitForChannelResubscription(oldChannelIdSymbolMap);		
	}
998069
@Override
    public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) {
        // register the newly established channel
        Channel channel = event.getChannel();
        LOG.info("connection established to :{}, local port:{}", client.getRemoteAddr(), channel.getLocalAddress());

        client.connectChannel(ctx.getChannel());
        client.handleResponse(ctx.getChannel(), null);
    }
342277
def on_connection_open(self, unused_connection):
        
        self._logger.info('Connection opened')
        self.add_on_connection_close_callback()
        self.open_channel()