CN105117230B - A kind of both-end task processing method - Google Patents

A kind of both-end task processing method Download PDF

Info

Publication number
CN105117230B
CN105117230B CN201510548482.9A CN201510548482A CN105117230B CN 105117230 B CN105117230 B CN 105117230B CN 201510548482 A CN201510548482 A CN 201510548482A CN 105117230 B CN105117230 B CN 105117230B
Authority
CN
China
Prior art keywords
peertask
data packet
request
response
fields
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.)
Active
Application number
CN201510548482.9A
Other languages
Chinese (zh)
Other versions
CN105117230A (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.)
Shenzhou Yunke Beijing Technology Co ltd
Wuhan Shenzhou Digital Cloud Technology Co ltd
Original Assignee
Shenzhen Science And Technology Co Ltd Digital Cloud Data
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 Shenzhen Science And Technology Co Ltd Digital Cloud Data filed Critical Shenzhen Science And Technology Co Ltd Digital Cloud Data
Priority to CN201510548482.9A priority Critical patent/CN105117230B/en
Publication of CN105117230A publication Critical patent/CN105117230A/en
Application granted granted Critical
Publication of CN105117230B publication Critical patent/CN105117230B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention discloses a kind of both-end task processing method, the method includes:First end generates both-end task PeerTask, and PeerTask is linked in preset chained list according to preset both-end task PeerTask data structures;First end generates request data package, and request data package is sent to second end according to preset universal communication packet structure;Second end is handled request data package after receiving request data package, and according to preset universal communication packet structure, generates response data packet, and response data packet is sent to first end;First end terminates PeerTask after receiving response data packet.The both-end task processing method of the present invention proposes a kind of general dual control communication request task processing scheme, the new simple request task of addition that can be easier, it supports the multiple interactive communication task without additional response data, and unified communication disconnection process mode is provided.

Description

