Package org.fisco.bcos.sdk.service
Class GroupManagerServiceImpl
java.lang.Object
org.fisco.bcos.sdk.service.GroupManagerServiceImpl
- All Implemented Interfaces:
GroupManagerService
public class GroupManagerServiceImpl extends java.lang.Object implements GroupManagerService
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SM_CRYPTO_STR
-
Constructor Summary
Constructors Constructor Description GroupManagerServiceImpl(Channel channel, ConfigOption configOption)
-
Method Summary
Modifier and Type Method Description void
asyncSendMessageToGroup(java.lang.Integer groupId, Message message, ResponseCallback callback)
Send a message to a node in the group and select the node with the highest block height in the groupvoid
asyncSendMessageToGroupByRule(java.lang.Integer groupId, Message message, PeerSelectRule rule, ResponseCallback callback)
Send messages to nodes in the group according to specified rules (If multiple nodes are filtered out, only select one of them to send the message)void
asyncSendTransaction(java.lang.Integer groupId, Message transactionMessage, TransactionCallback callback, ResponseCallback responseCallback)
void
broadcastMessageToGroup(java.lang.Integer groupId, Message message)
Broadcast messages to all the nodes of the specified groupvoid
eraseBlockNotifyCallback(java.lang.String registerId)
void
eraseTransactionSeq(java.lang.String seq)
void
fetchGroupList()
java.math.BigInteger
getBlockLimitByGroup(java.lang.Integer groupId)
Get block limit of specified groupChannel
getChannel()
ConfigOption
getConfig()
java.lang.Integer
getCryptoType(java.lang.String peerInfo)
java.util.List<java.lang.String>
getGroupAvailablePeers(java.lang.Integer groupId)
get available ip and port info of specified groupjava.util.List<ConnectionInfo>
getGroupConnectionInfo(java.lang.Integer groupId)
java.util.List<java.lang.String>
getGroupInfoByNodeInfo(java.lang.String nodeAddress)
Get the group list of specified nodejava.util.Set<java.lang.Integer>
getGroupList()
java.util.Set<java.lang.String>
getGroupNodeList(java.lang.Integer groupId)
Get the node list of the specified groupjava.math.BigInteger
getLatestBlockNumberByGroup(java.lang.Integer groupId)
NodeVersion
getNodeVersion(java.lang.String peerInfo)
protected void
onReceiveBlockNotifyImpl(EnumChannelProtocolVersion version, java.lang.String peerIpAndPort, Message blockNumberNotifyMessage)
Get the blockNumber notify message from the AMOP module, parse the package and update the latest block height of each groupprotected void
onReceiveTransactionNotify(Message message)
calls the transaction callback when receive the transaction notifyjava.lang.String
registerBlockNotifyCallback(BlockNumberNotifyCallback callback)
void
registerBlockNumberNotifyHandler()
void
registerGetNodeVersionHandler()
void
registerTransactionNotifyHandler()
Response
sendMessageToGroup(java.lang.Integer groupId, Message message)
Send a message to a node in the group and select the node with the highest block height in the groupResponse
sendMessageToGroupByRule(java.lang.Integer groupId, Message message, PeerSelectRule rule)
Send messages to nodes in the group according to specified rules (If multiple nodes are filtered out, only select one of them to send the message)void
setAmop(Amop amop)
protected void
start()
start the thread to obtain group list information periodicallyvoid
stop()
Stop group list fetching threadprotected void
updateBlockNotify(java.lang.String peer, java.util.List<java.lang.String> groupList)
void
updateBlockNumberInfo(java.lang.Integer groupId, java.lang.String peerInfo, java.math.BigInteger currentBlockNumber)
update the block number information for the specified groupvoid
updateGroupInfo(java.lang.String peerIpAndPort, java.util.List<java.lang.String> groupList)
Update the group list information of the nodevoid
updateNodeVersion()
-
Field Details
-
SM_CRYPTO_STR
public static final java.lang.String SM_CRYPTO_STR- See Also:
- Constant Field Values
-
-
Constructor Details
-
Method Details
-
getConfig
- Specified by:
getConfig
in interfaceGroupManagerService
-
getCryptoType
public java.lang.Integer getCryptoType(java.lang.String peerInfo)- Specified by:
getCryptoType
in interfaceGroupManagerService
-
getNodeVersion
- Specified by:
getNodeVersion
in interfaceGroupManagerService
-
updateNodeVersion
public void updateNodeVersion()- Specified by:
updateNodeVersion
in interfaceGroupManagerService
-
registerGetNodeVersionHandler
public void registerGetNodeVersionHandler() -
registerBlockNumberNotifyHandler
public void registerBlockNumberNotifyHandler() -
registerTransactionNotifyHandler
public void registerTransactionNotifyHandler() -
onReceiveBlockNotifyImpl
protected void onReceiveBlockNotifyImpl(EnumChannelProtocolVersion version, java.lang.String peerIpAndPort, Message blockNumberNotifyMessage)Get the blockNumber notify message from the AMOP module, parse the package and update the latest block height of each group- Parameters:
version
- the EnumChannelProtocolVersion instancepeerIpAndPort
- Node ip and portblockNumberNotifyMessage
- the blockNumber notify message
-
registerBlockNotifyCallback
- Specified by:
registerBlockNotifyCallback
in interfaceGroupManagerService
-
eraseBlockNotifyCallback
public void eraseBlockNotifyCallback(java.lang.String registerId)- Specified by:
eraseBlockNotifyCallback
in interfaceGroupManagerService
-
onReceiveTransactionNotify
calls the transaction callback when receive the transaction notify- Parameters:
message
- the message contains the transactionReceipt
-
asyncSendTransaction
public void asyncSendTransaction(java.lang.Integer groupId, Message transactionMessage, TransactionCallback callback, ResponseCallback responseCallback)- Specified by:
asyncSendTransaction
in interfaceGroupManagerService
-
eraseTransactionSeq
public void eraseTransactionSeq(java.lang.String seq)- Specified by:
eraseTransactionSeq
in interfaceGroupManagerService
-
getChannel
- Specified by:
getChannel
in interfaceGroupManagerService
-
stop
public void stop()Stop group list fetching thread- Specified by:
stop
in interfaceGroupManagerService
-
start
protected void start()start the thread to obtain group list information periodically -
updateGroupInfo
public void updateGroupInfo(java.lang.String peerIpAndPort, java.util.List<java.lang.String> groupList)Description copied from interface:GroupManagerService
Update the group list information of the node- Specified by:
updateGroupInfo
in interfaceGroupManagerService
- Parameters:
peerIpAndPort
- Node ip and port informationgroupList
- Group list of nodes
-
updateBlockNumberInfo
public void updateBlockNumberInfo(java.lang.Integer groupId, java.lang.String peerInfo, java.math.BigInteger currentBlockNumber)Description copied from interface:GroupManagerService
update the block number information for the specified group- Specified by:
updateBlockNumberInfo
in interfaceGroupManagerService
- Parameters:
groupId
- the specified groupIdpeerInfo
- the info of the peerscurrentBlockNumber
- the current blockNumber
-
getBlockLimitByGroup
public java.math.BigInteger getBlockLimitByGroup(java.lang.Integer groupId)Description copied from interface:GroupManagerService
Get block limit of specified group- Specified by:
getBlockLimitByGroup
in interfaceGroupManagerService
- Parameters:
groupId
- The specified groupId- Returns:
- the blockLimit(needed by the transaction module)
-
getLatestBlockNumberByGroup
public java.math.BigInteger getLatestBlockNumberByGroup(java.lang.Integer groupId)- Specified by:
getLatestBlockNumberByGroup
in interfaceGroupManagerService
-
getGroupNodeList
public java.util.Set<java.lang.String> getGroupNodeList(java.lang.Integer groupId)Description copied from interface:GroupManagerService
Get the node list of the specified group- Specified by:
getGroupNodeList
in interfaceGroupManagerService
- Parameters:
groupId
- The group id- Returns:
- The node list that started the group
-
getGroupInfoByNodeInfo
public java.util.List<java.lang.String> getGroupInfoByNodeInfo(java.lang.String nodeAddress)Description copied from interface:GroupManagerService
Get the group list of specified node- Specified by:
getGroupInfoByNodeInfo
in interfaceGroupManagerService
- Parameters:
nodeAddress
- The ip and port info of the node- Returns:
- List of groups started by the node
-
sendMessageToGroup
Description copied from interface:GroupManagerService
Send a message to a node in the group and select the node with the highest block height in the group- Specified by:
sendMessageToGroup
in interfaceGroupManagerService
- Parameters:
groupId
- The group the message is sent tomessage
- The message to be sent- Returns:
- response of the node located in the specified group
-
asyncSendMessageToGroup
public void asyncSendMessageToGroup(java.lang.Integer groupId, Message message, ResponseCallback callback)Description copied from interface:GroupManagerService
Send a message to a node in the group and select the node with the highest block height in the group- Specified by:
asyncSendMessageToGroup
in interfaceGroupManagerService
- Parameters:
groupId
- The group the message is sent tomessage
- The message to be sentcallback
- callback to be called after receiving response
-
sendMessageToGroupByRule
public Response sendMessageToGroupByRule(java.lang.Integer groupId, Message message, PeerSelectRule rule)Description copied from interface:GroupManagerService
Send messages to nodes in the group according to specified rules (If multiple nodes are filtered out, only select one of them to send the message)- Specified by:
sendMessageToGroupByRule
in interfaceGroupManagerService
- Parameters:
groupId
- The group the message is sent tomessage
- The message to be sentrule
- Rule for filtering the target nodes- Returns:
- callback to be called after receiving response
-
getGroupConnectionInfo
- Specified by:
getGroupConnectionInfo
in interfaceGroupManagerService
-
getGroupAvailablePeers
public java.util.List<java.lang.String> getGroupAvailablePeers(java.lang.Integer groupId)Description copied from interface:GroupManagerService
get available ip and port info of specified group- Specified by:
getGroupAvailablePeers
in interfaceGroupManagerService
- Parameters:
groupId
- get the connection info of the group- Returns:
- the available ip and port info of the group
-
asyncSendMessageToGroupByRule
public void asyncSendMessageToGroupByRule(java.lang.Integer groupId, Message message, PeerSelectRule rule, ResponseCallback callback)Description copied from interface:GroupManagerService
Send messages to nodes in the group according to specified rules (If multiple nodes are filtered out, only select one of them to send the message)- Specified by:
asyncSendMessageToGroupByRule
in interfaceGroupManagerService
- Parameters:
groupId
- The group the message is sent tomessage
- The message to be sentrule
- Rules for filtering the target nodescallback
- Function to be called after receiving response
-
broadcastMessageToGroup
Description copied from interface:GroupManagerService
Broadcast messages to all the nodes of the specified group- Specified by:
broadcastMessageToGroup
in interfaceGroupManagerService
- Parameters:
groupId
- The group the message is sent tomessage
- The message to be sent
-
fetchGroupList
public void fetchGroupList()- Specified by:
fetchGroupList
in interfaceGroupManagerService
-
getGroupList
public java.util.Set<java.lang.Integer> getGroupList()- Specified by:
getGroupList
in interfaceGroupManagerService
-
updateBlockNotify
protected void updateBlockNotify(java.lang.String peer, java.util.List<java.lang.String> groupList) -
setAmop
- Specified by:
setAmop
in interfaceGroupManagerService
-