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.StringSM_CRYPTO_STR -
Constructor Summary
Constructors Constructor Description GroupManagerServiceImpl(Channel channel, ConfigOption configOption) -
Method Summary
Modifier and Type Method Description voidasyncSendMessageToGroup(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 groupvoidasyncSendMessageToGroupByRule(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)voidasyncSendTransaction(java.lang.Integer groupId, Message transactionMessage, TransactionCallback callback, ResponseCallback responseCallback)voidbroadcastMessageToGroup(java.lang.Integer groupId, Message message)Broadcast messages to all the nodes of the specified groupvoideraseBlockNotifyCallback(java.lang.String registerId)voideraseTransactionSeq(java.lang.String seq)voidfetchGroupList()java.math.BigIntegergetBlockLimitByGroup(java.lang.Integer groupId)Get block limit of specified groupChannelgetChannel()ConfigOptiongetConfig()java.lang.IntegergetCryptoType(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.BigIntegergetLatestBlockNumberByGroup(java.lang.Integer groupId)NodeVersiongetNodeVersion(java.lang.String peerInfo)protected voidonReceiveBlockNotifyImpl(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 voidonReceiveTransactionNotify(Message message)calls the transaction callback when receive the transaction notifyjava.lang.StringregisterBlockNotifyCallback(BlockNumberNotifyCallback callback)voidregisterBlockNumberNotifyHandler()voidregisterGetNodeVersionHandler()voidregisterTransactionNotifyHandler()ResponsesendMessageToGroup(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 groupResponsesendMessageToGroupByRule(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)voidsetAmop(Amop amop)protected voidstart()start the thread to obtain group list information periodicallyvoidstop()Stop group list fetching threadprotected voidupdateBlockNotify(java.lang.String peer, java.util.List<java.lang.String> groupList)voidupdateBlockNumberInfo(java.lang.Integer groupId, java.lang.String peerInfo, java.math.BigInteger currentBlockNumber)update the block number information for the specified groupvoidupdateGroupInfo(java.lang.String peerIpAndPort, java.util.List<java.lang.String> groupList)Update the group list information of the nodevoidupdateNodeVersion()
-
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:
getConfigin interfaceGroupManagerService
-
getCryptoType
public java.lang.Integer getCryptoType(java.lang.String peerInfo)- Specified by:
getCryptoTypein interfaceGroupManagerService
-
getNodeVersion
- Specified by:
getNodeVersionin interfaceGroupManagerService
-
updateNodeVersion
public void updateNodeVersion()- Specified by:
updateNodeVersionin 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:
registerBlockNotifyCallbackin interfaceGroupManagerService
-
eraseBlockNotifyCallback
public void eraseBlockNotifyCallback(java.lang.String registerId)- Specified by:
eraseBlockNotifyCallbackin 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:
asyncSendTransactionin interfaceGroupManagerService
-
eraseTransactionSeq
public void eraseTransactionSeq(java.lang.String seq)- Specified by:
eraseTransactionSeqin interfaceGroupManagerService
-
getChannel
- Specified by:
getChannelin interfaceGroupManagerService
-
stop
public void stop()Stop group list fetching thread- Specified by:
stopin 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:GroupManagerServiceUpdate the group list information of the node- Specified by:
updateGroupInfoin 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:GroupManagerServiceupdate the block number information for the specified group- Specified by:
updateBlockNumberInfoin 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:GroupManagerServiceGet block limit of specified group- Specified by:
getBlockLimitByGroupin 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:
getLatestBlockNumberByGroupin interfaceGroupManagerService
-
getGroupNodeList
public java.util.Set<java.lang.String> getGroupNodeList(java.lang.Integer groupId)Description copied from interface:GroupManagerServiceGet the node list of the specified group- Specified by:
getGroupNodeListin 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:GroupManagerServiceGet the group list of specified node- Specified by:
getGroupInfoByNodeInfoin interfaceGroupManagerService- Parameters:
nodeAddress- The ip and port info of the node- Returns:
- List of groups started by the node
-
sendMessageToGroup
Description copied from interface:GroupManagerServiceSend a message to a node in the group and select the node with the highest block height in the group- Specified by:
sendMessageToGroupin 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:GroupManagerServiceSend a message to a node in the group and select the node with the highest block height in the group- Specified by:
asyncSendMessageToGroupin 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:GroupManagerServiceSend 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:
sendMessageToGroupByRulein 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:
getGroupConnectionInfoin interfaceGroupManagerService
-
getGroupAvailablePeers
public java.util.List<java.lang.String> getGroupAvailablePeers(java.lang.Integer groupId)Description copied from interface:GroupManagerServiceget available ip and port info of specified group- Specified by:
getGroupAvailablePeersin 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:GroupManagerServiceSend 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:
asyncSendMessageToGroupByRulein 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:GroupManagerServiceBroadcast messages to all the nodes of the specified group- Specified by:
broadcastMessageToGroupin interfaceGroupManagerService- Parameters:
groupId- The group the message is sent tomessage- The message to be sent
-
fetchGroupList
public void fetchGroupList()- Specified by:
fetchGroupListin interfaceGroupManagerService
-
getGroupList
public java.util.Set<java.lang.Integer> getGroupList()- Specified by:
getGroupListin interfaceGroupManagerService
-
updateBlockNotify
protected void updateBlockNotify(java.lang.String peer, java.util.List<java.lang.String> groupList) -
setAmop
- Specified by:
setAmopin interfaceGroupManagerService
-