A kind of both-end task processing method
Technical field
The present invention relates to fields of communication technology, and in particular to a kind of both-end task processing method.
Background technology
When handling both-end task, need to handle various types of communication requests, such as【Synchronous cache request of data】, 【Synchronous flush results request】Etc..Many requests are required for responding requesting party after processing is complete, such as【Together Walk cache request of data】, could report that IO is completed to IO promoters after cache is synchronously completed.In this case, it is setting When setting the data structure of communication, multiple types are just must be provided with, for example if be provided with type【Synchronous cache request of data】, It just must be provided with corresponding【Synchronous cache data answerings】, to be handled in the data packet for receiving corresponding types.
Existing both-end task processing method the problem is that:The request that needs are responded, it is necessary to be set specifically for it Corresponding response is set, even if the response only needs simple response to ask successfully or fail.And without a kind of unification of offer Mode is handled initiating the communication disconnected event that request occurs later.
Invention content
The technical problem to be solved by the present invention is to the requests that existing both-end task processing method responds needs, must Must corresponding response be set specifically for it, a kind of unified mode is not provided, be disconnected to initiating the communication that request occurs later Event is handled.
For this purpose, the present invention provides a kind of both-end task processing method, the method includes:
First end generates both-end task PeerTask according to preset both-end task PeerTask data structures, and by institute PeerTask is stated to be linked in preset chained list;
First end generates request data package according to preset universal communication packet structure, and by the request data package It is sent to second end;
Second end is handled the request data package after receiving the request data package, and according to default Universal communication packet structure, generate response data packet, and response data packet be sent to first end;
First end terminates PeerTask after receiving the response data packet.
Optionally, the preset both-end task PeerTask data structures, including:
Chained list node, for marking PeerTask to be linked to the position of preset chained list;
Private data pointer, the private data for being directed toward PeerTask;The private data pointer is at the beginning of PeerTask Assignment when beginningization;
Call back function pointer, for calling call back function to be handled at the end of PeerTask, the call back function Parameter is the local terminal PeerTask pointers, opposite end PeerTask pointers and error code, and the call back function pointer exists Assignment when PeerTask is initialized;The response data that the PeerTask pointers and error code of the response are sent according to second end Packet determines;
Second end disconnects mark, for marking communication state, value that the second end disconnects mark be false or True, false indicate that communication does not disconnect, and true indicates that communication disconnects.
Optionally, the preset universal communication packet structure, including:
Type of data packet field, the type for indicating data packet, the type include request and response;
PeerTaskReq fields, the PeerTask pointers for indicating first end;
PeerTaskRsp fields, for indicating that the PeerTask of second end responds pointer;
Errno fields, for indicate second end response whether succeed, it is successful then be 0, be otherwise error code;
Elongated data fields, for storing PeerTask private datas, the length and content root of the elongated data fields It is determined according to preset request type.
Optionally, the first end generates both-end task according to preset both-end task PeerTask data structures PeerTask, and the PeerTask is linked in preset chained list, including:
The value that second end is disconnected mark by first end is initialized as false, initializes private data pointer and call back function Pointer, and PeerTask is linked to preset chained list.
Optionally, the first end generates request data package, and will be described according to preset universal communication packet structure Request data package is sent to second end, including:
First end sets the PeerTaskReq fields of request data package to PeerTask pointers, and by request data package It is sent to second end.
Optionally, the second end is handled the request data package after receiving the request data package, And according to preset universal communication packet structure, response data packet is generated, and response data packet is sent to first end, it wraps It includes:
Second end is handled the request data package after receiving the request data package;
After second end handles the request data package, according to preset universal communication packet structure, generate Response data packet, type of data packet field is set as respond style PeerTaskResponse in the response data packet, described The value of PeerTaskReq fields is determined according to the content of type of data packet field in request data package in response data packet, described The value of PeerTaskRsp fields is the value of PeerTaskReq fields in the request data package, the response in response data packet The value of errno fields is the error code that the second end returns after handling the request data package in data packet, if error-free Accidentally, then the value of errno fields is 0, and otherwise, the value of errno fields is predefined error code;
Second end sends the response data packet to first end;
Correspondingly, the first end uses the response data packet after receiving the response data packet PeerTaskRsp, PeerTaskReq and errno field terminate PeerTask.
Optionally, in the response data packet value of PeerTaskReq fields according to type of data packet in request data package The content determination of field, including:
The content of second end type of data packet field in determining request data package be interactive task after, by number of responses It is set as the PeerTask that the second end generates during handling request data package according to the value of PeerTaskReq fields in packet Pointer;
The content of second end type of data packet field in determining request data package is general after simple request response task The value of PeerTaskReq fields is set as empty in response data packet.
Optionally, after the second end sends the step of response data packet, the method further includes:
If generating PeerTask during handling request data package, second end is determining transmission response data packet After failure, using PeerTaskReq fields, null pointer and errno fields, terminate PeerTask.
Optionally, the method further includes general communication disconnection process steps, including:
First end traverses preset chained list and finds corresponding PeerTask, and terminate to each chained list node PeerTask。
Optionally, the end PeerTask, including:
The chained list node of PeerTask is removed from preset chained list;
After determining that error code is the error code that communication disconnects, the second end of PeerTask, which is disconnected traffic sign placement, is true;
Call back function is called to be handled according to call back function pointer.
Compared with the prior art, mutually isostructural sound is arranged for different requests in both-end task processing method of the invention Answer data packet;Different requests is handled using the mutually isostructural response data packet, need not be individually for each Corresponding response data Packet type is arranged in request;General communication disconnection process scheme is designed, it need not be additional to various requests The similar solution of design.The both-end task processing method of the present invention proposes a kind of general dual control communication request task (herein referred to as PeerTask) processing scheme, new simple request task of adding that can be easier (only need to receive One response), support the multiple interactive communication task without additional response data, and provide unified communication disconnection process side Formula.
Description of the drawings
Fig. 1 shows a kind of both-end task processing method flow chart.
Specific implementation mode
As shown in Figure 1, the present embodiment discloses a kind of both-end task processing method, including:
General request data structure PeerTask is set:
(1) PeerTask is linked in some chained list by chained list nodes structure, and the chain can be traversed when communicating disconnection Table carries out disconnection process to traverse all outstanding requests;
(2) context pointers, the assignment when PeerTask is initialized, in the call back function of processing request as parameter It is incoming;
(3) the call back function pointer of requests, the assignment when PeerTask is initialized will be called when PeerTask is completed The function is handled, and parameter is the context pointers of PeerTask, the pointer (asking pointer) of PeerTask itself, sound Pointer (i.e. opposite end responds pointer), the error code of the PeerTask answered;
(4) opposite ends disconnect mark, are initialized as false, are disconnected if the error code when PeerTask is completed is communication Error code, then the mark can be arranged to true.
General communication data pack arrangement is set:
(1) which kind of data packet data type fields, expression are, most data packets are all request classes, are especially arranged PeerTaskResponse indicates general respond style;
(2) .PeerTaskReq fields indicate PeerTask pointers used in requesting party;
(3) .PeerTaskRsp fields indicate the request PeerTask pointers that responder is responded, i.e. communication request data The value of the PeerTaskReq fields of packet;
(4) .errno fields, indicate response whether succeeds, it is successful then be 0, be otherwise error code;
(5) the elongated data fields of, store the private data of request, length and content with the difference of request type and It is different.
Ask responding process:
(1) initializes PeerTask, context pointers and call back function is arranged, and insert it into PeerTask chained lists In;
(2) organizes and sends data packet, sets the PeerTaskReq fields of data packet to task pointers;
(3) opposite ends receive data packet, are handled, and call end_peer_task to be responded after processing is complete:
A) setting type of data packet is PeerTaskResponse;
B) if it is necessary, the PeerTask of response can be generated, PeerTaskReq is set to the task pointers (for end_ The parameter of peer_task).Note that only needing in the response to be configured the field in multiple interactive task, simply It is sky to ask the response task field;
C) PeerTaskRsp is set to the PeerTaskReq fields in request communication data packets (for end_peer_ The parameter of task);
D) setting errno (for the parameter of end_peer_task);
E) transmission data packet;
If f) sending failure, peer_task_done is called using the error code that communication disconnects;
(4) local terminals receive PeerTaskResponse, and peer_task_ is called using the corresponding field in data packet done。
The flow that ends task (peer_task_done):
(1) removes PeerTask from PeerTask chained lists;
(2) if error codes are the error code that opposite end disconnects, the opposite end of PeerTask is disconnected into mark and is set to true;
(3) calls call back function to be handled.
Communicate disconnection process:
(1) traverses PeerTask chained lists;
(2) calls peer_task_done to each chained list node, and parameter errno is that communication disconnects error code.
Call back function generalized flowsheet (example):
(1) checks that the opposite end of PeerTask disconnects mark, and abnormality processing is turned off if for true;
(2) checks errno, and corresponding abnormality processing is entered if mistake occurs;
(3) preserves PeerTaskRsp pointers, prepares for response next time;
(4) handles End Event, such as exterior I O is notified to be completed, or release resource etc..
Simple request responds flow of task example:
(1) creates PeerTask and sends request (can be any kind of request);
(2) opposite ends receive request and handle, and then send PeerTaskResponse;
(3) local terminals receive PeerTaskResponse, and call peer_task_done.
Interactive request flow of task example:
(1) creates PeerTask and sends request;
(2) opposite ends receive request and handle, and then send PeerTaskResponse, subsidiary PeerTaskReq fields, I.e. the response is also a request simultaneously;
(3) local terminals receive PeerTaskResponse, and call peer_task_done;
(4) completions in peer_task_done are handled, and send PeerTaskResponse to opposite end;
(5) opposite ends receive PeerTaskResponse, and call peer_task_done;
(6) is if desired, above-mentioned flow can be repeated constantly.
The both-end task processing method of the present embodiment proposes that a kind of general dual control communication request task (is herein referred to as PeerTask) processing scheme, the new simple request task (only needing to receive a response) of addition that can be easier are supported Without the multiple interactive communication task of additional response data, and provide unified communication disconnection process mode.
The method that those skilled in the art can also correspond to the present invention designs corresponding system, which can perform side above-mentioned Flow in method embodiment, is not described in detail herein.

Claims (9)

1. a kind of both-end task processing method, which is characterized in that the method includes:
First end generates both-end task PeerTask, and will be described according to preset both-end task PeerTask data structures PeerTask is linked in preset chained list;
First end generates request data package, and the request data package is sent according to preset universal communication packet structure To second end;
Second end is handled the request data package after receiving the request data package, and according to preset logical With communication data pack arrangement, response data packet is generated, and response data packet is sent to first end;
First end terminates PeerTask after receiving the response data packet;
The preset both-end task PeerTask data structures, including:
Chained list node, for marking PeerTask to be linked to the position of preset chained list;
Private data pointer, the private data for being directed toward PeerTask;The private data pointer is initialized in PeerTask When assignment;
Call back function pointer, for calling call back function to be handled at the end of PeerTask, the parameter of the call back function For local terminal PeerTask pointers, opposite end PeerTask pointers and error code, the call back function pointer is initial in PeerTask Assignment when change;The PeerTask pointers and error code of the response are determined according to the response data packet that second end is sent;
Second end disconnects mark, is false or true for marking communication state, the value that the second end disconnects mark, False indicates that communication does not disconnect, and true indicates that communication disconnects.
2. according to the method described in claim 1, it is further characterized in that, the preset universal communication packet structure, including:
Type of data packet field, the type for indicating data packet, the type include request and response;
PeerTaskReq fields, the PeerTask pointers for indicating first end;
PeerTaskRsp fields, for indicating that the PeerTask of second end responds pointer;
Errno fields, for indicate second end response whether succeed, it is successful then be 0, be otherwise error code;
Elongated data fields, for storing PeerTask private datas, the length and content of the elongated data fields are according to pre- If request type determine.
3. according to the method described in claim 2, it is characterized in that, the first end is according to preset both-end task PeerTask Data structure generates both-end task PeerTask, and the PeerTask is linked in preset chained list, including:
The value that second end is disconnected mark by first end is initialized as false, initializes private data pointer and call back function pointer, And PeerTask is linked to preset chained list.
4. according to the method described in claim 3, it is characterized in that, the first end is according to preset universal communication data inclusion Structure generates request data package, and the request data package is sent to second end, including:
First end sets the PeerTaskReq fields of request data package to PeerTask pointers, and request data package is sent To second end.
5. according to the method described in claim 4, it is characterized in that, the second end receive the request data package it Afterwards, the request data package is handled, and according to preset universal communication packet structure, generates response data packet, and Response data packet is sent to first end, including:
Second end is handled the request data package after receiving the request data package;
After second end handles the request data package, according to preset universal communication packet structure, response is generated Data packet, type of data packet field is set as respond style PeerTaskResponse, the response in the response data packet The value of PeerTaskReq fields is determined according to the content of type of data packet field in request data package in data packet, the response The value of PeerTaskRsp fields is the value of PeerTaskReq fields in the request data package, the response data in data packet The value of errno fields is the error code that the second end returns after handling the request data package in packet, if inerrancy, The value of errno fields is 0, and otherwise, the value of errno fields is predefined error code;
Second end sends the response data packet to first end;
Correspondingly, the first end uses the response data packet after receiving the response data packet PeerTaskRsp, PeerTaskReq and errno field terminate PeerTask.
6. according to the method described in claim 5, it is characterized in that, in the response data packet PeerTaskReq fields value It is determined according to the content of type of data packet field in request data package, including:
The content of second end type of data packet field in determining request data package be interactive task after, by response data packet The value of middle PeerTaskReq fields is set as the PeerTask that the second end generates during handling request data package and refers to Needle;
The content of second end type of data packet field in determining request data package be simple request response task after, will respond The value of PeerTaskReq fields is set as empty in data packet.
7. according to the method described in claim 5, it is further characterized in that, the step of second end sends the response data packet Later, the method further includes:
If generating PeerTask during handling request data package, second end is determining that sending response data packet fails Later, using PeerTaskReq fields, null pointer and errno fields, terminate PeerTask.
8. according to the method described in claim 2, it is further characterized in that, the method further includes general communication gaps Step is managed, including:
First end traverses preset chained list and finds corresponding PeerTask, and terminate PeerTask to each chained list node.
9. according to claim 1-8 any one of them methods, which is characterized in that the end PeerTask, including:
The chained list node of PeerTask is removed from preset chained list;
After determining that error code is the error code that communication disconnects, it is true that the second end of PeerTask, which is disconnected traffic sign placement,;
Call back function is called to be handled according to call back function pointer.
CN201510548482.9A 2015-08-31 2015-08-31 A kind of both-end task processing method Active CN105117230B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510548482.9A CN105117230B (en) 2015-08-31 2015-08-31 A kind of both-end task processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510548482.9A CN105117230B (en) 2015-08-31 2015-08-31 A kind of both-end task processing method

Publications (2)

Publication Number Publication Date
CN105117230A CN105117230A (en) 2015-12-02
CN105117230B true CN105117230B (en) 2018-08-10

Family

ID=54665232

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510548482.9A Active CN105117230B (en) 2015-08-31 2015-08-31 A kind of both-end task processing method

Country Status (1)

Country Link
CN (1) CN105117230B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1867898A (en) * 2003-10-14 2006-11-22 国际商业机器公司 Method and apparatus for processing service requests in a service-oriented architecture
CN103701830A (en) * 2014-01-13 2014-04-02 浪潮(北京)电子信息产业有限公司 Method and system for realizing data processing and interaction
CN103856440A (en) * 2012-11-29 2014-06-11 腾讯科技(深圳)有限公司 Message processing method, server and message processing system based on distributed bus
CN104424105A (en) * 2013-08-26 2015-03-18 华为技术有限公司 Memory data reading and writing processing method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8917738B2 (en) * 2009-04-27 2014-12-23 Lsi Corporation Multicasting traffic manager in a network communications processor architecture

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1867898A (en) * 2003-10-14 2006-11-22 国际商业机器公司 Method and apparatus for processing service requests in a service-oriented architecture
CN103856440A (en) * 2012-11-29 2014-06-11 腾讯科技(深圳)有限公司 Message processing method, server and message processing system based on distributed bus
CN104424105A (en) * 2013-08-26 2015-03-18 华为技术有限公司 Memory data reading and writing processing method and device
CN103701830A (en) * 2014-01-13 2014-04-02 浪潮(北京)电子信息产业有限公司 Method and system for realizing data processing and interaction

