CN108984544A - A kind of method and apparatus of distributed system modification configuration information - Google Patents

A kind of method and apparatus of distributed system modification configuration information Download PDF

Info

Publication number
CN108984544A
CN108984544A CN201710398336.1A CN201710398336A CN108984544A CN 108984544 A CN108984544 A CN 108984544A CN 201710398336 A CN201710398336 A CN 201710398336A CN 108984544 A CN108984544 A CN 108984544A
Authority
CN
China
Prior art keywords
node
control mechanism
monitor control
content
configuration information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710398336.1A
Other languages
Chinese (zh)
Other versions
CN108984544B (en
Inventor
于淼
刘卫程
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710398336.1A priority Critical patent/CN108984544B/en
Publication of CN108984544A publication Critical patent/CN108984544A/en
Application granted granted Critical
Publication of CN108984544B publication Critical patent/CN108984544B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a kind of method and apparatus of distributed system modification configuration information, are related to field of computer technology.In one specific embodiment of this method, distributed system includes the host instances that at least one is deployed with same application, this applies configuration information having the same, this method comprises: when starting application, attempt to register this to monitor control mechanism using at least one corresponding node, and the content of node is configuration information;If node exists, to the altering event of monitor control mechanism register node, if node is not present, register node, then to the altering event of monitor control mechanism register node;Monitor altering event;After altering event generation, according to the content for the node Notification of Changes modification node that monitor control mechanism is sent.The embodiment can a key modification distributed system in configuration information, the modification for the configuration information for making user that once-through operation only be needed to can be completed to the All hosts example for being deployed with same application.

Description

A kind of method and apparatus of distributed system modification configuration information
Technical field
The present invention relates to field of computer technology more particularly to the methods and dress of a kind of distributed system modification configuration information It sets.
Background technique
The configuration information for the software installed in system is some data being stored in memory, for configuring to software To execute operation.Common software configuration information such as log configuration information, cached configuration information, thread configuration information etc.. These configuration informations can preferably specification software execution, so that user is best understood from running situation.
By taking log configuration information as an example, the network equipment, system and service routine etc. can all generate one in running and cry The logout of log (that is: log);Every a line log all recites retouching for the relevant operations such as date, time, user and movement It states.Log is quite useful to system security officer, by may determine that whether the operation of system is normal to the analysis of log And stablize, system whether safety etc..
The current essentially all of network equipment, system and service routine can all have log output at runtime, while large-scale Internet project or corporate lan project be all distributed deployment (the more examples of multimachine).In order to which what a distribution managed More example projects, just seem even more important to the management of log.It can be with by reasonably carrying out parameter setting to log system Be better achieved the management to log, settable parameter for example: log rank, log output source and log output format With record date format etc..
By taking log rank as an example, the log being normally applied can be divided into debug (debugging), info (letter by rank from low to high Breath), four ranks of warn (warning) and error (mistake).In order to save machine hard disk resources, unnecessary a large amount of logs are reduced Output, using issue it is online after generally can with info rank export application log, at this time be higher than info rank log It can be exported, such as the log of warn and error rank.But if needing to print the progress of debug log content using generation problem Debugging, it is necessary to log rank is dynamically reduced to debug rank, switching at runtime returns info rank again after completion debugging.So clever The cost using operation and maintenance can be greatly reduced in log rank switching living.
Currently, in the other adjustment of progress journal stage, major programme is as follows for multiple examples of distributed system:
Scheme one: in the project of distributed deployment, each deployment examples provide a http/https interface, this connects Mouth is supplied to user's calling, provides the functions such as log switching, such as uses Java log log4j Api according to the parameter that user is passed to Adjust log rank etc.;
Scheme two: each example creation monitor is used to monitor log configuration file, after journal file changes, by supervising It listens device to be based on journal file Current Content and adjusts log rank using log4j Api.
Wherein, log4j is reliable, the quick and flexible log frame with written in Java that Apache is provided.
In realizing process of the present invention, at least there are the following problems in the prior art for inventor's discovery:
It is very cumbersome for the adjustment of configuration information for the distributed system of more host instances, need user to all Host instances all execute relevant operation respectively, synchronous to realize difficult and low efficiency, waste a large amount of time and efforts, user's body It tests very poor.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method and apparatus of distributed system modification configuration information, it can One key modifies the configuration information in distributed system, makes user that once-through operation only be needed to can be completed to being deployed with same application The modification of the configuration information of All hosts example.
To achieve the above object, according to an aspect of an embodiment of the present invention, a kind of modification of distributed system is provided to match The method of confidence breath.
A kind of method of distributed system modification configuration information, the distributed system include at least one be deployed with it is identical The host instances of application, the application configuration information having the same, which comprises when starting is described in application, attempting To at least one corresponding node of the monitor control mechanism registration application, and the content of the node is the configuration information;If institute Node presence is stated, then registers the altering event of the node to the monitor control mechanism, if the node is not present, described in registration Then node registers the altering event of the node to the monitor control mechanism;Monitor the altering event;In the altering event After generation, the node Notification of Changes sent according to the monitor control mechanism modifies the content of the node.
Optionally, the monitor control mechanism is zookeeper.
Optionally, the altering event includes: NodeDataChanged event and NodeChildrenChanged event.
Optionally, the node Notification of Changes includes the type of the altering event, the path of the node and described The content of node;Also, the step of node Notification of Changes sent according to the monitor control mechanism modifies the content of node packet It includes: the content of the type of the altering event, the path of the node and the node sent according to the monitor control mechanism, The content of the corresponding node of the monitor control mechanism is modified using log4j Api.
Optionally, the node Notification of Changes includes the type of the altering event and the path of the node;Also, root The step of node Notification of Changes sent according to the monitor control mechanism modifies the content of the node includes: according to the monitor control mechanism The type for the altering event sent and the path of the node, obtain the section from the corresponding node of the monitor control mechanism The content of point, then modifies the content of the node using log4j Api.
Other side according to an embodiment of the present invention provides a kind of device of distributed system modification configuration information.
A kind of device of distributed system modification configuration information, the distributed system include at least one be deployed with it is identical The host instances of application, the application configuration information having the same, described device includes: Node registry module, is opened for working as In application, attempting to register at least one corresponding node of the application to monitor control mechanism described in dynamic, and the content of the node is The configuration information;Change of registration module registers the change of the node to the monitor control mechanism if existing for the node More event registers the node if the node is not present, and the change thing of the node is then registered to the monitor control mechanism Part;Event monitoring module, for monitoring the altering event;Execution module is changed, is used for after altering event generation, root The node Notification of Changes sent according to the monitor control mechanism modifies the content of the node.
Optionally, the monitor control mechanism is zookeeper.
Optionally, the altering event includes: NodeDataChanged event and NodeChildrenChanged event.
Optionally, the node Notification of Changes includes the type of the altering event, the path of the node and described The content of node;Also, the change execution module is also used to: according to the class for the altering event that the monitor control mechanism is sent The content of type, the path of the node and the node, the corresponding node of the monitor control mechanism is modified using log4j Api Content.
Optionally, the node Notification of Changes includes the type of the altering event and the path of the node;Also, institute It states change execution module to be also used to: the type for the altering event sent according to the monitor control mechanism and the road of the node Diameter obtains the content of the node from the corresponding node of the monitor control mechanism, and the section is then modified using log4j Api The content of point.
Another aspect according to an embodiment of the present invention provides a kind of terminal of distributed system modification configuration information.
A kind of terminal of distributed system modification configuration information, comprising: one or more processors;Storage device is used for One or more programs are stored, when one or more of programs are executed by one or more of processors, so that described one The method that a or multiple processors realize the modification configuration information of distributed system provided by the embodiment of the present invention.
It is according to an embodiment of the present invention in another aspect, providing a kind of computer-readable medium.
A kind of computer-readable medium is stored thereon with computer program, realizes this when described program is executed by processor The method of the modification configuration information of distributed system provided by inventive embodiments.
One embodiment in foregoing invention has the following advantages that or the utility model has the advantages that by using monitor control mechanism The directory tree structure of zookeeper stores the state of more applied host machine examples, while utilizing the monitoring of zookeeper and notice machine System reaches the trustships of more applied host machine examples, also, makes using register node and monitoring correlation in monitor control mechanism on startup The altering event of node, and in the node Notification of Changes modification node sent after altering event generation according to monitor control mechanism Hold, the configuration information in key modification distributed system may be implemented, user is made only once-through operation to be needed to can be completed to deployment There is the modification of the configuration information of the All hosts example of same application, so that saving user carries out distributed system configuration information The time of modification improves the efficiency of configuration information modification;In the middle part of the modification distributed system of a key according to demand Divide the configuration information of host instances, to adapt to the diversified demand for control of system.
Further effect possessed by above-mentioned non-usual optional way adds hereinafter in conjunction with specific embodiment With explanation.
Detailed description of the invention
Attached drawing for a better understanding of the present invention, does not constitute an undue limitation on the present invention.Wherein:
Fig. 1 is the signal of the key step of the method for distributed system modification configuration information according to an embodiment of the present invention Figure;
Fig. 2 is the principle architecture diagram of one embodiment of the invention;
Fig. 3 is the log configuration information changing process figure of one embodiment of the invention;
Fig. 4 is the realization process schematic of another embodiment of the present invention;
Fig. 5 is the signal of the main modular of the device of distributed system modification configuration information according to an embodiment of the present invention Figure;
Fig. 6 is that the embodiment of the present invention can be applied to exemplary system architecture figure therein;
Fig. 7 is adapted for the structural schematic diagram for the computer system for realizing the terminal of the embodiment of the present invention.
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.
It is asked in order to which cumbersome when solving the progress configuration information setting mentioned in the prior art and synchronous realization is difficult Topic, the embodiment provides a kind of configuration informations that can be modified with a key in distributed system, and user is made only to need one It is secondary to operate the update that the configuration information of All hosts example can be completed.Under most of distributed scenes, especially multimachine is more The scene of exemplary application deployment, in the identical application program of many example deployments, each application program is safeguarded some identical Information, and need dynamic modify these information in the case where, can use the embodiment of the present invention provided by technical solution.
Fig. 1 is the signal of the key step of the method for distributed system modification configuration information according to an embodiment of the present invention Figure.As shown in Figure 1, distributed system includes the host instances that at least one is deployed with same application in the embodiment of the present invention, And each host instances using configuration information having the same.The distributed system modification configuration information of the embodiment of the present invention Method mainly includes the following steps, namely S101 to step S104.
Step S101: at least one corresponding node is applied in application, attempting to register to monitor control mechanism when starting, and node Content be configuration information.
Wherein, configuration information is for example including log configuration information, thread configuration information, cached configuration information etc..With day For will configuration information, log configuration information for example, log rank, log output source, log output format, log recording Date format etc..
According to one embodiment of present invention, in order to be changed to log configuration information, when application starting, Ke Yi Multiple nodes are registered in monitor control mechanism, wherein node may include the node of application and the Log Directory node of application, according to not Same need log configuration information to be changed can also include other nodes.For example, when needing newly-increased and updating adapter It can also include the corresponding node of corresponding appender when appender.The content of each node is log configuration information, And the content type of each node is identical, and such as: the content of all nodes is that the content of log rank or all nodes is Log output format.
According to one embodiment of present invention, monitor control mechanism can be zookeeper.Zookeeper is a distribution , the distributed application program coordination service of open source code is one and provides the software of Consistency service for Distributed Application, mentions The function of confession includes: configuring maintenance, domain name service, distributed synchronization, group service etc..It will be recognized by those skilled in the art that its He is any to have with zookeeper the software frame of identical function (such as: the monitoring callback function in the present embodiment) can quilt As the monitor control mechanism.
Each host instances need to register this to Apache zookeeper using corresponding at least one in application starting A node.This is generally comprised using corresponding root node and relevant child node using corresponding node, wherein is answered when multiple It is each that corresponding root node is applied generally to can be this using the corresponding node of domain name when with being connected for internet;When multiple When using for LAN connection, the corresponding root node of each application generally can be the corresponding node of the application identities, wherein answer With mark e.g. Apply Names etc..Child node for example may include the node that each host instances are registered according to host identification, Wherein, the IP address etc. of host identification such as Hostname, host.Child node for example can also include that data save contents correspondence Child node etc..
Step S102: if node exists, the altering event of the node is registered to monitor control mechanism, if node is not present, Then register node registers the altering event of the node to monitor control mechanism.
Each host instances need to register this to monitor control mechanism zookeeper and apply corresponding node in application starting, But same apply be only capable of registering on zookeeper primary identical node, and such as: use the domain name registration of the application Root node, the child node registered using each host IP address etc..When host instances register corresponding node to zookeeper, Zookeeper can decide whether to carry out Node registry according to the registration scenarios of the application node.When the application interdependent node When being registered, can inform that the host instances of the sending node registration request node is existing, at this point, the host instances only need to Zookeeper registers the altering event of the node;When the node of the application is not registered, zookeeper will be according to master The Node registry request that machine example is sent carries out Node registry and then registers the altering event of the node for the host instances.
Step S103: altering event is monitored.
Each host instances can supervise in real time after application registers this using corresponding node to Apache zookeeper Corresponding node and its child node are listened, so that whether the content found in corresponding node and its child node has altered.Work as node When content has altered, the altering event of node content can be triggered.
Technical solution according to an embodiment of the present invention, when monitor control mechanism is zookeeper, altering event mainly be can wrap It includes: NodeDataChanged event and NodeChildrenChanged event two types.Wherein, NodeDataChanged Event refers to the node content altering event on zookeeper;NodeChildrenChanged event refers to Child node altering event on zookeeper, such as increase or delete child node.
Step S104: it after altering event generation, is modified in node according to the node Notification of Changes that monitor control mechanism is sent Hold.
Wherein, when node Notification of Changes includes the content of the type of altering event, the path of node and node, host The step of content for the node Notification of Changes modification node that example is sent according to monitor control mechanism, specifically may is that according to monitor control mechanism The content of the type for the altering event sent, the path of node and node modifies pair of monitor control mechanism using log4j Api Answer the content of node.
When node Notification of Changes include altering event type and node path when, host instances are sent out according to monitor control mechanism The step of content of the node Notification of Changes modification node come, specifically may is that the class for the altering event sent according to monitor control mechanism The path of type and node is obtained the content of node from the corresponding node of monitor control mechanism, section is then modified using log4j Api The content of point.
Wherein, type of the node Notification of Changes for example including altering event, the path of node and content of node etc..Its In, the type of altering event mainly includes NodeDataChanged event and two kinds of NodeChildrenChanged event, master The application disposed in machine example can determine corresponding node, then basis according to the type of altering event and the path of node The content of node in node Notification of Changes carries out corresponding operating to the content of determining node.Such as: when configuration information is day When will rank, using can be used log4j API modification apply respective nodes log rank.
Since the distributed system of the embodiment of the present invention includes the host instances that at least one is deployed with same application, and it is every A host instances using configuration information having the same, therefore, when need a key modify distributed system All hosts example Configuration information when, it is only necessary to this is changed using the content of corresponding root node, has registered the change of root node at this time The All hosts example of event can listen to the altering event of node content.Also, after altering event generation, it is deployed with this The All hosts example of application can receive the node Notification of Changes that monitor control mechanism is sent, and be repaired according to node Notification of Changes Change the content of more node.Furthermore it, can be by answering this when only needing to modify the wherein configuration information of certain several host instances With under root node, the content of the child node of the IP address registration of different host instances is changed, and has registered correlator section at this time The host instances of the altering event of point can listen to the altering event of node content, and the section that can be sent according to monitor control mechanism The content of point Notification of Changes modification change node.
The configuration in key modification distributed system had both may be implemented in the technical solution for using the embodiment of the present invention as a result, Information makes user only need once-through operation that repairing to the configuration information for the All hosts example for being deployed with same application can be completed Change;The configuration information of part host instances in distributed system can be modified, with a key according to demand again to adapt to the multiplicity of system Change demand.
According to previously described step S101 to step S104, by using the directory tree knot of monitor control mechanism zookeeper Structure stores the state of the more host instances of same application, while reaching more hosts realities using the monitoring of zookeeper and informing mechanism The trustship of example, also, make using register node and monitoring the altering event of interdependent node in monitor control mechanism on startup, and The content for the node Notification of Changes modification node that altering event is sent after occurring according to monitor control mechanism, may be implemented key modification point Configuration information in cloth system makes user that once-through operation only be needed to can be completed real to the All hosts for being deployed with same application The modification of the configuration information of example improves configuration to save the time that user carries out the modification of distributed system configuration information The efficiency of information modification;The configuration information of part host instances in distributed system is modified at the same time it can also a key according to demand, To adapt to the diversified demand for control of system.
Fig. 2 is the principle architecture diagram of one embodiment of the invention.In the present embodiment by taking log rank as an example, introduce distributed More host instances carry out the process of configuration information modification in system.
As shown in Fig. 2, the value of the directory node on zookeeper is all log rank: debug, info, warn, error Deng.By taking the multiple main frames example of certain application is connected by internet as an example, it is assumed that certain is using corresponding domain name Model.app1.com applies the corresponding node of domain name using needing to register this on startup to Apache zookeeper, that Just need registration/LogLevelTab/model.app1.com node on zookeeper.Wherein ,/LogLevelTab is Fixed root ,/LogLevelTab/model.app1.com are the root node (root node) of the application registration, which deposits The content of storage is the log rank entirely applied.Meanwhile in application starting, it is also necessary to which the Log Directory for registering application is corresponding Node.Wherein, the Log Directory of application must have, can be with self-setting directory path, can also be according to the function of application The Log Directory of any number is arranged in module, and different Log Directories might have different log ranks.Assuming that this is answered With default, there are two Log Directories: com.app1.package1 and com.app1.package2, then, in the application starting Then also need to register the node of these Log Directories, such as :/LogLevelTab/model.app1.com/ Com.app1.package1 and/LogLevelTab/model.app1.com/com.app1.package2 the two nodes.
The host instances for being deployed with the application register this using domain name pair to Apache zookeeper in application starting After the root node answered and the corresponding child node of two Log Directory, while the altering event of interdependent node will be also registered, mainly There are the NodeDataChanged event and NodeChildrenChanged event and two Log Directory child nodes of root node NodeDataChanged event, then, the host instances for being deployed with the application will also monitor the altering event of interdependent node.
Wherein, NodeDataChanged event is the node content altering event on zookeeper; NodeChildrenChanged event is the child node altering event on zookeeper, such as increases or delete child node.
When such an event occurs, if applications client (applied host machine example) has registered the event of a certain node, thing Zookeeper will notify applications client when part occurs.
In one embodiment, if there is the entitled model.app1.com of an application domain, log frame uses log4j, Log4j is reliable, the quick and flexible log frame with written in Java that Apache is provided, then can be when the application starting A node is registered in zookeeper, and monitors the two events of the node.Wherein, the entitled model.app1.com of node, Node content is set as the log rank for applying log4j.When needing to modify the log rank for applying All hosts example, Can modify zookeeper /content of LogLevelTab/model.app1.com node, zookeeper will be by this Notification of Changes is to applications client, after applications client receives Notification of Changes, reuses the log that log4j API modifies the application Rank.
In another embodiment, if there is the entitled model.app1.com of an application domain, the section registered in zookeeper Point is /LogLevelTab/model.app1.com, if there are two sub- Log Directories under the node, such as :/ LogLevelTab/model.app1.com/com.app1.package1 and/LogLevelTab/model.app1.com/ Com.app1.package2 the two child nodes, then, when having modified/LogLevelTab/model.app1.com node After log rank, zookeeper also can be by this Notification of Changes to the application client for having registered the altering event for applying root node End, so that applications client modifies the two log ranks for applying subdirectory using log4j API.
In another embodiment, if there is the entitled model.app1.com of an application domain, the section registered in zookeeper Point is /LogLevelTab/model.app1.com, if there are two under/LogLevelTab/model.app1.com node Sub- Log Directory, such as :/LogLevelTab/model.app1.com/com.app1.package1 and/LogLevelTab/ The two child nodes of model.app1.com/com.app1.package2, then, when having modified/LogLevelTab/ After the log rank of model.app1.com/com.app1.package1 node, zookeeper can also be arrived this Notification of Changes The applications client of the altering event of the child node is had registered, so that applications client modifies application using log4j API The log rank of catalogue.
It, can be in addition, when needing certain several rather than whole host instances to certain application to carry out the modification of configuration informations It is arranged when each host instances are starting this in application, registering the root node of the application to zookeeper, and use the host IP registers the level-one child node of the root node, then under level-one child node re-registration Log Directory child node as second level sub- section Point, meanwhile, the altering event of the root node for registering the application to zookeeper all child nodes corresponding with the host instances. So, when modifying the content of root node of the application, all Log Directories of the All hosts example of the application match confidence Breath can execute modification;When modifying the content for applying certain several level-one child node, corresponding several host instances own The configuration information of Log Directory can execute modification.
Notification of Changes has used the monitoring watcher mechanism of zookeeper, using needing permanently to monitor after starting The upper each Log Directory node of zookeeper.It include that event type is (such as aforementioned in zookeeper node Notification of Changes NodeDataChanged event and NodeChildrenChanged event) and change node path and change node in Hold etc..Applications client can obtain the content in corresponding node and carry out corresponding operating according to event type.
In an embodiment as illustrated in figure 2, a web console is provided and corresponding front end shows the page, to need It changes operation for user when carrying out the change of log rank and carries out information and show.In the front end for realizing web console When showing the page, different program languages can be used, it is, for example, possible to use the programs such as java servlet, PHP, C-sharp Language.With reference to the accompanying drawing 3, it is introduced for using java servlet to realize that front end shows the page and how to be to distribution More application examples of system carry out the change of configuration information.
Fig. 3 is the log configuration information changing process figure of one embodiment of the invention.It is real by taking the other change of journal stage as an example Existing process are as follows: firstly, reading on the node content to the page on zookeeper, and the content of node is modified on the page, then It is submitted to servlet background program;It is right on zookeeper API modification zookeeper server that servlet background program uses The content of node is answered, node content is log rank, such as debug/info/warn/error;Finally, zookeeper meeting By node Notification of Changes to each applied host machine example.
In Fig. 3, for modifying the log rank saved in Log Directory node com.app1.package1, in figure Key step be described as follows:
1.: Servlet background program request read zookeeper server on Log Directory node/ The content of LogLevelTab/model.app1.com/com.app1.package1, node content are log rank;
2.: the Log Directory node content is returned to Servlet background program by zookeeper;
3.: the Log Directory node content is transferred to the page to show by Servlet background program;
4.: user is submitted to the backstage Servlet journey after the page has changed the Log Directory node content, by changed content Sequence;
5.: Servlet background program arrives content (log rank) update for the Log Directory node that user modifies In the upper corresponding Log Directory node/LogLevelTab/model.app1.com/com.app1.package1 of zookeeper;
6., 7., 8.: zookeeper gives the Notification of Changes of Log Directory node content to applied host machine example, so that this is more A applied host machine example carries out corresponding operating according to Notification of Changes.Wherein, when content of announcement includes altering event type and change Node path when, multiple applied host machine example is according to the node path of altering event type and change, from monitor control mechanism The node content of change is obtained in the corresponding node of zookeeper, then carries out corresponding operation;When content of announcement includes change When the node content of event type, the node path of change and change, multiple applied host machine example can lead to based on the received Know that content carries out corresponding operation.
Wherein, the corresponding operating that applied host machine example carries out refers to: applied host machine example can according to nodename and Node content switches log rank using log4j Api.Wherein, Log4j is an open source projects of Apache, by making With Log4j, the destination that can control log information conveying is console, file, GUI component, even socket server, Event recorder, UNIX syslog demon of NT etc.;Also it can control the output format of each log;Pass through definition The rank of each log information can more meticulously control the generating process of log.
Such as: modifying the log rank for applying corresponding root node using log4j API is debug rank, can be held The following code of row:
Level level=Level.toLevel (Level.DEBUG);
LogManager.getRootLogger().setLevel(level);
For another example: the log rank using log4j API modification Log Directory com.app1.package1 is debug rank, Following code can be performed:
Level level=Level.toLevel (Level.DEBUG);
Logger logger=LogManager.getLogger (" com.app1.package1 ");
logger.setLevel(level)。
Scheme provided in the embodiment of the present invention can also realize the other content alterations of log, and such as newly-increased and update is additional Device appender etc..
Fig. 4 is the realization process schematic of another embodiment of the present invention.As shown in figure 4, in the embodiment, in certain application For increasing child node newly under corresponding node, the process that dynamic adjusts distributed system journal configuration information is introduced.
By taking the log4j occurred in an embodiment in the present invention as an example, log4j mainly includes 3 components:
Which log sentence in program enabled or disable for controlling by logger (logger), it is possible to specify this A little ranks: ALL, DEBUG, INFO, WARN, ERROR, FATA;
Layout (layout), according to the expectation of user, formatted log record request;
Appender sends the output formatted to destination.
Wherein, there are many types by log4j included appender, such as: ConsoleAppender, FileAppender, JDBCAppender, JMSAppender, SyslogAppender etc. are the log that may know that these appender according to the meaning of word The way of output, such as: the log way of output of FileAppender is file f ile, the log output side of JDBCAppender Formula is database file JDBC, etc..Meanwhile log4j also allows customized appender, realizes customized output source.
In the present embodiment, if the entitled model.app1.com of application domain, can infuse in zookeeper Volume/model.app1.com/appender node, and register the NodeChildrenChanged event of the node.
If creating DailyRollingFileAppender node under this node, zookeeper is notified that application Client changes, applications client acquisition/model.app1.com/appender node child node, and uses log4j API modifies the appender node on monitor control mechanism zookeeper, and the code of execution is as follows:
In addition, in order to reach the finer control of the log configuration information to the application, can also/ Created again under model.app1.com/appender/DailyRollingFileAppender node file, datePattern, The nodes such as layout, and the content of appender node is modified in code above using corresponding nodal value.
Fig. 5 is the signal of the main modular of the device of distributed system modification configuration information according to an embodiment of the present invention Figure.As shown in figure 5, distributed system includes the host instances that at least one is deployed with same application in the embodiment of the present invention, And each host instances using configuration information having the same.The distributed system of the embodiment of the present invention modifies configuration information Device 500 mainly include Node registry module 501, change of registration module 502, event monitoring module 503 and change execute mould Block 504.
Node registry module 501 be used for when starting in application, attempt to monitor control mechanism register application it is corresponding at least one Node, and the content of node is configuration information;
If change of registration module 502 exists for node, to the altering event of monitor control mechanism register node, if node is not In the presence of then register node, then to the altering event of the monitor control mechanism register node;
Event monitoring module 503 is for monitoring altering event;
It changes execution module 504 to be used for after altering event generation, the node Notification of Changes sent according to monitor control mechanism is repaired Change the content of node.
According to one embodiment of present invention, monitor control mechanism can be zookeeper.Zookeeper is a distribution , the distributed application program coordination service of open source code is one and provides the software of Consistency service for Distributed Application, mentions The function of confession includes: configuring maintenance, domain name service, distributed synchronization, group service etc..It will be recognized by those skilled in the art that its He is any to have with zookeeper the software frame of identical function (such as: the monitoring callback function in the present embodiment) can quilt As the monitor control mechanism.
Technical solution according to an embodiment of the present invention, when monitor control mechanism is zookeeper, altering event mainly be can wrap It includes: NodeDataChanged event and NodeChildrenChanged event two types.Wherein, NodeDataChanged Event refers to the node content altering event on zookeeper;NodeChildrenChanged event refers to Child node altering event on zookeeper, such as increase or delete child node.
Wherein, node Notification of Changes may include the content of the type of altering event, the path of node and node;And And change execution module 504 and can be also used for: the type of altering event sent according to monitor control mechanism, the path of node and The content of node modifies the content of the corresponding node of monitor control mechanism using log4j Api.
Node Notification of Changes can also include the type of altering event and the path of node;Also, change execution module 504 It can be also used for: the type for the altering event sent according to monitor control mechanism and the path of node, from the corresponding node of monitor control mechanism The upper content for obtaining node, then modifies the content of node using log4j Api.
Wherein, the type of altering event such as NodeDataChanged event and NodeChildrenChanged event two Kind, according to the path of the type of altering event and node, corresponding node can be determined, then according in node Notification of Changes The content of node carries out corresponding operating to the content of determining node.
According to one embodiment of present invention, it in order to be changed to log configuration information, when application starting, can infuse The multiple nodes of volume, wherein node may include the node of application and the Log Directory node of application, need to change according to different Log configuration information, can also include other nodes.
Technical solution according to an embodiment of the present invention is stored by using the directory tree structure of monitor control mechanism zookeeper The state of more applied host machine examples, while reaching using the monitoring of zookeeper and informing mechanism the support of more applied host machine examples Pipe, also, make using register node and monitoring the altering event of interdependent node in monitor control mechanism on startup, and in change thing The content for the node Notification of Changes modification node that part is sent after occurring according to monitor control mechanism, may be implemented the distributed system of key modification Configuration information in system makes user only need once-through operation that matching to the All hosts example for being deployed with same application can be completed The modification of confidence breath improves configuration information and repairs to save the time that user carries out the modification of distributed system configuration information The efficiency changed;At the same time it can also the configuration information of part host instances in the modification distributed system of a key according to demand, to adapt to The diversified demand for control of system.
Fig. 6 is shown can be using the method or distribution of the distributed system modification configuration information of the embodiment of the present invention The exemplary system architecture 600 of the device of system modification configuration information.
As shown in fig. 6, system architecture 600 may include terminal device 601,602,603, network 604 and server 605. Network 604 between terminal device 601,602,603 and server 605 to provide the medium of communication link.Network 604 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 601,602,603 and be interacted by network 604 with server 605, to receive or send out Send message etc..Various telecommunication customer end applications, such as the application of shopping class, net can be installed on terminal device 601,602,603 (merely illustrative) such as the application of page browsing device, searching class application, instant messaging tools, mailbox client, social platform softwares.
Terminal device 601,602,603 can be the various electronic equipments with display screen and supported web page browsing, packet Include but be not limited to smart phone, tablet computer, pocket computer on knee and desktop computer etc..
Server 605 can be to provide the server of various services, such as utilize terminal device 601,602,603 to user The shopping class website browsed provides the back-stage management server (merely illustrative) supported.Back-stage management server can be to reception To the data such as information query request analyze etc. processing, and by processing result (such as target push information, product letter Breath -- merely illustrative) feed back to terminal device.
It should be noted that the method for the modification configuration information of distributed system provided by the embodiment of the present invention is generally by taking Business device 605 executes, and correspondingly, the device of distributed system modification configuration information is generally positioned in server 605.
It should be understood that the number of terminal device, network and server in Fig. 6 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
Below with reference to Fig. 7, it illustrates the knots of the computer system 700 for the terminal for being suitable for being used to realize the embodiment of the present invention Structure schematic diagram.Terminal device shown in Fig. 7 is only an example, should not function and use scope band to the embodiment of the present invention Carry out any restrictions.
As shown in fig. 7, computer system 700 includes central processing unit (CPU) 701, it can be read-only according to being stored in Program in memory (ROM) 702 or be loaded into the program in random access storage device (RAM) 703 from storage section 708 and Execute various movements appropriate and processing.In RAM 703, also it is stored with system 700 and operates required various programs and data. CPU 701, ROM 702 and RAM 703 are connected with each other by bus 704.Input/output (I/O) interface 705 is also connected to always Line 704.
I/O interface 705 is connected to lower component: the importation 706 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 707 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 708 including hard disk etc.; And the communications portion 709 of the network interface card including LAN card, modem etc..Communications portion 709 via such as because The network of spy's net executes communication process.Driver 710 is also connected to I/O interface 705 as needed.Detachable media 711, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 710, in order to read from thereon Computer program be mounted into storage section 708 as needed.
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 709, and/or from can Medium 711 is dismantled to be mounted.When the computer program is executed by central processing unit (CPU) 701, system of the invention is executed The above-mentioned function of middle restriction.
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: have the electrical connection, just of one or more conducting wires 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: wireless, electric wire, optical cable, RF etc. are 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 the embodiment of the present invention involved module or unit can be realized by way of software, can also be with It is realized by way of hardware.Described module or unit also can be set in the processor, for example, can be described as: A kind of processor includes Node registry module, change of registration module, event monitoring module and change execution module.Wherein, these Module or the title of unit do not constitute the restriction to the module or unit itself under certain conditions, for example, Node registry mould Block be also described as " for when starting in application, attempt to monitor control mechanism register apply at least one corresponding node, and The content of node is the module of configuration information ".
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 The equipment includes: when starting is described in application, attempting to register at least one corresponding node of the application to monitor control mechanism, and The content of the node is the configuration information;If the node exists, the change of the node is registered to the monitor control mechanism More event registers the node if the node is not present, and the change thing of the node is then registered to the monitor control mechanism Part;Monitor the altering event;After altering event generation, the node Notification of Changes sent according to the monitor control mechanism is repaired Change the content of the node.
Technical solution according to an embodiment of the present invention is stored by using the directory tree structure of monitor control mechanism zookeeper The state of more applied host machine examples, while reaching using the monitoring of zookeeper and informing mechanism the support of more applied host machine examples Pipe, also, make using register node and monitoring the altering event of interdependent node in monitor control mechanism on startup, and in change thing The content for the node Notification of Changes modification node that part is sent after occurring according to monitor control mechanism, may be implemented the distributed system of key modification Configuration information in system makes user only need once-through operation that matching to the All hosts example for being deployed with same application can be completed The modification of confidence breath improves configuration information and repairs to save the time that user carries out the modification of distributed system configuration information The efficiency changed;At the same time it can also the configuration information of part host instances in the modification distributed system of a key according to demand, to adapt to The diversified demand for control of system.
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.

Claims (12)

1. a kind of method of distributed system modification configuration information, which is characterized in that the distributed system includes at least one It is deployed with the host instances of same application, the application configuration information having the same, which comprises
When starting is described in application, attempting to apply at least one corresponding node, and the node to monitor control mechanism registration is described Content be the configuration information;
If the node exists, the altering event of the node is registered to the monitor control mechanism, if the node is not present, The node is registered, the altering event of the node is then registered to the monitor control mechanism;
Monitor the altering event;
After altering event generation, the node Notification of Changes sent according to the monitor control mechanism is modified in the node Hold.
2. the method according to claim 1, wherein the monitor control mechanism is zookeeper.
3. method according to claim 1 or 2, which is characterized in that the altering event includes: NodeDataChanged Event and NodeChildrenChanged event.
4. the method according to claim 1, wherein
The node Notification of Changes includes the content of the type of the altering event, the path of the node and the node; Also,
The step of node Notification of Changes sent according to the monitor control mechanism modifies the content of the node include:
In the type of the altering event, the path of the node and the node sent according to the monitor control mechanism Hold, the content of the corresponding node of the monitor control mechanism is modified using log4j Api.
5. the method according to claim 1, wherein
The node Notification of Changes includes the type of the altering event and the path of the node;Also,
The step of node Notification of Changes sent according to the monitor control mechanism modifies the content of the node include:
The type for the altering event sent according to the monitor control mechanism and the path of the node, from the monitor control mechanism The content of the node is obtained in corresponding node, and the content of the node is then modified using log4j Api.
6. a kind of device of distributed system modification configuration information, which is characterized in that the distributed system includes at least one The host instances of same application, the application configuration information having the same are deployed with, described device includes:
Node registry module, it is described in application, attempting to register the application corresponding at least one to monitor control mechanism for working as starting A node, and the content of the node is the configuration information;
Change of registration module registers the altering event of the node to the monitor control mechanism if existing for the node, if The node is not present, then registers the node, and the altering event of the node is then registered to the monitor control mechanism;
Event monitoring module, for monitoring the altering event;
Execution module is changed, the node Notification of Changes for being sent after altering event generation according to the monitor control mechanism Modify the content of the node.
7. device according to claim 6, which is characterized in that the monitor control mechanism is zookeeper.
8. device according to claim 6 or 7, which is characterized in that the altering event includes: NodeDataChanged Event and NodeChildrenChanged event.
9. device according to claim 6, which is characterized in that
The node Notification of Changes includes the content of the type of the altering event, the path of the node and the node; Also,
The change execution module is also used to:
In the type of the altering event, the path of the node and the node sent according to the monitor control mechanism Hold, the content of the corresponding node of the monitor control mechanism is modified using log4j Api.
10. device according to claim 6, which is characterized in that
The node Notification of Changes includes the type of the altering event and the path of the node;Also,
The change execution module is also used to:
The type for the altering event sent according to the monitor control mechanism and the path of the node, from the monitor control mechanism The content of the node is obtained in corresponding node, and the content of the node is then modified using log4j Api.
11. a kind of terminal of distributed system modification configuration information characterized by comprising
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 processors are real Now such as method as claimed in any one of claims 1 to 5.
12. a kind of computer-readable medium, is stored thereon with computer program, which is characterized in that described program is held by processor Such as method as claimed in any one of claims 1 to 5 is realized when row.
CN201710398336.1A 2017-05-31 2017-05-31 Method and device for modifying configuration information of distributed system Active CN108984544B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710398336.1A CN108984544B (en) 2017-05-31 2017-05-31 Method and device for modifying configuration information of distributed system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710398336.1A CN108984544B (en) 2017-05-31 2017-05-31 Method and device for modifying configuration information of distributed system

Publications (2)

Publication Number Publication Date
CN108984544A true CN108984544A (en) 2018-12-11
CN108984544B CN108984544B (en) 2021-04-30

Family

ID=64502241

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710398336.1A Active CN108984544B (en) 2017-05-31 2017-05-31 Method and device for modifying configuration information of distributed system

Country Status (1)

Country Link
CN (1) CN108984544B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109885414A (en) * 2019-02-21 2019-06-14 北京宝兰德软件股份有限公司 Distributed event notification method and device based on ZooKeeper
CN110083504A (en) * 2019-03-29 2019-08-02 北京奇安信科技有限公司 The running state monitoring method and device of distributed task scheduling
CN110166528A (en) * 2019-04-16 2019-08-23 平安科技(深圳)有限公司 The method, apparatus and computer equipment for preventing node Notification of Changes from losing
CN111884834A (en) * 2020-07-07 2020-11-03 杭州安恒信息技术股份有限公司 Zookeeper-based distributed system upgrading method and system and computer equipment
CN112818063A (en) * 2021-02-04 2021-05-18 厦门安盟网络股份有限公司 Data synchronization method and device of distributed system
CN114089967A (en) * 2022-01-19 2022-02-25 武汉源启科技股份有限公司 API interface generation method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090172387A1 (en) * 2005-03-30 2009-07-02 Smith Brian K Managing dynamic configuration modifications in a computer infrastructure
US20100306786A1 (en) * 2006-03-31 2010-12-02 Isilon Systems, Inc. Systems and methods for notifying listeners of events
CN104092718A (en) * 2013-12-12 2014-10-08 腾讯数码(天津)有限公司 Distributed system and configuration information updating method in distributed system
CN104202383A (en) * 2014-08-26 2014-12-10 浪潮软件股份有限公司 Centralized configuration distribution and management method in distributed cluster environment
CN104969222A (en) * 2013-01-23 2015-10-07 脸谱公司 Method and system for using a recursive event listener on a node in hierarchical data structure

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090172387A1 (en) * 2005-03-30 2009-07-02 Smith Brian K Managing dynamic configuration modifications in a computer infrastructure
US20100306786A1 (en) * 2006-03-31 2010-12-02 Isilon Systems, Inc. Systems and methods for notifying listeners of events
CN104969222A (en) * 2013-01-23 2015-10-07 脸谱公司 Method and system for using a recursive event listener on a node in hierarchical data structure
CN104092718A (en) * 2013-12-12 2014-10-08 腾讯数码(天津)有限公司 Distributed system and configuration information updating method in distributed system
CN104202383A (en) * 2014-08-26 2014-12-10 浪潮软件股份有限公司 Centralized configuration distribution and management method in distributed cluster environment

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109885414A (en) * 2019-02-21 2019-06-14 北京宝兰德软件股份有限公司 Distributed event notification method and device based on ZooKeeper
CN110083504A (en) * 2019-03-29 2019-08-02 北京奇安信科技有限公司 The running state monitoring method and device of distributed task scheduling
CN110166528A (en) * 2019-04-16 2019-08-23 平安科技(深圳)有限公司 The method, apparatus and computer equipment for preventing node Notification of Changes from losing
CN110166528B (en) * 2019-04-16 2022-03-18 平安科技(深圳)有限公司 Method and device for preventing node change notification from being lost and computer equipment
CN111884834A (en) * 2020-07-07 2020-11-03 杭州安恒信息技术股份有限公司 Zookeeper-based distributed system upgrading method and system and computer equipment
CN112818063A (en) * 2021-02-04 2021-05-18 厦门安盟网络股份有限公司 Data synchronization method and device of distributed system
CN114089967A (en) * 2022-01-19 2022-02-25 武汉源启科技股份有限公司 API interface generation method and device

Also Published As

Publication number Publication date
CN108984544B (en) 2021-04-30

Similar Documents

Publication Publication Date Title
CN108984544A (en) A kind of method and apparatus of distributed system modification configuration information
CN107491488B (en) Page data acquisition method and device
WO2021017301A1 (en) Management method and apparatus based on kubernetes cluster, and computer-readable storage medium
US9633106B1 (en) Log data analysis
US10496605B2 (en) Application deployment for data intake and query system
CN110019350A (en) Data query method and apparatus based on configuration information
CN110324169A (en) A kind of method and apparatus of interface management
CN107491382B (en) Log output method and device
CN109245908B (en) Method and device for switching master cluster and slave cluster
CN110851468A (en) Method and device for making simulation response to test request of client
CN109241033A (en) The method and apparatus for creating real-time data warehouse
CN110019158A (en) A kind of method and apparatus of monitoring data quality
CN110019539A (en) A kind of method and apparatus that the data of data warehouse are synchronous
CN109656799A (en) Test method and device
CN102567517A (en) Device and method for issuing data of database
US20230319054A1 (en) Tenant-specific solution subscriptions for an extensibility platform
CN110071840A (en) Upgrade method, device and client
CN110019059A (en) A kind of method and apparatus of Timing Synchronization
CN110244975A (en) A kind of generation method and device of static resource version number
CN109788010A (en) A kind of method and apparatus of data localization access
CN112579447A (en) Browser testing method and device
CN113762910A (en) Document monitoring method and device
CN113434384A (en) Pressure testing method and device
CN110445628A (en) A kind of task control method and device based on NGINX
CN110311819A (en) Automatic production of HTML page and MIBs table generating method, management method, equipment end and management system based on page configuration file

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant