public class NettyClient extends AbstractPoolClient implements StatisticCallback
netty client 相关
1) timeout 设置 (connecttimeout,sotimeout, application timeout)
2) 线程池设置
3) 最大连接池设置
4) 最大消息队列设置 (netty channel内部: writeQueue)
5) 最大返回数据包设置
6) RPC 的测试的时候,需要非常关注 OOM的问题
| 限定符和类型 | 字段和说明 |
|---|---|
protected ConcurrentMap<Long,ResponseFuture> |
callbackMap |
defaultMinEvictableIdleTimeMillis, defaultSoftMinEvictableIdleTimeMillis, defaultTimeBetweenEvictionRunsMillis, factory, pool, poolConfigcodec, localAddress, remoteAddress, state, url| 构造器和说明 |
|---|
NettyClient(URL url) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
cleanup() |
void |
close() |
void |
close(int timeout)
目前close不支持timeout的概念
|
protected org.apache.commons.pool.BasePoolableObjectFactory |
createChannelFactory()
connection factory
|
org.jboss.netty.bootstrap.ClientBootstrap |
getBootstrap() |
URL |
getUrl() |
void |
heartbeat(Request request) |
boolean |
isAvailable() |
boolean |
isClosed() |
boolean |
open() |
void |
registerCallback(long requestId,
ResponseFuture nettyResponseFuture)
注册回调的resposne
进行最大的请求并发数的控制,如果超过NETTY_CLIENT_MAX_REQUEST的话,那么throw reject exception
|
ResponseFuture |
removeCallback(long requestId)
移除回调的response
|
Response |
request(Request request) |
String |
statisticCallback()
统计回调接口
|
borrowObject, initConnection, initPool, invalidateObject, returnObjectgetLocalAddress, getRemoteAddress, setLocalAddress, setRemoteAddressprotected ConcurrentMap<Long,ResponseFuture> callbackMap
public NettyClient(URL url)
public Response request(Request request) throws TransportException
request 在接口中 ChannelTransportExceptionpublic void heartbeat(Request request)
heartbeat 在接口中 Clientheartbeat 在类中 AbstractClientpublic boolean isAvailable()
isAvailable 在接口中 Channelprotected org.apache.commons.pool.BasePoolableObjectFactory createChannelFactory()
createChannelFactory 在类中 AbstractPoolClientpublic void registerCallback(long requestId,
ResponseFuture nettyResponseFuture)
进行最大的请求并发数的控制,如果超过NETTY_CLIENT_MAX_REQUEST的话,那么throw reject exception
requestId - nettyResponseFuture - MotanServiceExceptionpublic String statisticCallback()
statisticCallback 在接口中 StatisticCallbackpublic ResponseFuture removeCallback(long requestId)
requestId - public org.jboss.netty.bootstrap.ClientBootstrap getBootstrap()
Copyright © 2021. All rights reserved.