Method and device for transmitting peer node instruction, proxy server and storage medium
1. A method for transmitting a peer node instruction is applied to a chain code system, the chain code system comprises a proxy server, a plurality of docker servers and a plurality of peer nodes, the plurality of docker servers are in network connection with the plurality of peer nodes, the method is applied to the proxy server, and the method comprises the following steps:
acquiring a chain code container life cycle instruction sent by at least one peer node;
judging whether a first docker server in the plurality of docker servers is down;
and if the first docker server is not down, forwarding the chain code container life cycle instruction to the first docker server.
If the first docker server is down, judging whether other docker servers except the first docker server in the plurality of docker servers are down;
if at least one of the other docker servers is not down, forwarding the chain code container life cycle instruction to a first non-down docker server of the non-down docker servers, so that the first non-down docker server executes the chain code container life cycle instruction.
2. The method for transmitting a peer node instruction according to claim 1, wherein the determining whether a first docker server of the plurality of docker servers is down comprises:
acquiring a data packet for communication sent by the first docker server according to a preset period;
if the data packet sent by the first docker server is obtained, determining that the first docker server is not down;
and if the data packet sent by the first docker server is not acquired, determining that the first docker server is down.
3. The method for transmitting a peer node instruction according to claim 1, wherein the determining whether any other docker server of the plurality of docker servers except the first docker server is down if the first docker server is down comprises:
acquiring data packets for communication sent by other docker servers according to a preset period;
if the data packets corresponding to the data packets sent by the other docker servers are obtained, determining that the other docker servers are not down;
and if the data packets corresponding to the data packets sent by the other docker servers are not obtained, determining that the docker server which does not send the corresponding data packets in the other docker servers is down.
4. The method for instruction transmission of a peer node according to claim 3, wherein if the data packet corresponding to the data packet sent by the other docker servers is not obtained, and after it is determined that the docker server that does not send the corresponding data packet in the other docker servers is down, the method further comprises:
and if the data packet sent by the downtime docker server is obtained again, determining that the downtime server is recovered to be normal.
5. The method of peer node instruction transmission according to claim 1, further comprising:
if an additional docker server is monitored, judging whether the additional docker server is down, wherein the additional docker server is a newly added docker server on the basis of the original plurality of docker servers;
if the additional docker server is down, determining that the additional docker server is unavailable;
if the additional docker server is not down, determining that the additional docker server is a candidate docker server, and sending the chain code container life cycle instruction to the candidate docker server when the first docker server is down.
6. The method of claim 1, wherein if the first docker server is not down, forwarding the chain container lifecycle instructions to the first docker server, the method further comprising:
if the first docker server is down when executing the chain code container life cycle instruction, determining that transmission fails, and judging whether other docker servers in the plurality of docker servers are down;
and if at least one of the other docker servers is not down, re-transmitting the chain code container life cycle instruction to the first docker server which is not down.
7. The device for transmitting the order of the peer nodes is characterized by being applied to a chain code system, wherein the chain code system comprises a proxy server, a plurality of docker servers and a plurality of peer nodes, the docker servers are in network connection with the peer nodes, the method is applied to the proxy server, and the device comprises:
the obtaining module is used for obtaining a chain code container life cycle instruction sent by at least one peer node;
the first judging module is used for judging whether a first docker server in the plurality of docker servers is down;
a first forwarding module, configured to forward the chain code container life cycle instruction to the first docker server if the first docker server is not down;
a second judging module, configured to judge whether any other docker server, except the first docker server, of the plurality of docker servers is down if the first docker server is down;
and the second forwarding module is used for forwarding the chain code container life cycle instruction to a first non-downtime docker server in the non-downtime servers if at least one of the other docker servers is not down, so that the first non-downtime docker server executes the chain code container life cycle instruction.
8. A proxy server, characterized in that the proxy server comprises:
one or more processors;
a memory; and
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the method of peer node instruction transmission of any of claims 1-6.
9. A storage medium having stored thereon a computer program to be loaded by a processor for performing the method of peer node instruction transmission according to any of claims 1 to 6.
Background
In order to avoid the problem of single-point failure, there are two common approaches in the prior art, the first is to modify the api (application Programming interface) of the source code integration k8s (kubernets, which is an arrangement management tool of a portable container generated for container services) of fabric, and let k8s manage the life cycle of the link code. Secondly, a dockerin docker environment is created, which (i.e. a container, inside which a docker service runs) allows k8s to host its lifecycle, and the peer node accesses the docker service in the container to control the lifecycle of the chain code.
However, in the prior art, there is an environmental isolation problem in the pod (dockeroutside of docker), name conflict problem occurs when different containers construct mirror image containers, parallelism is not supported, and the internal container needs to be consistent with the docker environment of the host. And Dind (dockerin docker) has the problems of image bloat, incapability of using cache and storage and other unknown problems, and the most obvious defect is that the instruction sent by the node cannot be responded when the server is down.
Disclosure of Invention
The application provides a method for transmitting a peer node instruction, which can learn whether each docker server is down according to communication conditions by keeping synchronous communication with different docker servers, and avoid the problem that various execution instructions cannot be sent to the docker servers after the execution instructions sent by the peer node are acquired.
In one aspect, the application provides a method for transmitting a peer node instruction, which is applied to a chain code system, the chain code system comprises a proxy server, a plurality of docker servers and a plurality of peer nodes, the plurality of docker servers are in network connection with the plurality of peer nodes, the method is applied to the proxy server, and the method comprises the following steps:
acquiring a chain code container life cycle instruction sent by at least one peer node;
judging whether a first docker server in the plurality of docker servers is down;
and if the first docker server is not down, forwarding the chain code container life cycle instruction to the first docker server.
If the first docker server is down, judging whether other docker servers except the first docker server in the plurality of docker servers are down;
if at least one of the other docker servers is not down, forwarding the chain code container life cycle instruction to a first non-down docker server of the non-down docker servers, so that the first non-down docker server executes the chain code container life cycle instruction.
In some embodiments of the present application, the determining whether a first docker server of the plurality of docker servers is down includes:
acquiring a data packet for communication sent by the first docker server according to a preset period;
if the data packet sent by the first docker server is obtained, determining that the first docker server is not down;
and if the data packet sent by the first docker server is not acquired, determining that the first docker server is down.
In some embodiments of the present application, if the first docker server is down, determining whether other docker servers of the plurality of docker servers except the first docker server are down includes:
acquiring data packets for communication sent by other docker servers according to a preset period;
if the data packets corresponding to the data packets sent by the other docker servers are obtained, determining that the other docker servers are not down;
and if the data packets corresponding to the data packets sent by the other docker servers are not obtained, determining that the docker server which does not send the corresponding data packets in the other docker servers is down.
In some embodiments of the present application, after determining that a docker server that does not send a corresponding data packet in another docker server is down if the data packet corresponding to the data packet sent by the another docker server is not obtained, the method further includes:
and if the data packet sent by the downtime docker server is obtained again, determining that the downtime server is recovered to be normal.
In some embodiments of the present application, the method further comprises:
if an additional docker server is monitored, judging whether the additional docker server is down, wherein the additional docker server is a newly added docker server on the basis of the original plurality of docker servers;
if the additional docker server is down, determining that the additional docker server is unavailable;
if the additional docker server is not down, determining that the additional docker server is a candidate docker server, and sending the chain code container life cycle instruction to the candidate docker server when the first docker server is down.
In some embodiments of the present application, after forwarding the chain code container lifecycle instruction to a chain code container directly connected to the first docker server if the first docker server is not down, the method further includes:
if the first docker server is down when executing the chain code container life cycle instruction, determining that transmission fails, and judging whether other docker servers in the plurality of docker servers are down;
and if at least one of the other docker servers is not down, re-transmitting the chain code container life cycle instruction to the first docker server which is not down.
On the other hand, this application still provides a device of peer node instruction transmission, is applied to chain code system, chain code system includes proxy server, a plurality of docker servers and a plurality of peer node, a plurality of docker servers with a plurality of peer node network connection, the method is applied to proxy server, the device includes:
the obtaining module is used for obtaining a chain code container life cycle instruction sent by at least one peer node;
the first judging module is used for judging whether a first docker server in the plurality of docker servers is down;
the first forwarding module is used for forwarding the chain code container life cycle instruction to a chain code container directly connected with the first docker server if the first docker server is not down;
a second judging module, configured to judge whether any other docker server, except the first docker server, of the plurality of docker servers is down if the first docker server is down;
and the second forwarding module is used for forwarding the chain code container life cycle instruction to a first non-downtime docker server in the non-downtime servers if at least one of the other docker servers is not down, so that the first non-downtime docker server executes the chain code container life cycle instruction.
In some embodiments of the present application, the first determining module is specifically configured to:
acquiring a data packet for communication sent by the first docker server according to a preset period;
if the data packet sent by the first docker server is obtained, determining that the first docker server is not down;
and if the data packet sent by the first docker server is not acquired, determining that the first docker server is down.
In some embodiments of the present application, the second determining module is specifically configured to:
acquiring data packets for communication sent by other docker servers according to a preset period;
if the data packets corresponding to the data packets sent by the other docker servers are obtained, determining that the other docker servers are not down;
and if the data packets corresponding to the data packets sent by the other docker servers are not obtained, determining that the docker server which does not send the corresponding data packets in the other docker servers is down.
In some embodiments of the present application, the second determining module is further specifically configured to:
if an additional docker server is monitored, judging whether the additional docker server is down, wherein the additional docker server is a newly added docker server on the basis of the original plurality of docker servers;
if the additional docker server is down, determining that the additional docker server is unavailable;
if the additional docker server is not down, determining that the additional docker server is a candidate docker server, and sending the chain code container life cycle instruction to the candidate docker server when the first docker server is down.
In some embodiments of the present application, the second determining module is further specifically configured to:
if the first docker server is down when executing the chain code container life cycle instruction, determining that transmission fails, and judging whether other docker servers in the plurality of docker servers are down;
and if at least one of the other docker servers is not down, re-transmitting the chain code container life cycle instruction to the first docker server which is not down.
In another aspect, the present application further provides a proxy server, including:
one or more processors;
a memory; and
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement any of the methods of peer node instruction transmission.
In another aspect, the present application further provides a computer-readable storage medium, which stores a plurality of instructions, where the instructions are suitable for being loaded by a processor to perform any one of the steps of the transmission of the peer node instruction.
The method for transmitting the instructions of the peer nodes can keep synchronous communication for a plurality of deployed docker servers, if the server in the docker servers solves the problem that the instructions sent by the nodes are down, the instructions can be directly handed to other servers for synchronous communication to be processed, the problem that the instructions of the nodes cannot be responded when the servers are in trouble is solved, and meanwhile, the instructions of the nodes can be responded before the down condition of the servers is solved, so that the response efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic view of a scenario of a peer node instruction transmission provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of an embodiment of a method for transmitting a peer node instruction in an embodiment of the present application;
FIG. 3 is a schematic structural diagram of an apparatus for transmitting a peer node instruction in an embodiment of the present application;
fig. 4 is a schematic structural diagram of an embodiment of a proxy server in the embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the description of the present application, it is to be understood that the terms "first", "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, features defined as "first", "second", may explicitly or implicitly include one or more of the described features. In the description of the present application, "a plurality" means two or more unless specifically limited otherwise.
In this application, the word "exemplary" is used to mean "serving as an example, instance, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments. The following description is presented to enable any person skilled in the art to make and use the application. In the following description, details are set forth for the purpose of explanation. It will be apparent to one of ordinary skill in the art that the present application may be practiced without these specific details. In other instances, well-known structures and processes are not set forth in detail in order to avoid obscuring the description of the present application with unnecessary detail. Thus, the present application is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.
The application provides a method and a device for transmitting a peer node instruction, a proxy server and a storage medium, which are respectively described below.
Some basic concepts involved in the embodiments of the present application are first described below:
chain code: the chaincode is called chain code for short, and is generally an application code written by a user in a go language. Chain code is deployed on a Fabric (Fabric is a distributed accounting solution platform supported by a modular architecture, which provides high confidentiality, elasticity, flexibility and scalability), runs in a Docker container (a virtual system, a shared operating system core, less occupied resources and high starting speed) on a network node, and interacts with a corresponding peer node (the peer node is a physical concept, a server can serve as the peer, the server can be a private physical machine or a resource on the cloud, the peer is an infrastructure of the whole Fabric system) through a gPC Protocol (in many Remote Procedure Call Protocol systems, the gPC is based on defining a service, and appoints a method with parameters and a return type which can be called remotely), to manipulate data in the distributed ledger.
Referring to fig. 1, fig. 1 is a schematic view of a scenario of a method for transmitting a peer node instruction according to an embodiment of the present application, where the system for transmitting a peer node instruction may include a server 10 and a proxy server 20, the server 10 is in communication with the proxy server 20, the server 10 may transmit data to the proxy server 20, and the proxy server 20 may also transmit data to the server 10, such as the server 10 in fig. 1, which may transmit data to the proxy server 20 according to obtained real-time data; the proxy server 20 may calculate a scheme for the transmission of the peer node command and then transmit the scheme for the transmission of the peer node command to the server 10.
In the embodiment of the present application, the server 10 includes, but is not limited to, an independent server, and may also be a server network or a server cluster composed of servers, which includes, but is not limited to, a computer, a network host, a single network server, a plurality of network server sets, or a cloud server composed of a plurality of servers. Among them, the Cloud server is constituted by a large number of computers or web servers based on Cloud Computing (Cloud Computing).
In this embodiment, the proxy server 20 may also be an independent server, or may also be a server network or a server cluster composed of servers, for example, the device for transmitting the peer node instruction described in this embodiment includes, but is not limited to, a computer, a network host, a single network server, multiple network server sets, or a cloud server composed of multiple servers. Among them, the Cloud server is constituted by a large number of computers or web servers based on Cloud Computing (Cloud Computing).
In the embodiment of the present application, the server 10 and the proxy server 20 may implement communication through any communication manner, including but not limited to mobile communication based on the third Generation Partnership Project (3 GPP), Long Term Evolution (LTE), Worldwide Interoperability for Microwave Access (WiMAX), or computer network communication based on the TCP/IP Protocol Suite (TCP/IP), User Datagram Protocol (UDP), and the like.
It can be understood by those skilled in the art that the application environment shown in fig. 1 is only one application scenario related to the present application, and does not constitute a limitation on the application scenario of the present application, and other application environments may further include more or fewer terminal devices and background devices than those shown in fig. 1, for example, only 1 terminal device or background device is shown in fig. 1, and the system for transmitting the peer node instruction may further include one or more other servers and proxy servers capable of processing data, which is not limited herein.
In addition, as shown in fig. 1, the system for transmitting the peer node instruction may further include a terminal device 30, where the terminal device 30 may be a desktop computer, a laptop computer, a network server, a Personal Digital Assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, a communication device, an embedded device, and the like. The connection mode between the terminal device 30 and the proxy server 20 includes, but is not limited to, mobile communication based on the third Generation Partnership Project (3rd 3GPP), Long Term Evolution (Long Term Evolution, LTE), Worldwide Interoperability for Microwave Access (WiMAX), or computer network communication based on the TCP/IP Protocol Suite (TCP/IP), User Datagram Protocol (UDP), and so on. The terminal device 30 may be configured to send data instructions to the proxy server 20, such as creating, starting, stopping, and upgrading the chain code container life cycle instructions.
It should be noted that the scenario diagram of the system for transmitting a peer node instruction shown in fig. 1 is merely an example, and the system and the scenario for transmitting a peer node instruction described in the embodiment of the present application are for more clearly illustrating the technical solution of the embodiment of the present application, and do not form a limitation on the technical solution provided in the embodiment of the present application.
As shown in fig. 2, fig. 2 is a method for transmitting a peer node instruction in an embodiment of the present application, and is applied to a chain code system, where the chain code system includes a proxy server, a plurality of docker servers and a plurality of peer nodes, the plurality of docker servers are connected to the plurality of peer nodes through a network, and the method is applied to the proxy server, and the method may include the following steps 201 to 205:
201. and acquiring a chain code container life cycle instruction sent by at least one peer node.
The peer node is introduced above, and thus will not be described herein. When different chain code container life cycle instructions are generated by different peer nodes, for example: when creating, starting, stopping and upgrading the chain code container life cycle instruction, the corresponding server is required to execute. In a complex network, when the instructions of the nodes are sent to the server for execution, the instructions are usually sent through the proxy server, and the proxy server can avoid the complex situation in the network, which is beneficial to improving the transmission speed.
202. And judging whether a first docker server in the plurality of docker servers is down.
When the peer node is directly connected with the docker server, if the docker server is down, the corresponding chain code container on the docker server cannot be used. Therefore, in order to avoid such a situation, the docker server needs to be kept down all the time, but the docker server is always unavailable due to an unexpected situation, so the purpose of the present application is to always run the chain code container. Therefore, when the docker server is down, if other available docker servers exist, the chain code container can be migrated to the available docker servers, so that the chain code container can perform corresponding work according to the life cycle instruction of the chain code container.
Therefore, in order to avoid sending the chain code container lifecycle instructions to the down docker server, after the proxy server obtains the chain code container lifecycle instructions sent by each peer node, in order to enable the chain code container lifecycle instructions to be smoothly executed, it is necessary to determine whether the current docker server is down, and if the server is down, the chain code container cannot execute the corresponding instructions. In the step, a plurality of docker servers are designed, so that when one docker server is down, the chain code containers can be migrated to other docker servers to execute the life cycle instructions of the chain code containers.
The first docker server may be any one of the plurality of docker servers, or may be a server with a first priority among the plurality of docker servers, for example: the server with the lowest transmission delay is not limited herein.
In some embodiments of the present application, the determining whether a first docker server of the plurality of docker servers is down includes:
and acquiring a data packet for communication sent by the first docker server according to a preset period.
In order to achieve better accuracy of judgment, a special communication mechanism can be established between the proxy server and the first docker server, a transmission function between normal servers is realized, and the first docker server is proved to be "on-line" through a self-defined data packet transmitted in a preset period if the first docker server is "on-line".
For example, the preset period may be 3 seconds, and the data packet may be any data, for example, "00001111", and in this case, it may be set that the first docker server transmits a data packet with data "00001111" to the proxy server every 3 seconds 2 times.
According to the above description, if the first docker server can send a data packet to the proxy server, the proxy server can determine whether the first docker server is down according to whether the data packet is received, and two situations may occur:
for example, if the above example is still used, at this time, if the proxy server can acquire the data packet with data of "00001111" sent by the first docker server 2 times every 3 seconds, it may be determined that the first docker server is working normally and is not down.
(1) And if the data packet sent by the first docker server is obtained, determining that the first docker server is not down.
For example, if the above example is still used, at this time, if the proxy server can acquire the data packet with data of "00001111" sent by the first docker server 2 times every 3 seconds, it may be determined that the first docker server is working normally.
(2) And if the data packet sent by the first docker server is not acquired, determining that the first docker server is down.
For example, if the above example is still used, at this time, if the proxy server does not obtain the data packet with data of "00001111" every 3 seconds or intermittently obtains the data packet with data of "00001111" every 3 seconds and 2 times, which is sent by the first docker server, it may be determined that the first docker server is not working normally, is in a downtime condition, or is about to be in a downtime condition.
The purpose of the embodiment of the present application is to avoid a problem of transmission failure when the chain code container lifecycle instruction is sent to the first docker server.
203. And if the first docker server is not down, forwarding the chain code container life cycle instruction to the first docker server.
Since the downtime of the docker server makes the chain code container also unusable, the transferring of the chain code container lifecycle instruction to a docker server that is not down is to implement the migration of the chain code container, and as the foregoing step 202 has already been described, it is not described here again.
According to the description of the above embodiment, if it can be determined that the first docker server is not down, the chain code container lifecycle instruction is directly forwarded to the first docker server, and the first docker server executes the chain code container lifecycle instruction to control the lifecycle of the chain code, which is not described herein again.
204. If the first docker server is down, judging whether other docker servers except the first docker server in the plurality of docker servers are down.
If the first docker server is down according to the description of the above embodiment, the first docker server cannot normally execute the chain code container lifecycle instruction at this time, and if the chain code container lifecycle instruction is still transferred to the first docker server at this time, the corresponding chain code container lifecycle instruction cannot be normally received due to the down of the first docker server, and transmission fails at this time, and in order to avoid such transmission failure, the chain code container lifecycle instruction needs to be transferred to other normally operating docker servers.
In order to avoid the situation that other docker servers are down, it is necessary to determine whether the other docker servers are down, so as to avoid the situation that the transmission of the link container lifecycle instructions is still failed.
In some embodiments of the present application, if the first docker server is down, determining whether other docker servers of the plurality of docker servers except the first docker server are down includes:
and acquiring data packets for communication sent by other docker servers according to a preset period.
And if the data packets corresponding to the data packets sent by the other docker servers are not obtained, determining that the docker server which does not send the corresponding data packets in the other docker servers is down.
And if the data packets corresponding to the data packets sent by the other docker servers are obtained, determining that the other docker servers are not down.
The purpose of this step is the same as that in the above embodiment, and is not described herein again.
Similarly, in order to determine whether other docker servers are down according to each corresponding data packet sent by different docker servers, the above embodiments are described, and details are not described here.
The same parts as those of the above embodiment will not be described herein again. It should be noted that the identities of different docker servers can be identified according to data packets sent by different docker servers.
For example, the data packets sent by different docker servers may contain identification information, such as: the data packet a sent by the docker server a may include an identification code, for example, the data packet a may be "a 00001111", where the first bit a is the identification code, and at this time, the data packet a from the docker may be obtained according to the identification code, and so on.
However, it should be noted that, the identification of different docker servers according to the data packet is only one identification method in the embodiment of the present application, and certainly, identification may also be performed directly according to network information that the proxy server is connected to each docker server, for example, an IP address, and the like, and this is not limited herein.
According to the above description in this embodiment, if the data packet B sent by the docker server B is not acquired, the data packet B may be "B00001111", and the data packet with the identification bit being B is not detected, so that it may be determined that the docker server B is down, and so on.
It should be noted that, the identification of different docker servers according to the data packet is only one identification method in the embodiment of the present application, and certainly, identification may also be performed directly according to network information that the proxy server is connected to each docker server, for example, an IP address, and the like, and this is not limited herein.
In order to better implement the scheme provided by the present application, in some embodiments of the present application, if a data packet corresponding to the data packet sent by the other docker servers is not obtained, after determining that a docker server that does not send the corresponding data packet in the other docker servers is down, the method further includes:
and if the data packet sent by the downtime docker server is obtained again, determining that the downtime server is recovered to be normal.
In a normal use scenario, the down docker server may not be in the down state all the time, for example, a worker may repair the down docker server and reconnect the network, at this time, the down docker server may send a corresponding data packet to the proxy server according to a previously set manner, and if the proxy server acquires the corresponding data packet sent by the corresponding docker server again, it may be determined that the down docker server is recovered to be normal, and the data packet may be used as an execution main body for executing the link container lifecycle instruction again.
205. If at least one of the other docker servers is not down, forwarding the chain code container life cycle instruction to a first non-down docker server of the non-down docker servers, so that the first non-down docker server executes the chain code container life cycle instruction.
And when the first docker server is down and at least one of the other docker servers is not down, sending the chain code container life cycle instruction to the docker server which is not down.
If the first docker server is down, but in other docker servers, when a plurality of docker servers are not down, the chain container lifecycle instruction may be forwarded to any docker server that is not down, and certainly, the chain container lifecycle instruction may be forwarded to a docker server that is not down, where a docker server with the highest priority, for example: the highest priority may be one of the non-down docker servers with the highest transmission speed.
The method for transmitting the instructions of the peer nodes can keep synchronous communication for a plurality of deployed docker servers, and if the server in the docker servers solves the problem that the instructions sent by the nodes are down, the instructions can be directly handed to other servers for synchronous communication to be processed, so that the problem that the instructions of the nodes cannot be responded when the servers are in trouble is solved, and meanwhile, the instructions of the nodes can be responded before the down condition of the servers is solved, and the response efficiency is improved.
For better understanding of the present solution, a general description is made herein in conjunction with some of the above embodiments, for example:
1) there are A, B, C available docker servers among the plurality of docker servers, and the docker proxy service will maintain communication with A, B, C three docker servers, at which time A, B, C exists in the available list in the docker proxy service.
2) And when the peer node receives the starting operation, the creation and starting of the chain code container life cycle instruction is initiated to the docker proxy server.
3) When the docker proxy server receives an execution instruction request sent by a peer, a first docker server A is selected from the docker service available list, and the execution instruction is sent to the docker server A.
4) When the docker server a receives the forwarded execution instruction request of the docker proxy server, the docker proxy server a executes the instruction, and finally, the chain code container runs on the host of the docker server a.
5) When the docker server a crashes, the corresponding link code container is also stopped, and at this time, the docker proxy server monitors that the docker server a is unavailable (in a preset period, the docker proxy server does not receive the corresponding data packet, and does not receive the data packet, which means that the docker server is crashed), and removes the data packet from the available list, and at this time, only the docker server B, docker server C is in the available list. At this time, the docker proxy server may forward the execution instruction to any one of the docker server B and the docker server C.
In some embodiments of the present application, the method further comprises:
if an additional docker server is monitored, judging whether the additional docker server is down, wherein the additional docker server is a newly added docker server on the basis of the original plurality of docker servers.
Under a general scenario, a problem that a docker server is permanently down may also exist, for example, as the usage time increases, the docker server is irreversibly damaged, resulting in a scrapping situation.
At this time, when an additional docker server accesses the network, the new docker server also needs to be judged, and if the new docker server accesses the network and cannot be normally used due to problems such as debugging and the like, the chain code container life cycle instruction still cannot be processed, so that the new docker server also can be judged. Specifically, determining whether the additional docker server is down is the same as the foregoing embodiment, and details are not repeated here. The same detection of whether the additional docker server is down still yields the following two results:
(1) and if the additional docker server is down, determining that the additional docker server is unavailable.
The method for determining that the additional docker server is unavailable is the same as the above embodiment, and is not described herein again.
(2) If the additional docker server is not down, determining that the additional docker server is a candidate docker server, and sending the chain code container life cycle instruction to the candidate docker server when the first docker server is down.
When an additional docker server newly connected to the network is not down, it may be determined that the new docker server may be used to execute the chain code container lifecycle instruction, and at this time, the available new docker servers may be set as candidate docker servers, and the candidate docker servers may be regarded as docker servers of the other docker servers, that is, if the first docker server is down, the candidate docker servers are used to process the chain code container lifecycle instruction.
In some embodiments of the present application, if the first docker server is not down, the method further includes forwarding the chain code container lifecycle instruction to the first docker server, where the method further includes:
(1) if the first docker server is down when executing the chain code container life cycle instruction, determining that transmission fails, and judging whether other docker servers in the plurality of docker servers are down.
(2) And if at least one of the other docker servers is not down, re-transmitting the chain code container life cycle instruction to the first docker server which is not down.
The purpose of the embodiment of the present application is to cause a downtime condition to occur before the chain code container lifecycle instruction is not completed after the first docker server receives the chain code container lifecycle instruction.
Under general environment, there are few circumstances, the condition of taking place to shut down when the server carries out corresponding instruction period, and the instruction can't normally be accomplished this moment, can't feed back the result of accomplishing to proxy server promptly, perhaps feeds back to a specified terminal, in order to continue to carry out corresponding instruction, until normally accomplishing, this application embodiment can continue to carry out corresponding instruction with the server of other non-taking down of call, avoids appearing the condition that the instruction was not carried out completely.
The method for determining that the docker server is not down is the same as the above embodiment, and is not described herein again.
In order to better implement the method for transmitting a peer node instruction in the embodiment of the present application, in addition to the method for transmitting a peer node instruction, in the embodiment of the present application, a device for transmitting a peer node instruction is further provided, where the device is applied to a chain code system, the chain code system includes a proxy server, a plurality of docker servers and a plurality of peer nodes, the plurality of docker servers are connected to the plurality of peer nodes through a network, the method is applied to the proxy server, and as shown in fig. 3, the device 300 includes:
an obtaining module 301, configured to obtain a chain code container life cycle instruction sent by at least one peer node;
a first determining module 302, configured to determine whether a first docker server of the multiple docker servers is down;
a first forwarding module 303, configured to forward the chain code container life cycle instruction to the first docker server if the first docker server is not down;
a second determining module 304, configured to determine, if the first docker server is down, whether any other docker server in the plurality of docker servers except the first docker server is down;
a second forwarding module 305, configured to forward the chain code container lifecycle instruction to a first non-downtime docker server of the non-downtime servers if at least one of the other docker servers is not down, so that the first non-downtime docker server executes the chain code container lifecycle instruction.
The method for transmitting a peer node instruction provided in this embodiment of the application may be implemented such that after the obtaining module 301 obtains the link container lifecycle instruction, the first determining module 302 may determine whether a plurality of deployed docker servers are down, if none of the docker servers are down, the first forwarding module 303 may forward the link container lifecycle instruction to the first docker server, if the first docker server is down, the second determining module 304 may continue to determine whether the remaining servers are down, if at least one of the remaining docker servers is not down, the second forwarding module 305 may forward the link container lifecycle instruction to the docker server that is not down, thereby solving a problem that the server cannot respond to the node instruction, and simultaneously responding to the node instruction before the server is down, the response efficiency is improved.
In some embodiments of the present application, the first determining module 302 is specifically configured to:
acquiring a data packet for communication sent by the first docker server according to a preset period;
if the data packet sent by the first docker server is obtained, determining that the first docker server is not down;
and if the data packet sent by the first docker server is not acquired, determining that the first docker server is down.
In some embodiments of the present application, the second determining module 304 is specifically configured to:
acquiring data packets for communication sent by other docker servers according to a preset period;
if the data packets corresponding to the data packets sent by the other docker servers are obtained, determining that the other docker servers are not down;
and if the data packets corresponding to the data packets sent by the other docker servers are not obtained, determining that the docker server which does not send the corresponding data packets in the other docker servers is down.
In some embodiments of the present application, the second determining module 304 is further specifically configured to:
if an additional docker server is monitored, judging whether the additional docker server is down, wherein the additional docker server is a newly added docker server on the basis of the original plurality of docker servers;
if the additional docker server is down, determining that the additional docker server is unavailable;
if the additional docker server is not down, determining that the additional docker server is a candidate docker server, and sending the chain code container life cycle instruction to the candidate docker server when the first docker server is down.
In some embodiments of the present application, the second determining module 304 is further specifically configured to:
if the first docker server is down when executing the chain code container life cycle instruction, determining that transmission fails, and judging whether other docker servers in the plurality of docker servers are down;
and if at least one of the other docker servers is not down, re-transmitting the chain code container life cycle instruction to the first docker server which is not down.
In another aspect, the present application further provides a proxy server, including:
one or more processors;
a memory; and
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to perform any of the steps of the peer node instruction transmission.
An embodiment of the present application further provides a proxy server, which integrates any method for transmitting a peer node instruction provided in the embodiment of the present application, and as shown in fig. 4, it shows a schematic structural diagram of the proxy server according to the embodiment of the present application, specifically:
the proxy server may include components such as a processor 401 of one or more processing cores, memory 402 of one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that the proxy server architecture shown in fig. 4 does not constitute a limitation of a proxy server and may include more or fewer components than shown, or some components in combination, or a different arrangement of components. Wherein:
the processor 401 is a control center of the proxy server, connects various parts of the entire proxy server using various interfaces and lines, performs various functions of the proxy server and processes data by running or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the proxy server. Optionally, processor 401 may include one or more processing cores; the Processor 401 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, preferably the processor 401 may integrate an application processor, which handles primarily the operating system, user interfaces, application programs, etc., and a modem processor, which handles primarily wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by operating the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the proxy server, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 access to the memory 402.
The proxy server further includes a power supply 403 for supplying power to each component, and preferably, the power supply 403 may be logically connected to the processor 401 through a power management system, so as to implement functions of managing charging, discharging, and power consumption through the power management system. The power supply 403 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The proxy server may also include an input unit 404, and the input unit 404 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the proxy server may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 401 in the proxy server loads the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application program stored in the memory 402, thereby implementing various functions, for example:
acquiring a chain code container life cycle instruction sent by at least one peer node;
judging whether a first docker server in the plurality of docker servers is down;
if the first docker server is not down, forwarding the chain code container life cycle instruction to a chain code container directly connected with the first docker server;
if the first docker server is down, judging whether other docker servers except the first docker server in the plurality of docker servers are down;
if at least one of the other docker servers is not down, forwarding the chain code container life cycle instruction to a first non-down docker server of the non-down docker servers, so that the first non-down docker server executes the chain code container life cycle instruction.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, an embodiment of the present application provides a computer-readable storage medium, which may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like. The computer program is loaded by a processor to execute the steps of any method for transmitting the instruction of the peer node provided by the embodiment of the application. For example, the computer program may be loaded by a processor to perform the steps of:
judging whether a first docker server in the plurality of docker servers is down;
if the first docker server is not down, forwarding the chain code container life cycle instruction to the first docker server;
if the first docker server is down, judging whether other docker servers except the first docker server in the plurality of docker servers are down;
if at least one of the other docker servers is not down, forwarding the chain code container life cycle instruction to a first non-down docker server of the non-down docker servers, so that the first non-down docker server executes the chain code container life cycle instruction.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and parts that are not described in detail in a certain embodiment may refer to the above detailed descriptions of other embodiments, and are not described herein again.
In a specific implementation, each unit or structure may be implemented as an independent entity, or may be combined arbitrarily to be implemented as one or several entities, and the specific implementation of each unit or structure may refer to the foregoing method embodiment, which is not described herein again.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
The method and the device for transmitting a peer node instruction provided by the embodiment of the present application are introduced in detail, and a specific example is applied to explain the principle and the implementation of the present application, and the description of the above embodiment is only used to help understand the method and the core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.
- 上一篇:石墨接头机器人自动装卡簧、装栓机
- 下一篇:输入源兼容性测试方法、装置和系统