CN110474963A - A kind of resource access method based on zookeeper, system, medium and electronic equipment - Google Patents

A kind of resource access method based on zookeeper, system, medium and electronic equipment Download PDF

Info

Publication number
CN110474963A
CN110474963A CN201910647172.0A CN201910647172A CN110474963A CN 110474963 A CN110474963 A CN 110474963A CN 201910647172 A CN201910647172 A CN 201910647172A CN 110474963 A CN110474963 A CN 110474963A
Authority
CN
China
Prior art keywords
node
target
destination
resource
destination client
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
CN201910647172.0A
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.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China 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 Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201910647172.0A priority Critical patent/CN110474963A/en
Publication of CN110474963A publication Critical patent/CN110474963A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching

Abstract

Present invention discloses a kind of resource access method based on zookeeper, system, medium and electronic equipments.The described method includes: obtaining the target access path of preset target resource when receiving acquisition request of the destination client for target resource;Target access path is searched in zookeeper cluster whether there is destination node;If there is destination node, the interim child node of target is created under destination node, and the interim child node of target is written into the characteristic of destination client, to determine that destination client gets node lock;It is locked to destination client return node.Under the method, the occupancy of memory space can be reduced, to reduce influence of the resource access to the performance of zookeeper.

Description

A kind of resource access method based on zookeeper, system, medium and electronic equipment
Technical field
The present invention relates to field of computer technology, in particular to a kind of resource access method based on zookeeper is System, medium and electronic equipment.
Background technique
In distributed environment, due to each node can by computer network access distributed system share Resource avoids the consistency of data from being destroyed, thereby produces to ensure the safety of resource access in distributed system Control the distributed lock of each same resource of node visit in distributed system.As it can be seen that can protect and step by distributed lock Journey, the shared resource across host, across a network realize exclusive reference, ensure that the consistency of data.
Currently, the mode of common realization distributed lock can be based on database or zookeeper.Wherein, Zookeeper is the centralization service system of a kind of offer configuration management, distributed collaboration and name, and zookeeper is provided These functions be all that very bottom and essential basic function, developer can be in zookeeper in distributed system On construct oneself various distributed systems.
In practice, it has been found that the prior art based on zookeeper realize distributed lock during, if client is asked Distributed lock is sought, generally requires and creates lasting node in zookeeper.When more client request accesses same resource information When, the lasting node for needing to create will increase therewith.But after resource information access, distributed lock can be released, And the lasting node that each client is created by the access resource information before is still stored in zookeeper cluster, is led It causes to occupy biggish memory space, to influence the performance of zookeeper.
Summary of the invention
Still be stored in zookeeper cluster to solve lasting node present in the relevant technologies, cause occupy compared with Big memory space, so that the present invention provides one kind to be based on zookeeper the technical issues of influencing the performance of Zookeeper Resource access method, system, medium and electronic equipment.
First aspect of the embodiment of the present invention discloses a kind of resource access method based on zookeeper, the method packet It includes:
When receiving acquisition request of the destination client for target resource, the mesh of the preset target resource is obtained Mark access path;
The target access path is searched in zookeeper cluster with the presence or absence of destination node;
If there is the destination node, the interim child node of target is created under the destination node, and by the target The interim child node of target is written in the characteristic of client, gets the node lock with the determination destination client;
The node lock is returned to the destination client.
As an alternative embodiment, in first aspect of the embodiment of the present invention, it is described under the destination node After the creation interim child node of target and the interim son section of the target is written in the characteristic by the destination client Before point, the method also includes:
Detect whether to receive other clients transmission in addition to the destination client is directed to what the node was locked Acquisition request;
If so, obtaining the sequence number of the interim child node of the target;
Judge whether the sequence number is minimum value in sequence number list;Wherein, the sequence number list is It is made of the sequence number of all interim child nodes under the destination node;
If the sequence number is the minimum value in the sequence number list, execute described by the client The interim child node of target is written in characteristic.
As an alternative embodiment, in first aspect of the embodiment of the present invention, if there is no the target section Point, the method also includes:
The destination node is created in the target access path, and creates the interim son section of target under the destination node Point.
As an alternative embodiment, in first aspect of the embodiment of the present invention, if the sequence number is not Minimum value in the sequence number list, the method also includes:
Event monitoring is arranged to the destination node, and obtains corresponding monitored data;
Match the anomalous event strategy of the monitored data and default setting;
If successful match generates anomalous event;
When the anomalous event indicates that the node data of the destination node changes, the destination client Xiang Suoshu hair Send alert notification;Wherein, the node data changes including node creation, knot removal, node data modification and son Node change.
As an alternative embodiment, in first aspect of the embodiment of the present invention, the method also includes:
When receiving acquisition request of the destination client for target resource, the needle that the destination client is sent is recorded To the accumulative request number of times of the acquisition request of the target resource;
Judge whether the accumulative request number of times is greater than preset request threshold value;
If the accumulative request number of times is greater than the preset request threshold value, the mesh is directed to the destination client The acquisition request for marking resource executes shielding processing;
If the accumulative request number of times is not more than the preset request threshold value, it is preset described to execute the acquisition The target access path of target resource.
As an alternative embodiment, in first aspect of the embodiment of the present invention, it is described to the destination client Shielding processing is executed for the acquisition request of the target resource, comprising:
Refuse the acquisition request that the destination client is directed to the target resource in preset duration, and described default The accumulative request number of times is reset after duration.
As an alternative embodiment, in first aspect of the embodiment of the present invention, it is described to be returned to destination client After the node lock, the method also includes:
Obtain the heartbeat connection letter between the Distributed Services equipment corresponding with the target resource of the destination client Breath;
Judge whether the destination client terminates the access to the target resource according to the heartbeat link information;
If the destination client terminates the access to the target resource, the interim child node of the target is deleted.
Second aspect of the embodiment of the present invention discloses a kind of resource access system based on zookeeper, comprising:
Detection unit, for detecting whether receiving the acquisition request that destination client is directed to target resource;
First acquisition unit, for detecting to receive the destination client for the target in the detection unit When the acquisition request of resource, the target access path of the preset target resource is obtained;
Searching unit, for searching the target access path in zookeeper cluster with the presence or absence of destination node;
Creating unit, for finding in the searching unit there are when the destination node, under the destination node Create the interim child node of target;
Writing unit, for the interim child node of target to be written in the characteristic of the destination client, with determination The destination client gets the node lock;
Return unit, for returning to the node lock to the destination client.
The third aspect of the embodiment of the present invention discloses a kind of computer readable storage medium, stores computer program, wherein The computer program makes computer execute a kind of resource based on zookeeper disclosed in first aspect of the embodiment of the present invention Access method.
Fourth aspect of the embodiment of the present invention discloses a kind of electronic equipment, and the electronic equipment includes:
Processor;
Memory is stored with computer-readable instruction on the memory, and the computer-readable instruction is by the processing When device executes, foregoing method is realized.
The technical solution that the embodiment of the present invention provides can include the following benefits:
Resource access method provided by the present invention based on zookeeper includes the following steps, objective when receiving target When family end is directed to the acquisition request of target resource, the target access path of preset target resource is obtained;In zookeeper cluster Middle lookup target access path whether there is destination node;If there is destination node, it is interim that target is created under destination node Child node, and the interim child node of target is written into the characteristic of destination client, to determine that destination client gets node Lock;It is locked to destination client return node.
It, can be temporarily sub to create target when destination client has the requirements for access to target resource under the method The mode of node feeds back the requirements for access to zookeeper cluster, and the characteristic of destination client write-in target is interim Child node, to determine that destination client gets node lock.Transient node have the characteristics that compared to lasting node it is deletable, because This this programme can reduce the occupancy of memory space, to reduce influence of the resource access to the performance of zookeeper.
It should be understood that the above general description and the following detailed description are merely exemplary, this can not be limited Invention.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows and meets implementation of the invention Example, and in specification together principle for explaining the present invention.
Fig. 1 is a kind of schematic diagram of device shown according to an exemplary embodiment;
Fig. 2 is a kind of flow chart of resource access method based on zookeeper shown according to an exemplary embodiment;
Fig. 3 is a kind of process of the resource access method based on zookeeper shown according to another exemplary embodiment Figure;
Fig. 4 is a kind of frame of resource access system of the data shown according to an exemplary embodiment based on zookeeper Figure;
Fig. 5 is the block diagram of another resource access system based on zookeeper shown according to an exemplary embodiment.
Specific embodiment
Here will the description is performed on the exemplary embodiment in detail, the example is illustrated in the accompanying drawings.Following description is related to When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment Described in embodiment do not represent all embodiments consistented with the present invention.On the contrary, they be only with it is such as appended The example of device and method being described in detail in claims, some aspects of the invention are consistent.
Fig. 1 is a kind of schematic diagram of device shown according to an exemplary embodiment.Device 100 can be electronic equipment. As shown in Figure 1, device 100 may include following one or more components: processing component 102, memory 104, power supply module 106, multimedia component 108, audio component 110, sensor module 114 and communication component 116.
The integrated operation of the usual control device 100 of processing component 102, such as with display, telephone call, data communication, phase Machine operation and the associated operation of record operation etc..Processing component 102 may include one or more processors 118 to execute Instruction, to complete all or part of the steps of following methods.In addition, processing component 102 may include one or more modules, For convenient for the interaction between processing component 102 and other assemblies.For example, processing component 102 may include multi-media module, use In to facilitate the interaction between multimedia component 108 and processing component 102.
Memory 104 is configured as storing various types of data to support the operation in device 100.These data are shown Example includes the instruction of any application or method for operating on the device 100.Memory 104 can be by any kind of Volatibility or non-volatile memory device or their combination are realized, such as static random access memory (Static Random Access Memory, abbreviation SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, abbreviation EEPROM), Erasable Programmable Read Only Memory EPROM (Erasable Programmable Read Only Memory, abbreviation EPROM), programmable read only memory (Programmable Red- Only Memory, abbreviation PROM), read-only memory (Read-Only Memory, abbreviation ROM), magnetic memory, flash Device, disk or CD.It is also stored with one or more modules in memory 104, is configured to for the one or more module It is executed by the one or more processors 118, to complete all or part of step in method as follows.
Power supply module 106 provides electric power for the various assemblies of device 100.Power supply module 106 may include power management system System, one or more power supplys and other with for device 100 generate, manage, and distribute the associated component of electric power.
Multimedia component 108 includes the screen of one output interface of offer between described device 100 and user.One In a little embodiments, screen may include liquid crystal display (Liquid Crystal Display, abbreviation LCD) and touch panel. If screen includes touch panel, screen may be implemented as touch screen, to receive input signal from the user.Touch panel Including one or more touch sensors to sense the gesture on touch, slide, and touch panel.The touch sensor can be with The boundary of a touch or slide action is not only sensed, but also detects duration associated with the touch or slide operation and pressure Power.Screen can also include display of organic electroluminescence (Organic Light Emitting Display, abbreviation OLED).
Audio component 110 is configured as output and/or input audio signal.For example, audio component 110 includes a Mike Wind (Microphone, abbreviation MIC), when device 100 is in operation mode, such as call model, logging mode and speech recognition mould When formula, microphone is configured as receiving external audio signal.The received audio signal can be further stored in memory 104 or via communication component 116 send.In some embodiments, audio component 110 further includes a loudspeaker, for exporting Audio signal.
Sensor module 114 includes one or more sensors, and the state for providing various aspects for device 100 is commented Estimate.For example, sensor module 114 can detecte the state that opens/closes of device 100, the relative positioning of component, sensor group Part 114 can be with the position change of 100 1 components of detection device 100 or device and the temperature change of device 100.Some In embodiment, which can also include Magnetic Sensor, pressure sensor or temperature sensor.
Communication component 116 is configured to facilitate the communication of wired or wireless way between device 100 and other equipment.Device 100 can access the wireless network based on communication standard, such as WiFi (Wireless-Fidelity, Wireless Fidelity).Show at one In example property embodiment, communication component 116 receives broadcast singal or broadcast from external broadcasting management system via broadcast channel Relevant information.In one exemplary embodiment, the communication component 116 further includes near-field communication (Near Field Communication, abbreviation NFC) module, for promote short range communication.For example, radio frequency identification can be based in NFC module (Radio Frequency Identification, abbreviation RFID) technology, Infrared Data Association (Infrared Data Association, abbreviation IrDA) technology, ultra wide band (Ultra Wideband, abbreviation UWB) technology, Bluetooth technology and other skills Art is realized.
In the exemplary embodiment, device 100 can be by one or more application specific integrated circuit (Application Specific Integrated Circuit, abbreviation ASIC), it is digital signal processor, digital signal processing appts, programmable Logical device, field programmable gate array, controller, microcontroller, microprocessor or other electronic components are realized, for executing Following methods.
Fig. 2 is a kind of flow chart of resource access method based on zookeeper shown according to an exemplary embodiment. As shown in Fig. 2, the method includes the following steps.
Step 201, when receiving acquisition request of the destination client for target resource, resource accesses system and obtains in advance If target resource target access path.
In the embodiment of the present invention, resource access system can detecte whether receive destination client for target resource Acquisition request, that is, for the access request of target resource, if received, the target of available preset target resource Access path.Wherein, destination client wants access to target resource, that is, wants the corresponding node of request target resource It locks (i.e. distributed lock).
Step 202, resource access system searches target access path with the presence or absence of target section in zookeeper cluster Point;If there is destination node, triggering executes step 203;If there is no the destination node, terminate this process.
In the embodiment of the present invention, whether resource access system can search target access path in zookeeper cluster There are destination node, lookup result is obtained, and destination node is judged whether there is according to the lookup result;If there is the target Node, triggering execute step 203;If there is no the destination node, optionally, target can be created in the target access path Node, and the interim child node of target is created under destination node.
It is understood that if resource access system is judged to may indicate that target visitor there is no the destination node Family end requests the node of the target resource to be locked earliest, therefore, can create in zookeeper cluster and be named with target resource identifier Destination node, and create under the destination node the interim child node of the corresponding target of acquisition request of the destination client;Its In, which is lasting node.
Step 203, resource access system creates the interim child node of target under destination node, and by the spy of destination client It levies data and the interim child node of target is written, to determine that destination client gets node lock.
As an alternative embodiment, after creating the interim child node of target under destination node, and by target Before the characteristic write-in interim child node of target of client, resource access system also executes following steps:
Detect whether to receive the acquisition request for node lock that other clients in addition to destination client are sent;
If so, obtaining the sequence number of the interim child node of target;
Judge whether sequence number is minimum value in sequence number list;Wherein, sequence number list is by target section The sequence number of all interim child nodes under point is constituted;
If sequence number is the minimum value in sequence number list, target is written in the characteristic by client of execution Interim child node.
In the embodiment of the present invention, in zookeeper cluster, the sequence number numerical value reckling for defaulting child node can be obtained Node lock, therefore, resource accesses the sequence number of the interim child node of the available target of system, by judging that sequence number is The no minimum value in sequence number list is locked to determine whether destination client can obtain the corresponding node of the destination node.
Further, as another optional embodiment, if sequence number be not in sequence number list most Following steps can also be performed in small value, above-mentioned resource access system:
Event monitoring is arranged to destination node, and obtains corresponding monitored data;
Match the anomalous event strategy of monitored data and default setting;
If successful match generates anomalous event;
When the node data of anomalous event instruction destination node changes, alert notification is sent to destination client; Wherein, node data changes including node creation, knot removal, node data modification and child node change.
In the embodiment of the present invention, resource access system can preset the resolution policy that a variety of anomalous events are arranged, i.e., extremely Event Policies, wherein anomalous event may include the node data of destination node change this event therefore can be right Event monitoring is arranged in destination node, and when the variation of data or structure occurs for node, triggering zookeeper notifies target customer End;Wherein, specifically, node data change specifically can be node creation, knot removal, node data modify and Child node change etc..For example, the transient node of its correspondence establishment can disappear immediately when any client disconnects every time, thus Clustered node exception can be listened to.In addition, other clients in addition to destination client can also be arranged destination node Event monitoring, and when monitoring anomalous event, other clients of event monitoring can be also provided with for destination node to other End sends alert notification.As it can be seen that the notice of message can be realized by asynchronous call using this method, that is to say, that message Publisher only needs to send alert notification, and recipient's (client) of message does not need cyclic query alert notification either with or without reaching It arrives, when there is alert notification arrival, the recipient of zookeeper meeting active warning message;Reduce the recipient of message in this way The wasting of resources of (client).
Step 204, resource accesses system and locks to destination client return node.
In the embodiment of the present invention, resource accesses system and locks to destination client return node, i.e., destination client is locked, The accessible target resource in destination client optionally access target resource and completes corresponding Business Stream in destination client After journey, the corresponding interim child node of target can be deleted, at this point, node lock is released.
As an alternative embodiment, after step 204, following steps can also be performed in resource access system:
Obtain the heartbeat link information between the Distributed Services equipment corresponding with target resource of destination client;
Judge whether destination client terminates the access to target resource according to heartbeat link information;
If destination client terminates the access to target resource, the interim child node of delete target.
As it can be seen that implementing the resource access method based on zookeeper described in Fig. 2, can exist in destination client When to the requirements for access of target resource, feeding back the access to zookeeper cluster in a manner of creating the interim child node of target is needed It asks, and the interim child node of target is written into the characteristic of destination client, to determine that destination client gets node lock.Face Shi Jiedian has the characteristics that deletable compared to lasting node, therefore this programme can reduce the occupancy of memory space, to drop Influence of the low resource access to the performance of zookeeper;In addition, can realize message by asynchronous call using this method Notice, that is to say, that the publisher of message only needs to send alert notification, and recipient's (client) of message does not need to follow Ring inquires alert notification either with or without reaching, and when there is alert notification arrival, zookeeper understands the recipient of active warning message; Reduce the wasting of resources of recipient's (client) of message in this way.
In the embodiment of the present invention, in target customer between destination client and the Distributed Services equipment for issuing target resource End keeps certain connection when accessing to target resource, and whether judges other side by way of regularly sending heartbeat packet It disconnects;If not receiving heartbeat packet in certain time, judgement is already off with the connection of other side, therefore can stop Request service is provided for other side or requests to service to other side.Therefore, resource access system can be connected by obtaining above-mentioned heartbeat Information is connect to judge whether the connection between destination client and distributed server is interrupted, and then may determine that destination client Whether access to target resource is terminated, if destination client terminates the access to target resource, the interim son section of delete target Point.Zookeeper safeguards node (i.e. znode), wherein node is divided into transient node and lasting node, and node Type is determining in creation and cannot modify again later.The difference of both nodes is: in the client of creation transient node When holding conversation end, zookeeper can delete the transient node (the interim child node of such as target);In contrast, lasting node (such as destination node) independent of client session, only when client clearly will delete the lasting node, lasting node is It can be deleted;And of short duration node cannot have child node.
In the present solution, destination client in access target resource, needs to know clustered machine list, by with cluster In a certain machine establish TCP (Transmission Control Protocol, transmission control protocol) connection use clothes Business, destination client can be used this TCP chain and fetch transmission request, obtain result, obtain monitoring event and send heartbeat Packet.So monitoring can be arranged for each machine (distributed server) in cluster, the load of its node is monitored;Work as reception When acquisition request (access request) for target resource sent to destination client, if the access of destination node is negative at this time Lotus is higher than default load threshold value, and the access request of destination client can be guided into the minimum machine of load (other distribution clothes Business device) in.It is further alternative, determine that the load of a certain machine in cluster is that minimum mode may is that detection is each The received access request (resource acquisition request) of platform machine institute, including read and write.The least machine of access request is determined For the machine that load is minimum, and the access request of destination client is guided into the minimum machine of the load.
As an alternative embodiment, resource access system can use zookeeper same node point and can store Same services are safeguarded for the child node function of sequence.For example, target resource can be a certain service, therefore destination node can be with It is stored with the related data (such as servicing online related configuration data) of the service, meanwhile, in zookeeper, there is also a certain Two nodes can store the offline related configuration data of the service and the third node of other related services, then can be with Destination node and second node, third node etc. are stored as the child node of sequence to facilitate user maintenance same services.
Fig. 3 is a kind of process of the resource access method based on zookeeper shown according to another exemplary embodiment Figure.As shown in figure 3, being somebody's turn to do the resource access method based on zookeeper may comprise steps of:
Step 301, when receiving acquisition request of the destination client for target resource, resource accesses system and records mesh Mark the accumulative request number of times for the acquisition request for target resource that client is sent.
Step 302, resource access system judges whether accumulative request number of times is greater than preset request threshold value;If accumulative ask Number is asked to be greater than preset request threshold value, triggering executes step 303;If accumulative request number of times is not more than preset request threshold Value, triggering execute step 304.
Step 303, acquisition request of the resource access system to destination client for target resource executes shielding processing.
In the embodiment of the present invention, the mode of shielding processing can be refuses destination client for target in preset duration Any acquisition request of resource;Further, resource access system can also carry out blacklist label to destination client, so that It destination client can not access target resource;Or resource access system can be directed to the acquisition of target resource to destination client Request carries out delay disposal, and the embodiment of the present invention is without limitation.
In the embodiment of the present invention, if destination client is excessively frequent to the number of the acquisition request of target resource, it is easy It causes target resource to be occupied for a long time by destination client, causes other clients in addition to destination client that can not access mesh Resource is marked, and then causes the pressure of zookeeper cluster excessive, the utilization rate of target resource reduces, therefore, by target visitor To destination client for target resource when family end is greater than preset request threshold value for the accumulative request number of times of target resource Acquisition request executes shielding processing, realizes the reasonable distribution of shared resource, while also reducing the processing of zookeeper cluster Pressure.
As an alternative embodiment, resource accesses the acquisition request that system is directed to target resource to destination client Shielding processing is executed, may include:
Refuse the acquisition request that destination client is directed to target resource in preset duration, and will tire out after preset duration Request number of times is counted to reset.
In the embodiment of the present invention, further, resource accesses system after resetting accumulative request number of times, can be again The new acquisition request that destination client is directed to target resource is received, and step 304 is executed according to the new acquisition request triggering.
Step 304, resource access system obtains the target access path of preset target resource.
Wherein, being somebody's turn to do the resource access method based on zookeeper further includes step 305~307, for step 305~307 Description, please refer to the detailed description that step 202~204 are directed in above-described embodiment one, the embodiment of the present invention repeats no more.
As it can be seen that the resource access method based on zookeeper described in implementing Fig. 3, can exist in destination client When to the requirements for access of target resource, feeding back the access to zookeeper cluster in a manner of creating the interim child node of target is needed It asks, and the interim child node of target is written into the characteristic of destination client, to determine that destination client gets node lock.Face Shi Jiedian has the characteristics that deletable compared to lasting node, therefore this programme can reduce the occupancy of memory space, to drop Influence of the low resource access to the performance of zookeeper;And message can be realized by asynchronous call using this method Notice, that is to say, that the publisher of message only needs to send alert notification, and recipient's (client) of message does not need to follow Ring inquires alert notification either with or without reaching, and when there is alert notification arrival, zookeeper understands the recipient of active warning message; Reduce the wasting of resources of recipient's (client) of message in this way;In addition, the reasonable distribution of shared resource is realized, while Reduce the processing pressure of zookeeper cluster.
It is the device of the invention embodiment below.
Fig. 4 is a kind of block diagram of resource access system based on zookeeper shown according to an exemplary embodiment.Such as Shown in Fig. 4, resource access system includes:
Detection unit 401, for detecting whether receiving the acquisition request that destination client is directed to target resource, and will inspection It surveys result and is supplied to first acquisition unit 402.
First acquisition unit 402, for detecting that receive destination client provides for target in above-mentioned detection unit 401 When the acquisition request in source, the target access path of preset target resource is obtained, and is supplied to searching unit 403.
Searching unit 403 whether there is destination node for searching target access path in zookeeper cluster, and Lookup result is supplied to creating unit 404.
Creating unit 404 is created under destination node for finding in above-mentioned searching unit 403 there are when destination node The interim child node of target is built, and is supplied to writing unit 405.
Writing unit 405, for the interim child node of target to be written in the characteristic of destination client, to determine target visitor Family end gets node lock, and triggers the starting of return unit 406.
Return unit 406, for being locked to destination client return node.
As it can be seen that implement system described in Fig. 4, can when destination client exists to the requirements for access of target resource, The requirements for access is fed back to zookeeper cluster in a manner of creating the interim child node of target, and by the feature of destination client The interim child node of target is written in data, to determine that destination client gets node lock.Transient node has compared to lasting node There is deletable feature, therefore this programme can reduce the occupancy of memory space, to reduce resource access to zookeeper Performance influence;In addition, the notice of message can be realized by asynchronous call using this method, that is to say, that the hair of message Cloth person only needs to send alert notification, and recipient's (client) of message does not need cyclic query alert notification either with or without reaching It arrives, when there is alert notification arrival, the recipient of zookeeper meeting active warning message;Reduce the recipient of message in this way The wasting of resources of (client).
Referring to Fig. 5, Fig. 5 another resource based on zookeeper shown according to an exemplary embodiment accesses system The block diagram of system, wherein system shown in fig. 5 is that system further progress as shown in Figure 4 optimizes.With it is shown in Fig. 4 System compares, in system shown in Fig. 5:
Above-mentioned detection unit 401 is also used to create the interim child node of target under destination node in above-mentioned creating unit 404 Later, detect whether to receive the acquisition request for node lock that other clients in addition to destination client are sent, and It will test result and be supplied to second acquisition unit 407.
It wherein, can be with detection trigger list after above-mentioned creating unit 404 creates the interim child node of target under destination node Member 401, which executes, detects whether to receive the acquisition request for node lock that other clients in addition to destination client are sent Operation.
Second acquisition unit 407 is also used to detect to receive other clients for the section in above-mentioned detection unit 401 When the acquisition request of point lock, the sequence number of the interim child node of target is obtained, and is supplied to the first judging unit 408.
First judging unit 408, for judging whether sequence number is minimum value in sequence number list, and will judgement As a result it is supplied to writing unit 405;Wherein, which is by the sequence of all interim child nodes under destination node Number is constituted.
Above-mentioned writing unit 405, specifically for judging the sequence number for sequence volume in above-mentioned first judging unit 408 When minimum value in number list, the interim child node of target is written into the characteristic of client.
As an alternative embodiment, as shown in figure 5, above-mentioned creating unit 404, is also used in above-mentioned searching unit 403 find there is no when destination node, create destination node in target access path, and create target under destination node and face When child node.
As another optional embodiment, as shown in figure 5, above-mentioned resource accesses system, can also include:
Monitoring unit 409 is sequence number list for judging the sequence number not in above-mentioned first judging unit 408 In minimum value when, event monitoring is arranged to destination node, and obtains corresponding monitored data, and the monitored data is provided To matching unit 410.
Matching unit 410 for matching the anomalous event strategy of monitored data and default setting, and matching result is provided To anomalous event unit 411.
Anomalous event unit 411, for the anomalous event in above-mentioned matching unit 410 matching monitored data and default setting When strategy matching success, anomalous event is generated, and triggers the starting of transmission unit 412.
Transmission unit 412, when for indicating that the node data of destination node changes when anomalous event, to target customer End sends alert notification;Wherein, it may include node creation, knot removal, node data modification which, which changes, And child node change.
Can also include: as shown in figure 5, above-mentioned resource accesses system as another optional embodiment
Recording unit 413, for detecting to receive destination client for target resource in above-mentioned detection unit 401 When acquisition request, the accumulative request number of times for the acquisition request for target resource that record destination client is sent, and be supplied to Second judgment unit 414.
Second judgment unit 414, for judging whether accumulative request number of times is greater than preset request threshold value.
Shielding processing unit 415, it is preset for judging that accumulative request number of times is greater than in above-mentioned second judgment unit 414 When requesting threshold value, the acquisition request to destination client for target resource executes shielding processing.
Wherein, as an alternative embodiment, shielding processing unit 415 is directed to target resource to destination client The mode that acquisition request executes shielding processing is specifically as follows:
Refuse the acquisition request that destination client is directed to target resource in preset duration, and will tire out after preset duration Request number of times is counted to reset.
Above-mentioned first acquisition unit 402, specifically for judging accumulative request number of times not in above-mentioned second judgment unit 414 When greater than preset request threshold value, the target access path of preset target resource is obtained.
As another optional embodiment, as shown in figure 5, above-mentioned second acquisition unit 407, is also used to return above-mentioned After receipt member 406 is locked to destination client return node, destination client Distributed Services corresponding with target resource are obtained Heartbeat link information between equipment, and the heartbeat link information is supplied to the first judging unit 408.
Above-mentioned first judging unit 408 is also used to judge whether destination client terminates to mesh according to heartbeat link information The access of resource is marked, and judging result is supplied to and deletes unit 416.
Unit 416 is deleted, for judging that destination client terminates to target resource in above-mentioned first judging unit 408 When access, the interim child node of delete target.
As it can be seen that implement system described in Fig. 5, can when destination client exists to the requirements for access of target resource, The requirements for access is fed back to zookeeper cluster in a manner of creating the interim child node of target, and by the feature of destination client The interim child node of target is written in data, to determine that destination client gets node lock.Transient node has compared to lasting node There is deletable feature, therefore this programme can reduce the occupancy of memory space, to reduce resource access to zookeeper Performance influence;And the notice of message can be realized by asynchronous call using this method, that is to say, that the hair of message Cloth person only needs to send alert notification, and recipient's (client) of message does not need cyclic query alert notification either with or without reaching It arrives, when there is alert notification arrival, the recipient of zookeeper meeting active warning message;Reduce the recipient of message in this way The wasting of resources of (client);In addition, realizing the reasonable distribution of shared resource, while also reducing zookeeper cluster Processing pressure.
The present invention also provides a kind of electronic equipment, which includes:
Processor;
Memory is stored with computer-readable instruction on the memory, when which is executed by processor, Realize performance test methods as previously shown.
In one exemplary embodiment, the present invention also provides a kind of computer readable storage mediums, are stored thereon with calculating Machine program when the computer program is executed by processor, realizes the resource access method as previously shown based on zookeeper.
It should be understood that the present invention is not limited to the precise structure already described above and shown in the accompanying drawings, and And various modifications and change can executed without departing from the scope.The scope of the present invention is limited only by the attached claims.

