WO2015051690A1 - Zookeeper-based information configuration method and device - Google Patents

Zookeeper-based information configuration method and device Download PDF

Info

Publication number
WO2015051690A1
WO2015051690A1 PCT/CN2014/086653 CN2014086653W WO2015051690A1 WO 2015051690 A1 WO2015051690 A1 WO 2015051690A1 CN 2014086653 W CN2014086653 W CN 2014086653W WO 2015051690 A1 WO2015051690 A1 WO 2015051690A1
Authority
WO
WIPO (PCT)
Prior art keywords
configuration information
local disk
zookeeper
server
zookeeper server
Prior art date
Application number
PCT/CN2014/086653
Other languages
French (fr)
Chinese (zh)
Inventor
冯所范
王超
朱超
Original Assignee
北京奇虎科技有限公司
奇智软件(北京)有限公司
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 北京奇虎科技有限公司, 奇智软件(北京)有限公司 filed Critical 北京奇虎科技有限公司
Publication of WO2015051690A1 publication Critical patent/WO2015051690A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms

Definitions

  • the present invention relates to the field of computer technology, and in particular, to a zookeeper-based information configuration method and apparatus.
  • zookeeper is often used to centrally manage all process configuration information in multiple servers.
  • Zookeeper as the name suggests, zookeeper, in the field of computer technology, zookeeper is a reliable coordination system for large-scale distributed systems, providing functions such as configuration maintenance, name service, distributed synchronization, group service and so on.
  • the existing zookeeper-based information configuration scheme is: each process in each server must establish a long connection with the zookeeper server, and each process monitors the configuration information of its own process by calling the interface of the zookeeper server, when a certain process When the configuration information needs to be modified, the operator only needs to modify the corresponding configuration information on the zookeeper server. Once the configuration information of the zookeeper server is changed, the corresponding server process updates the configuration of the process according to the modified configuration information on the zookeeper server. information.
  • each server Since in practice, there are often hundreds of servers serving together, each server usually runs at least hundreds of processes, for example, if there are 100 servers providing services together, and each server runs 200 processes, each server Each process establishes a long connection with the zookeeper server. A total of 20,000 connections need to be established. This configuration method imposes a large load on the zookeeper server and seriously affects the processing performance of the zookeeper server.
  • a zookeeper-based information configuration method and device are proposed to ensure that all process configuration information in the server is monitored while effectively reducing the load of the zookeeper server.
  • a zookeeper-based information configuration method the package include:
  • the process obtains the corresponding configuration information from the zookeeper server and updates the configuration information to the local disk according to the received update configuration information notification, so that the process of the configuration information to be read searches for the corresponding configuration information from the local disk. If the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the process of the configuration information to be read is established and zookeeper A short connection between the servers, and obtaining the corresponding configuration information from the zookeeper server and storing it on the local disk.
  • a zookeeper-based information configuration apparatus comprising:
  • a monitoring unit configured to start a process to occupy a lock between processes, establish a long connection between the process and the zookeeper server, and monitor all configuration information in the local disk by using the process, so that the zookeeper server is configured Sending an update configuration information notification to the process when the information changes;
  • an update unit configured to, according to the update configuration information, obtain the corresponding configuration information from the zookeeper server and update to the local disk, so that the process of the configuration information to be read searches for the corresponding information from the local disk.
  • the configuration information if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the configuration information to be read The process establishes a short connection with the zookeeper server, and obtains its corresponding configuration information from the zookeeper server and stores it on the local disk.
  • a computer program comprising computer readable code that, when executed on a server, causes the server to perform zookeeper-based information configuration as described in the preceding paragraph method.
  • a computer readable medium storing the computer program described in the preceding paragraph is provided.
  • the process obtains the corresponding configuration information from the zookeeper server and updates to the local disk.
  • the process obtains the corresponding configuration information from the zookeeper server and updates to the local disk.
  • the local disk search is required.
  • Corresponding configuration information no need to establish a long connection with the zookeeper server; if there is no corresponding configuration information on the local disk, the related configuration information of the process has not been monitored. In this case, only the zookeeper server is required.
  • each server does not need to establish a long connection between each process and the zookeeper server, but only establishes a process and zookeeper by utilizing a process to occupy the lock between the process and the local disk.
  • the long connection between the servers and the initial short connection ensure that the configuration information of all processes is monitored and the load of the zookeeper server is reduced.
  • Embodiment 1 is a flowchart of Embodiment 1 of a zookeeper-based information configuration method according to an embodiment of the present invention
  • Embodiment 2 is a flowchart of Embodiment 2 of a zookeeper-based information configuration method according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of an information configuration framework based on zookeeper according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of Embodiment 1 of an information configuration apparatus based on ZooKeeper according to an embodiment of the present invention
  • Embodiment 2 is a schematic diagram of Embodiment 2 of an information configuration apparatus based on ZooKeeper according to an embodiment of the present invention
  • Figure 7 shows a block diagram of an application server for performing the method according to the invention
  • Figure 8 shows a storage unit for holding or carrying program code implementing the method according to the invention.
  • FIG. 1 is a flowchart of Embodiment 1 of a zookeeper-based information configuration method according to an embodiment of the present invention.
  • the method includes Step 101 and Step 102:
  • Step 101 Start a process to occupy a lock between processes, and establish a long connection between the process and the zookeeper server, and monitor all configuration information in the local disk through the process, so that the zookeeper server changes when the configuration information changes. Sending an update configuration information notification to the process.
  • a process is the basis of the operating system structure. It is a program that is being executed. When any process in the server starts running, it needs to read the configuration information first, and then process the program according to the configuration.
  • a process is started to occupy a lock between processes in order to realize sharing of resources between multiple processes in a server.
  • a process modifies shared data, other processes cannot operate on shared data at the same time, any one. Processes operate on shared data, and other processes can see it immediately.
  • the server system kernel is required to provide locks.
  • the specific implementation of such locks is: file lock (record lock), System V semaphore lock (signal light), mutex lock, condition variables, read-write locks, and so on.
  • File locks and semaphore locks are generally used for synchronization between processes. Mutexes, condition variables, and read-write locks are generally used for synchronization between threads, and are determined according to actual conditions, and are not specifically limited herein.
  • the first implementation manner may include:
  • a long connection between the process dedicated to monitoring process configuration information and the zookeeper server is established, and all configuration information in the local disk is monitored by the process dedicated to monitoring process configuration information.
  • the server starts a process dedicated to monitoring process configuration information.
  • This process is only used to monitor the configuration information of all processes in the server.
  • the process occupies a lock between processes to achieve synchronization between all processes.
  • the actual function of the lock is that when a process dedicated to monitoring process configuration information writes data to the local disk, other processes cannot perform any operations on the data of the local disk. Similarly, when other processes read data from the local disk. Processes that are dedicated to monitoring process configuration information cannot perform any operations on the local disk. Therefore, by occupying inter-process locks, all processes do not interfere with local disk operations.
  • the second implementation manner may include:
  • the process of starting the configuration information to be read occupies a lock between processes
  • the process of the configuration information to be read may start a long connection between a thread and a zookeeper server, and monitor all configuration information in the local disk through the thread; or, the process of the configuration information to be read starts a A long connection between the process and the zookeeper server, and through this process to monitor all configuration information on the local disk.
  • the embodiment of the present invention further provides a preferred solution.
  • a thread started by the process of the configuration information to be read may be an asynchronous thread.
  • Step 102 The process obtains corresponding configuration information from the zookeeper server and updates it to the local disk according to the received update configuration information notification, so that the process of the configuration information to be read searches for the corresponding one from the local disk.
  • the configuration information if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the process of the configuration information to be read Establish a short connection with the zookeeper server, and obtain the corresponding configuration information from the zookeeper server and store it on the local disk.
  • the configuration information is obtained from the zookeeper server and updated to the local disk, so that the latest configuration information is stored in the local disk, so that any process can be
  • the configuration information corresponding to the local disk read is the latest configuration information, ensuring real-time update of the configuration information to ensure that each process in the server is correctly executed.
  • the process of the current configuration information to be read needs to establish a short connection with the zookeeper server.
  • the zookeeper server obtains its corresponding configuration information and stores it on the local disk.
  • the so-called short connection is two connection methods opposite to the long connection.
  • the short connection operation steps are: establishing a connection---data transmission---closing the connection.
  • the short connection method is to disconnect immediately after establishing the connection transmission data.
  • the long connection is performed by: establishing a connection---data transfer---(always staying connected)---data transfer----closing the connection.
  • the long connection method does not disconnect after establishing the connection transmission data, and this communication connection relationship always exists.
  • short connection methods can save server system resources.
  • the process of establishing a long connection with the zookeeper server scans the local disk. When it finds the configuration information of the new process in the local disk (that is, when there is configuration information that has not been monitored in the local disk), the configuration information is added to the monitoring content. Ensure that the configuration information of all processes on the local disk can be monitored in time to update the configuration information of all processes in real time.
  • any process needs to obtain the configuration information, only the local disk needs to be obtained to obtain the corresponding configuration information, and no need to cooperate with the zookeeper.
  • a long connection is established between the servers; if there is no corresponding configuration information in the local disk, the related configuration information of the process has not been monitored. In this case, the process only needs to establish a short connection with the zookeeper server.
  • the zookeeper server obtains its own configuration information and stores it on the local disk so that the configuration information is also monitored.
  • each server does not need to establish a long connection between each process and the zookeeper server, but uses the lock between the process and the local disk to establish only one process and the zookeeper server. Long connection between the two, and using the short connection method at the beginning, It can ensure that the configuration information of all processes is monitored and the load of the zookeeper server is reduced.
  • the configuration information of the above-mentioned zookeeper-based information configuration method is stored in the local disk.
  • the process of viewing the local disk and obtaining the corresponding configuration information is inferior, resulting in low process performance of the entire server.
  • the invention also provides a preferred solution.
  • Step 201 a flowchart of Embodiment 2 of a zookeeper-based information configuration method according to an embodiment of the present invention is shown.
  • the method includes Step 201 and Step 202:
  • step 201 a process is started to occupy the lock between the processes, and a long connection between the process and the zookeeper server is established, and all configuration information in the shared memory is monitored by the process, so that the zookeeper server changes when the configuration information changes. Sending an update configuration information notification to the process;
  • Step 202 The process obtains corresponding configuration information from the zookeeper server and updates to the local disk and the shared memory according to the received update configuration information notification, so that the process of the configuration information to be read is from the shared memory and the local
  • the process of searching for the corresponding configuration information on the disk, if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the shared memory; if the corresponding configuration information is not found, the The process of reading the configuration information establishes a short connection with the zookeeper server, and obtains the corresponding configuration information from the zookeeper server and stores it in the shared memory and the local disk.
  • any of the processes in the server needs to be run, you need to obtain the configuration information.
  • the configuration information of the process is saved on the local disk while being saved in the shared memory. Therefore, the configuration information saved in the local disk and the shared memory is the same. Just look at any of them, but consider that the data in the shared memory may be lost for some reason, and the data on the local disk is generally persistent and not easily lost. Therefore, the way to store the configuration information on the local disk ensures the reliability of the configuration information.
  • the way to store the configuration information in the shared memory ensures the operating rate of the system and improves system performance. Therefore, both shared memory and local disks are viewed to avoid information viewing omissions.
  • the configuration information is stored in the local disk
  • the configuration information is further stored in the shared memory, and the process reads the data from the shared memory at a slower speed. It is much faster than reading data from a local disk, so the rate of process configuration information is increased by reading the corresponding configuration information from the shared memory.
  • FIG. 3 shows an information configuration framework of the zookeeper based on the embodiment of the present invention.
  • a web server usually runs 128 fast page mode (English short page mode, abbreviated as fpm) process to provide services.
  • a process is started to occupy the lock between processes, and a process is established between the process and the zookeeper server.
  • the process according to the update configuration information notification to obtain configuration information from the zookeeper server, and update to the local disk and shared memory, when any process in the web server needs to obtain configuration information, directly from the share
  • the corresponding configuration information is found in the memory. If the configuration information is found, the configuration information is directly obtained.
  • the short connection is established with the zookeeper server, the corresponding configuration information is obtained and stored in the local disk and the shared memory. It can be seen that the entire web server only needs to establish a long connection with the zookeeper server and establish a short connection when the configuration information is first acquired, so that the configuration information of all processes can be monitored and updated in time.
  • FIG. 4 shows a prior art zookeeper-based information configuration framework.
  • Each process in the web server must establish a long connection with the zookeeper server, as compared to the embodiment of the present invention.
  • the zookeeper-based information configuration method can greatly reduce the long connection with the zookeeper, thereby reducing the load of the zookeeper server while ensuring that all process configuration information in the server is monitored.
  • the configuration information used by the process is updated and saved in time, reducing the load on the zookeeper server.
  • the configuration information is stored in the shared memory, so that the process of the configuration information to be read obtains the configuration information corresponding to the configuration through the shared memory, thereby improving the rate of obtaining the configuration information, thereby improving the processing performance of the server.
  • the embodiment of the present invention further provides a zookeeper-based information configuration device.
  • FIG. 5 is a schematic diagram of Embodiment 1 of a zookeeper-based information configuration apparatus according to an embodiment of the present invention.
  • the apparatus includes: a monitoring unit 301 and an updating unit 302, which are further introduced below in conjunction with the working principle of the apparatus. Internal structure and connection relationship.
  • the monitoring unit 301 is configured to start a process to occupy a lock between processes, and establish the process and a long connection between the zookeeper servers, wherein all the configuration information in the local disk is monitored by the process, so that the zookeeper server sends an update configuration information notification to the process when the configuration information changes;
  • the updating unit 302 is configured to notify, according to the update configuration information, that the corresponding configuration information is obtained from the zookeeper server and updated to the local disk, so that the process of the configuration information to be read searches for the self from the local disk.
  • Corresponding configuration information if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the configuration information to be read The process establishes a short connection with the zookeeper server, and obtains its corresponding configuration information from the zookeeper server and stores it on the local disk.
  • the monitoring unit includes:
  • the first possession sub-unit for starting a process dedicated to monitoring process configuration information to occupy an inter-process lock
  • the first monitoring subunit is configured to establish a long connection between the process dedicated to monitoring process configuration information and the zookeeper server, and monitor all configuration information in the local disk by using the process of monitoring the configuration information.
  • the monitoring unit includes:
  • a second monitoring subunit configured to start a thread or a process in the process of the configuration information to be read, establish a long connection between the thread or the process and the zookeeper server, by using the thread or the The process monitors all configuration information on the local disk.
  • the second monitoring sub-unit is configured to start an asynchronous thread in the process of the configuration information to be read, and establish a long connection between the asynchronous process and the zookeeper server, by using the asynchronous thread Monitor configuration information of all processes in the interprocess communication.
  • each server does not need to establish a long connection between each process and the zookeeper server, but uses the lock between the process and the local disk to establish only one process and the zookeeper server.
  • the long connection between the two, and the use of the initial short connection method can ensure that the configuration information of all processes are monitored while reducing the load of the zookeeper server.
  • the embodiment of the present invention further provides a zookeeper-based information configuration device.
  • FIG. 6 is a schematic diagram of Embodiment 2 of a ZooKeeper-based information configuration apparatus according to an embodiment of the present invention.
  • the apparatus includes: a monitoring unit 401, an update unit 402, and a storage unit 403, and the following works in conjunction with the apparatus.
  • the principle further introduces its internal structure and connection relationship.
  • the monitoring unit 401 is configured to start a process to occupy a lock between processes, and establish a long connection between the process and the zookeeper server, and monitor all configuration information in the local disk by using the process, so that the zookeeper server is configured. When the information changes, the update configuration information notification is sent to the process;
  • the updating unit 402 is configured to, according to the update configuration information, obtain the corresponding configuration information from the zookeeper server and update to the local disk, so that the process of the configuration information to be read searches for the self from the local disk.
  • Corresponding configuration information if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the configuration information to be read The process establishes a short connection with the zookeeper server, and obtains its corresponding configuration information from the zookeeper server and stores it on the local disk;
  • the storage unit 403 is configured to update the configuration information to the local disk or to be stored in the shared memory, so that the process of the configuration information to be read reads the corresponding information from the shared memory. Configuration information.
  • the embodiment adds a storage unit for updating or storing the configuration information to the local disk, and also updating or Save to shared memory.
  • the processing is such that the configuration information of all the processes is also saved in the shared memory, so that the process of the configuration information to be read reads the configuration information corresponding to the shared memory from the shared memory.
  • the process By starting a process to occupy the lock between processes and establishing a long connection between the process and the zookeeper server, it is ensured that the configuration information used by the process is updated and saved in time, reducing the load on the zookeeper server.
  • the process obtains the configuration information through the shared memory, thereby improving the rate at which the configuration information is obtained, thereby improving the processing performance of the server.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some or all of the components of the zookeeper-based information configuration apparatus in accordance with embodiments of the present invention.
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
  • FIG. 7 illustrates a server, such as an application server, that can implement a zookeeper-based information configuration method in accordance with the present invention.
  • the application server traditionally includes a processor 710 and a computer program product or computer readable medium in the form of a memory 720.
  • Memory 720 can be an electronic memory such as a flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • Memory 720 has a memory space 730 for program code 731 for performing any of the method steps described above.
  • storage space 730 for program code may include various program code 731 for implementing various steps in the above methods, respectively.
  • the program code can be read from or written to one or more computer program products.
  • These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
  • Such computer program products are typically portable or fixed storage units as described in FIG.
  • the storage unit may have a storage section, a storage space, and the like arranged similarly to the storage 720 in the application server of FIG.
  • the program code can be compressed, for example, in an appropriate form.
  • the storage unit includes computer readable code 831', code that can be read by a processor, such as 810, for example.
  • the server is caused to perform the various steps in the methods described above.

