CN105117230A - Peertask processing method - Google Patents

Peertask processing method Download PDF

Info

Publication number
CN105117230A
CN105117230A CN201510548482.9A CN201510548482A CN105117230A CN 105117230 A CN105117230 A CN 105117230A CN 201510548482 A CN201510548482 A CN 201510548482A CN 105117230 A CN105117230 A CN 105117230A
Authority
CN
China
Prior art keywords
peertask
request
packet
field
data packet
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.)
Granted
Application number
CN201510548482.9A
Other languages
Chinese (zh)
Other versions
CN105117230B (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
Divine Land Beijing Yun Ke Data Technologies Co Ltd
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 Divine Land Beijing Yun Ke Data Technologies Co Ltd filed Critical Divine Land Beijing Yun Ke Data Technologies Co Ltd
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

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a peertask processing method. The method comprises the steps that: a first end, according to a preset PeerTask data structure, generates a PeerTask and links the PeerTask into a preset linked list; the first end, according to a preset universal data package structure, generates a request data package and sends the request data package to a second end; after receiving the request data package, the second end performs processing on the request data package, generates a response data package according to the preset universal communication data package structure, and sends the response data package to the first end; after receiving the response data package, the first end terminates the PeerTask. According to the peertask processing method, a universal double-control communication request task processing scheme is proposed, a new simple request task can be added more simply and conveniently, a multi-time interactive communication task without additional response data is supported, and a unified communication disconnection processing mode is provided.

Description

A kind of both-end task processing method
Technical field
The present invention relates to communication technical field, be specifically related to a kind of both-end task processing method.
Background technology
When processing both-end task, need to process various types of communication request, such as [synchronous cache request of data], [request of synchronous flush result] etc.A lot of request all needs to respond requesting party after processing is complete, such as [synchronous cache request of data], could report that IO completes after cache synchronously completes to IO promoter.Like this, when arranging the data structure of communication, just must polytype be set, if be such as provided with type [synchronous cache request of data], just must arrange corresponding [synchronous cache data answering], to process when receiving the packet of corresponding types.
Existing both-end task processing method Problems existing is: for the request needing response, must be in particular it and arrange corresponding response, even if this response only needs the success of simple acknowledges requests or failure.And a kind of unified mode is not provided, the communication disconnected event occurred after initiation request is processed.
Summary of the invention
Technical matters to be solved by this invention is the request of existing both-end task processing method for needs response, must be in particular it and arrange corresponding response, not provide a kind of unified mode, processes the communication disconnected event of generation after initiation request.
For this purpose, the invention provides a kind of both-end task processing method, described method comprises:
First end, according to the both-end task PeerTask data structure preset, generates both-end task PeerTask, and is linked in default chained list by described PeerTask;
First end, according to the universal communication packet structure preset, generates request data package, and by described request Packet Generation to the second end;
Second end, after receiving described request packet, processes described request packet, and according to the universal communication packet structure preset, generates response data packet, and response data packet is sent to first end;
First end, after receiving described response data packet, terminates PeerTask.
Optionally, described default both-end task PeerTask data structure, comprising:
Chained list node, is linked to the position of default chained list for marking PeerTask;
Private data pointer, is used in reference to the private data to PeerTask; Described private data pointer is assignment when PeerTask initialization;
Call back function pointer, process for calling call back function at the end of PeerTask, the parameter of described call back function is described local terminal PeerTask pointer, opposite end PeerTask pointer and error code, and described call back function pointer is assignment when PeerTask initialization; The response data packet that the PeerTask pointer of described response and error code send according to the second end is determined;
Second end disconnects mark, and for marking communication state, the value that described second end disconnects mark is that false or true, false represent that communication does not disconnect, and true represents that communication disconnects.
Optionally, described default universal communication packet structure, comprising:
Type of data packet field, for representing the type of packet, described type comprises request and response;
PeerTaskReq field, for representing the PeerTask pointer of first end;
PeerTaskRsp field, for representing that the PeerTask of the second end responds pointer;
Errno field, for representing the second end response whether success, successful then be 0, otherwise be error code;
Elongated data field, for storing PeerTask private data, the length of described elongated data field and content are determined according to the request type preset.
Optionally, described first end, according to the both-end task PeerTask data structure preset, generates both-end task PeerTask, and is linked in default chained list by described PeerTask, comprising:
The value that second end disconnects mark is initialized as false, initialization private data pointer and call back function pointer by first end, and PeerTask is linked to default chained list.
Optionally, described first end, according to the universal communication packet structure preset, generates request data package, and by described request Packet Generation to the second end, comprising:
The PeerTaskReq field of request data package is set to PeerTask pointer by first end, and request data package is sent to the second end.
Optionally, described second end, after receiving described request packet, processes described request packet, and according to the universal communication packet structure preset, generates response data packet, and response data packet is sent to first end, comprising:
Second end, after receiving described request packet, processes described request packet;
After two port described request packet processes, according to the universal communication packet structure preset, generate response data packet, in described response data packet, type of data packet field is set to respond style PeerTaskResponse, in described response data packet, the value of PeerTaskReq field is determined according to the content of type of data packet field in request data package, in described response data packet, the value of PeerTaskRsp field is the value of PeerTaskReq field in described request packet, in described response data packet, the value of errno field is the error code that described second end returns after processes said request packet, if inerrancy, then the value of errno field is 0, otherwise, the value of errno field is predefined error code,
Second end sends described response data packet to first end;
Correspondingly, described first end, after receiving described response data packet, uses PeerTaskRsp, PeerTaskReq and errno field of described response data packet, terminates PeerTask.
Optionally, in described response data packet, the value of PeerTaskReq field is determined according to the content of type of data packet field in request data package, comprising:
The value of PeerTaskReq field in response data packet, after determining that the content of type of data packet field in request data package is interactive task, is set to the PeerTask pointer that described second end generates in process request msg packet procedures by the second end;
The value of PeerTaskReq field in response data packet, after determining that the content of type of data packet field in request data package is simple request response task, is set to sky by the second end.
Optionally, after described second end sends the step of described response data packet, described method also comprises:
If generate PeerTask in the process of process request data package, then the second end is after determining to send response data packet failure, uses PeerTaskReq field, null pointer and errno field, terminates PeerTask.
Optionally, described method comprises general communication disconnection process step further, comprising:
The chained list that first end traversal is preset, to each chained list node, finds corresponding PeerTask, and terminates PeerTask.
Optionally, described end PeerTask, comprising:
The chained list node of PeerTask is removed from the chained list preset;
After determining that error code is the error code of communication disconnection, it is true that second end of PeerTask is disconnected traffic sign placement;
Call call back function according to call back function pointer to process.
Compared to prior art, both-end task processing method of the present invention arranges mutually isostructural response data packet for different requests; Use described mutually isostructural response data packet to process for different requests, do not need to be separately that each request arranges corresponding response data Packet type; Design general communication disconnection process scheme, do not need solution like the extra design class of various request.Both-end task processing method of the present invention proposes a kind of general dual control communication request task (being referred to as PeerTask here) processing scheme, the simple request task (only needing to receive a response) that interpolation that can be easier is new, support the repeatedly interactive communication task not with additional response data, and unified communication disconnection process mode is provided.
Accompanying drawing explanation
Fig. 1 shows a kind of both-end task processing method process flow diagram.
Embodiment
As shown in Figure 1, the present embodiment discloses a kind of both-end task processing method, comprising:
General request data structure PeerTask is set:
(1). chained list node structure, is linked in certain chained list by PeerTask, can travel through this chained list to travel through all requests do not completed, and carry out disconnection process when communication disconnects;
(2). context pointers, the assignment when PeerTask initialization, imports into as parameter when processing the call back function of request;
(3). the call back function pointer of request, the assignment when PeerTask initialization, to call this function to process when PeerTask completes, its parameter is context pointers, the pointer (namely asking pointer) of PeerTask self, the pointer (i.e. opposite end response pointer) of the PeerTask of response, the error code of PeerTask;
(4). opposite end disconnects mark, is initialized as false, if the error code when PeerTask completes is the error code that communication disconnects, then this mark can be set to true.
General communication data pack arrangement is set:
(1). data type field, which kind of packet expression is, most data packets is all request class, arranges the respond style that PeerTaskResponse represents general especially;
(2) .PeerTaskReq field, represents the PeerTask pointer that requesting party uses;
(3) .PeerTaskRsp field, represents the request PeerTask pointer that responder responds, the i.e. value of the PeerTaskReq field of communication request packet;
(4) .errno field, represents response whether success, successful then be 0, otherwise is error code;
(5). elongated data field, the private data of storage resource request, its length and content are different along with the difference of request type.
Request responding process:
(1). initialization PeerTask, arranges context pointers and call back function, and is inserted in PeerTask chained list;
(2). organize and send packet, the PeerTaskReq field of packet is set to task pointer;
(3). opposite end receives packet, processes, and calls end_peer_task after processing is complete and responds:
A) setting data Packet type is PeerTaskResponse;
B) if necessary, the PeerTask of response can be generated, PeerTaskReq is set to this task pointer (parameter for end_peer_task).Note, only need to arrange this field in the response in repeatedly interactive task, simple this field of request response task be sky;
C) PeerTaskRsp is set to ask the PeerTaskReq field (parameter for end_peer_task) in communication data packets;
Errno (parameter for end_peer_task) d) is set;
E) packet is sent;
If f) send unsuccessfully, then the error code using communication to disconnect calls peer_task_done;
(4). local terminal receives PeerTaskResponse, and the corresponding field in usage data bag calls peer_task_done.
The flow process that ends task (peer_task_done):
(1). PeerTask is removed from PeerTask chained list;
(2) if. error code be opposite end disconnect error code, by the opposite end of PeerTask disconnect mark be set to true;
(3). call call back function and process.
Communication disconnection process:
(1). traversal PeerTask chained list;
(2). peer_task_done is called to each chained list node, and parameter errno is communication disconnection error code.
Call back function generalized flowsheet (example):
(1). check that the opposite end of PeerTask disconnects mark, as then carried out disconnection abnormality processing for true;
(2). checking errno, as made a mistake, entering corresponding abnormality processing;
(3). preserve PeerTaskRsp pointer, for response is next time prepared;
(4). process End Event, as notice exterior I O completes, or releasing resource etc.
Simple request response flow of task example:
(1). create PeerTask and send request (request that can be any type);
(2). opposite end receives asks and processes, and then sends PeerTaskResponse;
(3). local terminal receives PeerTaskResponse, and calls peer_task_done.
Interactive request flow of task example:
(1). create PeerTask and send request;
(2). opposite end receives asks and processes, and then sends PeerTaskResponse, subsidiary PeerTaskReq field, and namely this response is also a request simultaneously;
(3). local terminal receives PeerTaskResponse, and calls peer_task_done;
(4). in peer_task_done, complete process, and send PeerTaskResponse to opposite end;
(5). opposite end receives PeerTaskResponse, and calls peer_task_done;
(6) if. need, can constantly repeat above-mentioned flow process.
The both-end task processing method of the present embodiment proposes a kind of general dual control communication request task (being referred to as PeerTask here) processing scheme, the simple request task (only needing to receive a response) that interpolation that can be easier is new, support the repeatedly interactive communication task not with additional response data, and unified communication disconnection process mode is provided.
Those skilled in the art also may correspond to the corresponding system of method design of the present invention, and this system can perform the flow process in aforesaid embodiment of the method, does not describe in detail at this.

