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