Abstract

Provided are a zookeeper-based information configuration method and device. The method comprises: occupying a lock between processes by way of starting a process, establishing a long-term connection between the process and a zookeeper server, and monitoring all configuration information on a local disk via the process, so that a process of reading configuration information only requires searching for configuration information corresponding thereto from the local disk; if corresponding configuration information is found, reading, by the process of reading the configuration information, configuration information corresponding thereto from the local disk; and if corresponding configuration information is not found, establishing, by the process of reading the configuration information, a short-term connection with a zookeeper server, and acquiring configuration information corresponding thereto from the zookeeper server and storing same on the local disk. The method and device of the present invention can reduce the load of a zookeeper server.

Description

一种基于zookeeper的信息配置方法及装置Zookeeper-based information configuration method and device 技术领域Technical field
本发明涉及计算机技术领域,具体涉及一种基于zookeeper的信息配置方法及装置。The present invention relates to the field of computer technology, and in particular, to a zookeeper-based information configuration method and apparatus.
背景技术Background technique
随着计算机技术的不断发展,在网络应用中通常采用分布式系统,利用多台服务器一起提供服务,每个服务器都有上百个进程,这些服务器的进程配置通常都是一样的,当某一个进程配置需要修改时,必须对所有的服务器中该进程配置都进行修改。With the continuous development of computer technology, distributed systems are usually used in network applications. Multiple servers are used to provide services. Each server has hundreds of processes. The process configuration of these servers is usually the same. When the process configuration needs to be modified, the process configuration must be modified for all servers.
目前常利用zookeeper对多台服务器中的所有进程配置信息进行集中管理。zookeeper顾名思义动物园管理员,在计算机技术领域中zookeeper是一个针对大型分布式系统的可靠协调系统,提供的功能包括:配置维护、名字服务、分布式同步、组服务等。现有的基于zookeeper的信息配置方案是:每个服务器中每个进程都要建立与zookeeper服务器之间的长连接,每个进程通过调用zookeeper服务器的接口监控自身进程的配置信息,当某一个进程的配置信息需要修改时,操作人员只需要修改zookeeper服务器上相应的配置信息,一旦发现zookeeper服务器的配置信息发生变动,对应的服务器进程会根据zookeeper服务器上修改过的配置信息及时更新自身进程的配置信息。At present, zookeeper is often used to centrally manage all process configuration information in multiple servers. Zookeeper, as the name suggests, zookeeper, in the field of computer technology, zookeeper is a reliable coordination system for large-scale distributed systems, providing functions such as configuration maintenance, name service, distributed synchronization, group service and so on. The existing zookeeper-based information configuration scheme is: each process in each server must establish a long connection with the zookeeper server, and each process monitors the configuration information of its own process by calling the interface of the zookeeper server, when a certain process When the configuration information needs to be modified, the operator only needs to modify the corresponding configuration information on the zookeeper server. Once the configuration information of the zookeeper server is changed, the corresponding server process updates the configuration of the process according to the modified configuration information on the zookeeper server. information.
由于在实际应用中常常是上百台服务器共同服务,每个服务器通常至少运行上百个进程,比如:若有100个服务器一起提供服务,每个服务器上运行200个进程时,每个服务器中的每个进程都与zookeeper服务器建立一个长连接,共需要建立20000个连接,可见这种配置方式给zookeeper服务器带来较大的负载,严重影响zookeeper服务器的处理性能。Since in practice, there are often hundreds of servers serving together, each server usually runs at least hundreds of processes, for example, if there are 100 servers providing services together, and each server runs 200 processes, each server Each process establishes a long connection with the zookeeper server. A total of 20,000 connections need to be established. This configuration method imposes a large load on the zookeeper server and seriously affects the processing performance of the zookeeper server.
发明内容Summary of the invention
鉴于上述问题,提出了一种基于zookeeper的信息配置方法及装置,用以保证服务器中所有进程配置信息得到监控的同时有效地降低zookeeper服务器的负载。In view of the above problems, a zookeeper-based information configuration method and device are proposed to ensure that all process configuration information in the server is monitored while effectively reducing the load of the zookeeper server.
根据本发明的第一方面,提供了一种基于zookeeper的信息配置方法,其包 括:According to a first aspect of the present invention, a zookeeper-based information configuration method is provided, the package include:
启动一个进程占有进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有配置信息,以使所述zookeeper服务器在配置信息发生变动时,向所述进程发送更新配置信息通知;以及Initiating a process to occupy a lock between processes and establishing a long connection between the process and the zookeeper server, and monitoring all configuration information on the local disk through the process, so that the zookeeper server changes the configuration information when the configuration information is changed. The process sends an update configuration information notification;
所述进程根据接收到的更新配置信息通知,从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘中,以使待读取配置信息的进程从本地磁盘中查找自身对应的配置信息,若查找到对应的配置信息,所述待读取配置信息的进程从本地磁盘中读取自身对应的配置信息;若没有查找到对应的配置信息,所述待读取配置信息的进程建立与zookeeper服务器之间的短连接,并从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘。The process obtains the corresponding configuration information from the zookeeper server and updates the configuration information to the local disk according to the received update configuration information notification, so that the process of the configuration information to be read searches for the corresponding configuration information from the local disk. If the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the process of the configuration information to be read is established and zookeeper A short connection between the servers, and obtaining the corresponding configuration information from the zookeeper server and storing it on the local disk.
根据本发明的第二方面,提供了一种基于zookeeper的信息配置装置,所述装置包括:According to a second aspect of the present invention, there is provided a zookeeper-based information configuration apparatus, the apparatus comprising:
监控单元,用于启动一个进程占有进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,并通过所述进程监控本地磁盘中所有的配置信息,以使所述zookeeper服务器在配置信息发生变动时,向所述进程发送更新配置信息通知;以及a monitoring unit, configured to start a process to occupy a lock between processes, establish a long connection between the process and the zookeeper server, and monitor all configuration information in the local disk by using the process, so that the zookeeper server is configured Sending an update configuration information notification to the process when the information changes;
更新单元,用于通过所述进程根据所述更新配置信息通知从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘中,以使待读取配置信息的进程从本地磁盘中查找自身对应的配置信息,若查找到对应的配置信息,所述待读取配置信息的进程从本地磁盘中读取自身对应的配置信息;若没有查找到对应的配置信息,所述待读取配置信息的进程建立与zookeeper服务器之间的短连接,并从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘。And an update unit, configured to, according to the update configuration information, obtain the corresponding configuration information from the zookeeper server and update to the local disk, so that the process of the configuration information to be read searches for the corresponding information from the local disk. The configuration information, if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the configuration information to be read The process establishes a short connection with the zookeeper server, and obtains its corresponding configuration information from the zookeeper server and stores it on the local disk.
根据本发明的又一个方面,提供了一种计算机程序,其包括计算机可读代码,当所述计算机可读代码在服务器上运行时,导致所述服务器执行前项所述的基于zookeeper的信息配置方法。According to still another aspect of the present invention, a computer program is provided, comprising computer readable code that, when executed on a server, causes the server to perform zookeeper-based information configuration as described in the preceding paragraph method.
根据本发明的再一个方面,提供了一种计算机可读介质,其中存储了前项所述的计算机程序。According to still another aspect of the present invention, a computer readable medium storing the computer program described in the preceding paragraph is provided.
由上述实施例可以看出,与现有技术相比,本发明的有益效果在于:It can be seen from the above embodiments that the advantages of the present invention are compared with the prior art:
通过启动一个进程占用进程间的锁,使得该进程对共享数据的修改的时间段内其他进程无法对该共享数据进行任何操作,且该进程对共享数据的操作其他进程都能够立刻知道,建立该进程与zookeeper服务器之间的长连接,通过该 进程监控本地磁盘中所有的配置信息。By starting a process that occupies a lock between processes, other processes in the process of modifying the shared data cannot perform any operation on the shared data, and the process can immediately know the operation of the shared data, and establish the Long connection between the process and the zookeeper server, through The process monitors all configuration information on the local disk.
根据接收到zookeeper服务器发出的更新配置信息的通知,所述进程从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘中,任意一个进程运行需要获取配置信息时,只需要去本地磁盘查找自身对应的配置信息,而无需再与zookeeper服务器之间建立长连接;若本地磁盘中没有对应的配置信息,说明该进程的相关配置信息还没有被监控,这种情况下只需与zookeeper服务器之间的建立一个短连接,从所述zookeeper服务器中获取自身配置信息并储存在本地磁盘,以使该进程的配置信息也得到监控,由于已经与zookeeper服务器之间建立了长连接的用于监控本地磁盘中所有配置信息的进程会实时或者定期扫描本地磁盘,当扫描到本地磁盘中存在该进程的配置信息,将对该进程的配置信息也进行监控,以保证实时更新该进程的配置信息。由此可见:利用本发明的方法每个服务器不需要建立每个进程与zookeeper服务器之间的长连接,而是通过利用一个进程占有进程间的锁和本地磁盘的共享,只建立一个进程与zookeeper服务器之间的长连接和最初时的短连接的方式即可保证所有进程的配置信息都得到监控,同时降低zookeeper服务器的负载。According to the notification of the update configuration information sent by the zookeeper server, the process obtains the corresponding configuration information from the zookeeper server and updates to the local disk. When any process needs to obtain the configuration information, only the local disk search is required. Corresponding configuration information, no need to establish a long connection with the zookeeper server; if there is no corresponding configuration information on the local disk, the related configuration information of the process has not been monitored. In this case, only the zookeeper server is required. Establish a short connection, obtain the configuration information from the zookeeper server and store it on the local disk, so that the configuration information of the process is also monitored, because a long connection has been established with the zookeeper server for monitoring the local The process of all the configuration information on the disk scans the local disk in real time or periodically. When the configuration information of the process exists in the local disk, the configuration information of the process is also monitored to ensure that the configuration information of the process is updated in real time. It can be seen that by using the method of the present invention, each server does not need to establish a long connection between each process and the zookeeper server, but only establishes a process and zookeeper by utilizing a process to occupy the lock between the process and the local disk. The long connection between the servers and the initial short connection ensure that the configuration information of all processes is monitored and the load of the zookeeper server is reduced.
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solutions of the present invention, and the above-described and other objects, features and advantages of the present invention can be more clearly understood. Specific embodiments of the invention are set forth below.
附图说明DRAWINGS
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those skilled in the art from a The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting. Throughout the drawings, the same reference numerals are used to refer to the same parts. In the drawing:
图1是本发明实施例一种基于zookeeper的信息配置方法实施例1的流程图;1 is a flowchart of Embodiment 1 of a zookeeper-based information configuration method according to an embodiment of the present invention;
图2是本发明实施例一种基于zookeeper的信息配置方法实施例2的流程图;2 is a flowchart of Embodiment 2 of a zookeeper-based information configuration method according to an embodiment of the present invention;
图3是本发明实施例一种基于zookeeper的信息配置框架图;FIG. 3 is a schematic diagram of an information configuration framework based on zookeeper according to an embodiment of the present invention; FIG.
图4是现有技术的基于zookeeper的信息配置框架图;4 is a prior art zookeeper-based information configuration framework diagram;
图5是本发明实施例一种基于zookeeper的信息配置装置实施例1的示意图;FIG. 5 is a schematic diagram of Embodiment 1 of an information configuration apparatus based on ZooKeeper according to an embodiment of the present invention; FIG.
图6是本发明实施例一种基于zookeeper的信息配置装置实施例2的示意图;6 is a schematic diagram of Embodiment 2 of an information configuration apparatus based on ZooKeeper according to an embodiment of the present invention;
图7示出了用于执行根据本发明的方法的应用服务器的框图;以及 Figure 7 shows a block diagram of an application server for performing the method according to the invention;
图8示出了用于保持或者携带实现根据本发明的方法的程序代码的存储单元。Figure 8 shows a storage unit for holding or carrying program code implementing the method according to the invention.
附图实施例BRIEF DESCRIPTION OF THE DRAWINGS
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the embodiments of the present invention have been shown in the drawings, the embodiments Rather, these embodiments are provided so that this disclosure will be more fully understood and the scope of the disclosure will be fully disclosed.
请参考图1,其示出了本发明实施例一种基于zookeeper的信息配置方法实施例1的流程图,所述方法包括步骤101和步骤102:Please refer to FIG. 1 , which is a flowchart of Embodiment 1 of a zookeeper-based information configuration method according to an embodiment of the present invention. The method includes Step 101 and Step 102:
步骤101,启动一个进程占有进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有配置信息,以使所述zookeeper服务器在配置信息发生变动时,向所述进程发送更新配置信息通知。Step 101: Start a process to occupy a lock between processes, and establish a long connection between the process and the zookeeper server, and monitor all configuration information in the local disk through the process, so that the zookeeper server changes when the configuration information changes. Sending an update configuration information notification to the process.
进程是操作系统结构的基础,是一个正在执行的程序,服务器中任意一个进程启动运行时,都需要先读取配置信息,然后按照配置进行程序流程处理。A process is the basis of the operating system structure. It is a program that is being executed. When any process in the server starts running, it needs to read the configuration information first, and then process the program according to the configuration.
本发明实施例中启动一个进程占有进程间的锁是为了实现服务器中多个进程之间共享资源,一个进程对共享数据的修改的时候,其他进程无法在同一时间对共享数据进行操作,任何一个进程对共享数据进行操作,其他进程能够立刻看到。为了实现这个目的,需要服务器系统内核提供锁,这种锁的具体实现方式是:文件锁(记录锁)、System V信号量锁(信号灯)、互斥锁、条件变量、读写锁等。文件锁、信号量锁一般用于进程间的同步,互斥锁、条件变量、读写锁一般用于线程间的同步,具体根据实际的情况决定,在此并不做具体限定。In the embodiment of the present invention, a process is started to occupy a lock between processes in order to realize sharing of resources between multiple processes in a server. When a process modifies shared data, other processes cannot operate on shared data at the same time, any one. Processes operate on shared data, and other processes can see it immediately. In order to achieve this, the server system kernel is required to provide locks. The specific implementation of such locks is: file lock (record lock), System V semaphore lock (signal light), mutex lock, condition variables, read-write locks, and so on. File locks and semaphore locks are generally used for synchronization between processes. Mutexes, condition variables, and read-write locks are generally used for synchronization between threads, and are determined according to actual conditions, and are not specifically limited herein.
本步骤中启动一个进程占用进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有的配置信息,具体有两种实现方式,下面分别对这两种实现方式进行解释说明。In this step, a process is started to occupy the lock between the processes, and a long connection between the process and the zookeeper server is established, and all the configuration information on the local disk is monitored by the process. Specifically, there are two implementation manners. Two implementations are explained.
第一种实现方式,可以包括:The first implementation manner may include:
启动一个专用于监控进程配置信息的进程占有进程间的锁;以及Start a process dedicated to monitoring process configuration information to occupy locks between processes;
建立所述专用于监控进程配置信息的进程与zookeeper服务器之间的长连接,通过所述专用于监控进程配置信息的进程监控本地磁盘中所有的配置信息。A long connection between the process dedicated to monitoring process configuration information and the zookeeper server is established, and all configuration information in the local disk is monitored by the process dedicated to monitoring process configuration information.
服务器启动一个专用于监控进程配置信息的进程,该进程只用于监控服务器中所有进程的配置信息。该进程占有进程间的锁就实现所有进程间的同步, 锁的实际功能是当专用于监控进程配置信息的进程对本地磁盘中数据进行写入操作时,其他进程不能对该本地磁盘的数据进行任何操作,同样,当其他进程从本地磁盘中读取数据时,专用于监控进程配置信息的进程也不能对本地磁盘进行任何操作,因此通过占有进程间的锁来保证所有进程对本地磁盘操作的互不干扰。The server starts a process dedicated to monitoring process configuration information. This process is only used to monitor the configuration information of all processes in the server. The process occupies a lock between processes to achieve synchronization between all processes. The actual function of the lock is that when a process dedicated to monitoring process configuration information writes data to the local disk, other processes cannot perform any operations on the data of the local disk. Similarly, when other processes read data from the local disk. Processes that are dedicated to monitoring process configuration information cannot perform any operations on the local disk. Therefore, by occupying inter-process locks, all processes do not interfere with local disk operations.
第二种实现方式,可以包括:The second implementation manner may include:
启动所述待读取配置信息的进程占有进程间的锁;以及The process of starting the configuration information to be read occupies a lock between processes;
在所述待读取配置信息的进程中启动一个线程或者一个进程,建立所述线程或者所述进程与zookeeper服务器之间的长连接,通过所述线程或者所述进程监控本地磁盘中所有的配置信息。Starting a thread or a process in the process of the configuration information to be read, establishing a long connection between the thread or the process and the zookeeper server, and monitoring all configurations in the local disk by the thread or the process information.
当服务器中一个进程需要读取配置信息时,利用这个待读取配置信息的进程占有进程间的锁,这个锁的具体作用和上面的功能一样,在此不再赘述。When a process in the server needs to read the configuration information, the process that uses the configuration information to be read occupies the lock between the processes. The specific function of the lock is the same as the above function, and will not be described here.
所述待读取配置信息的进程可以启动一个线程与zookeeper服务器之间的长连接,并通过该线程监控本地磁盘中所有的配置信息;也可以是,所述待读取配置信息的进程启动一个进程与zookeeper服务器之间的长连接,并通过该进程监控本地磁盘中所有的配置信息。The process of the configuration information to be read may start a long connection between a thread and a zookeeper server, and monitor all configuration information in the local disk through the thread; or, the process of the configuration information to be read starts a A long connection between the process and the zookeeper server, and through this process to monitor all configuration information on the local disk.
为了不影响进程的主流程执行速率,不浪费系统资源,本发明实施例还提供了一种优选方案。In order to not affect the main process execution rate of the process, and the system resources are not wasted, the embodiment of the present invention further provides a preferred solution.
作为本发明实施例一种优选方案,所述待读取配置信息的进程启动的一个线程可以为异步线程。As a preferred solution of the embodiment of the present invention, a thread started by the process of the configuration information to be read may be an asynchronous thread.
由于进程与zookeeper服务器之间保持着长连接,当操作人员需要修改配置时,只需要修改zookeeper服务器上的对应的配置信息即可,当zookeeper服务器中监控的配置信息发生变动时,就会立刻向所述进程发出更新配置信息通知。Because the process maintains a long connection with the zookeeper server, when the operator needs to modify the configuration, only the corresponding configuration information on the zookeeper server needs to be modified. When the configuration information monitored in the zookeeper server changes, it will immediately The process issues an update configuration information notification.
步骤102,所述进程根据接收到的更新配置信息通知,从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘中,以使待读取配置信息的进程从本地磁盘中查找自身对应的配置信息,若查找到对应的配置信息,所述待读取配置信息的进程从本地磁盘中读取自身对应的配置信息;若没有查找到对应的配置信息,所述待读取配置信息的进程建立与zookeeper服务器之间的短连接,并从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘。Step 102: The process obtains corresponding configuration information from the zookeeper server and updates it to the local disk according to the received update configuration information notification, so that the process of the configuration information to be read searches for the corresponding one from the local disk. The configuration information, if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the process of the configuration information to be read Establish a short connection with the zookeeper server, and obtain the corresponding configuration information from the zookeeper server and store it on the local disk.
根据所述更新配置信息通知从zookeeper服务器中获取配置信息并更新到本地磁盘中,保证本地磁盘中储存的是最新的配置信息,以使任意一个进程从所 述本地磁盘读取对应的配置信息都是最新的配置信息,确保配置信息的实时更新,以保证服务器中各个进程正确执行。According to the update configuration information, the configuration information is obtained from the zookeeper server and updated to the local disk, so that the latest configuration information is stored in the local disk, so that any process can be The configuration information corresponding to the local disk read is the latest configuration information, ensuring real-time update of the configuration information to ensure that each process in the server is correctly executed.
当服务器中有进程需要运行,必须先读取自身配置信息,且只需要从本地磁盘中查找自身对应的配置信息。When a process needs to be run on the server, you must first read its own configuration information and only need to find its own configuration information from the local disk.
当没有查找到对应的配置信息时,说明当前待读取配置信息的进程的配置信息还没有被监控,因此,需要当前待读取配置信息的进程建立与zookeeper服务器之间的短连接,从所述zookeeper服务器中获取自身对应的配置信息,并储存在本地磁盘中。When the corresponding configuration information is not found, the configuration information of the current process to be read configuration information has not been monitored. Therefore, the process of the current configuration information to be read needs to establish a short connection with the zookeeper server. The zookeeper server obtains its corresponding configuration information and stores it on the local disk.
所谓短连接是与长连接相对的两种连接方式,短连接的操作步骤是:建立连接---数据传输---关闭连接。短连接的方式是在建立连接传输数据后立刻断开连接。长连接的操作步骤是:建立连接---数据传输---(一直保持连接)---数据传输----关闭连接。长连接的方式在建立连接传输数据后并不断开,这种通信连接关系一直存在。相比之下短连接方式能够节约服务器系统资源。The so-called short connection is two connection methods opposite to the long connection. The short connection operation steps are: establishing a connection---data transmission---closing the connection. The short connection method is to disconnect immediately after establishing the connection transmission data. The long connection is performed by: establishing a connection---data transfer---(always staying connected)---data transfer----closing the connection. The long connection method does not disconnect after establishing the connection transmission data, and this communication connection relationship always exists. In contrast, short connection methods can save server system resources.
与zookeeper服务器建立长连接的进程会扫描本地磁盘,当发现本地磁盘中有新的进程的配置信息时(也就是本地磁盘中存在还未被监控的配置信息时),将该配置信息加入监控内容中,保证本地磁盘中所有进程的配置信息都能够及时得到监控,以实现实时更新所有进程的配置信息。The process of establishing a long connection with the zookeeper server scans the local disk. When it finds the configuration information of the new process in the local disk (that is, when there is configuration information that has not been monitored in the local disk), the configuration information is added to the monitoring content. Ensure that the configuration information of all processes on the local disk can be monitored in time to update the configuration information of all processes in real time.
由上述实施例可以看出,与现有技术相比,本发明的有益效果在于:It can be seen from the above embodiments that the advantages of the present invention are compared with the prior art:
通过启动一个进程占用进程间的锁,使得该进程对共享数据的修改的时间段内其他进程无法对该共享数据进行任何操作,且该进程对共享数据的操作其他进程都能够立刻知道,建立该进程与zookeeper服务器之间的长连接,该进程扫描本地磁盘,以监控本地磁盘中所有的配置信息。By starting a process that occupies a lock between processes, other processes in the process of modifying the shared data cannot perform any operation on the shared data, and the process can immediately know the operation of the shared data, and establish the A long connection between the process and the zookeeper server, which scans the local disk to monitor all configuration information on the local disk.
根据接收到的通知从所述zookeeper服务器中获取对应的配置信息,并更新到本地磁盘中,任意一个进程运行需要获取配置信息时,只需要去本地磁盘获取对应的配置信息,而无需再与zookeeper服务器之间建立长连接;若本地磁盘中没有对应的配置信息,说明该进程的相关配置信息还没有被监控,这种情况下该进程只需建立与zookeeper服务器之间的短连接,从所述zookeeper服务器中获取自身配置信息并储存在本地磁盘,以使该配置信息也得到监控。Obtain the corresponding configuration information from the zookeeper server according to the received notification, and update to the local disk. When any process needs to obtain the configuration information, only the local disk needs to be obtained to obtain the corresponding configuration information, and no need to cooperate with the zookeeper. A long connection is established between the servers; if there is no corresponding configuration information in the local disk, the related configuration information of the process has not been monitored. In this case, the process only needs to establish a short connection with the zookeeper server. The zookeeper server obtains its own configuration information and stores it on the local disk so that the configuration information is also monitored.
由此可见:依据本发明提供的方法,每个服务器不需要建立每个进程与zookeeper服务器之间的长连接,而是利用进程间的锁和本地磁盘的共享,只建立一个进程与zookeeper服务器之间的长连接,并利用最初时的短连接方式,就 能够保证所有进程的配置信息都得到监控,同时降低zookeeper服务器的负载。It can be seen that, according to the method provided by the present invention, each server does not need to establish a long connection between each process and the zookeeper server, but uses the lock between the process and the local disk to establish only one process and the zookeeper server. Long connection between the two, and using the short connection method at the beginning, It can ensure that the configuration information of all processes is monitored and the load of the zookeeper server is reduced.
上述基于zookeeper的信息配置方法实施例1中将配置信息储存在本地磁盘中,由于进程查看本地磁盘并从中获取自身对应的配置信息的处理速率低下,导致整个服务器的进程处理性能低下,因此,本发明还提供了一种优选方案。The configuration information of the above-mentioned zookeeper-based information configuration method is stored in the local disk. The process of viewing the local disk and obtaining the corresponding configuration information is inferior, resulting in low process performance of the entire server. The invention also provides a preferred solution.
请参考图2,其示出了本发明实施例一种基于zookeeper的信息配置方法实施例2的流程图,所述方法包括步骤201和步骤202:Referring to FIG. 2, a flowchart of Embodiment 2 of a zookeeper-based information configuration method according to an embodiment of the present invention is shown. The method includes Step 201 and Step 202:
步骤201,启动一个进程占有进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控共享内存中所有配置信息,以使所述zookeeper服务器在配置信息发生变动时,向所述进程发送更新配置信息通知;In step 201, a process is started to occupy the lock between the processes, and a long connection between the process and the zookeeper server is established, and all configuration information in the shared memory is monitored by the process, so that the zookeeper server changes when the configuration information changes. Sending an update configuration information notification to the process;
步骤202,所述进程根据接收到的更新配置信息通知,从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘和共享内存中,以使待读取配置信息的进程从共享内存和本地磁盘中查找自身对应的配置信息,若查找到对应的配置信息,所述待读取配置信息的进程从共享内存中读取自身对应的配置信息;若没有查找到对应的配置信息,所述待读取配置信息的进程建立与zookeeper服务器之间的短连接,并从所述zookeeper服务器中获取自身对应的配置信息并储存在共享内存和本地磁盘中。Step 202: The process obtains corresponding configuration information from the zookeeper server and updates to the local disk and the shared memory according to the received update configuration information notification, so that the process of the configuration information to be read is from the shared memory and the local The process of searching for the corresponding configuration information on the disk, if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the shared memory; if the corresponding configuration information is not found, the The process of reading the configuration information establishes a short connection with the zookeeper server, and obtains the corresponding configuration information from the zookeeper server and stores it in the shared memory and the local disk.
当服务器中的任意一个进程需要运行时需要先获取自身配置信息,首先查看共享内存中是否保存对应的配置信息,若没有,再查看本地磁盘中是否保存对应的配置信息,步骤202中可知任意一个进程的配置信息当保存在共享内存的同时都会保存在本地磁盘中,因此,本地磁盘和共享内存中所保存的配置信息是一致的。只需要查看其中任意一个即可,但是考虑到,共享内存中的数据可能由于某些原因造成数据丢失,而本地磁盘中的数据一般都是持久化保存的、不容易丢失。因此,将配置信息储存在本地磁盘的方式保证了配置信息的可靠性,将配置信息储存在共享内存的方式保证了系统的运行速率,提高系统性能。因此,在共享内存和本地磁盘都进行查看避免信息查看疏漏。If any of the processes in the server needs to be run, you need to obtain the configuration information. First, check whether the configuration information is saved in the shared memory. If not, check whether the corresponding configuration information is saved in the local disk. The configuration information of the process is saved on the local disk while being saved in the shared memory. Therefore, the configuration information saved in the local disk and the shared memory is the same. Just look at any of them, but consider that the data in the shared memory may be lost for some reason, and the data on the local disk is generally persistent and not easily lost. Therefore, the way to store the configuration information on the local disk ensures the reliability of the configuration information. The way to store the configuration information in the shared memory ensures the operating rate of the system and improves system performance. Therefore, both shared memory and local disks are viewed to avoid information viewing omissions.
与实施例1所不同的是,本实施例中在将所述配置信息储存在本地磁盘之后,还增加了将所述配置信息储存在共享内存,进程从共享内存中读取数据的速度要远远大于从本地磁盘中读取数据的速度,因此通过从共享内存中读取对应的配置信息,以提高进程配置信息的速率。 Different from the first embodiment, in the embodiment, after the configuration information is stored in the local disk, the configuration information is further stored in the shared memory, and the process reads the data from the shared memory at a slower speed. It is much faster than reading data from a local disk, so the rate of process configuration information is increased by reading the corresponding configuration information from the shared memory.
下面以web服务器为例对上述一种基于zookeeper的信息配置方法实施例2做进一步解释说明,具体请参考图3,其示出的是本发明实施例一种基于zookeeper的信息配置框架图。The following is a description of the above-mentioned example of the information configuration method of the zookeeper based on the web server. For details, please refer to FIG. 3, which shows an information configuration framework of the zookeeper based on the embodiment of the present invention.
一个web服务器通常运行128个快速页模式(英文fast page mode,缩写fpm)进程提供服务,按照上述步骤201和步骤202,启动一个进程占用进程间的锁,并建立一个进程与zookeeper服务器之间的长连接,然后所述进程根据所述更新配置信息通知从所述zookeeper服务器中获取配置信息,并更新至本地磁盘和共享内存中,当web服务器中任意一个进程需要获取配置信息时,直接从共享内存中查找对应的配置信息,若查找到,直接获取该配置信息;若没有通过建立与zookeeper服务器之间的短连接,以获取自身对应的配置信息,并储存在本地磁盘和共享内存中。可见,整个web服务器只需要与zookeeper服务器之间建立一个长连接和初次获取配置信息时建立的短连接,即可保证所有进程的配置信息得到监控和及时更新。A web server usually runs 128 fast page mode (English short page mode, abbreviated as fpm) process to provide services. According to step 201 and step 202 above, a process is started to occupy the lock between processes, and a process is established between the process and the zookeeper server. Long connection, then the process according to the update configuration information notification to obtain configuration information from the zookeeper server, and update to the local disk and shared memory, when any process in the web server needs to obtain configuration information, directly from the share The corresponding configuration information is found in the memory. If the configuration information is found, the configuration information is directly obtained. If the short connection is established with the zookeeper server, the corresponding configuration information is obtained and stored in the local disk and the shared memory. It can be seen that the entire web server only needs to establish a long connection with the zookeeper server and establish a short connection when the configuration information is first acquired, so that the configuration information of all processes can be monitored and updated in time.
请参考图4,其示出的是现有技术的基于zookeeper的信息配置框架图,web服务器中的每个进程都必须与zookeeper服务器之间建立一个长连接,相比之下本发明实施例提供的基于zookeeper的信息配置方法,能够大幅度减少与zookeeper之间的长连接,从而在保证服务器中所有进程配置信息得到监控的同时,降低zookeeper服务器的负载。Please refer to FIG. 4, which shows a prior art zookeeper-based information configuration framework. Each process in the web server must establish a long connection with the zookeeper server, as compared to the embodiment of the present invention. The zookeeper-based information configuration method can greatly reduce the long connection with the zookeeper, thereby reducing the load of the zookeeper server while ensuring that all process configuration information in the server is monitored.
由上述实施例可以看出,与现有技术相比,本发明的有益效果在于:It can be seen from the above embodiments that the advantages of the present invention are compared with the prior art:
通过启动一个进程占有进程间的锁,并建立该进程与zookeeper服务器之间的长连接,就能够保证进程运行所使用的配置信息及时得到更新保存,降低zookeeper服务器的负载。另外,通过将配置信息储存在共享内存中,以使待读取配置信息的进程通过共享内存获取自身对应的配置信息,提高获取配置信息的速率,进而提高服务器的处理性能。By starting a process to occupy the lock between processes and establishing a long connection between the process and the zookeeper server, it is ensured that the configuration information used by the process is updated and saved in time, reducing the load on the zookeeper server. In addition, the configuration information is stored in the shared memory, so that the process of the configuration information to be read obtains the configuration information corresponding to the configuration through the shared memory, thereby improving the rate of obtaining the configuration information, thereby improving the processing performance of the server.
与基于zookeeper的信息配置方法实施例1相对应,本发明实施例还提供了一种基于zookeeper的信息配置装置。Corresponding to the ZooKeeper-based information configuration method embodiment 1, the embodiment of the present invention further provides a zookeeper-based information configuration device.
请参考图5,其示出了本发明实施例一种基于zookeeper的信息配置装置实施例1的示意图,所述装置包括:监控单元301和更新单元302,下面结合该装置的工作原理进一步介绍其内部结构以及连接关系。Please refer to FIG. 5, which is a schematic diagram of Embodiment 1 of a zookeeper-based information configuration apparatus according to an embodiment of the present invention. The apparatus includes: a monitoring unit 301 and an updating unit 302, which are further introduced below in conjunction with the working principle of the apparatus. Internal structure and connection relationship.
监控单元301,用于启动一个进程占用进程间的锁,并建立所述进程与 zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有的配置信息,以使所述zookeeper服务器在配置信息发生变动时,向所述进程发送更新配置信息通知;以及The monitoring unit 301 is configured to start a process to occupy a lock between processes, and establish the process and a long connection between the zookeeper servers, wherein all the configuration information in the local disk is monitored by the process, so that the zookeeper server sends an update configuration information notification to the process when the configuration information changes;
更新单元302,用于通过所述进程根据所述更新配置信息通知从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘中,以使待读取配置信息的进程从本地磁盘中查找自身对应的配置信息,若查找到对应的配置信息,所述待读取配置信息的进程从本地磁盘中读取自身对应的配置信息;若没有查找到对应的配置信息,所述待读取配置信息的进程建立与zookeeper服务器之间的短连接,并从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘。The updating unit 302 is configured to notify, according to the update configuration information, that the corresponding configuration information is obtained from the zookeeper server and updated to the local disk, so that the process of the configuration information to be read searches for the self from the local disk. Corresponding configuration information, if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the configuration information to be read The process establishes a short connection with the zookeeper server, and obtains its corresponding configuration information from the zookeeper server and stores it on the local disk.
作为本发明一种优选方案,所述监控单元,包括:As a preferred solution of the present invention, the monitoring unit includes:
第一占有子单元,用于启动一个专用于监控进程配置信息的进程占有进程间的锁;以及The first possession sub-unit for starting a process dedicated to monitoring process configuration information to occupy an inter-process lock;
第一监控子单元,用于建立所述专用于监控进程配置信息的进程与zookeeper服务器之间的长连接,通过所述专用监控配置信息的进程监控本地磁盘中所有的配置信息。The first monitoring subunit is configured to establish a long connection between the process dedicated to monitoring process configuration information and the zookeeper server, and monitor all configuration information in the local disk by using the process of monitoring the configuration information.
作为本发明另一种优选方案,所述监控单元,包括:As another preferred solution of the present invention, the monitoring unit includes:
第二占有子单元,用于启动所述待读取配置信息的进程占有进程间的锁;以及a second occupant subunit, wherein the process for starting the configuration information to be read occupies a lock between processes;
第二监控子单元,用于在所述待读取配置信息的进程中启动一个线程或者一个进程,建立所述线程或者所述进程与zookeeper服务器之间的长连接,通过所述线程或者所述进程监控本地磁盘中所有的配置信息。a second monitoring subunit, configured to start a thread or a process in the process of the configuration information to be read, establish a long connection between the thread or the process and the zookeeper server, by using the thread or the The process monitors all configuration information on the local disk.
优选地,所述第二监控子单元,具体用于在所述待读取配置信息的进程中启动一个异步线程,建立所述异步进程与zookeeper服务器之间的一个长连接,通过所述异步线程监控所述进程间通信中所有进程的配置信息。Preferably, the second monitoring sub-unit is configured to start an asynchronous thread in the process of the configuration information to be read, and establish a long connection between the asynchronous process and the zookeeper server, by using the asynchronous thread Monitor configuration information of all processes in the interprocess communication.
由上述实施例可以看出,本发明的有益效果在于:As can be seen from the above embodiments, the beneficial effects of the present invention are:
通过启动一个进程占用进程间的锁,使得该进程对共享数据的修改的时间段内其他进程无法对该共享数据进行任何操作,且该进程对共享数据的操作其他进程都能够立刻知道,建立该进程与zookeeper服务器之间的长连接,该进程扫描本地磁盘,以监控本地磁盘中所有的配置信息。By starting a process that occupies a lock between processes, other processes in the process of modifying the shared data cannot perform any operation on the shared data, and the process can immediately know the operation of the shared data, and establish the A long connection between the process and the zookeeper server, which scans the local disk to monitor all configuration information on the local disk.
根据接收到的通知从所述zookeeper服务器中获取对应的配置信息,并更新 到本地磁盘中,任意一个进程运行需要获取配置信息时,只需要去本地磁盘获取对应的配置信息,而无需再与zookeeper服务器之间建立长连接;若本地磁盘中没有对应的配置信息,说明该进程的相关配置信息还没有被监控,这种情况下该进程只需建立与zookeeper服务器之间的短连接,从所述zookeeper服务器中获取自身配置信息并储存在本地磁盘,以使该配置信息也得到监控。Obtain corresponding configuration information from the zookeeper server according to the received notification, and update On the local disk, if you need to obtain the configuration information, you need to go to the local disk to obtain the corresponding configuration information. You do not need to establish a long connection with the zookeeper server. If there is no corresponding configuration information on the local disk, The configuration information about the process has not been monitored. In this case, the process only needs to establish a short connection with the zookeeper server, obtain the configuration information from the zookeeper server and store it on the local disk, so that the configuration information is also Get monitored.
由此可见:依据本发明提供的装置,每个服务器不需要建立每个进程与zookeeper服务器之间的长连接,而是利用进程间的锁和本地磁盘的共享,只建立一个进程与zookeeper服务器之间的长连接,并利用最初时的短连接方式,就能够保证所有进程的配置信息都得到监控的同时,降低zookeeper服务器的负载。It can be seen that, according to the device provided by the present invention, each server does not need to establish a long connection between each process and the zookeeper server, but uses the lock between the process and the local disk to establish only one process and the zookeeper server. The long connection between the two, and the use of the initial short connection method, can ensure that the configuration information of all processes are monitored while reducing the load of the zookeeper server.
与基于zookeeper的信息配置方法实施例2相对应,本发明实施例还提供了一种基于zookeeper的信息配置装置。Corresponding to the zookeeper-based information configuration method embodiment 2, the embodiment of the present invention further provides a zookeeper-based information configuration device.
请参考图6,其示出了本发明实施例一种基于zookeeper的信息配置装置实施例2的示意图,所述装置包括:监控单元401、更新单元402和储存单元403,下面结合该装置的工作原理进一步介绍其内部结构以及连接关系。Please refer to FIG. 6 , which is a schematic diagram of Embodiment 2 of a ZooKeeper-based information configuration apparatus according to an embodiment of the present invention. The apparatus includes: a monitoring unit 401, an update unit 402, and a storage unit 403, and the following works in conjunction with the apparatus. The principle further introduces its internal structure and connection relationship.
监控单元401,用于启动一个进程占用进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有的配置信息,以使所述zookeeper服务器在配置信息发生变动时,向所述进程发送更新配置信息通知;The monitoring unit 401 is configured to start a process to occupy a lock between processes, and establish a long connection between the process and the zookeeper server, and monitor all configuration information in the local disk by using the process, so that the zookeeper server is configured. When the information changes, the update configuration information notification is sent to the process;
更新单元402,用于通过所述进程根据所述更新配置信息通知从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘中,以使待读取配置信息的进程从本地磁盘中查找自身对应的配置信息,若查找到对应的配置信息,所述待读取配置信息的进程从本地磁盘中读取自身对应的配置信息;若没有查找到对应的配置信息,所述待读取配置信息的进程建立与zookeeper服务器之间的短连接,并从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘;以及The updating unit 402 is configured to, according to the update configuration information, obtain the corresponding configuration information from the zookeeper server and update to the local disk, so that the process of the configuration information to be read searches for the self from the local disk. Corresponding configuration information, if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the configuration information to be read The process establishes a short connection with the zookeeper server, and obtains its corresponding configuration information from the zookeeper server and stores it on the local disk;
储存单元403,用于将配置信息更新到本地磁盘或者储存在本地磁盘的同时,更新或者储存至共享内存中,以使所述待读取配置信息的进程从所述共享内存中读取自身对应的配置信息。The storage unit 403 is configured to update the configuration information to the local disk or to be stored in the shared memory, so that the process of the configuration information to be read reads the corresponding information from the shared memory. Configuration information.
与上述基于zookeeper的信息配置装置实施例1所不同的是,本实施例增加了储存单元,用于在将配置信息更新或者储存至本地磁盘的同时,还更新或者 储存至共享内存中。这样处理使得共享内存中同时也保存在所有进程的配置信息,以使所述待读取配置信息的进程从所述共享内存中读取自身对应的配置信息。Different from the above-described zookeeper-based information configuration device embodiment 1, the embodiment adds a storage unit for updating or storing the configuration information to the local disk, and also updating or Save to shared memory. The processing is such that the configuration information of all the processes is also saved in the shared memory, so that the process of the configuration information to be read reads the configuration information corresponding to the shared memory from the shared memory.
由上述实施例可以看出,与现有技术相比,本发明的有益效果在于:It can be seen from the above embodiments that the advantages of the present invention are compared with the prior art:
通过启动一个进程占有进程间的锁,并建立该进程与zookeeper服务器之间的长连接,就能够保证进程运行所使用的配置信息及时得到更新保存,降低zookeeper服务器的负载。另外,通过将配置信息储存在共享内存中,以使进程通过共享内存获取配置信息,提高获取配置信息的速率,进而提高服务器的处理性能。By starting a process to occupy the lock between processes and establishing a long connection between the process and the zookeeper server, it is ensured that the configuration information used by the process is updated and saved in time, reducing the load on the zookeeper server. In addition, by storing the configuration information in the shared memory, the process obtains the configuration information through the shared memory, thereby improving the rate at which the configuration information is obtained, thereby improving the processing performance of the server.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的基于zookeeper的信息配置装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the components of the zookeeper-based information configuration apparatus in accordance with embodiments of the present invention. The invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein. Such a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
例如,图7示出了可以实现根据本发明的基于zookeeper的信息配置方法的服务器,例如应用服务器。该应用服务器传统上包括处理器710和以存储器720形式的计算机程序产品或者计算机可读介质。存储器720可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器720具有用于执行上述方法中的任何方法步骤的程序代码731的存储空间730。例如,用于程序代码的存储空间730可以包括分别用于实现上面的方法中的各种步骤的各个程序代码731。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如图8所述的便携式或者固定存储单元。该存储单元可以具有与图7的应用服务器中的存储器720类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括计算机可读代码831’,即可以由例如诸如810之类的处理器读取的代码,这些代码 当由服务器运行时,导致该服务器执行上面所描述的方法中的各个步骤。For example, FIG. 7 illustrates a server, such as an application server, that can implement a zookeeper-based information configuration method in accordance with the present invention. The application server traditionally includes a processor 710 and a computer program product or computer readable medium in the form of a memory 720. Memory 720 can be an electronic memory such as a flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM. Memory 720 has a memory space 730 for program code 731 for performing any of the method steps described above. For example, storage space 730 for program code may include various program code 731 for implementing various steps in the above methods, respectively. The program code can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such computer program products are typically portable or fixed storage units as described in FIG. The storage unit may have a storage section, a storage space, and the like arranged similarly to the storage 720 in the application server of FIG. The program code can be compressed, for example, in an appropriate form. Typically, the storage unit includes computer readable code 831', code that can be read by a processor, such as 810, for example. When run by the server, the server is caused to perform the various steps in the methods described above.
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。"an embodiment," or "an embodiment," or "an embodiment," In addition, it is noted that the phrase "in one embodiment" is not necessarily referring to the same embodiment.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下被实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that the embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of the description.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包括”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It is to be noted that the above-described embodiments are illustrative of the invention and are not intended to be limiting, and that the invention may be devised without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as a limitation. The word 'comprising' does not exclude the presence of the elements or steps that are not recited in the claims. The word "a" or "an" The invention can be implemented by means of hardware comprising several distinct elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means can be embodied by the same hardware item. The use of the words first, second, and third does not indicate any order. These words can be interpreted as names.
此外,还应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。 In addition, it should be noted that the language used in the specification has been selected for the purpose of readability and teaching, and is not intended to be construed or limited. Therefore, many modifications and changes will be apparent to those skilled in the art without departing from the scope of the invention. The disclosure of the present invention is intended to be illustrative, and not restrictive, and the scope of the invention is defined by the appended claims.

