CN109885414A - Distributed event notification method and device based on ZooKeeper - Google Patents

Distributed event notification method and device based on ZooKeeper Download PDF

Info

Publication number
CN109885414A
CN109885414A CN201910128938.4A CN201910128938A CN109885414A CN 109885414 A CN109885414 A CN 109885414A CN 201910128938 A CN201910128938 A CN 201910128938A CN 109885414 A CN109885414 A CN 109885414A
Authority
CN
China
Prior art keywords
event
application
zookeeper
data
cluster
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910128938.4A
Other languages
Chinese (zh)
Inventor
易存道
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Boln Software Ltd By Share Ltd
Original Assignee
Beijing Boln Software Ltd By Share Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Boln Software Ltd By Share Ltd filed Critical Beijing Boln Software Ltd By Share Ltd
Priority to CN201910128938.4A priority Critical patent/CN109885414A/en
Publication of CN109885414A publication Critical patent/CN109885414A/en
Pending legal-status Critical Current

Links

Landscapes

  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The embodiment of the present invention provides a kind of distributed event notification method and device based on ZooKeeper, wherein method includes: event publisher publication object event of first application by the first application;The event monitoring person of first application receives object event automatically, judges whether object event is cluster event;If object event is then converted into preset data type, the data of preset path on ZooKeeper are updated based on the object event for being converted into preset data type, when so that the data of preset path changing in event monitoring person's AM automatic monitoring to ZooKeeper of the second application, preset path obtains the data after variation from ZooKeeper, after data after the variation that will acquire are converted into object event by preset data type, into local event process flow.The present embodiment can realize the notice of distributed event based on ZooKeeper, compared with prior art, do not have to concern bottom layer treatment, can be supplied to the simplicity of user's out-of-the-box.

Description

