cn.teleinfo.idpointer.sdk.transport.ChannelPoolMapDefault Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of id-pointer-sdk Show documentation
Show all versions of id-pointer-sdk Show documentation
基于Java语言开发的工业互联网标识解析体系客户端软件开发工具包,应用通过集成 id-pointer-sdk,快速对接标识解析、标识注册、标识维护等功能服务。
The newest version!
package cn.teleinfo.idpointer.sdk.transport;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.pool.*;
import java.net.InetSocketAddress;
public class ChannelPoolMapDefault extends AbstractChannelPoolMap {
private final Bootstrap bootstrap;
private final ChannelPoolHandler channelPoolHandler;
private final int minConnectionsPerServer;
private final int maxConnectionsPerServer;
public ChannelPoolMapDefault(Bootstrap bootstrap, ChannelPoolHandler channelPoolHandler, int minConnectionsPerServer, int maxConnectionsPerServer) {
this.bootstrap = bootstrap;
this.channelPoolHandler = channelPoolHandler;
this.minConnectionsPerServer = minConnectionsPerServer;
this.maxConnectionsPerServer = maxConnectionsPerServer;
}
@Override
protected TimedChannelPool newPool(InetSocketAddress key) {
Bootstrap bootstrapPooled = bootstrap.clone();
bootstrapPooled.remoteAddress(key);
//return new FixedChannelPool(bootstrapPooled, channelPoolHandler, ChannelHealthChecker.ACTIVE, FixedChannelPool.AcquireTimeoutAction.FAIL, 5000L, maxConnectionsPerServer, 10000, true, false);
return new DefaultChannelPool(bootstrapPooled, channelPoolHandler, ChannelHealthChecker.ACTIVE, AbstractFixedChannelPool.AcquireTimeoutAction.FAIL, 5000L, minConnectionsPerServer, maxConnectionsPerServer, 10000, true, false);
}
}