Claims (12)

  1. 一种基于zookeeper的信息配置方法,其包括:A zookeeper-based information configuration method, which includes:
    启动一个进程占有进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有配置信息,以使所述zookeeper服务器在配置信息发生变动时,向所述进程发送更新配置信息通知;以及Initiating a process to occupy a lock between processes and establishing a long connection between the process and the zookeeper server, and monitoring all configuration information on the local disk through the process, so that the zookeeper server changes the configuration information when the configuration information is changed. The process sends an update configuration information notification;
    所述进程根据接收到的更新配置信息通知,从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘中,以使待读取配置信息的进程从本地磁盘中查找自身对应的配置信息,若查找到对应的配置信息,所述待读取配置信息的进程从本地磁盘中读取自身对应的配置信息,若没有查找到对应的配置信息,所述待读取配置信息的进程建立与zookeeper服务器之间的短连接,从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘。The process obtains the corresponding configuration information from the zookeeper server and updates the configuration information to the local disk according to the received update configuration information notification, so that the process of the configuration information to be read searches for the corresponding configuration information from the local disk. If the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk. If the corresponding configuration information is not found, the process of the configuration information to be read is established with the zookeeper. A short connection between the servers, obtaining the corresponding configuration information from the zookeeper server and storing it on the local disk.
  2. 根据权利要求1所述的方法,其中,在将所述对应的配置信息更新到本地磁盘中之后,所述方法还包括:The method of claim 1, wherein after updating the corresponding configuration information to a local disk, the method further comprises:
    将所述对应的配置信息更新到共享内存中,以使所述待读取配置信息的进程从所述共享内存中查找自身对应的配置信息,Updating the corresponding configuration information to the shared memory, so that the process of the configuration information to be read searches for the configuration information corresponding to the shared memory from the shared memory.
    则所述从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘的动作包括:And the act of obtaining the configuration information corresponding to the zookeeper server and storing the configuration information on the local disk includes:
    从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘和共享内存中。Obtain the corresponding configuration information from the zookeeper server and store it in the local disk and the shared memory.
  3. 根据权利要求1或2所述的方法,其中,所述启动一个进程占有进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有配置信息的动作,包括:The method according to claim 1 or 2, wherein said initiating a process occupies a lock between processes and establishing a long connection between said process and a zookeeper server, and monitoring all configuration information in the local disk through said process Actions, including:
    启动一个专用于监控进程配置信息的进程占有进程间的锁;以及Start a process dedicated to monitoring process configuration information to occupy locks between processes;
    建立所述专用于监控进程配置信息的进程与zookeeper服务器之间的长连接,通过所述专用监控配置信息的进程监控本地磁盘中所有的配置信息。A long connection between the process dedicated to monitoring process configuration information and the zookeeper server is established, and all configuration information on the local disk is monitored by the process of the dedicated monitoring configuration information.
  4. 根据权利要求1或2所述的方法,其中,所述启动一个进程占有进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有配置信息的动作,包括:The method according to claim 1 or 2, wherein said initiating a process occupies a lock between processes and establishing a long connection between said process and a zookeeper server, and monitoring all configuration information in the local disk through said process Actions, including:
    启动待读取配置信息的进程占有进程间的锁;以及The process that starts the configuration information to be read occupies the lock between processes;
    在所述待读取配置信息的进程中启动一个线程或者一个进程,建立所述线 程或者所述进程与zookeeper服务器之间的长连接,通过所述线程或者所述进程监控本地磁盘中所有的配置信息。Starting a thread or a process in the process of the configuration information to be read, establishing the line A long connection between the process and the zookeeper server, and the configuration information of the local disk is monitored by the thread or the process.
  5. 根据权利要求4所述的方法,其中,在所述待读取配置信息的进程中启动的一个线程为异步线程。The method of claim 4, wherein one thread initiated in the process of the configuration information to be read is an asynchronous thread.
  6. 一种基于zookeeper的信息配置装置,其包括:A zookeeper-based information configuration device, comprising:
    监控单元,用于启动一个进程占用进程间的锁,并建立所述进程与zookeeper服务器之间的长连接,通过所述进程监控本地磁盘中所有的配置信息,以使所述zookeeper服务器在配置信息发生变动时,向所述进程发送更新配置信息通知;以及a monitoring unit, configured to start a process to occupy a lock between processes, and establish a long connection between the process and the zookeeper server, and monitor all configuration information on the local disk by using the process, so that the zookeeper server is configured in the configuration information. When a change occurs, an update configuration information notification is sent to the process;
    更新单元,用于通过所述进程根据所述更新配置信息通知从所述zookeeper服务器中获取对应的配置信息并更新到本地磁盘中,以使待读取配置信息的进程从本地磁盘中查找自身对应的配置信息,若查找到对应的配置信息,所述待读取配置信息的进程从本地磁盘中读取自身对应的配置信息;若没有查找到对应的配置信息,所述待读取配置信息的进程建立与zookeeper服务器之间的短连接,并从所述zookeeper服务器中获取自身对应的配置信息并储存在本地磁盘。And an update unit, configured to, according to the update configuration information, obtain the corresponding configuration information from the zookeeper server and update to the local disk, so that the process of the configuration information to be read searches for the corresponding information from the local disk. The configuration information, if the corresponding configuration information is found, the process of the configuration information to be read reads the configuration information corresponding to the configuration from the local disk; if the corresponding configuration information is not found, the configuration information to be read The process establishes a short connection with the zookeeper server, and obtains its corresponding configuration information from the zookeeper server and stores it on the local disk.
  7. 根据权利要求6所述的装置,其中,所述装置还包括:The apparatus of claim 6 wherein said apparatus further comprises:
    储存单元,用于将配置信息更新或者储存至本地磁盘时,并更新或者储存至共享内存,以使所述待读取配置信息的进程从所述共享内存中查找自身对应的配置信息。And a storage unit, configured to update or store the configuration information to the local disk, and update or store the configuration information to the shared memory, so that the process of the configuration information to be read searches for the configuration information corresponding to the shared memory.
  8. 根据权利要求6或7所述的装置,其中,所述监控单元包括:The apparatus according to claim 6 or 7, wherein the monitoring unit comprises:
    第一占有子单元,用于启动一个专用于监控进程配置信息的进程占有进程间的锁;以及The first possession sub-unit for starting a process dedicated to monitoring process configuration information to occupy an inter-process lock;
    第一监控子单元,用于建立所述专用于监控进程配置信息的进程与zookeeper服务器之间的长连接,通过所述专用监控配置信息的进程监控本地磁盘中所有的配置信息。The first monitoring subunit is configured to establish a long connection between the process dedicated to monitoring process configuration information and the zookeeper server, and monitor all configuration information in the local disk by using the process of monitoring the configuration information.
  9. 根据权利要求6或7所述的装置,其中,所述监控单元包括:The apparatus according to claim 6 or 7, wherein the monitoring unit comprises:
    第二占有子单元,用于启动待读取配置信息的进程占有进程间的锁;以及The second occupant subunit, the process for starting the configuration information to be read occupies the lock between processes;
    第二监控子单元,用于在所述待读取配置信息的进程中启动一个线程或者一个进程,建立所述线程或者所述进程与zookeeper服务器之间的长连接,通过所述线程或者所述进程监控本地磁盘中所有的配置信息。a second monitoring subunit, configured to start a thread or a process in the process of the configuration information to be read, establish a long connection between the thread or the process and the zookeeper server, by using the thread or the The process monitors all configuration information on the local disk.
  10. 根据权利要求9所述的装置,其中,所述第二监控子单元,用于在所 述待读取配置信息的进程中启动一个异步线程,建立所述异步进程与zookeeper服务器之间的一个长连接,通过所述异步线程监控所述进程间通信中所有进程的配置信息。The apparatus according to claim 9, wherein said second monitoring subunit is used in An asynchronous thread is started in the process of reading the configuration information, and a long connection between the asynchronous process and the zookeeper server is established, and the configuration information of all processes in the inter-process communication is monitored by the asynchronous thread.
  11. 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行根据权利要求1至5中的任一个所述的方法。A computer program comprising computer readable code that, when executed on a computing device, causes the computing device to perform the method of any one of claims 1 to 5.
  12. 一种计算机可读介质,其中存储了如权利要求11所述的计算机程序。 A computer readable medium storing the computer program of claim 11.
