本文整理汇总了Java中io.netty.channel.pool.ChannelPoolHandler类的典型用法代码示例。如果您正苦于以下问题:Java ChannelPoolHandler类的具体用法?Java ChannelPoolHandler怎么用?Java ChannelPoolHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelPoolHandler类属于io.netty.channel.pool包,在下文中一共展示了ChannelPoolHandler类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BasicMultiNodeConnPoolMock
import io.netty.channel.pool.ChannelPoolHandler; //导入依赖的package包/类
public BasicMultiNodeConnPoolMock(
final Semaphore concurrencyThrottle, final String[] nodes, final Bootstrap bootstrap,
final ChannelPoolHandler connPoolHandler, final int defaultPort,
final int connFailSeqLenLimit
) {
super(
concurrencyThrottle, nodes, bootstrap, connPoolHandler, defaultPort,
connFailSeqLenLimit
);
}
示例2: HubManager
import io.netty.channel.pool.ChannelPoolHandler; //导入依赖的package包/类
private HubManager(final Properties properties) {
Runtime.getRuntime().addShutdownHook(new Thread(){
public void run() { try { close(); } catch (Exception x) {/* No Op */} }
});
log.info(">>>>> Initializing HubManager...");
metricMetaService = new MetricsMetaAPIImpl(properties);
tsdbEndpoint = TSDBEndpoint.getEndpoint(metricMetaService.getSqlWorker());
for(String url: tsdbEndpoint.getUpServers()) {
final URL tsdbUrl = URLHelper.toURL(url);
tsdbAddresses.add(new InetSocketAddress(tsdbUrl.getHost(), tsdbUrl.getPort()));
}
endpointCount = tsdbAddresses.size();
endpointSequence = new AtomicInteger(endpointCount);
group = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2, metricMetaService.getForkJoinPool());
bootstrap = new Bootstrap();
bootstrap
.handler(channelInitializer)
.group(group)
.channel(NioSocketChannel.class)
.option(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator())
.option(ChannelOption.ALLOCATOR, BufferManager.getInstance());
final ChannelPoolHandler poolHandler = this;
poolMap = new AbstractChannelPoolMap<InetSocketAddress, SimpleChannelPool>() {
@Override
protected SimpleChannelPool newPool(final InetSocketAddress key) {
final Bootstrap b = new Bootstrap().handler(channelInitializer)
.group(group)
.remoteAddress(key)
.channel(NioSocketChannel.class)
.option(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator())
.option(ChannelOption.ALLOCATOR, BufferManager.getInstance());
return new SimpleChannelPool(b, poolHandler);
}
};
eventExecutor = new DefaultEventExecutor(metricMetaService.getForkJoinPool());
channelGroup = new DefaultChannelGroup("MetricHubChannelGroup", eventExecutor);
// tsdbAddresses.parallelStream().forEach(addr -> {
// final Set<Channel> channels = Collections.synchronizedSet(new HashSet<Channel>(3));
// IntStream.of(1,2,3).parallel().forEach(i -> {
// final ChannelPool pool = poolMap.get(addr);
// try {channels.add(pool.acquire().awaitUninterruptibly().get());
// } catch (Exception e) {}
// log.info("Acquired [{}] Channels", channels.size());
// channels.parallelStream().forEach(ch -> pool.release(ch));
// });
// });
log.info("<<<<< HubManager Initialized.");
}
示例3: ConnectionlessChannelPool
import io.netty.channel.pool.ChannelPoolHandler; //导入依赖的package包/类
public ConnectionlessChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler) {
super(bootstrap, handler);
}
示例4: getChannelPoolHandler
import io.netty.channel.pool.ChannelPoolHandler; //导入依赖的package包/类
/**
* @return The {@link ChannelPoolHandler}
*/
public ChannelPoolHandler getChannelPoolHandler() {
return channelPoolHandler;
}
示例5: newPool
import io.netty.channel.pool.ChannelPoolHandler; //导入依赖的package包/类
ChannelPool newPool(Bootstrap b,
ChannelPoolHandler handler,
ChannelHealthChecker checker);