private void channelRelease() { for (Entry<String, List<Channel>> entry : channelMap.entrySet()) { for (Channel each : entry.getValue()) { CLIENT_MANAGER.getBackendNettyClient(logicSchema.getName()).getPoolMap().get(entry.getKey()).release(each); } } } }
private void channelRelease() { for (Entry<String, List<Channel>> entry : channelMap.entrySet()) { for (Channel each : entry.getValue()) { CLIENT_MANAGER.getBackendNettyClient(logicSchema.getName()).getPoolMap().get(entry.getKey()).release(each); } } } }
private void initPoolMap(final Bootstrap bootstrap) throws InterruptedException { poolMap = new AbstractChannelPoolMap<String, SimpleChannelPool>() { @Override protected SimpleChannelPool newPool(final String dataSourceName) { DataSourceMetaData dataSourceMetaData = logicSchema.getMetaData().getDataSource().getActualDataSourceMetaData(dataSourceName); return new FixedChannelPool( bootstrap.remoteAddress(dataSourceMetaData.getHostName(), dataSourceMetaData.getPort()), new BackendNettyClientChannelPoolHandler(dataSourceName, logicSchema.getName()), maxConnections); } }; for (String each : logicSchema.getDataSources().keySet()) { SimpleChannelPool pool = poolMap.get(each); Channel[] channels = new Channel[maxConnections]; for (int i = 0; i < maxConnections; i++) { try { channels[i] = pool.acquire().get(connectionTimeoutSeconds, TimeUnit.SECONDS); } catch (final ExecutionException | TimeoutException ex) { log.error(ex.getMessage(), ex); } } for (int i = 0; i < maxConnections; i++) { pool.release(channels[i]); } } } }
private void initPoolMap(final Bootstrap bootstrap) throws InterruptedException { poolMap = new AbstractChannelPoolMap<String, SimpleChannelPool>() { @Override protected SimpleChannelPool newPool(final String dataSourceName) { DataSourceMetaData dataSourceMetaData = logicSchema.getMetaData().getDataSource().getActualDataSourceMetaData(dataSourceName); return new FixedChannelPool( bootstrap.remoteAddress(dataSourceMetaData.getHostName(), dataSourceMetaData.getPort()), new BackendNettyClientChannelPoolHandler(dataSourceName, logicSchema.getName()), maxConnections); } }; for (String each : logicSchema.getDataSources().keySet()) { SimpleChannelPool pool = poolMap.get(each); Channel[] channels = new Channel[maxConnections]; for (int i = 0; i < maxConnections; i++) { try { channels[i] = pool.acquire().get(connectionTimeoutSeconds, TimeUnit.SECONDS); } catch (final ExecutionException | TimeoutException ex) { log.error(ex.getMessage(), ex); } } for (int i = 0; i < maxConnections; i++) { pool.release(channels[i]); } } } }
private void executeSQL(final String dataSourceName, final String sql) throws InterruptedException, ExecutionException, TimeoutException { if (!channelMap.containsKey(dataSourceName)) { channelMap.put(dataSourceName, new ArrayList<Channel>()); } SimpleChannelPool pool = CLIENT_MANAGER.getBackendNettyClient(logicSchema.getName()).getPoolMap().get(dataSourceName); Channel channel = pool.acquire().get(GLOBAL_REGISTRY.getShardingProperties().<Long>getValue(ShardingPropertiesConstant.PROXY_BACKEND_CONNECTION_TIMEOUT_SECONDS), TimeUnit.SECONDS); channelMap.get(dataSourceName).add(channel); ChannelRegistry.getInstance().putConnectionId(channel.id().asShortText(), connectionId); channel.writeAndFlush(new ComQueryPacket(sequenceId, sql)); }
private void executeSQL(final String dataSourceName, final String sql) throws InterruptedException, ExecutionException, TimeoutException { if (!channelMap.containsKey(dataSourceName)) { channelMap.put(dataSourceName, new ArrayList<Channel>()); } SimpleChannelPool pool = CLIENT_MANAGER.getBackendNettyClient(logicSchema.getName()).getPoolMap().get(dataSourceName); Channel channel = pool.acquire().get(GLOBAL_REGISTRY.getShardingProperties().<Long>getValue(ShardingPropertiesConstant.PROXY_BACKEND_CONNECTION_TIMEOUT_SECONDS), TimeUnit.SECONDS); channelMap.get(dataSourceName).add(channel); ChannelRegistry.getInstance().putConnectionId(channel.id().asShortText(), connectionId); channel.writeAndFlush(new ComQueryPacket(sequenceId, sql)); }
ChannelPool channelPool = poolMap.get(new RequestKey(requestURI)); Future<Channel> channelFuture = channelPool.acquire(); channelFuture.addListener(future -> {
public FixedChannelPool getChannelPool(InetSocketAddress address) { if (poolMap == null) return null; return poolMap.get(address); }
protected ChannelPool getPooledChannelFuture(String downstreamHost, int downstreamPort) { return getPoolMap().get( resolveHostnameToInetSocketAddressWithMultiIpSupport(downstreamHost, downstreamPort) ); }
protected ChannelPool getPooledChannelFuture(String downstreamHost, int downstreamPort) { return getPoolMap().get( resolveHostnameToInetSocketAddressWithMultiIpSupport(downstreamHost, downstreamPort) ); }
ChannelPoolKey poolKey = new ChannelPoolKey(address, useSsl); final FixedChannelPool pool = _poolMap.get(poolKey); _pools.add(pool); Future<Channel> f = pool.acquire();
ChannelPool channelPool = poolMap.get(new RequestKey(requestURI)); Future<Channel> channelFuture = channelPool.acquire(); channelFuture.addListener(future -> {
ChannelPool channelPool = poolMap.get(new RequestKey(requestURI)); Future<Channel> channelFuture = channelPool.acquire(); channelFuture.addListener(future -> {