类 ConnectManager
- java.lang.Object
-
- network.nerve.core.rpc.netty.channel.manager.ConnectManager
-
public class ConnectManager extends Object
链接管理类 Link Management Class- 作者:
- tag 2019/2/21
-
-
字段概要
字段 修饰符和类型 字段 说明 static Map<io.netty.channel.Channel,ConnectData>CHANNEL_DATA_MAP链接与链接数据的集合static Map<String,Integer>CMD_PRIORITY_MAP本模块各个CMD优先级 Each CMD priority of this modulestatic 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 interfacestatic Map<String,ConfigItem>CONFIG_ITEM_MAP本模块配置信息 Configuration information of this module Key: The key Value: Config detailstatic Map<String,BaseInvoke>INVOKE_MAP调用远程方法时,可以设置自动回调的本地方法。static RegisterApiLOCAL本模块所有对外提供的接口的详细信息 local module(io.nuls.rpc.RegisterApi) informationstatic 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_MAPmessageId对应链接通道对象,用于取消订阅的Request Key:messageId, Value:链接通道static Map<String,io.netty.channel.Channel>ROLE_CHANNEL_MAP角色与链接通道集合 KEY:ROLE VALUE:Channelstatic Map<String,Map>ROLE_MAPKey: 角色,Value:角色的连接信息 Key: role, Value: Connection information of the rolestatic booleanstartService本模块是否可以启动服务(所依赖模块是否可以连接) Can this module start the service?static intsubRequestCount当前正在处理的订阅请求数量 Number of subscription requests currently being processedstatic Map<String,Integer>SUBSCRIBE_COUNT接口被订阅次数(事件方式) Number of changes in the return value of the subscribed interface Key: Cmd Value: subscribe count
-
构造器概要
构造器 构造器 说明 ConnectManager()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static intaddCmdChangeCount(String cmd)返回值改变次数增加1 Increase the changes number of return value by 1static voidaddCmdDetail(Class<?> claszs)static io.netty.channel.ChannelcacheConnect(String role, io.netty.channel.Channel channel, boolean isSender)缓存链接信息 Cache link informationstatic io.netty.channel.ChannelcreateConnect(String url)static voidcreateConnectData(io.netty.channel.Channel channel)static voiddisConnect(io.netty.channel.socket.SocketChannel channel)停止或断开一个连接,清除该连接相关信息 Stop or disconnect a connectionstatic voideventTrigger(String cmd, Response response)订阅接口被调用,判断订阅该接口的事件是否触发static intgetCmdChangeCount(String cmd)得到返回值的改变数量 Get current changes number of return valuestatic io.netty.channel.ChannelgetConnectByRole(String role)static io.netty.channel.ChannelgetConnectByUrl(String url)static ConnectDatagetConnectDataByRole(String role)static CmdDetailgetLocalInvokeCmd(String cmd)根据cmd命令获取最高版本的方法,逻辑同上 Getting the highest version of local methods from CMD commandsstatic CmdDetailgetLocalInvokeCmd(String cmd, double minVersion)根据cmd命令和版本号获取本地方法 Getting local methods from CMD commands and versionstatic ResponsegetRealResponse(String cmd, String messageId, Response response)封装真正的返回结果 Encapsulate the true return resultstatic StringgetRemoteUri(io.netty.channel.socket.SocketChannel channel)根据channel的连接信息 Return the role's connection information based on the rolestatic StringgetRemoteUri(String role)根据角色返回角色的连接信息 Return the role's connection information based on the rolestatic StringgetRoleByChannel(io.netty.channel.Channel channel)static StringgetSubscribeKey(String messageId, String cmd)static booleanisPureDigital(String string)判断是否为正整数 Determine whether it is a positive integerstatic booleanisReady()本模块是否可以启动服务(所依赖模块是否可以连接) Can this module start the service?static voidscanPackage(Set<String> packageName)扫描指定路径,得到所有接口的详细信息 Scan the specified path for details of all interfacesstatic voidsendMessage(io.netty.channel.Channel channel, io.netty.buffer.ByteBuf message)static voidsendMessage(String moduleAbbr, Message message)static voidsubscribeByEvent(ConnectData connectData, Message message, Request request)订阅接口(按接口改变次数) Subscription interface (number of changes per interface)static voidsubscribeCountAdd(String cmd)Cmd订阅次数加1 Subscription times add 1static voidsubscribeCountAdd(Message message)订阅 Subscription times add 1static voidsubscribeCountMinus(String cmd)Cmd订阅次数减1 Subscription times minus 1static voidsubscribeCountMinus(Message message)取消订阅 Subscription times minus 1static voidunsubscribeByEvent(Message message)取消订阅接口(按接口改变次数) Unsubscribe interface (number of changes per interface)static voidupdateStatus()更新模块是否可启动状态 Update module bootAble status
-
-
-
字段详细资料
-
startService
public static boolean startService
本模块是否可以启动服务(所依赖模块是否可以连接) Can this module start the service? (Can the dependent modules be connected?)
-
LOCAL
public static final RegisterApi LOCAL
本模块所有对外提供的接口的详细信息 local module(io.nuls.rpc.RegisterApi) information
-
CMD_PRIORITY_MAP
public static final Map<String,Integer> CMD_PRIORITY_MAP
本模块各个CMD优先级 Each CMD priority of this module
-
CONFIG_ITEM_MAP
public static final Map<String,ConfigItem> CONFIG_ITEM_MAP
本模块配置信息 Configuration information of this module Key: The key Value: Config detail
-
ROLE_MAP
public static final Map<String,Map> ROLE_MAP
Key: 角色,Value:角色的连接信息 Key: role, Value: Connection information of the role
-
INVOKE_MAP
public static final Map<String,BaseInvoke> INVOKE_MAP
调用远程方法时,可以设置自动回调的本地方法。 Key:调用远程方法的messageId,Value:自动回调的本地方法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
-
CHANNEL_DATA_MAP
public static final Map<io.netty.channel.Channel,ConnectData> CHANNEL_DATA_MAP
链接与链接数据的集合Key: Channel, Value: ConnectData
-
ROLE_CHANNEL_MAP
public static final Map<String,io.netty.channel.Channel> ROLE_CHANNEL_MAP
角色与链接通道集合 KEY:ROLE VALUE:Channel
-
MSG_ID_KEY_CHANNEL_MAP
public static final ConcurrentMap<String,io.netty.channel.Channel> MSG_ID_KEY_CHANNEL_MAP
messageId对应链接通道对象,用于取消订阅的Request Key:messageId, Value:链接通道key: messageId, value: channel
-
CMD_SUBSCRIBE_MESSAGE_MAP
public static final 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
-
MESSAGE_TO_CHANNEL_MAP
public static final Map<Message,ConnectData> MESSAGE_TO_CHANNEL_MAP
订阅接口的Message对应的连接 Connection corresponding to Message of Subscription Interface Key:订阅消息/Subscribe message Value:该订阅消息所属连接
-
SUBSCRIBE_COUNT
public static final Map<String,Integer> SUBSCRIBE_COUNT
接口被订阅次数(事件方式) Number of changes in the return value of the subscribed interface Key: Cmd Value: subscribe count
-
subRequestCount
public static int subRequestCount
当前正在处理的订阅请求数量 Number of subscription requests currently being processed
-
-
方法详细资料
-
getLocalInvokeCmd
public static CmdDetail getLocalInvokeCmd(String cmd, double minVersion)
根据cmd命令和版本号获取本地方法 Getting local methods from CMD commands and version- 参数:
cmd- Command of remote methodminVersion- Version of remote method- 返回:
- CmdDetail
-
getLocalInvokeCmd
public static CmdDetail getLocalInvokeCmd(String cmd)
根据cmd命令获取最高版本的方法,逻辑同上 Getting the highest version of local methods from CMD commands- 参数:
cmd- Command of remote method- 返回:
- CmdDetail
-
scanPackage
public static void scanPackage(Set<String> packageName) throws Exception
扫描指定路径,得到所有接口的详细信息 Scan the specified path for details of all interfaces- 参数:
packageName- Package full path- 抛出:
Exception- Duplicate commands found
-
addCmdDetail
public static void addCmdDetail(Class<?> claszs)
-
addCmdChangeCount
public static int addCmdChangeCount(String cmd)
返回值改变次数增加1 Increase the changes number of return value by 1- 参数:
cmd- Command of remote method
-
getCmdChangeCount
public static int getCmdChangeCount(String cmd)
得到返回值的改变数量 Get current changes number of return value- 参数:
cmd- Command of remote method- 返回:
- long
-
subscribeCountMinus
public static void subscribeCountMinus(String cmd)
Cmd订阅次数减1 Subscription times minus 1- 参数:
cmd-
-
subscribeCountMinus
public static void subscribeCountMinus(Message message)
取消订阅 Subscription times minus 1- 参数:
message-
-
subscribeCountAdd
public static void subscribeCountAdd(String cmd)
Cmd订阅次数加1 Subscription times add 1- 参数:
cmd-
-
subscribeCountAdd
public static void subscribeCountAdd(Message message)
订阅 Subscription times add 1- 参数:
message-
-
subscribeByEvent
public static void subscribeByEvent(ConnectData connectData, Message message, Request request)
订阅接口(按接口改变次数) Subscription interface (number of changes per interface)- 参数:
connectData- 链接信息message- 订阅消息
-
unsubscribeByEvent
public static void unsubscribeByEvent(Message message)
取消订阅接口(按接口改变次数) Unsubscribe interface (number of changes per interface)- 参数:
message- 取消的订阅消息
-
eventTrigger
public static void eventTrigger(String cmd, Response response)
订阅接口被调用,判断订阅该接口的事件是否触发- 参数:
cmd- Command of remote methodresponse- Response
-
getRealResponse
public static Response getRealResponse(String cmd, String messageId, Response response)
封装真正的返回结果 Encapsulate the true return result
-
updateStatus
public static void updateStatus()
更新模块是否可启动状态 Update module bootAble status
-
isReady
public static boolean isReady()
本模块是否可以启动服务(所依赖模块是否可以连接) Can this module start the service? (Can the dependent modules be connected?)
-
getRemoteUri
public static String getRemoteUri(String role)
根据角色返回角色的连接信息 Return the role's connection information based on the role
-
getRemoteUri
public static String getRemoteUri(io.netty.channel.socket.SocketChannel channel)
根据channel的连接信息 Return the role's connection information based on the role
-
getConnectDataByRole
public static ConnectData getConnectDataByRole(String role) throws Exception
- 抛出:
Exception
-
getConnectByRole
public static io.netty.channel.Channel getConnectByRole(String role) throws Exception
- 抛出:
Exception
-
getConnectByUrl
public static io.netty.channel.Channel getConnectByUrl(String url) throws Exception
- 抛出:
Exception
-
createConnect
public static io.netty.channel.Channel createConnect(String url) throws Exception
- 抛出:
Exception
-
createConnectData
public static void createConnectData(io.netty.channel.Channel channel)
-
disConnect
public static void disConnect(io.netty.channel.socket.SocketChannel channel)
停止或断开一个连接,清除该连接相关信息 Stop or disconnect a connection
-
isPureDigital
public static boolean isPureDigital(String string)
判断是否为正整数 Determine whether it is a positive integer- 参数:
string- 待验证的值,Value to be verified- 返回:
- boolean
-
sendMessage
public static void sendMessage(io.netty.channel.Channel channel, io.netty.buffer.ByteBuf message)
-
sendMessage
public static void sendMessage(String moduleAbbr, Message message) throws Exception
- 抛出:
Exception
-
getRoleByChannel
public static String getRoleByChannel(io.netty.channel.Channel channel)
-
cacheConnect
public static io.netty.channel.Channel cacheConnect(String role, io.netty.channel.Channel channel, boolean isSender)
缓存链接信息 Cache link information
-
-