Claims (10)

1. a both-end task processing method, is characterized in that, described method comprises:
First end, according to the both-end task PeerTask data structure preset, generates both-end task PeerTask, and is linked in default chained list by described PeerTask;
First end, according to the universal communication packet structure preset, generates request data package, and by described request Packet Generation to the second end;
Second end, after receiving described request packet, processes described request packet, and according to the universal communication packet structure preset, generates response data packet, and response data packet is sent to first end;
First end, after receiving described response data packet, terminates PeerTask.
2. method according to claim 1, is characterized in that, described default both-end task PeerTask data structure, comprising:
Chained list node, is linked to the position of default chained list for marking PeerTask;
Private data pointer, is used in reference to the private data to PeerTask; Described private data pointer is assignment when PeerTask initialization;
Call back function pointer, process for calling call back function at the end of PeerTask, the parameter of described call back function is described local terminal PeerTask pointer, opposite end PeerTask pointer and error code, and described call back function pointer is assignment when PeerTask initialization; The response data packet that the PeerTask pointer of described response and error code send according to the second end is determined;
Second end disconnects mark, and for marking communication state, the value that described second end disconnects mark is that false or true, false represent that communication does not disconnect, and true represents that communication disconnects.
3. method according to claim 2, is further characterized in that, described default universal communication packet structure, comprising:
Type of data packet field, for representing the type of packet, described type comprises request and response;
PeerTaskReq field, for representing the PeerTask pointer of first end;
PeerTaskRsp field, for representing that the PeerTask of the second end responds pointer;
Errno field, for representing the second end response whether success, successful then be 0, otherwise be error code;
Elongated data field, for storing PeerTask private data, the length of described elongated data field and content are determined according to the request type preset.
4. method according to claim 3, is characterized in that, described first end, according to the both-end task PeerTask data structure preset, generates both-end task PeerTask, and is linked in default chained list by described PeerTask, comprising:
The value that second end disconnects mark is initialized as false, initialization private data pointer and call back function pointer by first end, and PeerTask is linked to default chained list.
5. method according to claim 4, is characterized in that, described first end, according to the universal communication packet structure preset, generates request data package, and by described request Packet Generation to the second end, comprising:
The PeerTaskReq field of request data package is set to PeerTask pointer by first end, and request data package is sent to the second end.
6. method according to claim 5, is characterized in that, described second end is after receiving described request packet, described request packet is processed, and according to the universal communication packet structure preset, generates response data packet, and response data packet is sent to first end, comprising:
Second end, after receiving described request packet, processes described request packet;
After two port described request packet processes, according to the universal communication packet structure preset, generate response data packet, in described response data packet, type of data packet field is set to respond style PeerTaskResponse, in described response data packet, the value of PeerTaskReq field is determined according to the content of type of data packet field in request data package, in described response data packet, the value of PeerTaskRsp field is the value of PeerTaskReq field in described request packet, in described response data packet, the value of errno field is the error code that described second end returns after processes said request packet, if inerrancy, then the value of errno field is 0, otherwise, the value of errno field is predefined error code,
Second end sends described response data packet to first end;
Correspondingly, described first end, after receiving described response data packet, uses PeerTaskRsp, PeerTaskReq and errno field of described response data packet, terminates PeerTask.
7. method according to claim 6, is characterized in that, in described response data packet, the value of PeerTaskReq field is determined according to the content of type of data packet field in request data package, comprising:
The value of PeerTaskReq field in response data packet, after determining that the content of type of data packet field in request data package is interactive task, is set to the PeerTask pointer that described second end generates in process request msg packet procedures by the second end;
The value of PeerTaskReq field in response data packet, after determining that the content of type of data packet field in request data package is simple request response task, is set to sky by the second end.
8. method according to claim 6, is further characterized in that, after described second end sends the step of described response data packet, described method also comprises:
If generate PeerTask in the process of process request data package, then the second end is after determining to send response data packet failure, uses PeerTaskReq field, null pointer and errno field, terminates PeerTask.
9. method according to claim 3, is further characterized in that, described method comprises general communication disconnection process step further, comprising:
The chained list that first end traversal is preset, to each chained list node, finds corresponding PeerTask, and terminates PeerTask.
10. the method according to any one of claim 1-9, is characterized in that, described end PeerTask, comprising:
The chained list node of PeerTask is removed from the chained list preset;
After determining that error code is the error code of communication disconnection, it is true that second end of PeerTask is disconnected traffic sign placement;
Call call back function according to call back function pointer to process.
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 true CN105117230A (en) 2015-12-02
CN105117230B 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 (5)

