A kind of AFC (Automatic Fare Collection) data processing method of many formationsTechnical field
The present invention relates to data in server disposal route in a kind of distributed system, particularly relate to the many formations AFC (Automatic Fare Collection) data processing method in a kind of AFC system.
Background technology
In the AFC system of subway station, equipment and station computer are formed the distributed system of a sealing, all devices is sent to station computer to the AFC (Automatic Fare Collection) data that produce at any time by network and handles in real time, and in time feed back to the station operating personnel, finish information sharing and monitoring.The AFC system data processing efficiency is normal to the station, high-efficient operation is most important.
Along with the subway business development, traditional AFC (Automatic Fare Collection) data processing method can't satisfy flexibly, the lot of data processing requirements.Its reason is: at first, in the subway line, the scale of each website is inconsistent, causes data volume that the station computer of each website handles and inequality; Secondly, along with updating of subway business, traffic data type constantly changes, and the data volume that equipment produces is also in continuous growth.As changing by increasing number of computers reply data volume, so the hardware input cost and at the software development design cost of many computing machines all than higher, and the computer hardware performance is upgraded and is promoted comparatively fast, makes that later stage HardwareUpgring cost is higher.So under former mentality of designing, the active computer hardware resource can't be given full play to and use to traditional automatic ticketing data processing method, bring adverse effect for the efficient use of hardware resource and ticket sale system, and cause the bigger wasting of resources.
How to make that existing AFC system forms efficiently, low-cost, easy flexible running status, the raising data handling procedure is wanted the problem that solves with regard to becoming the present invention.
Summary of the invention
In view of above-mentioned the deficiencies in the prior art, the present invention aims to provide a kind of AFC (Automatic Fare Collection) data processing method of many formations, the low-cost expansion scheme of software view is provided for computer equipment, guaranteeing on the basis of data-handling efficiency, calculate the phenomenon that realizes that reply AFC system data volume constantly changes by configuration, with operation, the regulatory requirement that satisfies the AFC (Automatic Fare Collection) station.
The present invention is achieved by the following technical solutions:
A kind of AFC (Automatic Fare Collection) data processing method of many formations is characterized in that concrete steps comprise:
Step 1, in the computer equipment data handling procedure, at first set up: one-level formation and dispatch thread pond, and the secondary formation and with secondary formation corresponding service processing threads pond.
Step 2, utilize the real time data bag of described one-level formation receiving front-end station equipment, simultaneously, the one-level formation also provides the CPU that blocks the machine-processed equipment that uses a computer, detailed process is: do not have data in the one-level formation as described, thread in the described dispatch thread pond can block when obtaining data, just continues to carry out after obtaining data; After data packet number reaches the upper limit in the one-level formation as described, will no longer receive packet.
Step 3, obtain data from described one-level formation by described dispatch thread pond, the resolution data bag and judge type after put into described secondary formation.
Step 4, described secondary formation receive the packet that meets preset kind from described dispatch thread pond, simultaneously, the secondary formation also provides the CPU that blocks the machine-processed equipment that uses a computer, detailed process is: do not have data in the secondary formation as described, thread in the corresponding service processing threads pond can block when obtaining data, just continues to carry out after obtaining data; After data packet number reached the upper limit in the secondary formation as described, the dispatch thread pond can send obstruction when depositing data in, up to etc. just continue after the success to be deposited to carry out.
The packet that step 5, described business processing thread pool obtain from the described secondary formation of correspondence carries out business processing, finishes data handling procedure.
If packet requires to return, then the data that business processing is finished are assembled the packet that returns, and send back to by network service.
The quantity in described one-level formation and dispatch thread pond respectively is one, and the thread in dispatch thread pond is carried out with concurrent or parallel mode.
The quantity of described secondary formation is one or more; The quantity of described business processing thread pool is identical with described secondary number of queues and corresponding one by one, the data in the secondary formation of a correspondence of the only responsible processing of corresponding service processing thread pool; The thread of described business processing thread pool is carried out with concurrent or parallel mode.
The capacity of the capacity of described one-level formation and secondary formation calculates from corresponding calculated machine equipment memory size and anticipatory data bag treatment capacity respectively, and formula is as follows:
Wherein, N is the number of secondary formation, DT1... DTnBe the data strip number that each formation per second expection is handled, PM is the size of every data of expection, and TM is the computer equipment memory size, and FQ is an one-level queue assignment size, SQiIt is the allocated size of i secondary formation.
In the described dispatch thread pond in number of threads and the described business processing thread pool number of threads calculate from the CPU quantity and the anticipatory data bag treatment effeciency of computer equipment respectively, formula is as follows:
Wherein N is the number of secondary formation, DT1... DTnBe the data strip number that each formation per second expection is handled, UT is a CPU sum in the computer equipment, the number of threads that FT distributes for the dispatch thread pond, STiIt is thread quantity allotted in i the secondary formation business processing thread pool.
Thread in thread in the described dispatch thread pond and the described business processing thread pool, as in the computer equipment of single cpu, thread is carried out in concurrent mode; As in the computer equipment of a plurality of CPU, thread is carried out with parallel or concurrent mode.
Described computer equipment comprises personal computer, server or other network equipment.
By such scheme as can be seen, the capacity of one-level formation and secondary formation among the present invention, and dispatch thread pond and business processing thread pool can change flexibly at data volume and hardware configuration.When data volume changes, need not to adjust number of computers or revise software design, can self make rapid adjustment, satisfy the needs of communication transmission, not only saved the hardware and software cost, also solved the AFC (Automatic Fare Collection) data volume and changed a difficult problem of bringing, concrete beneficial effect comprises:
(1) is convenient to dispose, is easy to realize, effectively reduce cost
The present invention adopts the mode of software arrangements to satisfy the processing requirements of flexible portfolio, need not to increase hardware input or change software design, the cost when having reduced increase of reply portfolio or professional the change.
(2) applied range
Can be widely used in the service end data processing of distributed system under the LAN (Local Area Network) state.
(3) data-handling efficiency height
Adopt the concurrent or parallel mode of a plurality of threads to carry out AFC (Automatic Fare Collection) data distribution and processing, speed is fast, and data-handling efficiency can satisfy business need fully.
Description of drawings
Fig. 1 is the AFC (Automatic Fare Collection) data processing method structural representation of a kind of many formations of the present invention;
Fig. 2 is the data distribution schematic flow sheet of the AFC (Automatic Fare Collection) data processing method of a kind of many formations of the present invention;
Fig. 3 is the flow chart of data processing synoptic diagram of the AFC (Automatic Fare Collection) data processing method of a kind of many formations of the present invention.
Embodiment
The present invention is described in further detail below in conjunction with the drawings and specific embodiments:
The AFC (Automatic Fare Collection) data processing method of a kind of many formations of the present invention, concrete steps comprise:
Step S100, in the data handling procedure of computer equipment, at first set up one-level formation and dispatch thread pond, and the secondary formation and with secondary formation corresponding service processing threads pond.
Computer equipment can be personal computer, server or other network equipment, in the present embodiment, as shown in Figure 1, the quantity in one-level formation 1 anddispatch thread pond 2 respectively is one, the quantity ofsecondary formation 3 is two, the quantity of businessprocessing thread pool 4 is identical withsecondary formation 3 quantity and form annexation one to one, that is, and and the data in thesecondary formation 3 of a correspondence of 4 responsible processing of corresponding service processing thread pool.In the computer equipment of single cpu, the thread of the thread indispatch thread pond 2 and businessprocessing thread pool 4 is carried out in concurrent mode respectively; And in the computer equipment of a plurality of CPU, the thread of the thread indispatch thread pond 2 and businessprocessing thread pool 4 is then carried out with parallel or concurrent mode.
Then, as shown in Figure 2, one-level formation AFC (Automatic Fare Collection) data distribution flow process is as follows:
Step S101, utilize the one-level formation to receive the real time data bag of station equipment, promptly receive the AFC (Automatic Fare Collection) data by the network service thread, trial deposits the one-level formation in.
Step S102, judge whether AFC (Automatic Fare Collection) quantity has reached the upper limit in the one-level formation,, continue to attempt depositing in the one-level formation if then carry out S101; Otherwise carry out S103.
Step S103, AFC (Automatic Fare Collection) data deposit the one-level formation in.
Whether pending datas such as thread block are arranged in step S104, the dispatch thread pond, then carry out S107, otherwise carry out S105 if having.
Thread is attempted obtaining the AFC (Automatic Fare Collection) data from the one-level formation in step S105, the dispatch thread pond.
Step S106, judge that whether the one-level formation is empty,, otherwise carry out S108 if then carry out S107.
Attempt obtaining the thread block of AFC (Automatic Fare Collection) data in step S107, the dispatch thread pond, wait for that having data to deposit the back in the one-level formation continues to carry out.
Step S108, thread is got the AFC (Automatic Fare Collection) data in the dispatch thread pond, and the resolution data bag is put into corresponding secondary formation according to type.
Follow, as shown in Figure 3, described secondary AFC (Automatic Fare Collection) flow chart of data processing is as follows again:
Thread is attempted depositing the AFC (Automatic Fare Collection) data in to the secondary formation in step S201, the above-mentioned dispatch thread pond.
Whether pending datas such as thread block are arranged in step S202, the judgment processing thread pool, then carry out S208, wait for that the secondary queuing data deposits in if having; Otherwise carry out S203.
Whether the AFC (Automatic Fare Collection) data have reached the upper limit in step S203, the secondary formation, if then carry out S204, otherwise carry out S205.
Attempt depositing in the thread block of AFC (Automatic Fare Collection) data in step S204, the dispatch thread pond, wait for the back continuation execution of having living space in the secondary formation.
Step S205, AFC (Automatic Fare Collection) data deposit the secondary formation in.
Thread is attempted obtaining the AFC (Automatic Fare Collection) data from the secondary formation in step S206, the business processing thread pool.
Whether step S207, secondary formation are empty, if then carry out S208, otherwise carry out S209.
Attempt obtaining the thread block of AFC (Automatic Fare Collection) data in step S208, the business processing thread pool, wait for and continue to carry out after data are arranged in the secondary formation.
Thread is got the AFC (Automatic Fare Collection) data and is handled in step S209, the business processing thread pool.
In step S210, the dispatch thread pond whether the obstruction thread is arranged, then carry out S204, otherwise this processing finishes if having.
In the said process, the capacity of the capacity of one-level formation and secondary formation calculates from corresponding calculated machine equipment memory size and anticipatory data bag treatment capacity respectively, and formula is as follows:
Wherein, N is the number of secondary formation, DT1... DTnBe the data strip number that each formation per second expection is handled, PM is the size of every data of expection, and TM is the computer equipment memory size, and FQ is an one-level queue assignment size, SQiIt is the allocated size of i secondary formation.
And in the dispatch thread pond in number of threads and the business processing thread pool number of threads calculate from the CPU quantity and the anticipatory data bag treatment effeciency of computer equipment respectively, formula is as follows:
Wherein N is the number of secondary formation, DT1... DTnBe the data strip number that each formation per second expection is handled, UT is a CPU sum in the computer equipment, the number of threads that FT distributes for the dispatch thread pond, STiIt is thread quantity allotted in i the secondary formation business processing thread pool.
Certainly, after information processing is finished, if packet requires to return, the packet that returns of the data assembling that business processing is finished then, and send back to by network service and to get final product.
By the description of above implementation process, the those skilled in the art can be well understood to the realization of the present invention at software view.Based on such understanding, technical scheme of the present invention embodies in essence or to the contribution of the prior art form with software product, this computer software product is stored in the storage medium, comprises that some instructions are used so that all or part of step of a described method of computer equipment execution each embodiment of the present invention.And aforesaid storage medium comprises: various media that can be program code stored such as ROM (read-only memory) (ROM), random-access memory (ram), magnetic disc or CD.
Obviously, said process only is a specific embodiment of the present invention, rather than whole embodiments.Based on the content that the present invention describes, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.