PCT/CN2014/086653 2013-10-11 2014-09-16 Zookeeper-based information configuration method and device WO2015051690A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310472913.9 2013-10-11
CN201310472913.9A CN103500111B (en) 2013-10-11 2013-10-11 A kind of information configuring methods based on zookeeper and device

Publications (1)

Publication Number Publication Date
WO2015051690A1 true WO2015051690A1 (en) 2015-04-16

Family

ID=49865326

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/086653 WO2015051690A1 (en) 2013-10-11 2014-09-16 Zookeeper-based information configuration method and device

Country Status (2)

Country Link
CN (2) CN106371932B (en)
WO (1) WO2015051690A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107220897A (en) * 2017-05-24 2017-09-29 腾讯科技(深圳)有限公司 Treating method and apparatus and processing system that a kind of income keeps accounts
CN109714188A (en) * 2018-11-02 2019-05-03 中国平安人寿保险股份有限公司 Configuration data management method, equipment and storage medium based on Zookeeper

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106371932B (en) * 2013-10-11 2020-02-28 北京奇虎科技有限公司 Zookeeper-based information configuration method and device
CN105320527A (en) * 2014-06-12 2016-02-10 中兴通讯股份有限公司 Configuration file renewing method, device and system based on zookeeper distributed type search engine
CN105320515A (en) * 2014-07-31 2016-02-10 腾讯科技(深圳)有限公司 Configuration method, device and system in flow computing system
CN104468547B (en) * 2014-11-28 2019-03-15 北京奇安信科技有限公司 Establish the method, apparatus and system of long connection
CN104636135B (en) * 2014-12-31 2018-05-04 北京奇虎科技有限公司 A kind of node visit method and system, Client Agent and client
CN105897817A (en) * 2015-09-17 2016-08-24 乐视云计算有限公司 Method for communication between servers, server and communication system
CN106909456A (en) * 2015-12-22 2017-06-30 北京奇虎科技有限公司 A kind of information acquisition method and device
CN106909464A (en) * 2015-12-22 2017-06-30 北京奇虎科技有限公司 A kind of information synchronization method and device
CN105677404B (en) * 2015-12-31 2019-03-19 拉扎斯网络科技(上海)有限公司 A kind of configuration update method and device based on Zookeeper
CN106453501B (en) * 2016-09-09 2019-05-31 北京奇虎科技有限公司 A kind of method and apparatus of the configuration information of modification service
CN107819798B (en) * 2016-09-13 2021-08-06 阿里巴巴集团控股有限公司 Data acquisition method, foreground server and data acquisition system
CN106648648B (en) * 2016-12-14 2020-09-15 深圳中顺易金融服务有限公司 Zookeeper-based configuration management method and system
CN108874531B (en) * 2017-05-12 2021-08-03 北京京东尚科信息技术有限公司 Method, device and system for fusing service and electronic equipment
CN109525406A (en) * 2017-09-18 2019-03-26 飞狐信息技术(天津)有限公司 A kind of operation system configuration method and device
CN109976822B (en) * 2017-12-25 2022-04-08 天翼云科技有限公司 Configuration method and device of distributed application and distributed system
CN110134453B (en) * 2018-02-09 2022-07-08 网宿科技股份有限公司 Server configuration overloading method and server

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102710554A (en) * 2012-06-25 2012-10-03 深圳中兴网信科技有限公司 Distributed message system and service status detection method thereof
US20130103729A1 (en) * 2011-10-24 2013-04-25 Nokia Corporation Method and apparatus for providing a key-value based storage interface
CN103297456A (en) * 2012-02-24 2013-09-11 阿里巴巴集团控股有限公司 Method for accessing sharing resources in distributed system and distributed system
CN103500111A (en) * 2013-10-11 2014-01-08 北京奇虎科技有限公司 Information configuration method and device based on zookeeper

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9063939B2 (en) * 2011-11-03 2015-06-23 Zettaset, Inc. Distributed storage medium management for heterogeneous storage media in high availability clusters
CN102591934A (en) * 2011-12-23 2012-07-18 国网电力科学研究院 Zookeeper-based method for realizing automatic expansion and switching of multiple Solr Shards
CN103294701B (en) * 2012-02-24 2016-12-28 联想(北京)有限公司 A kind of method that distributed file system and data process
CN103034541B (en) * 2012-11-16 2016-09-28 北京奇虎科技有限公司 A kind of distributed information system and equipment therein and method
CN103034540B (en) * 2012-11-16 2016-05-04 北京奇虎科技有限公司 Distributed information system and equipment thereof and coordination approach
CN102982141B (en) * 2012-11-20 2016-01-20 北京搜狐新媒体信息技术有限公司 A kind of method and device realizing distributed data base agency
CN103092698B (en) * 2012-12-24 2017-06-13 中国科学院深圳先进技术研究院 Cloud computing application automatic deployment system and method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130103729A1 (en) * 2011-10-24 2013-04-25 Nokia Corporation Method and apparatus for providing a key-value based storage interface
CN103297456A (en) * 2012-02-24 2013-09-11 阿里巴巴集团控股有限公司 Method for accessing sharing resources in distributed system and distributed system
CN102710554A (en) * 2012-06-25 2012-10-03 深圳中兴网信科技有限公司 Distributed message system and service status detection method thereof
CN103500111A (en) * 2013-10-11 2014-01-08 北京奇虎科技有限公司 Information configuration method and device based on zookeeper

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107220897A (en) * 2017-05-24 2017-09-29 腾讯科技(深圳)有限公司 Treating method and apparatus and processing system that a kind of income keeps accounts
CN109714188A (en) * 2018-11-02 2019-05-03 中国平安人寿保险股份有限公司 Configuration data management method, equipment and storage medium based on Zookeeper

