Summary of the invention
The technical problem to be solved be to provide a kind of realize data process and mutual method and
System, it is possible to increase the bandwidth utilization rate of physical connection and optimize the number that logic connects.
In order to solve above-mentioned technical problem, the invention provides a kind of data that realize and process and mutual side
Method, is applied to client, including:
Command process thread takes out request command from newly requested order chained list and insertion is just processing command chaining
In table, described request command is split, the one or more packets split into are inserted and sends bag
In chained list;
Transmission thread takes out packet from described transmission bag chained list and is transmitted;
Receiving thread such as receives the packet from service end, then inserted by packet and receive bag chained list
In;
Processing data packets thread judges to receive whether the packet in bag chained list can be assembled into one completely
Response command, be to take out packet and assemble, insert response life by assembling complete response command
Make in chained list, and according to this response command, the corresponding requests order just processed in order chained list is deleted;
Wherein, described transmission thread and receiving thread are multiple;Each thread parallel performs.
Further, the method also includes following feature:
Described transmission bag chained list is multiple with receiving bag chained list;
Send thread and send bag chained list one_to_one corresponding, receiving thread and reception bag chained list one_to_one corresponding;
The one or more packets split into are inserted and send in bag chained list by command process thread, including:
Command process thread selects a shortest transmission bag chained list of length from multiple transmission bag chained lists, will split
The one or more packets become insert this table tail sending bag chained list selected.
Further, the method also includes following feature:
Described request command is split by command process thread, including: command process thread is according to presetting
Single transmission bag maximum length, request command is split into one or more packet;Wherein, often
Individual packet carries the command id of this request command, the sequence number of notebook data bag and this request command altogether
The total number of packet split into;
Processing data packets thread judges to receive whether the packet in bag chained list can be assembled into one completely
Response command, be to take out packet and assemble, judge to receive bag including: processing data packets thread
The packet whether number of the packet in chained list with same command id splits into equal to this order
Total number, be from described reception bag chained list, to take out described packet assemble;Wherein, each
The packet received carries the command id of this response command, the sequence number of notebook data bag and this response life
The total number of packet that order splits into altogether;
Wherein, the command id phase of the command id that described response command carries and corresponding request command
With.
Further, the method also includes following feature:
Other nodes will be asked to insert the table tail of described newly requested order chained list by worker thread;
Worker thread inquires about described response command chained list, as found the response command corresponding with request command,
Then from described response command chained list, take out this response command, carry out resolving and obtaining response results.
Further, the method also includes following feature:
Time-out scanning thread periodic scan is just processing the order in order chained list, as certain order exceedes pre-
Fix time and be not the most deleted, then this order is taken out and reinsert in described newly requested order chained list.
In order to solve above-mentioned technical problem, present invention also offers a kind of data that realize and process and mutual side
Method, is applied to service end, including:
Receiving thread such as receives the packet from client, then inserted by packet and receive bag chained list
In;
Processing data packets thread judge to receive in bag chained list to packet whether can be assembled into one complete
Whole request command, is to take out described packet and assemble, and inserts assembling complete request command
In newly requested order chained list;
Worker thread takes out request command from described newly requested order chained list and processes, after being disposed
Generate response command, insert in response command chained list;
Command process thread takes out response command from described response command chained list and splits, and will split into
One or more packets insert and send in bag chained list;
Transmission thread takes out packet from described transmission bag chained list and is transmitted;
Wherein, described transmission thread, receiving thread, worker thread are multiple;Each thread parallel performs.
Further, the method also includes following feature:
Described reception bag chained list is multiple with sending bag chained list;
Send thread and send bag chained list one_to_one corresponding, receiving thread and reception bag chained list one_to_one corresponding;
The one or more packets split into are inserted and send in bag chained list by command process thread, including:
Command process thread selects a shortest transmission bag chained list of length from multiple transmission bag chained lists, will split
The one or more packets become insert this table tail sending bag chained list selected.
Further, the method also includes following feature:
Processing data packets thread judges to receive whether the packet in bag chained list can be assembled into one completely
Request command, be to take out packet and assemble, judge to receive bag including: processing data packets thread
The packet whether number of the packet in chained list with same command id splits into equal to this order
Total number, be from described reception bag chained list, to take out described packet assemble;Wherein, each
The packet received carries the command id of this request command, the sequence number of notebook data bag and this request life
The total number of packet that order splits into altogether;
Described response command is split by command process thread, including: command process thread is according to presetting
Single transmission bag maximum length, response command is split into one or more packet;Wherein, often
Individual packet carries the command id of this response command, the sequence number of notebook data bag and this response command altogether
The total number of packet split into;
Wherein, the command id phase of the command id that described response command carries and corresponding request command
With.
In order to solve above-mentioned technical problem, present invention also offers a kind of data that realize and process and mutual be
System, is applied to client, including:
Command processing module, takes out request command also for command process thread from newly requested order chained list
Inserting just is processing in order chained list, splits described request command, one or more by split into
Packet inserts and sends in bag chained list;
Sending module, is used for sending thread and takes out packet from described transmission bag chained list and be transmitted;
Receiver module, such as receives the packet from service end, is then inserted by packet for receiving thread
Enter to receive in bag chained list;
Whether processing data packets module, judge the packet in reception bag chained list for processing data packets thread
A complete response command can be assembled into, be, take out packet and assemble, complete by assembling
Response command inserts in response command chained list, and right by just process in order chained list according to this response command
Request command is answered to delete;
Wherein, described transmission thread and receiving thread are multiple;Each thread parallel performs.
Further, this system also includes following feature:
Described transmission bag chained list is multiple with receiving bag chained list;
Send thread and send bag chained list one_to_one corresponding, receiving thread and reception bag chained list one_to_one corresponding;
Command processing module, sends out the one or more packets insertion split into for command process thread
Send in bag chained list, including: it is the shortest that command process thread selects a length from multiple transmission bag chained lists
Send bag chained list, the one or more packets split into are inserted this table sending bag chained list selected
Tail.
Further, this system also includes following feature:
Command processing module, splits described request command for command process thread, including: life
Order processes the thread maximum length according to the single transmission bag preset, and request command splits into one or many
Individual packet;Wherein, each packet carries the command id of this request command, the sequence of notebook data bag
Number and the total number of packet that splits into altogether of this request command;
Whether processing data packets module, judge the packet in reception bag chained list for processing data packets thread
A complete response command can be assembled into, be, take out packet and assemble, including: packet
Process thread and whether judge to receive the number of the packet in bag chained list with same command id equal to being somebody's turn to do
Total number of the packet that order splits into, is to take out described packet from described reception bag chained list and enter
Row assembles;Wherein, the packet of each reception carries the command id of this response command, notebook data bag
Sequence number and the total number of packet that splits into altogether of this response command;
Wherein, the command id phase of the command id that described response command carries and corresponding request command
With.
Further, this system also includes following feature:
This system also includes request and respond module, will insert the request of other nodes for worker thread
The table tail of described newly requested order chained list;Worker thread inquires about described response command chained list, as found and this
The response command that before thread, the request command of transmission is corresponding, then taking out from described response command chained list should
Response command, carries out resolving and obtaining response results.
Further, this system also includes following feature:
This system also includes timeout treatment module, is just processing order for time-out scanning thread periodic scan
Order in chained list, is not the most deleted as certain order exceedes the scheduled time, then this order is taken out weight
In newly inserted described newly requested order chained list.
In order to solve above-mentioned technical problem, present invention also offers a kind of data that realize and process and mutual be
System, is applied to service end, including:
Receiver module, such as receives the packet from client, is then inserted by packet for receiving thread
Enter to receive in bag chained list;
For processing data packets thread, processing data packets module, judges that receiving the packet given in bag chained list is
No can be assembled into a complete request command, be to take out described packet and assemble, will assemble
Complete request command inserts in newly requested order chained list;
Request and respond module, take out request command for worker thread from described newly requested order chained list
Process, generate response command after being disposed, insert in response command chained list;
Command processing module, takes out response command for command process thread from described response command chained list
Split, the one or more packets split into are inserted and sends in bag chained list;
Sending module, is used for sending thread and takes out packet from described transmission bag chained list and be transmitted;
Wherein, described transmission thread, receiving thread, worker thread are multiple;Each thread parallel performs.
Further, this system also includes following feature:
Described reception bag chained list is multiple with sending bag chained list;
Send thread and send bag chained list one_to_one corresponding, receiving thread and reception bag chained list one_to_one corresponding;
Command processing module, sends out the one or more packets insertion split into for command process thread
Send in bag chained list, including: it is the shortest that command process thread selects a length from multiple transmission bag chained lists
Send bag chained list, the one or more packets split into are inserted this table sending bag chained list selected
Tail.
Further, this system also includes following feature:
Whether processing data packets module, judge the packet in reception bag chained list for processing data packets thread
A complete request command can be assembled into, be, take out packet and assemble, including: packet
Process thread and whether judge to receive the number of the packet in bag chained list with same command id equal to being somebody's turn to do
Total number of the packet that order splits into, is to take out described packet from described reception bag chained list and enter
Row assembles;Wherein, the packet of each reception carries the command id of this request command, notebook data bag
Sequence number and the total number of packet that splits into altogether of this request command;
Command processing module, splits described response command for command process thread, including: life
Order processes the thread maximum length according to the single transmission bag preset, and response command splits into one or many
Individual packet;Wherein, each packet carries the command id of this response command, the sequence of notebook data bag
Number and the total number of packet that splits into altogether of this response command;
Wherein, the command id phase of the command id that described response command carries and corresponding request command
With.
Compared with prior art, a kind of of present invention offer realizes data process and mutual method and is
System, is performed by multiple thread parallels, and uses chained list to transmit data so that the logic between node is even
The number connect can be controlled, and improves the bandwidth utilization rate of physical connection.
Detailed description of the invention
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing
Embodiments of the invention are described in detail.It should be noted that in the case of not conflicting, this Shen
Embodiment in please and the feature in embodiment can mutually be combined.
Process and mutual method as it is shown in figure 1, embodiments provide a kind of data that realize, should
For client, including:
S10, command process thread takes out request command from newly requested order chained list and insertion is just processing life
Make in chained list, described request command is split, the one or more packets split into are inserted and sends out
Send in bag chained list;
S20, transmission thread takes out packet from described transmission bag chained list and is transmitted;
S30, receiving thread such as receives the packet from service end, is then inserted by packet and receive bag
In chained list;
S40, processing data packets thread judges whether the packet received in bag chained list can be assembled into one
Complete response command, is to take out packet and assemble, inserts sound by assembling complete response command
In order chained list, and according to this response command, the corresponding requests order just processed in order chained list should be deleted
Remove;
Wherein, described transmission thread and receiving thread are multiple;Each thread parallel performs;
The method can also include following feature:
Preferably, described newly requested order chained list, transmission bag chained list and reception bag chained list are bidirectional circulating
Chained list;
Wherein, when inserting data in double-linked circular list, it is inserted into the afterbody of described double-linked circular list,
When taking out data from double-linked circular list, take out data from the gauge outfit of described double-linked circular list.
Preferably, same type of multiple thread can form thread pool;
Preferably, other nodes will be asked to insert the table of described newly requested order chained list by worker thread
Tail;
Preferably, worker thread inquires about described response command chained list, as found the sound corresponding with request command
Should order, then from described response command chained list, take out this response command, carry out resolving and obtain response knot
Really;
Wherein, worker thread is one or more;
Preferably, command process thread takes out request command in the following ways from newly requested order chained list
And insertion is just processing in order chained list: command process thread takes out from the gauge outfit of newly requested order chained list newly please
Ask order and insert the table tail just processing order chained list;
Preferably, described request command is split by command process thread in the following ways: at order
Request command, according to the maximum length of the single transmission packet preset, is split into one or many by reason thread
Individual packet;Wherein, each packet carries the command id of this request command, the sequence of notebook data bag
Number and the total number of packet that splits into altogether of this request command;
Preferably, it is multiple for sending thread, and it is multiple for sending bag chained list, and it is corresponding that each sends bag chained list
One sends thread;
Preferably, the one or more packets split into are inserted and send bag chained list by command process thread
In, including:
Command process thread selects a shortest transmission bag chained list of length from multiple transmission bag chained lists, will
The one or more packets split into insert this table tail sending bag chained list selected;
Preferably, transmission thread takes out packet from described transmission bag chained list and is transmitted, including: send out
Line sending journey is taken out packet from the corresponding gauge outfit sending bag chained list and is transmitted;
Preferably, receiving thread is multiple;It is multiple for receiving bag chained list;Receiving thread and reception bag chained list
One_to_one corresponding;
Preferably processing data packets thread judges whether the packet received in bag chained list can be assembled into one
The response command that bar is complete, is to take out packet and assemble, including: processing data packets thread judges
Whether the number receiving the packet in bag chained list with same command id is equal to what this order split into
Total number of packet, is to take out described packet from described reception bag chained list and assemble;Wherein,
The packet of each reception carries the command id of this response command, the sequence number of notebook data bag and this sound
The total number of the packet split into altogether should be ordered;
Wherein, the command id phase of the command id that described response command carries and corresponding request command
With;
Preferably, packet is assembled into response command by processing data packets thread, including: processing data packets
The serial number information of this packet that thread carries according to each packet, will have same commands mark
Data packet group dresses up response command.
Preferably, also including a time-out scanning thread, time-out scanning thread periodic scan is just processing order
Order in chained list, is not the most deleted as certain order exceedes the scheduled time, then this order is taken out weight
In newly inserted described newly requested order chained list.
Process and mutual method as in figure 2 it is shown, embodiments provide a kind of data that realize, should
For service end, including:
S10, receiving thread such as receives the packet from client, is then inserted by packet and receive bag
In chained list;
S20, processing data packets thread judge to receive in bag chained list to packet whether can be assembled into one
The request command that bar is complete, is to take out described packet and assemble, and will assemble complete request command
Insert in newly requested order chained list;
S30, worker thread takes out request command from described newly requested order chained list and processes, and processes
After generate response command, insert in response command chained list;
S40, command process thread takes out response command from described response command chained list and splits, will
The one or more packets split into insert and send in bag chained list;
S50, transmission thread takes out packet from described transmission bag chained list and is transmitted;
Wherein, described transmission thread, receiving thread, worker thread are multiple;Each thread parallel performs.
The method can also include following feature:
Preferably, same type of multiple threads composition thread pool;
Preferably, described reception bag chained list is multiple with sending bag chained list;
Send thread and send bag chained list one_to_one corresponding, receiving thread and reception bag chained list one_to_one corresponding;
Preferably, described reception bag chained list, transmission bag chained list, newly requested order chained list, response command chain
Table is double-linked circular list;
Wherein, when inserting data in double-linked circular list, it is inserted into the afterbody of described double-linked circular list,
When taking out data from double-linked circular list, take out data from the gauge outfit of described double-linked circular list.
Preferably, the one or more packets split into are inserted and send bag chained list by command process thread
In, including: command process thread selects a shortest transmission bag chain of length from multiple transmission bag chained lists
The one or more packets split into are inserted this table tail sending bag chained list selected by table.
Preferably, packet is inserted and receives in bag chained list by arbitrary receiving thread, including: arbitrary reception line
Packet is inserted the table tail receiving bag chained list by journey;
Preferably, processing data packets thread judges whether the packet received in bag chained list can be assembled into one
The request command that bar is complete, is to take out packet and assemble, including: processing data packets thread judges
Whether the number receiving the packet in bag chained list with same command id is equal to what this order split into
Total number of packet, is to take out described packet from described reception bag chained list and assemble;Wherein,
The packet of each reception carries the command id of this request command, the sequence number of notebook data bag and should ask
The total number of packet asking order to split into altogether;
Described response command is split by command process thread, including: command process thread is according to presetting
Single transmission bag maximum length, response command is split into one or more packet;Wherein, often
Individual packet carries the command id of this response command, the sequence number of notebook data bag and this response command altogether
The total number of packet split into;
Wherein, the command id phase of the command id that described response command carries and corresponding request command
With.
Preferably, packet is assembled into request command by processing data packets thread, including: processing data packets
The serial number information of this packet that thread carries according to each packet, will have same commands mark
Data packet group dresses up request command.
Fig. 3 shows the node as client and as the mutual mistake of the information between the node of service end
Journey.
As shown in Figure 4, embodiments provide a kind of data that realize and process and mutual system, should
For client, including:
Command processing module, takes out request command also for command process thread from newly requested order chained list
Inserting just is processing in order chained list, splits described request command, one or more by split into
Packet inserts and sends in bag chained list;
Sending module, is used for sending thread and takes out packet from described transmission bag chained list and be transmitted;
Receiver module, such as receives the packet from service end, is then inserted by packet for receiving thread
Enter to receive in bag chained list;
Whether processing data packets module, judge the packet in reception bag chained list for processing data packets thread
A complete response command can be assembled into, be, take out packet and assemble, complete by assembling
Response command inserts in response command chained list, and right by just process in order chained list according to this response command
Request command is answered to delete;
Wherein, described transmission thread and receiving thread are multiple;Each thread parallel performs.
This system can also include following feature:
Preferably, described transmission bag chained list is multiple with receiving bag chained list;
Send thread and send bag chained list one_to_one corresponding, receiving thread and reception bag chained list one_to_one corresponding;
Command processing module, sends out the one or more packets insertion split into for command process thread
Send in bag chained list, including: it is the shortest that command process thread selects a length from multiple transmission bag chained lists
Send bag chained list, the one or more packets split into are inserted this table sending bag chained list selected
Tail.
Preferably, command processing module, for command process thread, described request command is split,
Including: request command, according to the maximum length of the single transmission bag preset, is split into by command process thread
One or more packets;Wherein, each packet carries the command id of this request command, this number
The total number of packet split into altogether according to sequence number and this request command of bag;
Whether processing data packets module, judge the packet in reception bag chained list for processing data packets thread
A complete response command can be assembled into, be, take out packet and assemble, including: packet
Process thread and whether judge to receive the number of the packet in bag chained list with same command id equal to being somebody's turn to do
Total number of the packet that order splits into, is to take out described packet from described reception bag chained list and enter
Row assembles;Wherein, the packet of each reception carries the command id of this response command, notebook data bag
Sequence number and the total number of packet that splits into altogether of this response command;
Wherein, the command id phase of the command id that described response command carries and corresponding request command
With.
Preferably, this system also includes a request and respond module:
Request and respond module, will insert described newly requested life to the request of other nodes for worker thread
Make the table tail of chained list;Worker thread inquires about described response command chained list, sends before this thread as found
Response command corresponding to request command, then from described response command chained list, take out this response command, enter
Row resolves and obtains response results.
Preferably, this system also includes a timeout treatment module:
Timeout treatment module, is just processing the life in order chained list for time-out scanning thread periodic scan
Order, is not the most deleted as certain order exceedes the scheduled time, then this order taken out described in reinserting
In newly requested order chained list.
Process and mutual system as it is shown in figure 5, embodiments provide a kind of data that realize, should
For service end, including:
Receiver module, such as receives the packet from client, is then inserted by packet for receiving thread
Enter to receive in bag chained list;
For processing data packets thread, processing data packets module, judges that receiving the packet given in bag chained list is
No can be assembled into a complete request command, be to take out described packet and assemble, will assemble
Complete request command inserts in newly requested order chained list;
Request and respond module, take out request command for worker thread from described newly requested order chained list
Process, generate response command after being disposed, insert in response command chained list;
Command processing module, takes out response command for command process thread from described response command chained list
Split, the one or more packets split into are inserted and sends in bag chained list;
Sending module, is used for sending thread and takes out packet from described transmission bag chained list and be transmitted;
Wherein, described transmission thread, receiving thread, worker thread are multiple;Each thread parallel performs.
This system can also include following feature:
Preferably, described reception bag chained list is multiple with sending bag chained list;
Send thread and send bag chained list one_to_one corresponding, receiving thread and reception bag chained list one_to_one corresponding;
Command processing module, sends out the one or more packets insertion split into for command process thread
Send in bag chained list, including: it is the shortest that command process thread selects a length from multiple transmission bag chained lists
Send bag chained list, the one or more packets split into are inserted this table sending bag chained list selected
Tail.
Preferably, processing data packets module, judge to receive the number in bag chained list for processing data packets thread
Whether can be assembled into a complete request command according to bag, be, take out packet and assemble, including:
Whether processing data packets thread judges to receive in bag chained list the number of the packet with same command id
Equal to total number of the packet that this order splits into, it is to take out described number from described reception bag chained list
Assemble according to bag;Wherein, the packet of each reception carries the command id of this request command, basis
The total number of packet that the sequence number of packet and this request command split into altogether;
Command processing module, splits described response command for command process thread, including: life
Order processes the thread maximum length according to the single transmission bag preset, and response command splits into one or many
Individual packet;Wherein, each packet carries the command id of this response command, the sequence of notebook data bag
Number and the total number of packet that splits into altogether of this response command;
Wherein, the command id phase of the command id that described response command carries and corresponding request command
With.
Preferably, described reception bag chained list, transmission bag chained list, newly requested order chained list, response command chain
Table is double-linked circular list;
Wherein, when inserting data in double-linked circular list, it is inserted into the afterbody of described double-linked circular list,
When taking out data from double-linked circular list, take out data from the gauge outfit of described double-linked circular list.
A kind of data that realize that above-described embodiment provides process and mutual method and system, by multiple lines
Journey executed in parallel, and use chained list to transmit data so that the number that the logic between node connects can be hard to bear
Control, and improve the bandwidth utilization rate of physical connection.
One of ordinary skill in the art will appreciate that all or part of step in said method can pass through journey
Sequence instructs related hardware and completes, and described program can be stored in computer-readable recording medium, as only
Read memory, disk or CD etc..Alternatively, all or part of step of above-described embodiment can also make
Realizing with one or more integrated circuits, correspondingly, each module/unit in above-described embodiment can be adopted
Realize by the form of hardware, it would however also be possible to employ the form of software function module realizes.The present invention is not restricted to
The combination of the hardware and software of any particular form.
It should be noted that the present invention also can have other various embodiments, without departing substantially from the present invention spirit and
In the case of its essence, those of ordinary skill in the art can make various corresponding change according to the present invention
And deformation, but these change accordingly and deform the protection model that all should belong to appended claims of the invention
Enclose.