* 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
US20120002546A1 (en) * 2009-04-27 2012-01-05 Balakrishnan Sundararaman Multicasting traffic manager in a network communications processor 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

Patent Citations (5)

* 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
US20120002546A1 (en) * 2009-04-27 2012-01-05 Balakrishnan Sundararaman Multicasting traffic manager in a network communications processor 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
CN105117230B (en) 2018-08-10

Similar Documents

Publication Publication Date Title
CN109660639B (en) Data uploading method, device, system and medium
CN104202370A (en) Mobile terminal, remote control method, remote control system, server and remote control end thereof
EP4280685A1 (en) Information transmission method and device thereof
CN106708748B (en) Method and system for improving mounting performance of OpenStack block storage volume
CN110109766A (en) Data request method, device, system, data forwarding device and storage medium
US10715628B2 (en) Attribute operating method and device
CN107018189A (en) Migrate application data and receive the method and device of application data
CN104468594A (en) Data request method, device and system
CN105516250A (en) Internet-of-things service invoking platform and system
CN105516372B (en) Processing method, device and the server of filename
CN104754544A (en) International network registration method, device and system
CN106850554B (en) Method and device for dual-system directional connection
CN105117230A (en) Peertask processing method
CN103152428A (en) Method for carrying out service communication among nodes on cloud platform
US9826371B2 (en) SMS message management
CN113261249A (en) Data transmission method, related equipment and computer storage medium
CN115766829A (en) Communication processing method and communication node
CN103546513B (en) The method and device of communication between a kind of customer terminal webpage
CN109962962B (en) Socket connection method and device
CN113961218A (en) Remote batch upgrading method, device, equipment and storage medium for switch
CN105871917A (en) Transmission control protocol TCP connection scheduling method and device
CN104754545A (en) Own business access method, device and system
US8165137B2 (en) Fast database migration
CN104184727B (en) A kind of method and apparatus of message transmission
CN104754546A (en) International network registration method and device

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

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.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant
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.

TR01 Transfer of patent right