Also Published As

Publication number Publication date
CN106371932A (en) 2017-02-01
CN103500111A (en) 2014-01-08
CN106371932B (en) 2020-02-28
CN103500111B (en) 2016-09-28

Similar Documents

Publication Publication Date Title
WO2015051690A1 (en) Zookeeper-based information configuration method and device
US11550829B2 (en) Systems and methods for load balancing in a system providing dynamic indexer discovery
WO2016206600A1 (en) Information flow data processing method and device
CN110865888B (en) Resource loading method and device, server and storage medium
WO2020181810A1 (en) Data processing method and apparatus applied to multi-level caching in cluster
US8375200B2 (en) Embedded device and file change notification method of the embedded device
US20110088045A1 (en) Linking transactions
US20190372804A1 (en) Method and apparatus for operating smart network interface card
CN110019496B (en) Data reading and writing method and system
CN111597065B (en) Method and device for collecting equipment information
CN110929128A (en) Data crawling method, device, equipment and medium
US8316126B2 (en) Stitching transactions
CN110633046A (en) Storage method and device of distributed system, storage equipment and storage medium
CN110881224B (en) Network long connection method, device, equipment and storage medium
WO2016095644A1 (en) High availability solution method and device for database
CN113343312A (en) Page tamper-proofing method and system based on front-end point burying technology
CN110908644B (en) Configuration method and device of state node, computer equipment and storage medium
US20170324640A1 (en) Notifying original state listeners of events in a domain model
US9117013B2 (en) Combining monitoring techniques
CN109062602B (en) Data processing method and device for application program and electronic equipment
CN114201508A (en) Data processing method, data processing apparatus, electronic device, and storage medium
US20110087458A1 (en) Processing transaction timestamps
CN114780361A (en) Log generation method, device, computer system and readable storage medium
CN114168607A (en) Global serial number generation method, device, equipment, medium and product
CN113342759A (en) Content sharing method, device, equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14851529

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14851529

Country of ref document: EP

Kind code of ref document: A1