[ Background Art ]
The middle-station group business arrangement system is designed based on the idea of micro-service, after a large system is split into different micro-services, call addresses among the services cannot exist in one service independently, the addresses of the services must be decoupled to become a registry, which can be said to be an address book in a micro-service architecture, and the registry records the mapping relation between the services and the service addresses. In a distributed architecture, a service will register with a registry, where the service will find its address to invoke when it needs to invoke other services.
Then in a orchestration system, where a request is accessed by a web subsystem and then invokes the next N service subsystems, it is a problem to which registry the web subsystem goes to find the address of the corresponding service subsystem if both are registered on different registries. Resources are wasted if all registries traverse one pass, and the meaning of multiple registries is lost if one of them is missed. How the web subsystem matches the address of the corresponding service subsystem becomes an urgent issue to be addressed.
The original mode of the prior art platform business arrangement system is that only one registry is provided, one web subsystem is required to find the later-called service subsystem, all service addresses are concentrated in one registry, and service call is influenced when the registry is down or abnormal.
[ Invention ]
In order to overcome the problems, the invention provides a zookeeper-based system multi-registry matching method capable of effectively solving the problems.
The technical scheme provided by the invention for solving the technical problems is as follows: the utility model provides a system multi-registry matching method based on zookeeper, which comprises the following steps:
step S1, the registry information of all web subsystems and all service subsystems is well defined in different service systems according to data formats;
Step S2, when all service systems are started, the registry information in the step S1 is scanned, and the registry information is stored into a database MySQL of a middle service orchestration system through the characteristic of zk event monitoring;
Step S3, when a service method is selected by the editing interface, searching an address of a registry which can be matched with the current web subsystem;
And S4, traversing the group parameters and the address parameters of the registry of all the web subsystems when the registry is matched, and matching the group parameters and the address parameters of the registry of the selected service method one by one, wherein the address of the service is returned only if the group parameters and the address parameters of the registry are the same.
Preferably, in the step S4, two conditions, that is, address parameter and group parameter, are required for determining a call address.
Preferably, a plurality of zookeeper are involved.
Compared with the prior art, the zookeeper-based system multi-registry matching method has the advantages that resources are accurately positioned, and resources are wasted if all registries are traversed once; the pressure born by a single machine is reduced, the single registry is changed into a plurality of registries, and the load and the workload on the single machine are shared; the problem of single machine fault is solved, and the risk resistance of the system is improved; a machine in the multi-registration center is down for a short time, so that the complete unavailability of the system is not caused.
[ Detailed description ] of the invention
The present invention will be described in further detail with reference to the accompanying drawings and examples of implementation in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
It should be noted that in embodiments of the present invention, all directional indications (such as up, down, left, right, front, back … …) are limited to relative positions on a given view, not absolute positions.
Furthermore, descriptions such as those referred to as "first," "second," and the like, are provided for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implying an order of magnitude of the indicated technical features in the present disclosure. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present invention, the meaning of "plurality" means at least two, for example, two, three, etc., unless specifically defined otherwise.
Referring to fig. 1, the zookeeper-based system multi-registry matching method of the present invention includes the following steps:
In step S1, the registry information of all web subsystems and all service subsystems is well defined in different service systems according to data formats.
The data format is as follows:
dubbo.registries.r1.id=c1
dubbo.registries.r1.address=zookeeper://172.16.87.35:2181
dubbo.registries.r1.group=group_r1
dubbo.registries.zk1.id=registry_1
dubbo.registries.zk1.address=zookeeper://172.16.87.35:2181
dubbo.registries.zk1.group=group_r1。
And step S2, when all the service systems are started, the registry information in the step S1 is scanned, and the registry information is stored into a database MySQL of the middle service orchestration system through the characteristic of zk event monitoring.
And step S3, when the editing interface selects a service method, searching out the address of the registry which can be matched with the current web subsystem.
In step S4, two conditions are respectively address parameter and group parameter, because two conditions are needed for determining a call address. Therefore, when the registry is matched, the group parameters and the address parameters of the registry of all the web subsystems are traversed, and then the group parameters and the address parameters of the registry where the selected service method is located are matched one by one, and the address of the service is returned only if the group parameters and the address parameters are the same.
Specifically, for example, web is registered on zk1, zk2, and zk3, service1 is registered on zk2, zk3, zk4, and then the common registry of web and service1 is zk2 and zk3; service2 registers with zk2 and zkN, then the common registry for web and service2 is zk2. Zk is zookeeper, and the method involves a plurality of zookeeper, namely zookeeper1, zookeeper2 and zookeeper3 … zookeeperN respectively.
Compared with the prior art, the zookeeper-based system multi-registry matching method has the advantages that resources are accurately positioned, and resources are wasted if all registries are traversed once; the pressure born by a single machine is reduced, the single registry is changed into a plurality of registries, and the load and the workload on the single machine are shared; the problem of single machine fault is solved, and the risk resistance of the system is improved; a machine in the multi-registration center is down for a short time, so that the complete unavailability of the system is not caused.
The foregoing description of the preferred embodiments of the invention is not intended to limit the scope of the invention, but is intended to cover any modifications, equivalents, and improvements within the spirit of the invention.