A kind of OpenTsdb service indication polymerization based on Zookeeper
Technical field
The present invention discloses a kind of OpenTsdb service indication polymerization based on Zookeeper, is related to data processing skill
Art field.
Background technique
Internet of Things IoT (Internet of Things) system is divided into sensing layer, transport layer, application layer, with Internet of Things
The development of technology, more and more objects (equipment or sensor etc.) are connected with each other, so that the time series data of magnanimity is produced,
In this context, it has been born and has met the professional domain type database i.e. time series database OpenTsdb of mass data quick storage.
Time series data refers to the series of values data point of some specific indexes amount in a period of time, OpenTsdb
By time series data by index and label and timestamp come one index amount of unique identification, these achievement datas have immutable
Property.TSD is the service processes of OpenTsdb, it is the stateless service based on HBase, and OpenTsdb generally passes through multiple TSD
Realize the extending transversely of cluster, each TSD example can receive write-in and the read requests of time series data, unit time
Write-in, each TSD example of read requests quantitative index can only individually count, without the statistical number of entire OpenTsdb cluster
According to, but the overall performance index of OpenTsdb cluster just can accurately reflect the handling capacity of cluster.And the invention proposes
A kind of OpenTsdb service indication polymerization based on Zookeeper, it is interim orderly and permanent in Zookeeper by utilizing
Two kinds of znode node realizes the registration of Alive TSD process, the election of Worker TSD and service indication number
The work of indicator polymerization and persistence is realized according to processes, Worker TSD such as interim storages, increases the multiple whole of cluster
Body performance indicator can accurately reflect the handling capacity of OpenTsdb cluster and the actual use situation of persistent storage, side
OpenTsdb cluster performance Optimization Work, while be also convenient for monitoring OpenTsdb cluster.In platform of internet of things for
User understands the hot spot period that time series data generates, further to analyze time series data.
Summary of the invention
The present invention is directed to problem of the prior art, provides a kind of OpenTsdb service indication polymerization based on Zookeeper
Method increases multiple overall performance indexs of cluster, can accurately reflect OpenTsdb cluster handling capacity and persistently
Change the actual use situation of storage.
Concrete scheme proposed by the present invention is:
A kind of OpenTsdb service indication polymerization based on Zookeeper, each TSD process registers of OpenTsdb
On the interim orderly znode node in Zookeeper, and attempt to be registered as Worker TSD process, while interim orderly
WorkerChangedWatcher monitor is registered on znode node, carries out the hot-swap of Worker TSD process,
Worker TSD process starts service indication data aggregate task according to the timer of configuration, by each TSD process
Service indication data aggregate phase adduction persistence, Worker TSD process also according to client query request, will take accordingly
Indicator polymerization data of being engaged in generate response and return to client.
After each TSD process of OpenTsdb normally starts in the method, the metadata information of TSD process is write
Enter in the interim orderly data field of znode node, is registered on the interim orderly znode node of Zookeeper.
Each TSD process registers pass through choosing on the interim orderly znode node in Zookeeper in the method
It lifts algorithm and elects polymerization and persistence that Worker TSD process carries out service indication data.
WorkerChangedWatcher monitor is registered on interim orderly znode node in the method, is subscribed to
NodeDataChanged, NodeChildrenChanged and NodeDeleted event, when such an event occurs, each
TSD process reattempts to the Worker TSD process that is registered as, and carries out the hot-swap of Worker TSD process.
The service indication data of each TSD process are stored in corresponding permanent znode node in the method, permanently
Service indication data persistence in znode node is into bottom HBase Cluster Database.
The service indication inquiry request of client is forwarded to a certain TSD process in the method, by this certain TSD into
The reference of the Worker TSD process access point of journey, sends inquiry request in Worker TSD process.
OpenTsdb before multiple TSD processes by disposing Load Balancer load balancer in the method
The extending transversely of cluster is carried out, client is sent in service indication inquiry request to Load Balancer load balancer, according to
The tactful forwarding inquiries request of configuration passes through drawing for the Worker TSD process access point of a certain TSD process to a certain TSD process
With sending inquiry request in Worker TSD process.
Worker TSD process is handled using the MetricQueryHandler index requestor of itself in the method
Inquiry request, according to service indication and querying condition by znode node serve achievement data corresponding in Zookeeper and
Response is generated after service indication data aggregate in HBase, and response is finally returned to client.
Usefulness of the present invention is:
The present invention provides a kind of OpenTsdb service indication polymerization based on Zookeeper, by Zookeeper
The interim orderly znode node of upper registration indicates the TSD process of Alive, realizes the choosing for possessing the TSD process of Worker role
It lifts, realizes Worker TSD by registering customized WorkerChangedWatcher on interim orderly znode node
The broadcast of process metadata information, possess Worker role TSD process be responsible for timing polymerize index, persistence achievement data with
And the index inquiry request that customer in response end is initiated, it can accurately reflect that the handling capacity of OpenTsdb cluster and persistence are deposited
The actual use situation of storage, facilitates the performance Optimization Work of OpenTsdb cluster, while being also convenient for monitoring OpenTsdb cluster.
The hot spot period that time series data generates is understood for user in platform of internet of things, further to analyze time series data.
Detailed description of the invention
Fig. 1 is OpenTsdb aggregated structure schematic diagram;
The flow chart of Worker TSD process is obtained in Fig. 2 present invention;
OpenTsdb service indication querying flow figure in Fig. 3 present invention.
Specific embodiment
The present invention provides a kind of OpenTsdb service indication polymerization based on Zookeeper, each of OpenTsdb
TSD process registers are attempted to be registered as Worker TSD process on the interim orderly znode node in Zookeeper, together
When WorkerChangedWatcher monitor is temporarily registered on orderly znode node, carry out the fervent of Worker TSD process
It changes,
Worker TSD process starts service indication data aggregate task according to the timer of configuration, by each TSD process
Service indication data aggregate phase adduction persistence, Worker TSD process also according to client query request, will take accordingly
Indicator polymerization data of being engaged in generate response and return to client.
The present invention will be further explained below with reference to the attached drawings and specific examples, so that those skilled in the art can be with
It more fully understands the present invention and can be practiced, but illustrated embodiment is not as a limitation of the invention.
Using the method for the present invention, service indication polymerization is carried out to the time series database OpenTsdb of certain Internet of Things IoT,
With reference to Fig. 1, TSD process is registered after normally starting in Zookeeper, by the ID mark of TSD process, HTTP URI
In the interim orderly znode node (/tsdb/tsd-0) data field of the metadata informations such as address and version write-in, trial will be certainly
Oneself is registered as Worker TSD process, reads the data of "/tsdb " node, and "/tsdb " node preserves Worker TSD's
Relevant information such as " { worker:tsd-0 } " elects Worker TSD process by election algorithm and carries out service indication data
Polymerization and persistence, such as choose smallest sequence number TSD process assign its Worker role,
WorkerChangedWatcher monitor is registered on "/tsdb " znode node simultaneously, is subscribed to
NodeDataChanged, NodeChildrenChanged and NodeDeleted event, when such an event occurs, each
TSD can be reattempted to and is registered as oneself to possess Worker role, to realize the hot-swap of Worker TSD;
Each TSD process can be incited somebody to action when receiving write-in or the request of reading data point, establishing connection with client
Service indication data are stored in corresponding permanent znode node, and the service indication data persistence in permanent znode node is extremely
In the index raw data table tsdb_raw_metrics of bottom HBase Cluster Database, the service in permanent znode node refers to
It, can be by this permanent znode knot removal, Worker TSD process after marking data and persistence to bottom HBase Cluster Database
Start indicator polymerization task according to the timer of configuration, the service indication data of each TSD process are permanent in Zookeeper
Numerical value in the data field of znode node "/tsdb/total_dps ", which polymerize, to be added, and "/tsdb/total_ is still stored in
In the permanent znode node of dps ", until persistence is into the index raw data table of bottom HBase Cluster Database,
With reference to Fig. 1 and Fig. 3, OpenTsdb before multiple TSD processes by disposing Load Balancer load balancer
The extending transversely of cluster is carried out, in client transmission service indication inquiry request to Load Balancer load balancer, root
It requests according to the tactful forwarding inquiries of configuration to a certain TSD process, passes through the Worker TSD process access point of a certain TSD process
(WorkerTSDEndpoint) reference sends inquiry request in Worker TSD process, and Worker TSD process utilizes
The MetricQueryHandler index requestor of itself handles inquiry request, is read according to service indication and querying condition
Service indication data in tsdb_raw_metrics table, by znode node serve achievement data corresponding in Zookeeper and
Response, and the tables of data that service indication aggregated data persistence is extremely responded are generated after service indication data aggregate in HBase
In, response is finally returned to client.
Embodiment described above is only to absolutely prove preferred embodiment that is of the invention and being lifted, protection model of the invention
It encloses without being limited thereto.Those skilled in the art's made equivalent substitute or transformation on the basis of the present invention, in the present invention
Protection scope within.Protection scope of the present invention is subject to claims.