Claims (10)

1. a kind of resource access method based on zookeeper, which is characterized in that the described method includes:
When receiving acquisition request of the destination client for target resource, the target for obtaining the preset target resource is visited It asks the way diameter;
The target access path is searched in zookeeper cluster with the presence or absence of destination node;
If there is the destination node, the interim child node of target is created under the destination node, and by the target customer The interim child node of target is written in the characteristic at end, gets the node lock with the determination destination client;
The node lock is returned to the destination client.
2. the method according to claim 1, wherein described create the interim son section of target under the destination node After point and the characteristic by the destination client is written before the interim child node of target, the method Further include:
Detect whether to receive the acquisition for node lock that other clients in addition to the destination client are sent Request;
If so, obtaining the sequence number of the interim child node of the target;
Judge whether the sequence number is minimum value in sequence number list;Wherein, the sequence number list is by institute The sequence number for stating all interim child nodes under destination node is constituted;
If the sequence number is the minimum value in the sequence number list, the feature by the client is executed The interim child node of target is written in data.
3. the method according to claim 1, wherein if there is no the destination node, the method is also wrapped It includes:
The destination node is created in the target access path, and creates the interim child node of target under the destination node.
4. according to the method described in claim 2, it is characterized in that, if the sequence number is not the sequence number list In minimum value, the method also includes:
Event monitoring is arranged to the destination node, and obtains corresponding monitored data;
Match the anomalous event strategy of the monitored data and default setting;
If successful match generates anomalous event;
When the anomalous event indicates that the node data of the destination node changes, the destination client Xiang Suoshu sends and mentions It wakes up and notifies;Wherein, the node data changes including node creation, knot removal, node data modification and child node Change.
5. the method according to claim 1, wherein the method also includes:
When receiving acquisition request of the destination client for target resource, record the destination client transmission is directed to institute State the accumulative request number of times of the acquisition request of target resource;
Judge whether the accumulative request number of times is greater than preset request threshold value;
If the accumulative request number of times is greater than the preset request threshold value, the destination client is provided for the target The acquisition request in source executes shielding processing;
If the accumulative request number of times is not more than the preset request threshold value, the preset target of acquisition is executed The target access path of resource.
6. according to the method described in claim 5, it is characterized in that, described be directed to the target resource to the destination client Acquisition request execute shielding processing, comprising:
Refuse the acquisition request that the destination client is directed to the target resource in preset duration, and in the preset duration The accumulative request number of times is reset later.
7. method according to claim 1 or 2, which is characterized in that described to lock it to the destination client return node Afterwards, the method also includes:
Obtain the heartbeat link information between the Distributed Services equipment corresponding with the target resource of the destination client;
Judge whether the destination client terminates the access to the target resource according to the heartbeat link information;
If the destination client terminates the access to the target resource, the interim child node of the target is deleted.
8. a kind of resource based on zookeeper accesses system, which is characterized in that the resource accesses system and includes:
Detection unit, for detecting whether receiving the acquisition request that destination client is directed to target resource;
First acquisition unit, for detecting to receive the destination client for the target resource in the detection unit Acquisition request when, obtain the target access path of the preset target resource;
Searching unit, for searching the target access path in zookeeper cluster with the presence or absence of destination node;
Creating unit creates under the destination node for finding in the searching unit there are when the destination node The interim child node of target;
Writing unit, for the interim child node of target to be written in the characteristic of the destination client, described in determination Destination client gets the node lock;
Return unit, for returning to the node lock to the destination client.
9. a kind of computer readable storage medium, which is characterized in that it stores computer program, and the computer program makes to succeed in one's scheme Calculation machine perform claim requires 1~7 described in any item resource access methods based on zookeeper.
10. a kind of electronic equipment, including memory and processor, the memory are stored with computer program, which is characterized in that The step of processor realizes method according to any one of claims 1 to 7 when executing the computer program.
CN201910647172.0A 2019-07-17 2019-07-17 A kind of resource access method based on zookeeper, system, medium and electronic equipment Pending CN110474963A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910647172.0A CN110474963A (en) 2019-07-17 2019-07-17 A kind of resource access method based on zookeeper, system, medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910647172.0A CN110474963A (en) 2019-07-17 2019-07-17 A kind of resource access method based on zookeeper, system, medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN110474963A true CN110474963A (en) 2019-11-19

Family

ID=68509693

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910647172.0A Pending CN110474963A (en) 2019-07-17 2019-07-17 A kind of resource access method based on zookeeper, system, medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN110474963A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111246397A (en) * 2020-01-19 2020-06-05 阿里巴巴集团控股有限公司 Cluster system, service access method, device and server
CN112307105A (en) * 2020-11-03 2021-02-02 平安普惠企业管理有限公司 Timing task running method, device, equipment and storage medium based on multithreading
CN114661742A (en) * 2022-03-28 2022-06-24 浪潮卓数大数据产业发展有限公司 Zookeeper-based distributed lock acquisition method and system
CN115277735A (en) * 2022-07-20 2022-11-01 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107783842A (en) * 2016-08-31 2018-03-09 阿里巴巴集团控股有限公司 A kind of distributed lock implementation method, equipment and storage device
CN108038005A (en) * 2017-12-28 2018-05-15 广东蜂助手网络技术股份有限公司 Shared resource access method, client, server-side, system based on zookeeper
CN108897628A (en) * 2018-05-25 2018-11-27 北京奇艺世纪科技有限公司 A kind of implementation method of distributed lock, device and electronic equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107783842A (en) * 2016-08-31 2018-03-09 阿里巴巴集团控股有限公司 A kind of distributed lock implementation method, equipment and storage device
CN108038005A (en) * 2017-12-28 2018-05-15 广东蜂助手网络技术股份有限公司 Shared resource access method, client, server-side, system based on zookeeper
CN108897628A (en) * 2018-05-25 2018-11-27 北京奇艺世纪科技有限公司 A kind of implementation method of distributed lock, device and electronic equipment

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111246397A (en) * 2020-01-19 2020-06-05 阿里巴巴集团控股有限公司 Cluster system, service access method, device and server
CN111246397B (en) * 2020-01-19 2022-05-06 阿里巴巴集团控股有限公司 Cluster system, service access method, device and server
CN112307105A (en) * 2020-11-03 2021-02-02 平安普惠企业管理有限公司 Timing task running method, device, equipment and storage medium based on multithreading
CN114661742A (en) * 2022-03-28 2022-06-24 浪潮卓数大数据产业发展有限公司 Zookeeper-based distributed lock acquisition method and system
CN115277735A (en) * 2022-07-20 2022-11-01 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN115277735B (en) * 2022-07-20 2023-11-28 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110474963A (en) A kind of resource access method based on zookeeper, system, medium and electronic equipment
US20220300354A1 (en) System and method for tagging and tracking events of an application
US8204870B2 (en) Unwired enterprise platform
JP5391276B2 (en) Intelligent mobile device management client
CN108156265B (en) A kind of application control method and mobile device
CN103404193B (en) The connection that adjustment data transmission is established with the transmission being optimized for through wireless network
US8001150B2 (en) Device management method using nodes having additional attribute and device management client thereof
US10638279B2 (en) Method and system for generating local mobile device notifications
CN110515912A (en) Log processing method, device, computer installation and computer readable storage medium
CN108701281A (en) Contextual information engine
CN106375458B (en) Service calling system, method and device
CN107005597A (en) The wireless flow management system cached based on user characteristics in mobile device
CN107888444A (en) Service monitoring method, service monitoring device, computer equipment and storage medium
CN107204989A (en) Ad blocking method, terminal, server and storage medium
CN110795395A (en) File deployment system and file deployment method
CN110430121A (en) Message informing method and device
CN107908769A (en) Violation data querying method, device, system, equipment and readable storage medium storing program for executing
CN113094378A (en) Data processing method and device, electronic equipment and storage medium
CN108809805A (en) A kind of information interacting method, system and public's account client
CN115114359A (en) User data processing method and device
CN108270839A (en) Access frequency control system and method
CN112711518B (en) Log uploading method and device
CN108156071A (en) To method, terminal device and the computer readable storage medium of community's addition member
CN106940660A (en) The method and apparatus of the realization of caching
CN110389794A (en) Method, storage medium and the terminal of information sharing are established between a kind of plug-in unit

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

Application publication date: 20191119

RJ01 Rejection of invention patent application after publication