Summary of the invention
In view of this, the embodiment of the present invention provides the update method and device of a kind of configuration information, when being able to solve longer
The inconsistent problem of interior global configuration.
To achieve the above object, according to an aspect of an embodiment of the present invention, a kind of update side of configuration information is provided
Method is applied to update server, including:
Latest configuration information is sent to each application server, receives ready the disappearing of all application servers returns
Breath;
It is sent to each application server and prepares more new command, if receiving all application services in the first time-out time
The waiting update message that device returns then sends to each application server and submits instruction.
Optionally, the method also includes:
If not receiving the waiting update message that all application servers return in the first time-out time, answered to all
It is sent with server and cancels instruction.
In addition, other side according to an embodiment of the present invention, provides a kind of update method of configuration information, is applied to
Application server, including:
The latest configuration information that server is sent will be updated to be stored in local pre-updated buffer area, returned to server is updated
Ready message;
It receives and updates the preparation more new command that server is sent, start overtime monitoring thread, whether the second surpassed with monitoring
When the time it is inscribed receive the submission instruction or cancel instruction for updating that server is sent, suspend the local latest configuration information that obtains
Thread returns to waiting for update message to server is updated.
Optionally, the method also includes:
The submission instruction that server is sent is updated if receiving in the second time-out time, configuration is updated to local pre-
The latest configuration information in buffer area is updated, the local thread for obtaining latest configuration information is activated, destroys overtime monitoring thread, and
Message is finished to server return submission is updated;
The cancellation instruction that server is sent is updated if receiving in the second time-out time, activates local acquisition is newest to match
The thread of confidence breath destroys overtime monitoring thread, and returns to cancel to update server and finish message.
Optionally, the method also includes:
After returning to waiting for update message to update server, if not receiving update server in the second time-out time
The submission of transmission instructs or cancels instruction, then inquires latest configuration information in the database, updates local pre-updated buffer area
In configuration information, activate the local thread for obtaining latest configuration information, and destroy overtime monitoring thread.
In addition, other side according to an embodiment of the present invention, provides a kind of updating device of configuration information, setting exists
It updates in server, including:
Preparation module receives all application servers and returns for sending latest configuration information to each application server
Ready message;
Update module prepares more new command for sending to each application server, if receiving in the first time-out time
The waiting update message returned to all application servers, then send to each application server and submit instruction.
Optionally, the update module is also used to:
If not receiving the waiting update message that all application servers return in the first time-out time, answered to all
It is sent with server and cancels instruction.
In addition, other side according to an embodiment of the present invention, provides a kind of updating device of configuration information, setting exists
In application server, including:
Memory module, the latest configuration information for that will update server transmission are stored in local pre-updated buffer area, to
It updates server and returns to ready message;
Module is monitored, for receiving the preparation more new command for updating server and sending, starts overtime monitoring thread, to monitor
The submission instruction or cancel instruction for updating that server is sent whether are received in the second time-out time, suspend local obtain most
The thread of new configuration information returns to waiting for update message to server is updated.
Optionally, described device further includes submitting module, is used for:
The submission instruction that server is sent is updated if receiving in the second time-out time, configuration is updated to local pre-
The latest configuration information in buffer area is updated, the local thread for obtaining latest configuration information is activated, destroys overtime monitoring thread, and
Message is finished to server return submission is updated;
The cancellation instruction that server is sent is updated if receiving in the second time-out time, activates local acquisition is newest to match
The thread of confidence breath destroys overtime monitoring thread, and returns to cancel to update server and finish message.
Optionally, described device further includes enquiry module, is used for:
After returning to waiting for update message to update server, if not receiving update server in the second time-out time
The submission of transmission instructs or cancels instruction, then inquires latest configuration information in the database, updates local pre-updated buffer area
In configuration information, activate the local thread for obtaining latest configuration information, and destroy overtime monitoring thread.
In addition, other side according to an embodiment of the present invention, provides a kind of more new system of configuration information, including upper
Setting described in the updating device being arranged in described in any embodiment update in server and any of the above-described embodiment is stated to answer
With the updating device in server.
Other side according to an embodiment of the present invention additionally provides a kind of electronic equipment, including:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processing
Device realizes method described in any of the above-described embodiment.
Other side according to an embodiment of the present invention additionally provides a kind of computer-readable medium, is stored thereon with meter
Calculation machine program, realizes method described in any of the above-described embodiment when described program is executed by processor.
One embodiment in foregoing invention has the following advantages that or beneficial effect:Because by timeout mechanism, pull-mode and
The technological means that push-model combines, so overcoming the inconsistent technical problem of global configuration in the long period;The present invention be by
Timeout mechanism, pull-mode and push-model combine, and before guaranteeing at some time point, on application server used is all old configuration
Information, after some point in time, on all application servers is all latest configuration information.Therefore, the embodiment of the present invention mentions
The update method of the configuration information of confession can be under distributed environment, the configuration information of each application server of synchronized update, from
And achieve the purpose that global strong consistency.
Further effect possessed by above-mentioned non-usual optional way adds hereinafter in conjunction with specific embodiment
With explanation.
Specific embodiment
Below in conjunction with attached drawing, an exemplary embodiment of the present invention will be described, including the various of the embodiment of the present invention
Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize
It arrives, it can be with various changes and modifications are made to the embodiments described herein, without departing from scope and spirit of the present invention.Together
Sample, for clarity and conciseness, descriptions of well-known functions and structures are omitted from the following description.
Fig. 1 is the schematic diagram of the main flow of the update method of configuration information according to an embodiment of the present invention.Such as Fig. 1 institute
Show, as an embodiment of the present invention, is applied to update server, the update method of the configuration information may include:
Step 101, latest configuration information is sent to each application server, receives the preparation that all application servers return
Finish message.
In this step, it when some configuration needs to update, updates server and first looks for all applications under the configuration
Then server distributes the corresponding latest configuration information of the configuration to these servers.Optionally, distribution of configuration information it
Before, the method can also include:Reachability test is carried out to all application servers under the configuration, if any one is answered
Unreachable with server, then this updates failure, if all application servers are all up, to each application if updating server
Server distributes latest configuration information.
Application server returns to ready message, and to inform update server, I is ready for, and updates server and receives
The ready message that all application servers return, illustrates that all application servers are all ready for.It should be pointed out that such as
Fruit does not receive the ready message that all application servers return within the preset time, then this updates failure.
Step 102, it is sent to each application server and prepares more new command, if being received in the first time-out time all
The waiting update message that application server returns then sends to each application server and submits instruction.
After receiving the ready message that all application servers return, server is updated to each application service
Device, which is sent, prepares more new command, if update server receives what all application servers returned etc. in the first time-out time
Message to be updated then sends to each application server and submits instruction, so that each application server carries out configuration update.
Optionally, if update server receives the waiting of all application servers returns more in the first time-out time
Then new information sends to each application server then first by latest configuration information update into database and submits instruction.
But if update server does not receive the waiting of all application servers returns more in the first time-out time
New information, then sending cancellation instruction to all application servers (can also be only to the application service for having returned to waiting for update message
Device, which is sent, cancels instruction) so that each application server stops updating.
Fig. 2 is another signal that can refer to the main flow of the update method of the configuration information of embodiment according to the present invention
Figure.As shown in Fig. 2, as an embodiment of the present invention, being applied to application server, the update method of the configuration information can
To include:
Step 201, the latest configuration information that server is sent will be updated to be stored in local pre-updated buffer area, is taken to updating
Business device returns to ready message.
Each application server, which receives, updates the latest configuration information that server is sent, and latest configuration information is stored in respectively
From local pre-updated buffer area in, then create overtime monitoring thread, and return to ready message to server is updated, with
Informing update server, I is ready for.In this step, overtime monitoring thread is not started.It is pointed out that the time-out
Whether monitoring thread, which is used to monitor to receive to update the submission that server is sent and instruct or cancel in the second time-out time, refers to
It enables.
Step 202, receive and update the preparation more new command that server is sent, start overtime monitoring thread, with monitor whether
The submission instruction for updating server transmission is received in the second time-out time or cancels instruction, is suspended and is locally obtained newest match
The thread of confidence breath returns to waiting for update message to server is updated.
After application server receives the preparation more new command for updating server transmission, starting time-out first monitors line
Journey updates the submission instruction or cancel instruction that server is sent to monitor whether to receive in the second time-out time, then
The local all threads for obtaining latest configuration information of pause, finally return to waiting for update message to update server, to inform more
New demand servicing device I be ready for.
It should be pointed out that the second time-out time can be identical as the first time-out time, it can also be different, the present invention is implemented
Example is without limitation.
Step 203, the submission instruction that server is sent is updated if receiving in the second time-out time, configuration is updated
For the latest configuration information in local pre-updated buffer area, the local thread for obtaining latest configuration information is activated, destroys time-out prison
Thread is controlled, and finishes message to server return submission is updated;It is sent if being received in the second time-out time and updating server
Cancellation instruction, then activate the local thread for obtaining latest configuration information, destroy overtime monitoring thread, and return to server is updated
It returns to cancel and finishes message.
It monitors application server by overtime monitoring thread and whether is received in the second time-out time and update server hair
The submission instruction or cancellation instruction sent.If application server receives in the second time-out time updates what server was sent
Instruction is submitted, then latest configuration information configuration being updated in local pre-updated buffer area first, then activation is local obtains
The thread of latest configuration information destroys overtime monitoring thread, finally returns to submission to update server and finishes message, to inform me
Configuration is completed to update.If application server receives in the second time-out time updates the cancellation instruction that server is sent,
The local thread for obtaining latest configuration information is then activated first, destroys overtime monitoring thread, is then taken to update server return
Disappear and finish message, is updated with informing that I has stopped configuration.
Further, after returning to waiting for update message to update server, if do not received in the second time-out time
To the submission instruction or cancel instruction that server is sent is updated, then latest configuration information is inquired in the database, is updated local
Configuration information in pre-updated buffer area activates the local thread for obtaining latest configuration information, and destroys overtime monitoring thread.
According to various embodiments recited above, it can be seen that the present invention is used timeout mechanism, pull-mode and push-model
In conjunction with technical solution, to solve the problems, such as that global configuration is inconsistent in the long period.That is, in the prior art
In, mainly realize that configuration updates by pull-mode or push-model, both modes deposit in a long time that global configuration is not
Consistent problem.And the present invention is to combine timeout mechanism, pull-mode and push-model, and before guaranteeing (T) at some time point, institute
With on application server being all old configuration information (old), at some time point after (T), on all application servers all
It is latest configuration information (new), as shown in Figure 3.T is smaller to illustrate that global coherency is stronger.Therefore, provided in an embodiment of the present invention
The update method of configuration information can be under distributed environment, the configuration information of each application server of synchronized update, to reach
To the purpose of global strong consistency.
Fig. 4 is another signal that can refer to the main flow of the update method of the configuration information of embodiment according to the present invention
Figure.As yet another embodiment of the present invention, the update method of the configuration information mainly includes:Registration (Register) pushes away
(Touch) is sent, prepares (Begin), submit (Commit), cancelling (Cancel) and monitoring (Monitor).Wherein,
Server, which is represented, updates server, and client represents application server, each step is discussed in detail in turn below.
Registration step (Register):Application server creates configuration update on ZooKeeper and monitors service first, with
For updating server push information, configuration node is then registered on ZooKeeper.Specifically, it can be directed to different configurations,
Application server is registered under each configuration, such as application server 172.24.126.12 is registered at cib_bus:22002 with
And other application servers, application server 172.24.126.12 is registered at cib_service:22002 and other application
Server, as shown in Figure 5.It should be pointed out that can register multiple application servers under each configuration, the present invention is only to show
Example property by taking an application server as an example, moreover, the same application server can be registered under different configurations, this hair
Bright embodiment is without limitation.
It pushes step (Touch):As shown in fig. 6, when some configuration (such as:When cib_bus) needing to update, firstly, more
New demand servicing device goes on ZooKeeper to search all application servers under the configuration (cib_bus), then, updates server pair
These application servers carry out reachability test, if any one application server is unreachable, this updates failure.If
Whole application servers are all up, then update server to each application server and distribute newest configuration information.Finally, each
In the respective local pre-updated buffer area of latest configuration information deposit that application server receives, overtime monitoring thread is created
(but not starting), and ready message is returned to server is updated, to inform update server, I is ready for.
Preparation process (Begin):As shown in fig. 7, receive ready message that all application servers return it
Afterwards, it updates server and is sent to each application server and prepare more new command.Each application server receive the instruction it
Afterwards, start overtime monitoring thread (Monitor) first, then suspend the latest configuration information that all locals are obtaining the configuration
Thread, finally to update server return to waiting for update message.
It submits step (Commit):As shown in figure 8, if update server receives all answer in the first time-out time
With server return waiting update message, then update first in the latest configuration information to ZooKeeper of the configuration, then to
Each application server, which is sent, submits instruction.After each application server receives submission instruction, the configuration is updated to first
Then latest configuration information in pre-updated buffer area activates all locals obtaining the line of the latest configuration information of the configuration
Journey destroys overtime monitoring thread (Monitor), finally returns to submission to update server and finishes message.
Cancellation step (Cancel):As shown in figure 9, after Begin step, if updating server in the first time-out
The interior waiting update message for not receiving all application servers and returning, then trigger this step.Specifically, update server to
The application server for having returned to waiting for update message, which is sent, cancels instruction.After each application server receives cancellation instruction, swash
All locals living are obtaining the thread of the latest configuration information of the configuration, destroy overtime monitoring thread (Monitor), finally to
It updates server return cancellation and finishes message.
It monitors step (Monitor):As shown in Figure 10, after Begin step, overtime monitoring thread is monitored whether
Any instruction (submit instruction or cancel instruction) for updating server and sending is not received in two time-out times, if it is,
Trigger this step.Specifically, application server is inquired the latest configuration information of the configuration on ZooKeeper and is updated certainly first
Then the configuration of oneself local activates all locals obtaining the thread of the latest configuration information of the configuration, destroy time-out prison
It controls thread (Monitor).
It should be pointed out that another can refer to the specific of the update method of configuration information described in embodiment in the present invention
Implementation content has been described in detail in the update method of configuration information described above, therefore has no longer illustrated in this duplicate contents.
Figure 11 is the schematic diagram of the main modular of updating device according to an embodiment of the invention.As shown in figure 11, if
Setting updating the updating device 1100 in server includes preparation module 1101 and update module 1102.Wherein, the preparation mould
Block 1101 sends latest configuration information to each application server, receives the ready message that all application servers return;
The update module 1102 is sent to each application server prepares more new command, if receiving in the first time-out time all
The waiting update message that application server returns then sends to each application server and submits instruction.
Optionally, if not receiving the waiting update message that all application servers return in the first time-out time, institute
It states update module 1102 and is then sent to all application servers and cancel instruction.
Figure 12 is the schematic diagram of the main modular of the updating device of configuration information in accordance with another embodiment of the present invention.Such as
Shown in Figure 12, the updating device 1200 being arranged in the application server includes memory module 1201 and monitoring module 1202.Wherein,
The memory module 1201 is stored in the latest configuration information that server is sent is updated in local pre-updated buffer area, and is taken to updating
Business device returns to ready message;The module 1202 of monitoring receives the preparation more new command for updating server transmission, and starting is super
When monitoring thread, referred to monitoring whether to receive in the second time-out time to update submission instruction that server is sent or cancel
It enables, suspends the local thread for obtaining latest configuration information, return to waiting for update message to server is updated.
Optionally, described device further includes submitting module 1203, if receiving update server in the second time-out time
The submission of transmission instructs, and the latest configuration for submitting module 1203 that then configuration is updated in local pre-updated buffer area is believed
Breath activates the thread of locally acquisition latest configuration information, destroys overtime monitoring thread, and finish to server return submission is updated
Message;The cancellation instruction that server is sent is updated if receiving in the second time-out time, the submission module 1203 activates
The local thread for obtaining latest configuration information destroys overtime monitoring thread, and returns to cancel to update server and finish message.
Optionally, described device further includes enquiry module, after returning to waiting for update message to update server, if
The submission instruction or cancel instruction for updating that server is sent are not received in second time-out time, the enquiry module is then in data
Latest configuration information is inquired in library, updates the configuration information in local pre-updated buffer area, is activated and is locally obtained latest configuration letter
The thread of breath, and destroy overtime monitoring thread.
According to various embodiments recited above, it can be seen that the present invention is used timeout mechanism, pull-mode and push-model
In conjunction with technical solution, to solve the problems, such as that global configuration is inconsistent in the long period.That is, in the prior art
In, mainly realize that configuration updates by pull-mode or push-model, both modes deposit in a long time that global configuration is not
Consistent problem.And the present invention is to combine timeout mechanism, pull-mode and push-model, it is used before guaranteeing at some time point
On application server is all old configuration information, and after some point in time, on all application servers is all latest configuration
Information.Therefore, the updating device of configuration information provided in an embodiment of the present invention can be under distributed environment, and synchronized update is each
The configuration information of application server, to achieve the purpose that global strong consistency.
It should be noted that in the specific implementation content of updating device of the present invention, configuration information described above
It has been described in detail in update method, therefore has no longer illustrated in this duplicate contents.
Figure 13 is shown can be using the update method of the configuration information of the embodiment of the present invention or the update side of configuration information
The exemplary system architecture 1300 of method.
As shown in figure 13, system architecture 1300 may include terminal device 1301,1302,1303, network 1304 and service
Device 1305.Network 1304 between terminal device 1301,1302,1303 and server 1305 to provide Jie of communication link
Matter.Network 1304 may include various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 1301,1302,1303 and be interacted by network 1304 with server 1305, to receive
Or send message etc..Various telecommunication customer end applications, such as shopping class can be installed on terminal device 1301,1302,1303
(only show using, web browser applications, searching class application, instant messaging tools, mailbox client, social platform software etc.
Example).
Terminal device 1301,1302,1303 can be the various electronic equipments with display screen and supported web page browsing,
Including but not limited to smart phone, tablet computer, pocket computer on knee and desktop computer etc..
Server 1305 can be to provide the server of various services, for example, to user using terminal device 1301,1302,
The 1303 shopping class websites browsed provide the back-stage management server (merely illustrative) supported.Back-stage management server can be right
The data such as the information query request received analyze etc. processing, and by processing result (such as target push information, production
Product information --- merely illustrative) feed back to terminal device.
It should be noted that the update method of configuration information provided by the embodiment of the present invention is generally held in server 1305
Row, correspondingly, the updating device of the configuration information is generally located in server 1305.
It should be understood that the number of terminal device, network and server in Figure 13 is only schematical.According to realization need
It wants, can have any number of terminal device, network and server.
Below with reference to Figure 14, it illustrates the computer systems for the terminal device for being suitable for being used to realize the embodiment of the present invention
1400 structural schematic diagram.Terminal device shown in Figure 14 is only an example, should not function to the embodiment of the present invention and
Use scope brings any restrictions.
As shown in figure 14, computer system 1400 include central processing unit (CPU) 1401, can according to be stored in only
It reads the program in memory (ROM) 1402 or is loaded into random access storage device (RAM) 1403 from storage section 1408
Program and execute various movements appropriate and processing.In RAM 1403, also it is stored with system 1400 and operates required various journeys
Sequence and data.CPU 1401, ROM 1402 and RAM 1403 are connected with each other by bus 1404.Input/output (I/O) interface
1405 are also connected to bus 1404.
I/O interface 1405 is connected to lower component:Importation 1406 including keyboard, mouse etc.;Including such as cathode
The output par, c 1407 of ray tube (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section including hard disk etc.
1408;And the communications portion 1409 of the network interface card including LAN card, modem etc..Communications portion 1409 passes through
Communication process is executed by the network of such as internet.Driver 1410 is also connected to I/O interface 1405 as needed.It is detachable to be situated between
Matter 1411, such as disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 1410, so as to
In being mounted into storage section 1408 as needed from the computer program read thereon.
Particularly, disclosed embodiment, the process described above with reference to flow chart may be implemented as counting according to the present invention
Calculation machine software program.For example, embodiment disclosed by the invention includes a kind of computer program product comprising be carried on computer
Computer program on readable medium, the computer program include the program code for method shown in execution flow chart.?
In such embodiment, which can be downloaded and installed from network by communications portion 1409, and/or from can
Medium 1411 is dismantled to be mounted.When the computer program is executed by central processing unit (CPU) 1401, executes and of the invention be
The above-mentioned function of being limited in system.
It should be noted that computer-readable medium shown in the present invention can be computer-readable signal media or meter
Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but not
Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.Meter
The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to:Electrical connection with one or more conducting wires, just
Taking formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only storage
Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device,
Or above-mentioned any appropriate combination.In the present invention, computer readable storage medium can be it is any include or storage journey
The tangible medium of sequence, the program can be commanded execution system, device or device use or in connection.And at this
In invention, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal,
Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including but unlimited
In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can
Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for
By the use of instruction execution system, device or device or program in connection.Include on computer-readable medium
Program code can transmit with any suitable medium, including but not limited to:Wirelessly, electric wire, optical cable, RF etc. or above-mentioned
Any appropriate combination.
Flow chart and block diagram in attached drawing are illustrated according to the system of various embodiments of the invention, method and computer journey
The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation
A part of one module, program segment or code of table, a part of above-mentioned module, program segment or code include one or more
Executable instruction for implementing the specified logical function.It should also be noted that in some implementations as replacements, institute in box
The function of mark can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are practical
On can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it wants
It is noted that the combination of each box in block diagram or flow chart and the box in block diagram or flow chart, can use and execute rule
The dedicated hardware based systems of fixed functions or operations is realized, or can use the group of specialized hardware and computer instruction
It closes to realize.
Being described in module involved in the embodiment of the present invention can be realized by way of software, can also be by hard
The mode of part is realized.Described module also can be set in the processor, for example, can be described as:A kind of processor packet
It includes preparation module, update module, memory module and monitors module, wherein the title of these modules not structure under certain conditions
The restriction of the pairs of module itself.
As on the other hand, the present invention also provides a kind of computer-readable medium, which be can be
Included in equipment described in above-described embodiment;It is also possible to individualism, and without in the supplying equipment.Above-mentioned calculating
Machine readable medium carries one or more program, when said one or multiple programs are executed by the equipment, makes
Obtaining the equipment includes:Latest configuration information is sent to each application server, it is complete to receive the preparation that all application servers return
Finish message;It is sent to each application server and prepares more new command, if receiving all application services in the first time-out time
The waiting update message that device returns then sends to each application server and submits instruction.
Technical solution according to an embodiment of the present invention, because of the technology hand that timeout mechanism, pull-mode and push-model are combined
Section, so overcoming the inconsistent technical problem of global configuration in the long period;The present invention is by timeout mechanism, pull-mode and to push away
Mode combine, guarantee at some time point before, on application server used is all old configuration information, at some time point it
It afterwards, on all application servers is all latest configuration information.Therefore, the update side of configuration information provided in an embodiment of the present invention
Method can be under distributed environment, the configuration information of each application server of synchronized update, to reach global strong consistency
Purpose.
Above-mentioned specific embodiment, does not constitute a limitation on the scope of protection of the present invention.Those skilled in the art should be bright
It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and substitution can occur.It is any
Made modifications, equivalent substitutions and improvements etc. within the spirit and principles in the present invention, should be included in the scope of the present invention
Within.