Distributed event notification method and device based on ZooKeeper
Technical field
The present embodiments relate to Internet technical field more particularly to a kind of distributed events based on ZooKeeper Notification method and device.
Background technique
In typical distributed system, one group of application distribution formula with incidence relation it is deployed in different machines On, the work between these applications can effectively be coordinated by distributed event informing mechanism.
Currently, these Distributed Applications generally pass through voluntarily realization distributed event informing mechanism or pass through messaging bus To realize distributed event informing mechanism.
But voluntarily realize distributed event informing mechanism, need to consider network transmission, encoding and decoding, high availability, extension Property a series of problems, such as, development cost is larger, and do not have versatility;Realize that distributed event notifies machine based on messaging bus System can use the bottom facilities of messaging bus offer, not have to consider in network transmission, encoding and decoding, high availability, scalability etc. Problem is stated, but general messaging bus is all huger, it is to be understood that a series of API that messaging bus provides (compile by application program Journey interface) and service build mode.
Summary of the invention
In view of the problems of the existing technology, the embodiment of the present invention provides a kind of distributed event based on ZooKeeper Notification method and device.
The embodiment of the present invention provides a kind of distributed event notification method based on ZooKeeper, comprising:
First application issues object event by the event publisher of the first application;
The event monitoring person of first application receives the object event automatically, judges whether the object event is cluster thing Part;
If the object event is cluster event, the object event is converted into preset data type, based on conversion At the object event of preset data type, the data of preset path on ZooKeeper are updated, so that the event monitoring of the second application When the data of preset path change in person's AM automatic monitoring to ZooKeeper, preset path obtains variation from ZooKeeper Data afterwards, after the data after the variation that will acquire are converted into object event by preset data type, into local event processing Process;
Wherein, first application memory is in event publisher and event monitoring person, event monitoring person's note of the first application Volume is in the event publisher of the first application and while listening for the preset path on ZooKeeper;Second application memory exists The event monitoring person of event publisher and event monitoring person, the second application are registered in the event publisher of the second application and simultaneously Monitor the preset path on ZooKeeper;First application and second application are Distributed Application.
The embodiment of the present invention provides a kind of distributed event notification method based on ZooKeeper, comprising:
If the data of preset path change in event monitoring person's AM automatic monitoring to ZooKeeper of the second application, Preset path obtains the data after variation from ZooKeeper;
Data after the variation that will acquire are converted into object event by preset data type;
Based on the object event being converted into, into local event process flow;
Wherein, second application memory is in event publisher and event monitoring person, event monitoring person's note of the second application Volume is in the event publisher of the second application and while listening for the preset path on ZooKeeper.
The embodiment of the present invention provides a kind of distributed event notice device based on ZooKeeper, comprising:
Release module issues object event by the event publisher of the first application for the first application;
Judgment module, the event monitoring person for the first application receive the object event automatically, judge the target thing Whether part is cluster event;
The object event is converted into preset data if being cluster event for the object event by update module Type updates the data of preset path on ZooKeeper, so that second based on the object event for being converted into preset data type It is pre- from ZooKeeper when the data of preset path change in event monitoring person's AM automatic monitoring to ZooKeeper of application If path obtains the data after variation, after the data after the variation that will acquire are converted into object event by preset data type, into Enter local event process flow;
Wherein, first application memory is in event publisher and event monitoring person, event monitoring person's note of the first application Volume is in the event publisher of the first application and while listening for the preset path on ZooKeeper;Second application memory exists The event monitoring person of event publisher and event monitoring person, the second application are registered in the event publisher of the second application and simultaneously Monitor the preset path on ZooKeeper;First application and second application are Distributed Application.
The embodiment of the present invention provides a kind of distributed event notice device based on ZooKeeper, comprising:
Obtain module, if for second application event monitoring person's AM automatic monitoring to ZooKeeper on preset path number According to changing, then preset path obtains the data after variation from ZooKeeper;
Conversion module, the data after variation for will acquire are converted into object event by preset data type;
Into module, for based on the object event being converted into, into local event process flow;
Wherein, second application memory is in event publisher and event monitoring person, event monitoring person's note of the second application Volume is in the event publisher of the second application and while listening for the preset path on ZooKeeper.
The embodiment of the present invention provides a kind of electronic equipment, including memory, processor and storage are on a memory and can be The computer program run on processor, the processor are realized when executing described program such as the step of the above method.
Distributed event notification method and device provided in an embodiment of the present invention based on ZooKeeper, is answered by first Object event is issued with the event publisher by the first application, the event monitoring person of the first application receives object event automatically, Judge whether object event is cluster event, if object event is then converted into preset data type, based on being converted into presetting The object event of data type updates the data of preset path on ZooKeeper, so that the event monitoring person of the second application is automatic When listening to the data of preset path on ZooKeeper and changing, preset path obtains the number after variation from ZooKeeper According to the data after the variation that will acquire enter local event process flow after being converted into object event by preset data type;Its In, the first application memory is registered in the first application in event publisher and event monitoring person, the event monitoring person of the first application In event publisher and while listening for the preset path on ZooKeeper;Second application memory is supervised in event publisher and event The event monitoring person of hearer, the second application are registered in the event publisher of the second application and while listening on ZooKeeper Preset path;First application and the second application are Distributed Application, and thereby, it is possible to realize distributed event based on ZooKeeper Notice, compared with prior art, do not have to concern bottom layer treatment, the simplicity of user's out-of-the-box can be supplied to.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is this hair Bright some embodiments for those of ordinary skill in the art without creative efforts, can be with root Other attached drawings are obtained according to these attached drawings.
Fig. 1 is a kind of process for distributed event notification method based on ZooKeeper that one embodiment of the invention provides Schematic diagram;
Fig. 2 is the schematic illustration of the distributed event notification method provided in an embodiment of the present invention based on ZooKeeper;
Fig. 3 be another embodiment of the present invention provides a kind of distributed event notification method based on ZooKeeper stream Journey schematic diagram;
Fig. 4 is the structure that a kind of distributed event based on ZooKeeper that one embodiment of the invention provides notifies device Schematic diagram;
Fig. 5 be another embodiment of the present invention provides a kind of distributed event based on ZooKeeper notify the knot of device Structure schematic diagram;
Fig. 6 is the entity structure schematic diagram for the electronic equipment that one embodiment of the invention provides.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art Every other embodiment obtained without creative efforts, shall fall within the protection scope of the present invention.
Fig. 1 shows a kind of distributed event notification method based on ZooKeeper of one embodiment of the invention offer Flow diagram, as shown in Figure 1, the distributed event notification method based on ZooKeeper of the present embodiment, comprising:
S1, the first application issue object event by the event publisher of the first application.
S2, the first event monitoring person applied receive the object event automatically, judge whether the object event is collection Group's event.
If S3, the object event are cluster event, the object event is converted into preset data type, is based on turning It changes the object event of preset data type into, updates the data of preset path on ZooKeeper, so that the event prison of the second application When the data of preset path change in hearer's AM automatic monitoring to ZooKeeper, preset path, which obtains, from ZooKeeper becomes Data after change, after the data after the variation that will acquire are converted into object event by preset data type, at local event Manage process.
Wherein, first application memory is in event publisher and event monitoring person, event monitoring person's note of the first application Volume is in the event publisher of the first application and while listening for the preset path on ZooKeeper;Second application memory exists The event monitoring person of event publisher and event monitoring person, the second application are registered in the event publisher of the second application and simultaneously Monitor the preset path on ZooKeeper;First application and second application are Distributed Application.
In a particular application, the preset data type can be byte arrays.
In a particular application, for example, the upper preset path of ZooKeeper can on ZooKeeper /event/ The path example.
It is understood that ZooKeeper is a distributed application program coordination service system, it can be distribution Using offer Consistency service.Multiple ZooKeeper examples can form cluster, to provide High Availabitity service.The present embodiment In ZooKeeper can be a ZooKeeper, be also possible to the ZooKeeper cluster of multiple ZooKeeper composition, this Embodiment is not limited.
It is understood that the Consistency service that the present embodiment the method utilizes ZooKeeper to provide, provides a kind of logical The distributed event informing mechanism for being with, lightweight, unpacking, Distributed Application can be to using local event notification mechanism one Sample handles the publication and consumption of distributed event, and the principle of the present embodiment the method can refer to Fig. 2.
Distributed event notification method provided in an embodiment of the present invention based on ZooKeeper is passed through by the first application The event publisher of first application issues object event, and the event monitoring person of the first application receives object event automatically, judges mesh Whether mark event is cluster event, if object event is then converted into preset data type, based on being converted into preset data class The object event of type updates the data of preset path on ZooKeeper, so that event monitoring person's AM automatic monitoring of the second application is arrived When the data of the upper preset path of ZooKeeper change, preset path obtains the data after variation from ZooKeeper, will Data after the variation of acquisition enter local event process flow after being converted into object event by preset data type;Wherein, For one application memory in event publisher and event monitoring person, the event monitoring person of the first application is registered in the event hair of the first application Cloth person is upper and while listening for the preset path on ZooKeeper;Second application memory is in event publisher and event monitoring person, and The event monitoring person of two applications is registered in the event publisher of the second application and while listening for the default road on ZooKeeper Diameter;First application and the second application are Distributed Application, thereby, it is possible to realize the notice of distributed event based on ZooKeeper, Compared with the voluntarily realization distributed event informing mechanism of the prior art, do not have to concern bottom layer treatment, with the prior art based on Messaging bus realizes that distributed event informing mechanism is compared, and can be supplied to the simplicity of user's out-of-the-box.
Further, on the basis of the above embodiments, object event described in the present embodiment can be by a four-tuple table Show:<type, timestamp, payload, cluster identity>;
Wherein, type indicates the type of object event, can be 32 without symbol by business self-defining and explanation, data type Number integer;Timestamp indicates that the time at moment occurs for object event, can obtain the current time in system for generating moment time automatically, Data type can be 64 signless integers;Payload indicates the effective information that object event carries, and can be specified by business And explanation, data type are object type;Cluster identity indicates whether object event needs to issue to cluster, for example, can use < Cluster>attribute indicates cluster identity, if<cluster>attribute is<true>, expression object event is cluster event, if< Cluster>attribute is<fasle>, and expression object event is local event, and data type is Boolean type;
Correspondingly, described to judge whether the object event is cluster event, it may include: according to the object event Cluster identity judges whether the object event is cluster event.
Further, on the basis of the above embodiments, after the step S2, the present embodiment the method can be with Include:
If the object event is not cluster event, the object event is local event, into local event processing Process.
Distributed event notification method provided in an embodiment of the present invention based on ZooKeeper can be based on ZooKeeper The notice for realizing distributed event does not have to concern bottom compared with the voluntarily realization distributed event informing mechanism of the prior art Processing can be supplied to user and unpack i.e. compared with the prior art is based on messaging bus realization distributed event informing mechanism Simplicity.
Fig. 3 show another embodiment of the present invention provides a kind of distributed event notification method based on ZooKeeper Flow diagram, as shown in figure 3, the distributed event notification method based on ZooKeeper of the present embodiment, comprising:
If the data of preset path change on P1, the second event monitoring person's AM automatic monitoring to ZooKeeper applied, Then preset path obtains the data after variation from ZooKeeper.
Wherein, second application memory is in event publisher and event monitoring person, event monitoring person's note of the second application Volume is in the event publisher of the second application and while listening for the preset path on ZooKeeper.
It is understood that corresponding with embodiment of the method shown in Fig. 1, this step is that the first application passes through the first application After event publisher issues object event, the event monitoring person of the first application receives the object event automatically, judges target thing Whether part is cluster event, if object event is cluster event, object event is converted into preset data type, based on conversion It is updated on ZooKeeper after the data of preset path at the object event of preset data type, the event monitoring person of the second application The data of preset path change in AM automatic monitoring to ZooKeeper.Wherein, first application memory is in event publisher With event monitoring person, first application event monitoring person be registered in the event publisher of the first application and while listening for Preset path on ZooKeeper;First application and second application are Distributed Application.
In a particular application, for example, the upper preset path of ZooKeeper can on ZooKeeper /event/ The path example.
Data after P2, the variation that will acquire are converted into object event by preset data type.
In a particular application, the preset data type can be byte arrays.
P3, based on the object event being converted into, into local event process flow.
It is understood that ZooKeeper is a distributed application program coordination service system, it can be distribution Using offer Consistency service.Multiple ZooKeeper examples can form cluster, to provide High Availabitity service.The present embodiment In ZooKeeper can be a ZooKeeper, be also possible to the ZooKeeper cluster of multiple ZooKeeper composition, this Embodiment is not limited.
It is understood that the Consistency service that the present embodiment the method utilizes ZooKeeper to provide, provides a kind of logical The distributed event informing mechanism for being with, lightweight, unpacking, Distributed Application can be to using local event notification mechanism one Sample handles the publication and consumption of distributed event, and the principle of the present embodiment the method can refer to Fig. 2.
Distributed event notification method provided in an embodiment of the present invention based on ZooKeeper passes through the thing of the second application If the data of preset path change in part listener AM automatic monitoring to ZooKeeper, the preset path from ZooKeeper Data after obtaining variation, the data after the variation that will acquire are converted into object event by preset data type, based on being converted into Object event, into local event process flow, wherein second application memory is in event publisher and event monitoring The event monitoring person of person, the second application are registered in the event publisher of the second application and while listening for pre- on ZooKeeper If path, the notice of distributed event can be realized based on ZooKeeper, it is logical with the voluntarily realization distributed event of the prior art Know that mechanism is compared, do not have to concern bottom layer treatment, with the prior art based on messaging bus realization distributed event informing mechanism phase Than the simplicity of user's out-of-the-box can be supplied to.
Further, on the basis of the above embodiments, object event described in the present embodiment can be by a four-tuple table Show:<type, timestamp, payload, cluster identity>;
Wherein, wherein type indicates the type of object event, can be by business self-defining and explanation, data type 32 Position signless integer;Timestamp indicates that the time at moment occurs for object event, can obtain the system for generating moment time automatically and work as Preceding time, data type can be 64 signless integers;Payload indicates the effective information that object event carries, can be by industry Business is specified and explains, data type is object type;Cluster identity indicates whether object event needs to issue to cluster, for example, Cluster identity can be indicated with<cluster>attribute, if<cluster>attribute is<true>, expression object event is cluster thing Part, if<cluster>attribute is<fasle>, expression object event is local event, and data type is Boolean type;
Correspondingly, the data after the variation that will acquire are converted into object event by preset data type, may include:
Data after the variation that will acquire are converted into object event by preset data type, by the cluster mark in object event Know be revised as not needing the expression of the local event issued to cluster (such as can be by<cluster>attribute in object event It is revised as<fasle>).
Distributed event notification method provided in an embodiment of the present invention based on ZooKeeper can be based on ZooKeeper The notice for realizing distributed event does not have to concern bottom compared with the voluntarily realization distributed event informing mechanism of the prior art Processing can be supplied to user and unpack i.e. compared with the prior art is based on messaging bus realization distributed event informing mechanism Simplicity.
Fig. 4 shows a kind of distributed event notice device based on ZooKeeper of one embodiment of the invention offer Structural schematic diagram, as shown in figure 4, the distributed event based on ZooKeeper of the present embodiment notifies device, comprising: publication mould Block 41, judgment module 42 and update module 43;Wherein:
The release module 41 issues object event by the event publisher of the first application for the first application;
The judgment module 42, the event monitoring person for the first application receives the object event automatically, described in judgement Whether object event is cluster event;
The object event is converted into pre- by the update module 43 if being cluster event for the object event If data type, based on the object event for being converted into preset data type, the data of preset path on ZooKeeper are updated, with When the data of preset path in event monitoring person's AM automatic monitoring to ZooKeeper of the second application being made to change, from The upper preset path of ZooKeeper obtains the data after variation, and the data after the variation that will acquire are converted by preset data type After object event, into local event process flow;
Wherein, first application memory is in event publisher and event monitoring person, event monitoring person's note of the first application Volume is in the event publisher of the first application and while listening for the preset path on ZooKeeper;Second application memory exists The event monitoring person of event publisher and event monitoring person, the second application are registered in the event publisher of the second application and simultaneously Monitor the preset path on ZooKeeper;First application and second application are Distributed Application.
Specifically, the application of release module 41 first issues object event by the event publisher of the first application;Institute The event monitoring person for stating the application of judgment module 42 first receives the object event automatically, judges whether the object event is collection Group's event;If the update module 43 object event is cluster event, the object event is converted into preset data Type updates the data of preset path on ZooKeeper, so that second based on the object event for being converted into preset data type It is pre- from ZooKeeper when the data of preset path change in event monitoring person's AM automatic monitoring to ZooKeeper of application If path obtains the data after variation, after the data after the variation that will acquire are converted into object event by preset data type, into Enter local event process flow;Wherein, first application memory is in event publisher and event monitoring person, the thing of the first application Part listener is registered in the event publisher of the first application and while listening for the preset path on ZooKeeper;Described second For application memory in event publisher and event monitoring person, the event monitoring person of the second application is registered in the event publication of the second application Person is upper and while listening for the preset path on ZooKeeper;First application and second application are Distributed Application.
In a particular application, the preset data type can be byte arrays.
In a particular application, for example, the upper preset path of ZooKeeper can on ZooKeeper /event/ The path example.
It is understood that ZooKeeper is a distributed application program coordination service system, it can be distribution Using offer Consistency service.Multiple ZooKeeper examples can form cluster, to provide High Availabitity service.The present embodiment In ZooKeeper can be a ZooKeeper, be also possible to the ZooKeeper cluster of multiple ZooKeeper composition, this Embodiment is not limited.
It is understood that the Consistency service that the present embodiment described device utilizes ZooKeeper to provide, provides a kind of logical The distributed event informing mechanism for being with, lightweight, unpacking, Distributed Application can be to using local event notification mechanism one Sample handles the publication and consumption of distributed event.
Distributed event provided in an embodiment of the present invention based on ZooKeeper notifies device, can be based on ZooKeeper The notice for realizing distributed event does not have to concern bottom compared with the voluntarily realization distributed event informing mechanism of the prior art Processing can be supplied to user and unpack i.e. compared with the prior art is based on messaging bus realization distributed event informing mechanism Simplicity.
Further, on the basis of the above embodiments, object event described in the present embodiment can be by a four-tuple table Show:<type, timestamp, payload, cluster identity>;
Wherein, type indicates the type of object event, can be 32 without symbol by business self-defining and explanation, data type Number integer;Timestamp indicates that the time at moment occurs for object event, can obtain the current time in system for generating moment time automatically, Data type can be 64 signless integers;Payload indicates the effective information that object event carries, and can be specified by business And explanation, data type are object type;Cluster identity indicates whether object event needs to issue to cluster, for example, can use < Cluster>attribute indicates cluster identity, if<cluster>attribute is<true>, expression object event is cluster event, if< Cluster>attribute is<fasle>, and expression object event is local event, and data type is Boolean type;
Correspondingly, judge whether the object event is cluster event in the judgment module 42, may include: basis The cluster identity of the object event judges whether the object event is cluster event.
Further, on the basis of the above embodiments, the present embodiment described device can also include not shown in the figure:
Local event processing module, for after judging whether the object event is cluster event, if the target Event is not cluster event, then the object event is local event, into local event process flow.
Distributed event provided in an embodiment of the present invention based on ZooKeeper notifies device, can be based on ZooKeeper The notice for realizing distributed event does not have to concern bottom compared with the voluntarily realization distributed event informing mechanism of the prior art Processing can be supplied to user and unpack i.e. compared with the prior art is based on messaging bus realization distributed event informing mechanism Simplicity.
Distributed event provided in an embodiment of the present invention based on ZooKeeper notifies device, can be used for executing aforementioned The technical solution of embodiment of the method shown in Fig. 1, it is similar that the realization principle and technical effect are similar, and details are not described herein again.
Fig. 5 show another embodiment of the present invention provides a kind of distributed event based on ZooKeeper notify device Structural schematic diagram, as shown in figure 5, the distributed event based on ZooKeeper of the present embodiment notifies device, comprising: obtain Module 51, conversion module 52 and entrance module 53;Wherein:
The acquisition module 51, if presetting road in the event monitoring person's AM automatic monitoring to ZooKeeper applied for second The data of diameter change, then preset path obtains the data after variation from ZooKeeper;
The conversion module 52, the data after variation for will acquire are converted into object event by preset data type;
It is described to enter module 53, for based on the object event being converted into, into local event process flow;
Wherein, second application memory is in event publisher and event monitoring person, event monitoring person's note of the second application Volume is in the event publisher of the second application and while listening for the preset path on ZooKeeper.
Specifically, if described obtain is preset in event monitoring person's AM automatic monitoring to ZooKeeper that module 51 second is applied The data in path change, then preset path obtains the data after variation from ZooKeeper;The conversion module 52 will obtain Data after the variation taken are converted into object event by preset data type;It is described into module 53 based on the target thing being converted into Part, into local event process flow;Wherein, second application memory is answered in event publisher and event monitoring person, second Event monitoring person is registered in the event publisher of the second application and while listening for the preset path on ZooKeeper.
It is understood that the module 51 that obtains is event publisher publication target of first application by the first application After event, the event monitoring person of the first application receives the object event automatically, judges whether object event is cluster event, if Object event is cluster event, then object event is converted into preset data type, based on the mesh for being converted into preset data type It marks on event update ZooKeeper after the data of preset path, the second event monitoring person's AM automatic monitoring applied to ZooKeeper The data of upper preset path change.Wherein, first application memory is answered in event publisher and event monitoring person, first Event monitoring person is registered in the event publisher of the first application and while listening for the preset path on ZooKeeper;Institute Stating the first application and second application is Distributed Application.
In a particular application, for example, the upper preset path of ZooKeeper can on ZooKeeper /event/ The path example.
In a particular application, the preset data type can be byte arrays.
It is understood that ZooKeeper is a distributed application program coordination service system, it can be distribution Using offer Consistency service.Multiple ZooKeeper examples can form cluster, to provide High Availabitity service.The present embodiment In ZooKeeper can be a ZooKeeper, be also possible to the ZooKeeper cluster of multiple ZooKeeper composition, this Embodiment is not limited.
It is understood that the Consistency service that the present embodiment described device utilizes ZooKeeper to provide, provides a kind of logical The distributed event informing mechanism for being with, lightweight, unpacking, Distributed Application can be to using local event notification mechanism one Sample handles the publication and consumption of distributed event.
Distributed event provided in an embodiment of the present invention based on ZooKeeper notifies device, can be based on ZooKeeper The notice for realizing distributed event does not have to concern bottom compared with the voluntarily realization distributed event informing mechanism of the prior art Processing can be supplied to user and unpack i.e. compared with the prior art is based on messaging bus realization distributed event informing mechanism Simplicity.
Further, on the basis of the above embodiments, object event described in the present embodiment can be by a four-tuple table Show:<type, timestamp, payload, cluster identity>;
Wherein, wherein type indicates the type of object event, can be by business self-defining and explanation, data type 32 Position signless integer;Timestamp indicates that the time at moment occurs for object event, can obtain the system for generating moment time automatically and work as Preceding time, data type can be 64 signless integers;Payload indicates the effective information that object event carries, can be by industry Business is specified and explains, data type is object type;Cluster identity indicates whether object event needs to issue to cluster, for example, Cluster identity can be indicated with<cluster>attribute, if<cluster>attribute is<true>, expression object event is cluster thing Part, if<cluster>attribute is<fasle>, expression object event is local event, and data type is Boolean type;
Correspondingly, the data after the variation that the conversion module 52 will acquire are converted into target thing by preset data type Part may include:
Data after the variation that will acquire are converted into object event by preset data type, by the cluster mark in object event Know be revised as not needing the expression of the local event issued to cluster (such as can be by<cluster>attribute in object event It is revised as<fasle>).
Distributed event provided in an embodiment of the present invention based on ZooKeeper notifies device, can be based on ZooKeeper The notice for realizing distributed event does not have to concern bottom compared with the voluntarily realization distributed event informing mechanism of the prior art Processing can be supplied to user and unpack i.e. compared with the prior art is based on messaging bus realization distributed event informing mechanism Simplicity.
Distributed event provided in an embodiment of the present invention based on ZooKeeper notifies device, can be used for executing aforementioned The technical solution of embodiment of the method shown in Fig. 3, it is similar that the realization principle and technical effect are similar, and details are not described herein again.
Fig. 6 shows the entity structure schematic diagram of a kind of electronic equipment of one embodiment of the invention offer, as shown in fig. 6, The electronic equipment may include memory 602, processor 601 and be stored on memory 602 and can run on processor 601 Computer program, the step of processor 601 realizes the above method when executing described program, for example, the first application Object event is issued by the event publisher of the first application;The event monitoring person of first application receives the target thing automatically Part judges whether the object event is cluster event;If the object event is cluster event, the object event is turned It changes preset data type into, based on the object event for being converted into preset data type, updates the number of preset path on ZooKeeper According to, when so that the data of preset path changing in event monitoring person's AM automatic monitoring to ZooKeeper of the second application, from The upper preset path of ZooKeeper obtains the data after variation, and the data after the variation that will acquire are converted by preset data type After object event, into local event process flow;Wherein, first application memory is in event publisher and event monitoring The event monitoring person of person, the first application are registered in the event publisher of the first application and while listening for pre- on ZooKeeper If path;For second application memory in event publisher and event monitoring person, the event monitoring person of the second application is registered in the In the event publisher of two applications and while listening for the preset path on ZooKeeper;First application and described second is answered With for Distributed Application;Or, comprising: if preset path in event monitoring person's AM automatic monitoring to ZooKeeper of the second application Data change, then from ZooKeeper preset path obtain variation after data;Data after the variation that will acquire by Preset data type is converted into object event;Based on the object event being converted into, into local event process flow;Wherein, institute The second application memory is stated in event publisher and event monitoring person, the event monitoring person of the second application is registered in the thing of the second application Part publisher is upper and while listening for the preset path on ZooKeeper.
The embodiment of the present invention provides a kind of non-transient computer readable storage medium, is stored thereon with computer program, should The step of above method is realized when computer program is executed by processor, for example, the thing that the first application passes through the first application Part publisher issues object event;The event monitoring person of first application receives the object event automatically, judges the target thing Whether part is cluster event;If the object event is cluster event, the object event is converted into preset data type, Based on the object event for being converted into preset data type, the data of preset path on ZooKeeper are updated, so that the second application When the data of preset path change in event monitoring person's AM automatic monitoring to ZooKeeper, the preset path from ZooKeeper Data after obtaining variation, after the data after the variation that will acquire are converted into object event by preset data type, into local Event handling process;Wherein, first application memory is in event publisher and event monitoring person, the event monitoring of the first application Person is registered in the event publisher of the first application and while listening for the preset path on ZooKeeper;In second application There are event publisher and event monitoring person, the event monitoring person of the second application is registered in the event publisher of the second application simultaneously While listening for the preset path on ZooKeeper;First application and second application are Distributed Application;Alternatively, packet It includes: if the data of preset path change in event monitoring person's AM automatic monitoring to ZooKeeper of the second application, from The upper preset path of ZooKeeper obtains the data after variation;Data after the variation that will acquire are converted by preset data type Object event;Based on the object event being converted into, into local event process flow;Wherein, second application memory is in thing The event monitoring person of part publisher and event monitoring person, the second application are registered in the event publisher of the second application and supervise simultaneously Listen the preset path on ZooKeeper.
The apparatus embodiments described above are merely exemplary, wherein described, unit can as illustrated by the separation member It is physically separated with being or may not be, component shown as a unit may or may not be physics list Member, it can it is in one place, or may be distributed over multiple network units.It can be selected according to the actual needs In some or all of the modules achieve the purpose of the solution of this embodiment.Those of ordinary skill in the art are not paying creativeness Labour in the case where, it can understand and implement.
Through the above description of the embodiments, those skilled in the art can be understood that each embodiment can It realizes by means of software and necessary general hardware platform, naturally it is also possible to pass through hardware.Based on this understanding, on Stating technical solution, substantially the part that contributes to existing technology can be embodied in the form of software products in other words, should Computer software product may be stored in a computer readable storage medium, such as ROM/RAM, magnetic disk, CD, including several fingers It enables and using so that a computer equipment (can be personal computer, server or the network equipment etc.) executes each implementation Method described in certain parts of example or embodiment.
Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although Present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: it still may be used To modify the technical solutions described in the foregoing embodiments or equivalent replacement of some of the technical features; And these are modified or replaceed, technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution spirit and Range.

