public class ConnectManager extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static Map<io.netty.channel.Channel,ConnectData> |
CHANNEL_DATA_MAP
链接与链接数据的集合
Key: Channel, Value: ConnectData
|
static Map<String,Integer> |
CMD_PRIORITY_MAP
本模块各个CMD优先级
Each CMD priority of this module
|
static Map<String,CopyOnWriteArrayList<Message>> |
CMD_SUBSCRIBE_MESSAGE_MAP
接口被那些Message订阅
Interfaces have been subscribed to by those Messages
Key:cmd
Value:订阅该接口的message队列/Subscribe to the message of the interface
|
static Map<String,ConfigItem> |
CONFIG_ITEM_MAP
本模块配置信息
Configuration information of this module
Key: The key
Value: Config detail
|
static Map<String,BaseInvoke> |
INVOKE_MAP
调用远程方法时,可以设置自动回调的本地方法。
|
static RegisterApi |
LOCAL
本模块所有对外提供的接口的详细信息
local module(io.nuls.rpc.RegisterApi) information
|
static Map<Message,ConnectData> |
MESSAGE_TO_CHANNEL_MAP
订阅接口的Message对应的连接
Connection corresponding to Message of Subscription Interface
Key:订阅消息/Subscribe message
Value:该订阅消息所属连接
|
static ConcurrentMap<String,io.netty.channel.Channel> |
MSG_ID_KEY_CHANNEL_MAP
messageId对应链接通道对象,用于取消订阅的Request
Key:messageId, Value:链接通道
key: messageId, value: channel
|
static Map<String,io.netty.channel.Channel> |
ROLE_CHANNEL_MAP
角色与链接通道集合
KEY:ROLE
VALUE:Channel
|
static Map<String,Map> |
ROLE_MAP
Key: 角色,Value:角色的连接信息
Key: role, Value: Connection information of the role
|
static boolean |
startService
本模块是否可以启动服务(所依赖模块是否可以连接)
Can this module start the service?
|
static int |
subRequestCount
当前正在处理的订阅请求数量
Number of subscription requests currently being processed
|
static Map<String,Integer> |
SUBSCRIBE_COUNT
接口被订阅次数(事件方式)
Number of changes in the return value of the subscribed interface
Key: Cmd
Value: subscribe count
|
| 构造器和说明 |
|---|
ConnectManager() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
addCmdChangeCount(String cmd)
返回值改变次数增加1
Increase the changes number of return value by 1
|
static void |
addCmdDetail(Class<?> claszs) |
static io.netty.channel.Channel |
cacheConnect(String role,
io.netty.channel.Channel channel,
boolean isSender)
缓存链接信息
Cache link information
|
static io.netty.channel.Channel |
createConnect(String url) |
static void |
createConnectData(io.netty.channel.Channel channel) |
static void |
disConnect(io.netty.channel.socket.SocketChannel channel)
停止或断开一个连接,清除该连接相关信息
Stop or disconnect a connection
|
static void |
eventTrigger(String cmd,
Response response)
订阅接口被调用,判断订阅该接口的事件是否触发
|
static int |
getCmdChangeCount(String cmd)
得到返回值的改变数量
Get current changes number of return value
|
static io.netty.channel.Channel |
getConnectByRole(String role) |
static io.netty.channel.Channel |
getConnectByUrl(String url) |
static ConnectData |
getConnectDataByRole(String role) |
static CmdDetail |
getLocalInvokeCmd(String cmd)
根据cmd命令获取最高版本的方法,逻辑同上
Getting the highest version of local methods from CMD commands
|
static CmdDetail |
getLocalInvokeCmd(String cmd,
double minVersion)
根据cmd命令和版本号获取本地方法
Getting local methods from CMD commands and version
|
static Response |
getRealResponse(String cmd,
String messageId,
Response response)
封装真正的返回结果
Encapsulate the true return result
|
static String |
getRemoteUri(io.netty.channel.socket.SocketChannel channel)
根据channel的连接信息
Return the role's connection information based on the role
|
static String |
getRemoteUri(String role)
根据角色返回角色的连接信息
Return the role's connection information based on the role
|
static String |
getRoleByChannel(io.netty.channel.Channel channel) |
static String |
getSubscribeKey(String messageId,
String cmd) |
static boolean |
isPureDigital(String string)
判断是否为正整数
Determine whether it is a positive integer
|
static boolean |
isReady()
本模块是否可以启动服务(所依赖模块是否可以连接)
Can this module start the service?
|
static void |
scanPackage(Set<String> packageName)
扫描指定路径,得到所有接口的详细信息
Scan the specified path for details of all interfaces
|
static void |
sendMessage(io.netty.channel.Channel channel,
io.netty.buffer.ByteBuf message) |
static void |
sendMessage(String moduleAbbr,
Message message) |
static void |
subscribeByEvent(ConnectData connectData,
Message message,
Request request)
订阅接口(按接口改变次数)
Subscription interface (number of changes per interface)
|
static void |
subscribeCountAdd(Message message)
订阅
Subscription times add 1
|
static void |
subscribeCountAdd(String cmd)
Cmd订阅次数加1
Subscription times add 1
|
static void |
subscribeCountMinus(Message message)
取消订阅
Subscription times minus 1
|
static void |
subscribeCountMinus(String cmd)
Cmd订阅次数减1
Subscription times minus 1
|
static void |
unsubscribeByEvent(Message message)
取消订阅接口(按接口改变次数)
Unsubscribe interface (number of changes per interface)
|
static void |
updateStatus()
更新模块是否可启动状态
Update module bootAble status
|
public static boolean startService
public static final RegisterApi LOCAL
public static final Map<String,Integer> CMD_PRIORITY_MAP
public static final Map<String,ConfigItem> CONFIG_ITEM_MAP
public static final Map<String,Map> ROLE_MAP
public static final Map<String,BaseInvoke> INVOKE_MAP
When calling a remote method, you can set the local method for automatic callback Key: MessageId that calls remote methods, Value: Local method of automatic callback
public static final Map<io.netty.channel.Channel,ConnectData> CHANNEL_DATA_MAP
Key: Channel, Value: ConnectData
public static final Map<String,io.netty.channel.Channel> ROLE_CHANNEL_MAP
public static final ConcurrentMap<String,io.netty.channel.Channel> MSG_ID_KEY_CHANNEL_MAP
key: messageId, value: channel
public static final Map<String,CopyOnWriteArrayList<Message>> CMD_SUBSCRIBE_MESSAGE_MAP
public static final Map<Message,ConnectData> MESSAGE_TO_CHANNEL_MAP
public static final Map<String,Integer> SUBSCRIBE_COUNT
public static int subRequestCount
public static CmdDetail getLocalInvokeCmd(String cmd, double minVersion)
cmd - Command of remote methodminVersion - Version of remote methodpublic static CmdDetail getLocalInvokeCmd(String cmd)
cmd - Command of remote methodpublic static void scanPackage(Set<String> packageName) throws Exception
packageName - Package full pathException - Duplicate commands foundpublic static void addCmdDetail(Class<?> claszs)
public static int addCmdChangeCount(String cmd)
cmd - Command of remote methodpublic static int getCmdChangeCount(String cmd)
cmd - Command of remote methodpublic static void subscribeCountMinus(String cmd)
cmd - public static void subscribeCountMinus(Message message)
message - public static void subscribeCountAdd(String cmd)
cmd - public static void subscribeCountAdd(Message message)
message - public static void subscribeByEvent(ConnectData connectData, Message message, Request request)
connectData - 链接信息message - 订阅消息public static void unsubscribeByEvent(Message message)
message - 取消的订阅消息public static void eventTrigger(String cmd, Response response)
cmd - Command of remote methodresponse - Responsepublic static Response getRealResponse(String cmd, String messageId, Response response)
public static void updateStatus()
public static boolean isReady()
public static String getRemoteUri(String role)
public static String getRemoteUri(io.netty.channel.socket.SocketChannel channel)
public static ConnectData getConnectDataByRole(String role) throws Exception
Exceptionpublic static io.netty.channel.Channel getConnectByRole(String role) throws Exception
Exceptionpublic static io.netty.channel.Channel getConnectByUrl(String url) throws Exception
Exceptionpublic static io.netty.channel.Channel createConnect(String url) throws Exception
Exceptionpublic static void createConnectData(io.netty.channel.Channel channel)
public static void disConnect(io.netty.channel.socket.SocketChannel channel)
public static boolean isPureDigital(String string)
string - 待验证的值,Value to be verifiedpublic static void sendMessage(io.netty.channel.Channel channel,
io.netty.buffer.ByteBuf message)
public static void sendMessage(String moduleAbbr, Message message) throws Exception
Exceptionpublic static String getRoleByChannel(io.netty.channel.Channel channel)
public static io.netty.channel.Channel cacheConnect(String role, io.netty.channel.Channel channel, boolean isSender)
Copyright © 2021. All rights reserved.