Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
One embodiment of the invention provides a kind of method that control data are sent, as shown in Figure 1, this method comprises:
101, the consumer module of data producer module and receiving device establishes communication channel, and creation and receiving end
The corresponding transmission control unit of the consumer module of equipment.
Wherein, communication channel sending and receiving for realizing business datum, preferred data transmission module are reliable
Transmission module, for example may include: any one or a few in the transmission mechanisms such as TCP/TIPC/SCTP/UNIX/LLC2.
It is worth noting that communication channel can also be rendered as socket, filec descriptor, handle etc..
102, send control unit when detecting that communication channel allows to send business datum, successively according in caching to
The index for sending business datum obtains business datum to be sent, and generates new data to be sent, by communication channel, sends new
Pending transmit data to receiving device.
Specifically, since the index of business datum to be sent is the data generating unit of data producer module according to pending
Send business datum to generate, then business datum to be sent and the index are one-to-one, the index of business datum to be sent by
Business datum to be sent generates unit and is sent to transmission control unit, sends control unit to according to the industry to be sent cached
The index of business data can get business datum to be sent in the media such as memory, service database or application file,
And then the business datum that will acquire is cached, it is raw according to the index of business datum to be sent and the business datum got
The data to be sent of Cheng Xin, are sent.
The method that control data provided in an embodiment of the present invention are sent, when determining that testing mechanism can send business datum
When, the index of business datum to be sent is determined from caching, is obtained and the index pair according to the index of the business datum to be sent
The data to be sent answered generate new data to be sent, and send the new data to be sent by communication channel.With existing skill
In art, sending ending equipment has to cache all data to be sent, and in the case where communication channel allows, is sending these
Data are compared, technical solution provided in an embodiment of the present invention, it is only necessary to cache the index of data to be sent, the data volume of index is small
In the data volume of business datum corresponding with the index, so that the problem of significantly alleviating the wasting of resources, reduces overhead.
Another embodiment of the present invention provides a kind of methods that control data are sent, as shown in Fig. 2, this method comprises:
201, the data generating unit of data producer module generates business datum to be sent according to business datum to be sent
Index, and be sent to transmission control unit.
Optionally, this method is executed by the sending ending equipment of generation business datum, which can be the transmitting terminal
The data or the transmitting terminal that the received extraneous network of the data generating module of equipment or other sending ending equipments are sent are set
Changed data inside standby data generating module.
Preferably, according to the organizational form of business datum, index corresponding with the business datum is generated.
202, being indexed in preset cache structure for control unit preservation business datum is sent.
Wherein, preset cache structure includes at least: fifo queue and tree structure.Specifically, caching the business
When the index of data, storage is combined according to following two mode:
The first storage mode: it is stored according to the sequence in a manner of fifo queue for getting business datum;
Storage mode in second: index is stored according to tree structure.
It further, can be according to other storage rules of user or default come the index of storage service data.
It is worth noting that business datum can be guaranteed according to the sequence got when using the first storage mode
It is successively sent to the receiving end of business datum, to simplify the processing logic that business datum sends control with scheduling;Work as use
When second of storage mode, when removing specific index data, the search efficiency of the index of the business datum can be improved.
203, when detecting that communication channel allows to send business datum, according to the index of the business datum to be sent of caching
It obtains business datum to be sent, and generates new data to be sent, by communication channel, send and new pending transmit data to reception
End equipment.
It is worth noting that being sent in data procedures to be sent, further includes: following three kinds of situations by communication channel:
The first situation: when the data generating unit of data producer module carries out twice identical business datum to be sent
Or when multi-pass operation, due to for each time operate can all send the business datum to be sent to index transmission control single
Member sends the index that control unit only retains the business datum to be sent that data generating unit last time is sent.
Specifically, the corresponding control unit that sends will receive simultaneously when carrying out multi-pass operation to same a business datum
The index for caching the business datum to be sent of number corresponding with the number of operations of the business datum, will basis if be not processed
Multiple index gets business datum identical with the multiple groups of equivalent amount of index number of above-mentioned business datum, so
At this moment the index for the multiple identical business datums for needing to cache is deleted, and the index of the business datum is only retained, thus
Only retain one group of business datum to be sent, and the business datum of the reservation is sent to data transmission module.
Second situation: when service data manipulating to be sent variation, the data generating unit root of data producer module
It is different according to the operation of business datum to be sent, generate additional information;And the business to be sent generated according to business datum to be sent
The index of additional information and business datum to be sent is sent to transmission control unit by the index of data together;Data producer
The transmission control unit of module is generated and is sent by communication channel according to the additional information and the business datum to be sent of acquisition
New data to be sent.Send index and additional information that control unit receives business datum to be sent from data generating unit
Afterwards, when judging to preserve the index of identical business datum to be sent in preset cache structure, with currently received attached
Add the corresponding additional information of index of the business datum to be sent saved in information update preset cache structure.
Wherein, additional information is used to record the operational order or operation change to current business datum to be sent.Work as data
When generation unit modifies identical business datum to be sent twice, data generating unit is by additional information and according to be sent
The index for the business datum to be sent that business datum generates together, is sent to transmission control unit;Data generating unit according to
The index and tree-like buffer structure for sending business datum, quickly find in tree structure on present in preset cache structure
The index of primary business datum to be sent, and deleted from fifo queue and tree structure.Control unit is sent only to retain
The index for the business datum to be sent that data generating unit last time is sent.
When data generating unit is first added identical business datum to be sent, deletes afterwards, data generate single
The index of the relevant additional information of delete operation and business datum to be sent together, is sent to transmission control unit by member;It sends
Control unit quickly finds preset cache according to the index and tree-like buffer structure of business datum to be sent in tree structure
The index of the business datum to be sent of last time present in structure, and deleted from fifo queue and tree structure.If
It deletes successfully, sends the index that control unit does not retain business datum to be sent.
The change that current data occurs relative to the data of original storage, and then can be only to the changed a part
Data are handled.For example, the variation that business datum occurs are as follows: be added to data on the basis of original business datum, then root
Additional information is generated according to the data of the addition, wherein description has which number is added in the business datum in the additional information
According to, and then data described in upper additional information can be directly added on the index of the business datum of original caching, it constitutes most
Whole task data to be sent, buffered business datum before need not reacquiring again in this case have saved and are
System resource.
It is worth noting that a kind of above-mentioned only citing changed to business datum, the embodiment of the present invention is to business
The version of data is without limiting.
The third situation: when detecting communication channel exception, the index of specified services data is removed.
It is worth noting that in the first scenario, it is complete that storage is avoided in the sending ending equipment of business datum
Business datum and multiple storage to same a business datum, to reduce the waste of system resource.In the latter case,
It avoids in the same business datum of caching, when executing addition, delete operation to same a business datum, if adding or deleting
The operation service data removed are identical, can thus make data receiver first add and delete the business datum again, in this way in business
The receiving end of data executes useless action, wastes system resource.
Another embodiment of the present invention provides a kind of method that control data are sent, this method can be applied to transmission services
The sending ending equipment of data, the sending ending equipment include at least one data producer module, wherein data producer module is
The producer of data to be sent, preferably application program, data producer module are needing consumer's mould with receiving device
When block is communicated, communication channel is established with receiving device first, is specifically established with the consumer module of receiving device
Communication channel;The data producer module can create and initialize transmission control unit, and can be the communication channel of creation
It is associated with control unit foundation is sent, communication channel therein and transmission control unit pass through software realization.
In the present embodiment, the data generating unit of data producer module, after getting business datum, Neng Gougen
According to the organizational form of business datum, the index of business datum is generated, and can be when business datum changes, according to business number
According to rule of conversion generate additional information, which is used to embody the variation of business datum generation, and by the business datum
Index and additional information be sent to transmission control unit, and then send index that control unit caching is got and additional
Information, and according to preset schedule rule, the index of business datum to be sent is chosen, and produce from above-mentioned data according to the index
Business datum corresponding with the index is obtained at the data generating unit of person's module, it is further, to be sent getting this
New data to be sent are generated after business datum, and new data to be sent are sent to by receiving device by communication channel
Consumer module.In the present embodiment, sending ending equipment and receiving device can be same equipment, or distinct device.
Specifically, there is visioning procedure in embodiments of the present invention, i.e. it is single to send control for data producer module initialization
The embodiment of member, creation communication channel and the process for sending control unit.
Firstly, data producer module initialization sends control unit.
It is worth noting that while initializing the transmission control unit, it is possible to specify send the scheduling of control unit
Mode, i.e., specified preset schedule rule.Wherein, which includes: to send control unit automatically according to communication channel
Situation dispatch or data producer module dispatch manually according to demand.
Secondly, data producer module calls communication channel interface, communication channel is created.
Wherein, communication channel interface can be the interface that any communication channel provides, for example, interprocess communication interface, report
Literary transmission interface etc..
Further, data producer module creation sends control unit, and by communication channel and sends control unit pass
Connection.
It is worth noting that can also specify whether the transmission control unit needs when creating the transmission control unit
Queue to be sent is created, which is used to store to get from data producer module according to the index of business datum
Business datum.Furthermore it is also possible that it is that data readjustment, abnormality processing readjustment etc. return that index translation is arranged in the transmission control unit
Adjust interface.Wherein, index translation is data callback interface, can be corresponding with the index by index translation by calling the interface
Be actually subjected to send data;The abnormality detection result of communication channel can be notified to data by abnormality processing callback interface
Unit is generated, so that data producer module is made and being further processed.
Then after completing above-mentioned visioning procedure, following business datum transmission flows is executed, as shown in figure 3, the process
Include:
301, the data generating unit of data producer module generates business datum.
Note that data generating unit here generates business datum, it is to refer to that data generating unit obtains business datum, this
Kind obtains the business datum that can be data producer module itself generation, is also possible to the industry that data producer module receives
Business data.
302, data generating unit generates the index of business datum according to the organizational form of business datum.
303, data generating unit calls the transmission for sending control unit to index interface, which is sent to transmission control
Unit, and the index is cached by transmission control unit.
Optionally, the index received can be cached in sending index queue by sending control unit.
Optionally, it is worth noting that, the interface of transmission index can also send additional information.
Further, when data generating unit is there are also when other business datums, above-mentioned 301,302 are continued to execute.
304, send control unit detect communication channel allow send data when, according to preset schedule rule, from
The index of a business datum is taken in the index of caching.
Wherein, the index of a business datum of acquisition is the index of business datum to be sent.
305, the index translation that transmission control unit calls data generating unit to register will take out as data callback interface
Index translation be new data to be sent.
306, it sends control unit and the new business datum to be sent is sent by communication channel.
Specifically, when sending the business datum, including following two form:
The first form: being put into queue to be sent for business datum to be sent, allows transmission business number in communication channel
According to when, take out the business datum in the queue to be sent, send the business datum via communication channel.
Second of form: the business datum is directly sent by communication channel.
It is worth noting that being sent out since data generating unit and transmission control unit may be asynchronous process
Before sending control unit to send data, to same a business datum, it is understood that there may be multi-pass operation.When transmission control unit is according to rope
Draw when obtaining business datum from data generating unit, will get two parts of identical business datums, and by these identical industry
Business data are sent to the receiving end of data, in this way due to needing to store and sending how identical business datum, will lead to system
The waste of resource, in order to avoid the appearance of this problem, when only retain twice or when multi-pass operation to data to be sent
One group of business datum to be sent, and send receiving end of the business datum to be sent to business datum of reservation.
For example, the business datum of generation be illustrated for updating twice by data generating unit occur, as shown in figure 4,
Under the above-mentioned scene updated twice, the execution process of elimination of duplicate data includes:
401, when updating the first time of business datum, update message 1 is sent to transmission control list by data generating unit
Member sends control unit and deletes duplicate index in the index of the business datum of caching.
402, in second of update of business datum, continue for update message 2 to be sent to transmission control unit, send control
Unit processed deletes duplicate index in the index of the business datum of caching.
The index queue of business datum to be sent only retains portion to same part data, produces sending control unit from data
It is identical when judging to preserve in preset cache structure after raw unit receives index and the additional information of business datum to be sent
When the index of business datum to be sent, the industry to be sent saved in preset cache structure is updated with currently received additional information
The corresponding additional information of index for data of being engaged in, to achieve the purpose that delete duplicate index.
Data generating unit just has sent to transmission control unit in this way updates request twice, that is, is sending control list
The index of business datum twice can be stored in member will obtain when sender obtains business datum according to the index of business datum
To two groups of identical last updated business datums, this has resulted in the repetition of business datum, this just needs that is to delete
Except duplicate one group of business datum.The embodiment of the present invention, it is every to be updated by primary, it will successively be deleted duplicate operation.
403, control unit is sent from data generating unit request business datum.
Further, when transmission control unit detects communication channel exception, exception can be reported to data generating unit,
And then after data generating unit receives exception, and then it can enter and close or restart communication channel process.
Further, when restarting communication channel, transmission control unit is re-created, and again by communication channel and newly
Send control unit association.
Wherein, communication channel include: extremely can not storage allocation, communication channel disconnect.
It is worth noting that communication channel Shredding Process, data producer module can also be performed in data producer module
It calls to destroy and sends control unit, is i.e. communication channel and hair are removed in destruction and the associated transmission control unit of specified communication channel
Send the relationship between example;Further, data producer module calling interface destroys communication channel.
Another embodiment of the present invention provides a kind of control data Transmission system composition schematic diagram, as shown in figure 5, system
Including sending ending equipment 501 and receiving device 502, receiving device is that the control data in the embodiment of the present invention are sent
Device, it is specific as shown in Figure 6.Sending ending equipment includes at least one data producer module, and receiving device includes at least one
A data consumer module.It is worth noting that, those of ordinary skill in the art are clearly known sending ending equipment and
Receiving device is an opposite concept, and sending ending equipment and receiving device are functioned simultaneously as the same equipment
Role.That is the data producer module role that also similarly serves as data consumer.In embodiments of the present invention, sending ending equipment and
Receiving device can be same equipment.
Another embodiment of the present invention provides a kind of devices that control data are sent, as shown in fig. 6, the device includes at least
One data producer module 600, data producer module 600 are communicated for establishing with the consumer module of receiving device
Channel, and create transmission control unit 601 corresponding with the consumer module of receiving device;Control unit 601 is sent, is used for
When detect communication channel allow send business datum when, successively according to the index of the business datum to be sent in caching obtain to
Business datum is sent, and generates new data to be sent and sends the new receiving end pending that transmits data to by communication channel and set
It is standby.
Data producer module 600 further includes data generating unit 602, data generating unit 602, for according to be sent
Business datum generates the index of business datum to be sent, and is sent to transmission control unit;It is also used to, according to business number to be sent
According to operational order, generate additional information, by additional information and according to business datum to be sent generate business datum to be sent
Index together, be sent to transmission control unit,
It sends control unit 601 to be also used to, saves being indexed in preset cache structure for business datum;Wherein, it presets slow
It deposits structure to include at least: advanced to reveal queue and tree structure.Be also used to, receive data generating unit send additional information with
And business datum to be sent index and save into preset cache structure, according to additional information and the business to be sent of acquisition
Data generate the new data to be sent sent by communication channel.It sends control unit 601 to be also used to, be generated from data single
It is identical pending when judging to preserve in preset cache structure after member receives index and the additional information of business datum to be sent
When sending the index of business datum, the business number to be sent saved in preset cache structure is updated with currently received additional information
According to the corresponding additional information of index.
The device that control data provided in an embodiment of the present invention are sent, when determining that testing mechanism can send business datum
When, the index of business datum to be sent is determined from caching, is obtained and the index pair according to the index of the business datum to be sent
The data to be sent answered generate new data to be sent, and send the new data to be sent by communication channel.With existing skill
In art, sending ending equipment has to cache all data to be sent, and in the case where communication channel allows, is sending these
Data are compared, technical solution provided in an embodiment of the present invention, it is only necessary to cache the index of data to be sent, the data volume of index is small
In the data volume of business datum corresponding with the index, so that the problem of significantly alleviating the wasting of resources, reduces overhead.
Through the above description of the embodiments, it is apparent to those skilled in the art that the present invention can borrow
Help software that the mode of required common hardware is added to realize, naturally it is also possible to which the former is more preferably by hardware, but in many cases
Embodiment.Based on this understanding, the portion that technical solution of the present invention substantially in other words contributes to the prior art
Dividing can be embodied in the form of software products, which stores in a readable storage medium, such as count
The floppy disk of calculation machine, hard disk or CD etc., including some instructions are used so that computer equipment (it can be personal computer,
Server or the network equipment etc.) execute method described in each embodiment of the present invention.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.