Claims (10)

1. a kind of distributed event notification method based on ZooKeeper characterized by comprising
First application issues object event by the event publisher of the first application;
The event monitoring person of first application receives the object event automatically, judges whether the object event is cluster event;
If the object event is cluster event, the object event is converted into preset data type, it is pre- based on being converted into If the object event of data type, the data of preset path on ZooKeeper are updated, so that the event monitoring person of the second application is certainly When the dynamic data for listening to preset path on ZooKeeper change, after preset path obtains variation from ZooKeeper Data, after the data after the variation that will acquire are converted into object event by preset data type, into local event process flow;
Wherein, first application memory is registered in event publisher and event monitoring person, the event monitoring person of the first application In the event publisher of first application and while listening for the preset path on ZooKeeper;Second application memory is in event Publisher and event monitoring person, second application event monitoring person be registered in the event publisher of the second application and while listening for Preset path on ZooKeeper;First application and second application are Distributed Application.
2. the method according to claim 1, wherein the preset data type is byte arrays.
3. the method according to claim 1, wherein the object event is by a quadruple notation: < type, Timestamp, payload, cluster identity >;
Wherein, type indicates the type of object event;Timestamp indicates that the time at moment occurs for object event;Payload indicates The effective information that object event carries;Cluster identity indicates whether object event needs to issue to cluster;
Correspondingly, described to judge whether the object event is cluster event, comprising: according to the cluster mark of the object event Know, judges whether the object event is cluster event.
4. the method according to claim 1, wherein the event monitoring person in the first application receives the mesh automatically Mark event, after judging whether the object event is cluster event, the method also includes:
If the object event is not cluster event, the object event is local event, into local event process flow.
5. a kind of distributed event notification method based on ZooKeeper characterized by comprising
If the data of preset path change in event monitoring person's AM automatic monitoring to ZooKeeper of the second application, from The upper preset path of ZooKeeper obtains the data after variation;
Data after the variation that will acquire are converted into object event by preset data type;
Based on the object event being converted into, into local event process flow;
Wherein, second application memory is registered in event publisher and event monitoring person, the event monitoring person of the second application In the event publisher of second application and while listening for the preset path on ZooKeeper.
6. according to the method described in claim 5, it is characterized in that, the object event is by a quadruple notation: < type, Timestamp, payload, cluster identity >;
Wherein, type indicates the type of object event;Timestamp indicates that the time at moment occurs for object event;Payload indicates The effective information that object event carries;Cluster identity indicates whether object event needs to issue to cluster;
Correspondingly, the data after the variation that will acquire are converted into object event by preset data type, comprising:
Data after the variation that will acquire are converted into object event by preset data type, and the cluster identity in object event is repaired It is changed to not need the expression for the local event issued to cluster.
7. a kind of distributed event based on ZooKeeper notifies device characterized by comprising
Release module issues object event by the event publisher of the first application for the first application;
Judgment module, the event monitoring person for the first application receive the object event automatically, judge that the object event is No is cluster event;
The object event is converted into preset data type if being cluster event for the object event by update module, Based on the object event for being converted into preset data type, the data of preset path on ZooKeeper are updated, so that the second application When the data of preset path change in event monitoring person's AM automatic monitoring to ZooKeeper, the preset path from ZooKeeper Data after obtaining variation, after the data after the variation that will acquire are converted into object event by preset data type, into local Event handling process;
Wherein, first application memory is registered in event publisher and event monitoring person, the event monitoring person of the first application In the event publisher of first application and while listening for the preset path on ZooKeeper;Second application memory is in event Publisher and event monitoring person, second application event monitoring person be registered in the event publisher of the second application and while listening for Preset path on ZooKeeper;First application and second application are Distributed Application.
8. a kind of distributed event based on ZooKeeper notifies device characterized by comprising
Module is obtained, if the data of preset path are sent out in event monitoring person's AM automatic monitoring to ZooKeeper of the second application Changing, then preset path obtains the data after variation from ZooKeeper;
Conversion module, the data after variation for will acquire are converted into object event by preset data type;
Into module, for based on the object event being converted into, into local event process flow;
Wherein, second application memory is registered in event publisher and event monitoring person, the event monitoring person of the second application In the event publisher of second application and while listening for the preset path on ZooKeeper.
9. a kind of electronic equipment including memory, processor and stores the calculating that can be run on a memory and on a processor Machine program, which is characterized in that the processor is realized when executing described program such as any one of Claims 1-4 the method Step or the processor are realized when executing described program such as the step of claim 5 or 6 the method.
10. a kind of non-transient computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer Realize that the computer program is by processor such as the step of any one of Claims 1-4 the method when program is executed by processor It realizes when execution such as the step of claim 5 or 6 the method.
CN201910128938.4A 2019-02-21 2019-02-21 Distributed event notification method and device based on ZooKeeper Pending CN109885414A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910128938.4A CN109885414A (en) 2019-02-21 2019-02-21 Distributed event notification method and device based on ZooKeeper

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910128938.4A CN109885414A (en) 2019-02-21 2019-02-21 Distributed event notification method and device based on ZooKeeper