Also Published As

Publication number Publication date
CN105117230A (en) 2015-12-02

Similar Documents

Publication Publication Date Title
EP2853083A1 (en) System and method for persistent wireless docking
CN104202370A (en) Mobile terminal, remote control method, remote control system, server and remote control end thereof
US8775592B2 (en) Method for transmitting and negotiating network-controlled functional data between a client and a server
CN108418884A (en) A kind of method, apparatus and electronic equipment of transmission services data
WO2017088494A1 (en) Link management method and apparatus
CN109802995B (en) Message pushing method, device, equipment and storage medium
US20150256441A1 (en) Neighbor relationship processing method and routing device
EP3223459A1 (en) Method and device for detecting connectivity
WO2017220021A1 (en) Short message processing method and apparatus
CN105117230B (en) A kind of both-end task processing method
EP3029917A1 (en) Method and system for telecommunication device monitoring
CN107766149B (en) Method and device for ZooKeeper cluster configuration based on DUBBO
CN108667640B (en) Communication method and device, and network access system
CN107277163B (en) Equipment remote mapping method and device
CN105119944B (en) Application starting method and related device
CN109005301B (en) Intermediate number management and control method and intermediate number management and control device
CN108235281A (en) Application entity establishing resource and register method, communicating node device and terminal device
CN104301423B (en) A kind of method, apparatus and system sending heartbeat message
US9826371B2 (en) SMS message management
EP3094054A1 (en) Method and controller for notifying bandwidth of cluster system
WO2018076903A1 (en) Dynamic time allocation method and device
CN109392195A (en) Handle the device and method that secondary nodes change in dual link
CN103546513B (en) The method and device of communication between a kind of customer terminal webpage
CN106375357B (en) Method and device for indicating connection state of software defined network equipment and controller
EP3274862B1 (en) Method for provisioning and registration of devices

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20170401

Address after: Nanshan District Guangdong streets, Shenzhen city 518131 Guangdong Province Road No. 8 financial services technology innovation base 1 building 11 floor F3

Applicant after: Shenzhen science and Technology Co.,Ltd. digital cloud data

Address before: 100085 Beijing, Haidian District, No. 9 on the ground floor of the digital science and Technology Plaza, 9

Applicant before: YUNKE CHINA DATA TECHNOLOGY LTD.

GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20190717

Address after: 430200 Six Floors of 777B Office Building, Guanggu Third Road, Donghu New Technology Development Zone, Wuhan City, Hubei Province

Patentee after: Wuhan Shenzhou Digital Cloud Technology Co.,Ltd.

Address before: Nanshan District Guangdong streets, Shenzhen city 518131 Guangdong Province Road No. 8 financial services technology innovation base 1 building 11 floor F3

Patentee before: Shenzhen science and Technology Co.,Ltd. digital cloud data

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230414

Address after: 6 / F, office building B, No.777, Guanggu Third Road, Donghu New Technology Development Zone, Wuhan, Hubei 430200

Patentee after: Wuhan Shenzhou Digital Cloud Technology Co.,Ltd.

Patentee after: Shenzhou Yunke (Beijing) Technology Co.,Ltd.

Address before: 6 / F, office building B, No.777, Guanggu Third Road, Donghu New Technology Development Zone, Wuhan, Hubei 430200

Patentee before: Wuhan Shenzhou Digital Cloud Technology Co.,Ltd.