Publications (1)

Publication Number Publication Date
CN109885414A true CN109885414A (en) 2019-06-14

Family

ID=66928641

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910128938.4A Pending CN109885414A (en) 2019-02-21 2019-02-21 Distributed event notification method and device based on ZooKeeper

Country Status (1)

Country Link
CN (1) CN109885414A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111371898A (en) * 2020-03-13 2020-07-03 北京锐安科技有限公司 Message monitoring method, device, equipment and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103716182A (en) * 2013-12-12 2014-04-09 中国科学院信息工程研究所 Failure detection and fault tolerance method and failure detection and fault tolerance system for real-time cloud platform
CN104092591A (en) * 2014-08-04 2014-10-08 飞狐信息技术(天津)有限公司 Task monitoring method and system
CN105553682A (en) * 2015-12-23 2016-05-04 华为技术有限公司 Event notification method and event notification system
US20160321308A1 (en) * 2015-05-01 2016-11-03 Ebay Inc. Constructing a data adaptor in an enterprise server data ingestion environment
CN106815053A (en) * 2017-01-18 2017-06-09 努比亚技术有限公司 A kind of data-updating method, device, data call end and data update system
US20170310628A1 (en) * 2016-04-21 2017-10-26 Confluent, Inc. Distributed message queue stream verification
CN108984544A (en) * 2017-05-31 2018-12-11 北京京东尚科信息技术有限公司 A kind of method and apparatus of distributed system modification configuration information
CN109144748A (en) * 2018-07-26 2019-01-04 阿里巴巴集团控股有限公司 A kind of server, distributed server cluster and its state-driven method

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103716182A (en) * 2013-12-12 2014-04-09 中国科学院信息工程研究所 Failure detection and fault tolerance method and failure detection and fault tolerance system for real-time cloud platform
CN104092591A (en) * 2014-08-04 2014-10-08 飞狐信息技术(天津)有限公司 Task monitoring method and system
US20160321308A1 (en) * 2015-05-01 2016-11-03 Ebay Inc. Constructing a data adaptor in an enterprise server data ingestion environment
CN105553682A (en) * 2015-12-23 2016-05-04 华为技术有限公司 Event notification method and event notification system
US20170310628A1 (en) * 2016-04-21 2017-10-26 Confluent, Inc. Distributed message queue stream verification
CN106815053A (en) * 2017-01-18 2017-06-09 努比亚技术有限公司 A kind of data-updating method, device, data call end and data update system
CN108984544A (en) * 2017-05-31 2018-12-11 北京京东尚科信息技术有限公司 A kind of method and apparatus of distributed system modification configuration information
CN109144748A (en) * 2018-07-26 2019-01-04 阿里巴巴集团控股有限公司 A kind of server, distributed server cluster and its state-driven method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111371898A (en) * 2020-03-13 2020-07-03 北京锐安科技有限公司 Message monitoring method, device, equipment and storage medium
CN111371898B (en) * 2020-03-13 2022-07-08 北京锐安科技有限公司 Message monitoring method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111049705B (en) Method and device for monitoring distributed storage system
US9135093B2 (en) Event-driven approach for collecting monitoring data of messaging systems
US11171841B2 (en) System for propagating a modification of a first service, in a service graph, to a second service
CN109327351B (en) Method and device for collecting log data in real time, electronic equipment and storage medium
CN105573824B (en) Monitoring method and system for distributed computing system
EP3796167A1 (en) Router management by an event stream processing cluster manager
CN110162405A (en) A kind of method and system of automated service discovery and load balancing
CN111459763B (en) Cross-kubernetes cluster monitoring system and method
CN106940677A (en) One kind application daily record data alarm method and device
CN106789138B (en) A kind of method and device of network alarm association analysis
US10942792B2 (en) Event driven subscription matching
CN110532152A (en) A kind of monitoring alarm processing method and system based on Kapacitor computing engines
CN107193643B (en) A kind of highly reliable distributed traffic real-time statistical method and system
JP5933463B2 (en) Log occurrence abnormality detection device and method
US20180131585A1 (en) Cloud Visualization and Management Platform
CN110493043B (en) Distributed situation awareness calling method and device
WO2015077917A1 (en) Method and apparatus for anomaly detection in a network
CN105871581A (en) Method and device for processing of alarm information in cloud calculation
CN105872110A (en) Cloud platform service management method and cloud platform service management device
CN104980515A (en) Method and apparatus for distributing and processing messages in cloud storage systems
WO2024139516A1 (en) Method, system and apparatus for monitoring container orchestration engine
CN104933127A (en) Cross-machine-room database synchronization equipment and method based on MariaDB
US9596128B2 (en) Apparatus for processing one or more events
CN107666399A (en) A kind of method and apparatus of monitoring data
CN109885414A (en) Distributed event notification method and device based on ZooKeeper

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190614