CN109981674A - A kind of remote procedure calling (PRC) method, device, equipment and medium - Google Patents
A kind of remote procedure calling (PRC) method, device, equipment and medium Download PDFInfo
- Publication number
- CN109981674A CN109981674A CN201910271974.6A CN201910271974A CN109981674A CN 109981674 A CN109981674 A CN 109981674A CN 201910271974 A CN201910271974 A CN 201910271974A CN 109981674 A CN109981674 A CN 109981674A
- Authority
- CN
- China
- Prior art keywords
- data
- message
- remote procedure
- procedure call
- fragment
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/133—Protocols for remote procedure calls [RPC]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/544—Remote
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/548—Queue
Abstract
This application discloses a kind of remote procedure call devices, including message transmission module, message reception module, management module, network module, coding/decoding module and code generation module, it encodes the remote procedure call request by coding/decoding module, and fragment is carried out when the length after the remote procedure call request encodes is greater than preset length, each fragment has fragment flag bit, for characterizing whether the fragment is the last one fragment in all fragments of remote procedure call message, then the data after sending coding to the message transmission module according to fragment, so that the message transmission module coding is sent to the opposite equip. by the network module after data.In this way, client computer is avoided to occupy a large amount of Installed System Memory, and realized by allocation methods and be transferred to server-side for file as process parameter, moreover, improving efficiency of transmission by transmitting fragment.Disclosed herein as well is corresponding method, equipment and media.
Description
Technical field
This application involves the communications field more particularly to a kind of remote procedure calling (PRC) method, device, equipment and computer-readable
Storage medium.
Background technique
With the development of communication technology, remote procedure call (Remote Procedure Call, RPC) comes into being.Institute
It calls RPC, in particular to service is requested from remote computer by network, the agreement without understanding underlying network technology.
RPC uses Client/Server pattern, and requestor is equivalent to a client computer, and service providing program is suitable
In a server.There is the recalls information (i.e. RPC message) of process parameter to service firstly, client calls process sends one
Then process waits response message.In server end, process keeps sleep state until RPC message reaches.When RPC disappears
When breath reaches, server obtains process parameter, is based on the process parameter calculated result, and send reply message, under then waiting
One recalls information, finally, client call process receive reply message, obtain proceeding results, then call execute continue into
Row.
At present RPC realize as Google Google Protocol Buffer in, client computer send RPC message to service into
Cheng Shi is realized often by a TCP/UDP message is sent.When client computer send process parameter recalls information namely
When the data volume of RPC message is very big, client computer will occupy a large amount of Installed System Memory, in some instances it may even be possible to can not be complete because memory is used up
It is sent at message;Also, file can not be transferred to server as process parameter recalls information by client computer.
Summary of the invention
In view of this, when RPC message is larger, dividing it this application provides a kind of remote procedure calling (PRC) method
Piece processing, avoids client computer from occupying a large amount of Installed System Memory, so that memory is controllable using held stationary, and passes through allocation methods
It realizes and is transferred to server-side for file as process parameter.Accordingly, present invention also provides remote procedure call device, set
Standby, computer readable storage medium and computer program product.
The application first aspect provides a kind of remote procedure call device, and described device includes:
Message transmission module, message reception module, management module, network module, coding/decoding module and code building mould
Block;
The network module for establishing connection with opposite equip., and safeguards the connection;
The code generation module, for generating first code and second code according to remote procedure call message template,
The first code is asked for the user data for meeting the remote procedure call message template to be packaged into remote procedure call
It asks, the second code meets the remote procedure call message mould for decoded remote procedure call message to be parsed into
The user data of plate;
The management module, for sending the remote procedure call request to the message transmission module;
The message transmission module is stored in message team for the remote procedure call request to be packaged into data structure
In column, when having message to need to handle in detecting the message queue, first is taken out far from the head of the message queue
Journey procedure call request, and the remote procedure call request is sent to the coding/decoding module;
The coding/decoding module, for being encoded to the remote procedure call request, and in the remote process tune
Fragment is carried out when being greater than preset length with the length after request coding, each fragment has fragment flag bit, for characterizing this point
Whether piece is the last one fragment in all fragments of remote procedure call message, is then sent according to fragment to the message
Module sends the data after coding, so that the message transmission module sends institute to the opposite equip. by the network module
Data after stating coding;
The management module is also used to the response of the if desired opposite equip., then registration message processor;
The message reception module receives the remote procedure call for monitoring the remote procedure call message
When message, the coding/decoding module is called to be decoded, Xiang Suoshu management module sends decoded message, so that the management
Module sends decoded message to corresponding Message Processing person according to the sequence number of the remote procedure call message.
Optionally, the coding/decoding module is specifically used for:
If the length after the remote procedure call request coding is less than or equal to preset length, sent to the message
Module sends the data after coding, and setting characterization current slice for the fragment flag bit is that complete remote procedure call disappears
It is last a piece of in all fragments of breath;
If the length after the remote procedure call request coding is greater than preset length, length in encoded reaches pre-
If when length, i.e., sending the data after encoding to the message transmission module, and set characterization for the fragment flag bit and work as
Preceding fragment be not it is last a piece of in all fragments of complete remote procedure call message, then proceed to execute the coding step
Suddenly, until when the length after coding is not more than the preset length, Xiang Suoshu message transmission module sends the data after coding, and
Setting characterization current slice for the fragment flag bit is last in all fragments of complete remote procedure call message
Piece.
Optionally, the coding/decoding module is specifically used for:
When the data structure is fixed-length data, it is encoded to data type and initial data;
When the data structure is non-fixed-length data, it is encoded to data type, data length and initial data.
Optionally, the pre- first to file internal memory cache region of the coding/decoding module is used to save the data after coding, the memory
The size of buffer area is the determination according to the byte number after the byte number of fragment and maximum fixed-length data coding.
Optionally, described device further include:
Log module, for recording the remote procedure call message between local device and the opposite equip..
The application second aspect provides a kind of remote procedure calling (PRC) method, using remote process described in first aspect
Calling device, which comprises
According to the user data for meeting remote procedure call message template, the first code for calling code generation module to generate
Generate remote procedure call request;
The remote procedure call request is packaged into data structure to be stored in message queue, is detecting the message
When thering is message to need to handle in queue, first remote procedure call request is taken out from the head of the message queue, to described
Remote procedure call request is encoded;
Length after remote procedure call request coding carries out fragment when being greater than preset length, and sends out according to fragment
Data after sending coding;
Wherein, each fragment has fragment flag bit, for characterizing whether the fragment is the remote procedure call message
All fragments in the last one fragment.
Optionally, when the length after the remote procedure call request coding is less than or equal to preset length, after coding
Data as a fragment, and by the fragment flag bit be set as characterization current slice be complete remote procedure call message
All fragments in it is last a piece of;
When length after the remote procedure call request coding is greater than preset length, then length in encoded reaches pre-
If when length, that is, sending the data after coding, and it is not complete long-range for setting characterization current slice for the fragment flag bit
It is last a piece of in all fragments of invocation of procedure message, it then proceedes to execute the coding step, until the length after coding
When no more than the preset length, the data after encoding are sent, and set characterization current slice for the fragment flag bit to be
It is last a piece of in all fragments of complete remote procedure call message.
Optionally, when the data structure is fixed-length data, data type and initial data are encoded to;
When the data structure is non-fixed-length data, it is encoded to data type, data length and initial data.
Optionally, the data after the coding are stored in core buffer, the core buffer include data field and to
Treatment region, the byte number of the data field are equal to the byte number of fragment, and the byte number of the pending district is not less than maximum fixed length
Byte number after data encoding;
Then it is described to the remote procedure call request carry out coding include:
If the pending district is stored with data, the data of the pending district are moved to the data field;
It is completed if being encoded before internal memory cache region is used up, sends encoded data, and fragment flag bit is set
It is last a piece of in all fragments of complete remote procedure call message for being set to characterization current slice;
It is remained unfulfilled if being encoded when internal memory cache region is used up, sends the coded data of designated length, it is described specified
Length is equal to the byte number of fragment, and setting characterization current slice for fragment flag bit is not complete remote procedure call message
All fragments in it is last a piece of, also, when the remaining space in data field is not enough to put down the last one data type, press
It is encoded according to following principle:
The last one described data are fixed length types, then complete the coding of this data, the content beyond data field be put into
Treatment region;
The last one described data are elongated types, and data field can accommodate the data type and data length of the data
When, then data field is written into the data type of the data and data length and the remaining data that still can be put into data field, and
Current coded data length is recorded, continues to encode by remaining data when encode next time;
The last one described data are elongated types, and data field be not enough to accommodate the data data type and data it is long
When spending, then this fragment is no longer by this data encoding to data field.
Optionally, the method also includes:
If desired the response of opposite end, then registration message processor;
The remote procedure call message is monitored, when receiving the remote procedure call message, decodes the long-range mistake
Journey calls message, and sends decoded disappear to corresponding Message Processing person according to the sequence number of the remote procedure call message
Breath.
Optionally, the method also includes:
Record the remote procedure call message between local terminal and opposite end.
The embodiment of the present application third aspect provides a kind of remote procedure call equipment, and the equipment includes processor and deposits
Reservoir:
The memory is for storing computer program;
The processor be used for according to the computer program execute the application first aspect described in remote procedure call
Method.
The embodiment of the present application fourth aspect provides a kind of computer readable storage medium, the computer-readable storage medium
Matter is for storing computer program, and the computer program is for executing remote procedure call side described in the application first aspect
Method.
The aspect of the embodiment of the present application the 5th is provided in a kind of computer program product comprising computer-readable instruction, when
When the computer-readable instruction is run on computers, so that computer executes remote procedure call side described in above-mentioned various aspects
Method.
As can be seen from the above technical solutions, the embodiment of the present application has the advantage that
The embodiment of the present application provides a kind of remote procedure call device, which includes that message transmission module, message connect
Receive module, management module, network module, coding/decoding module and code generation module, wherein the coding/decoding module is used for
The remote procedure call request is encoded, and the length after remote procedure call request coding is greater than default length
Carry out fragment when spending, each fragment has fragment flag bit, for characterize the fragment whether be remote procedure call message institute
There is the last one fragment in fragment, the data after then sending coding to the message transmission module according to fragment, so that institute
State the data after message transmission module sends the coding to the opposite equip. by the network module;The management mould
Block is also used to the response of the if desired opposite equip., then registration message processor;The message reception module, for monitoring
The remote procedure call message when receiving the remote procedure call message, calls the coding/decoding module to be decoded,
Decoded message is sent to the management module, so that sequence of the management module according to the remote procedure call message
Number decoded message is sent to corresponding Message Processing person.
The device is sent by when message is larger, being carried out fragment processing according to fragment, and client computer is avoided to occupy
A large amount of Installed System Memory so that memory is controllable using held stationary, and is realized by allocation methods using file as process
Parameter is transferred to server-side.Also, after each fragment is transmitted, the coding work of next fragment can be carried out immediately
Make, completed without waiting for entire message coding, thus improves message efficiency of transmission.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of application without any creative labor, may be used also for those of ordinary skill in the art
To obtain other drawings based on these drawings.
Fig. 1 is a kind of structural schematic diagram of remote procedure call device in the embodiment of the present application.
Fig. 2 is a kind of flow chart of remote procedure calling (PRC) method in the embodiment of the present application;
Fig. 3 is a kind of structural schematic diagram of remote procedure call equipment in the embodiment of the present application.
Specific embodiment
In order to make those skilled in the art more fully understand application scheme, below in conjunction in the embodiment of the present application
Attached drawing, the technical scheme in the embodiment of the application is clearly and completely described, it is clear that described embodiment is only this
Apply for a part of the embodiment, instead of all the embodiments.Based on the embodiment in the application, those of ordinary skill in the art exist
Every other embodiment obtained under the premise of creative work is not made, shall fall in the protection scope of this application.
The description and claims of this application and term " first ", " second ", " third ", " in above-mentioned attached drawing
The (if present)s such as four " are to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should manage
The data that solution uses in this way are interchangeable under appropriate circumstances, so that embodiments herein described herein for example can be to remove
Sequence other than those of illustrating or describe herein is implemented.In addition, term " includes " and " having " and theirs is any
Deformation, it is intended that cover it is non-exclusive include, for example, containing the process, method of a series of steps or units, system, production
Product or equipment those of are not necessarily limited to be clearly listed step or unit, but may include be not clearly listed or for this
A little process, methods, the other step or units of product or equipment inherently.
When the network equipment gets network data, needs to upload onto the server network data and analyze.Work as net
Network data can be convenient in an orderly manner by data such as the Google Protocol Buffer of Google by RPC technology when small
It is transferred to server.But when the data volume of network data is huge or needs big file being transferred to server, commonly
RPC technology is unable to satisfy demand, and programmer often requires to use the data that other methods carry out transmission chunk, such as oneself is realized
The module of one transmission file specially transmits file, and is not available RPC technology, and such development efficiency is low and is easy to
It is wrong.
In view of this, the RPC device can be divided when message is larger this application provides a kind of RPC device
Piece processing, and sent according to fragment, avoid client computer from occupying a large amount of Installed System Memory, so that memory is controllable using held stationary,
And it is realized by allocation methods and is transferred to server-side for file as process parameter.In addition, each fragment is sent out
After going, the coding work of next fragment can be carried out immediately, is completed without waiting for entire message coding, thus is improved and disappeared
Cease efficiency of transmission.
Next, RPC device provided by the present application is introduced in conjunction with specific embodiments.
The structural schematic diagram of RPC device shown in Figure 1, the device 100 include: network module 110, code building mould
Block 120, management module 130, message transmission module 140, coding/decoding module 150 and message reception module 160;
The network module 110 for establishing connection with opposite equip., and safeguards the connection;
The code generation module 120, for generating first code and the second generation according to remote procedure call message template
Code, the first code are used to the user data for meeting the remote procedure call message template being packaged into remote procedure call
Request, the second code meet the remote procedure call message for decoded remote procedure call message to be parsed into
The user data of template;
The management module 130, for sending the remote procedure call request to the message transmission module;
The message transmission module 140, disappears for the remote procedure call request to be packaged into data structure and be stored in
It ceases in queue, when thering is message to need to handle in detecting the message queue, takes out first from the head of the message queue
A remote procedure call request, and the remote procedure call request is sent to the coding/decoding module 150;
The coding/decoding module 150, for being encoded to the remote procedure call request, and in the remote process
Length after call request coding carries out fragment when being greater than preset length, each fragment has fragment flag bit, for characterizing this
Whether fragment is the last one fragment in all fragments of remote procedure call message, is then sent out according to fragment to the message
Module 140 is sent to send the data after coding, so that the message transmission module 140 is by the network module 110 to described right
End equipment sends the data after the coding;
The management module 130, is also used to the response of the if desired opposite equip., then registration message processor;
The message reception module 160 receives the remote process tune for monitoring the remote procedure call message
When with message, the coding/decoding module 150 is called to be decoded, Xiang Suoshu management module 130 sends decoded message, so that
The management module 130 sends according to the sequence number of the remote procedure call message to corresponding Message Processing person decoded
Message.
It is appreciated that the RPC device 100 supports numerous types of data, including basic data type, such as integer, boolean, float
Points, character string, binary data, file data, wherein it is whole that integer from length is divided into 1 byte, 2 bytes, 4 bytes or 8 bytes
Type, from whether including that symbol can be divided into and have symbol integer and unsigned int.It should be noted that the RPC device is also supported
Complex data type, such as class, fixed length array, elongated array and/or is enumerated.
It should be noted that the data length of fixed-length data type in encoded is also fixed length, non-fixed-length data type exists
Data length after coding is random length.
In view of decoding process, in practical application, usually being encoded according to following principle:
When the data structure is fixed-length data, it is encoded to data type and initial data;
When the data structure is non-fixed-length data, it is encoded to data type, data length and initial data.
As an example, fixed-length data is encoded as 1 byte data type and initial data;Non- fixed-length data type quilt
It is encoded to 1 byte data type, 4 byte data lengths and initial data.
In the technical solution of the application, for RPC message, the heading being described not only includes that message is big
The information such as the type of small, message sequence number and message, further include fragment flag bit, for guaranteeing whether current slice is one
The last one fragment in all fragments of a complete RPC message.In this way, opposite end when receiving any fragment, passes through this point
Piece flag bit determines whether the fragment is the last one fragment of complete RPC message, if it is not, next fragment is then continued to, and
Execution determines whether it is the step of the last one fragment, if so, opposite end can will it is received twice recently the last one point
Fragment between piece is determined as all fragments of the RPC message including the last one the last received fragment.
It is appreciated that the RPC device 100 supports user to configure the size of each fragment of RPC message according to actual needs, i.e.,
The byte number of each fragment.When specific implementation, RPC fragment size can be configured by above-mentioned management module 130.Show as one
Example, can configure each fragment is 4096 bytes.In this way, when using the RPC device 100 transmission RPC message, RPC dress
It sets 100 to encode RPC request by coding/decoding module 150, specifically, the RPC device is by coding/decoding module 150
The input parameter of long-range RPC request is encoded, the size of data after coding is more than 4096 bytes, then can will current warp knit
4096 complete byte datas of code are first sent to opposite end, such as server-side, are further continued for being encoded, the data after coding reach 4096 words
When section, then by encoded data to opposite end transmission, until all data are encoded and send.
Based on this, in some possible implementations, coding/decoding module 150 is specifically used for: if RPC request coding
Length afterwards is less than or equal to preset length, then the data after sending coding to the message transmission module 140, and will be described point
It is last a piece of in all fragments of complete remote procedure call message that piece flag bit, which is set as characterization current slice,;If described
Length after RPC request coding is less than or equal to preset length, then when length in encoded reaches preset length, i.e., to described
Message transmission module 140 sends the data after coding, and it is not complete for setting characterization current slice for the fragment flag bit
It is last a piece of in all fragments of remote procedure call message, it then proceedes to execute the coding step, until after coding
When length is not more than the preset length, Xiang Suoshu message transmission module 140 sends the data after coding, and by the fragment mark
It is last a piece of in all fragments of complete remote procedure call message that will position, which is set as characterization current slice,.Wherein, above-mentioned
Preset length can be the length of fragment.
In specific implementation, coding/decoding module 150 can pre- first to file internal memory cache region be used for saves encode after data,
The size of the internal memory cache region is the determination according to the byte number after the byte number of fragment and maximum fixed-length data coding.Tool
Body, internal memory cache region may include data field and pending district, wherein the size of data field is equal to the size of fragment, above-mentioned
Pending district size can be determined according to the byte number after maximum fixed-length data coding, be based on this, the size of internal memory cache region
Not less than the sum of the byte number after the byte number of data field and maximum fixed-length data coding.
Based on this, coding/decoding module 150 first checks whether pending district has data when encoding to RPC request, if
Have, then the data of pending district is moved to data field.Coding/decoding module 150 carries out it according to the data type that RPC is requested
Coding, is completed, by coded data return message sending module if encoded before core buffer is used up
140, and inform that current slice is the last one fragment of RPC message by fragment flag bit, if core buffer is used up
Coding remains unfulfilled, then returns to message hair as a fragment with the equal-sized data of fragment in coded data
Module is sent, and informs that current slice is not the last one fragment of RPC message by fragment flag bit.
Wherein, data need fragment, and when the remaining space of data field is not enough to put down the last one data type, can be with
It is encoded according to following principle:
When the last one data is fixed length type, then the data are encoded, and will exceed the interior receiving of data field
Enter pending district;
When the last one data is elongated type, and data field is sufficient to accommodate the data type and data length of the data,
Data field then is written into the data type of the data and data length and the remaining data for still being able to be put into data field, and is remembered
Record is at this point, coded data length, continues to encode when encode next time to remaining data;
When the elongated type of the last one data, and data field is not enough to accommodate the data type and data length of the data
When, then this fragment is no longer by this data encoding to data field.
In some possible implementations, which can also include log module, set for recording local terminal
The standby RPC message between opposite equip., to be used when user's debugging.
From the foregoing, it will be observed that the embodiment of the present application provides a kind of RPC device, which includes that message transmission module, message connect
Module, management module, network module, coding/decoding module and code generation module are received, by coding/decoding module to described remote
Journey procedure call request is encoded, and is carried out when the length after the remote procedure call request encodes is greater than preset length
Fragment, each fragment has fragment flag bit, for characterizing whether the fragment is in all fragments of remote procedure call message
The last one fragment, then according to fragment to the message transmission module send coding after data so that the message send out
Data after sending module to send the coding to the opposite equip. by the network module.
This method is sent by when message is larger, being carried out fragment processing according to fragment, and client computer is avoided to occupy
A large amount of Installed System Memory so that memory is controllable using held stationary, and is realized by allocation methods using file as process
Parameter is transferred to server-side.Also, after each fragment is transmitted, the coding work of next fragment can be carried out immediately
Make, completed without waiting for entire message coding, thus improves message efficiency of transmission.
Based on above-mentioned RPC device provided by the embodiments of the present application, the embodiment of the present application also provides a kind of RPC method, tools
Body includes the transmission of RPC message and RPC message sink, in order to make it easy to understand, being transmitted across in conjunction with specific embodiments to RPC message first
Journey is introduced.
RPC method flow diagram shown in Figure 2, this method comprises:
S201: according to the user data for meeting remote procedure call message template, call that code generation module generates the
One code building remote procedure call request.
Wherein, RPC message template refers to the standardized format of RPC message, define field that RPC message includes and
The length etc. of each field.In practical application, to can be user customized for the RPC message template, it is also possible to preset configuration
, the present embodiment is not construed as limiting this.
After generation meets the user data of RPC message template, local terminal namely client call code generation module are generated
First code, according to above-mentioned user data generate RPC request.
S202: the remote procedure call request is packaged into data structure and is stored in message queue, detecting
It states when thering is message to need to handle in message queue, takes out first remote procedure call request from the head of the message queue,
The remote procedure call request is encoded.
RPC request is packaged into data structure by message transmission module and is stored in message queue by client, works as detection
Have into message queue message need to handle namely message queue in when being stored with data structure, taken from the head of message queue
First RPC request out specifically takes out first RPC and requests corresponding data structure, by coding/decoding module to institute
RPC request is stated to be encoded.
S203: the length after remote procedure call request coding carries out fragment when being greater than preset length, and according to
Fragment sends the data after coding.
Wherein, each fragment has fragment flag bit, for characterizing whether the fragment is the remote procedure call message
All fragments in the last one fragment.In this way, opposite end, after receiving fragment, can be determined according to the fragment flag bit should
Whether fragment is the last one fragment in all fragments of RPC message, and then determines all fragments corresponding with the RPC message.
In practical application, when the length after RPC request coding is less than or equal to preset length, then by the number after coding
The institute that characterization current slice is complete remote procedure call message is set as according to as a fragment, and by the fragment flag bit
Have last a piece of in fragment, is sent in this way, completing RPC message by fragment.
When length after RPC request coding is greater than preset length, then length in encoded reaches preset length
When, that is, the data after coding are sent, and setting characterization current slice for the fragment flag bit is not complete remote process tune
It with last a piece of in all fragments of message, then proceedes to execute the coding step, until the length after coding is not more than
When the preset length, the data after encoding are sent, and it is complete remote for setting characterization current slice for the fragment flag bit
It is last a piece of in all fragments of journey invocation of procedure message.
It should be noted that it can be encoded to data type and initial data when data structure is fixed-length data,
When data structure is non-fixed-length data, data type, data length and initial data can be encoded to.
In some possible implementations, acceptable pre- first to file internal memory cache region, for storing the data after encoding.
Specifically, internal memory cache region may include data field and pending district, and the byte number of the data field is equal to the byte number of fragment,
The byte number of the pending district is not less than the byte number after maximum fixed-length data coding.
Based on this, the implementation encoded is requested present invention also provides a kind of couple of RPC, specifically, if institute
It states pending district and is stored with data, then the data of the pending district are moved to the data field;If being used in internal memory cache region
Coding is completed before to the greatest extent, then sends encoded data, and it is complete remote for setting characterization current slice for fragment flag bit
It is last a piece of in all fragments of journey invocation of procedure message;It remains unfulfilled, sends if being encoded when internal memory cache region is used up
The coded data of designated length, the designated length is equal to the byte number of fragment, and sets characterization for fragment flag bit and work as
Preceding fragment is not last a piece of in all fragments of complete remote procedure call message.
Also, when the remaining space in data field is not enough to put down the last one data type, encoded according to following principle:
The last one described data are fixed length types, then complete the coding of this data, the content beyond data field be put into
Treatment region;
The last one described data are elongated types, and data field can accommodate the data type and data length of the data
When, then data field is written into the data type of the data and data length and the remaining data that still can be put into data field, and
Current coded data length is recorded, continues to encode by remaining data when encode next time;
The last one described data are elongated types, and data field be not enough to accommodate the data data type and data it is long
When spending, then this fragment is no longer by this data encoding to data field.
The above are the specific implementations for the RPC method that the angle that the embodiment of the present application is sent from message provides, in reality
In application, local device can also be can also be used as by far call namely local device as server-side, at this point, local device
The RPC message that can receive opposite equip. transmission, below will be described in detail message receive process.
In some possible implementations, if local device needs the response of opposite end, it can be registered in management module
Message Processing person, then local device monitors RPC message, and when receiving RPC message, decodes the RPC message, and according to
The sequence number of the RPC message sends decoded message to corresponding Message Processing person.
In practical application, local device can also record the remote procedure call message between local terminal and opposite end, so as to
User uses when debugging.
The embodiment of the present application provides a kind of RPC method, when this method is by transmission RPC message, according to the RPC message
Size is divided into slice and is transmitted, to avoid client computer from occupying a large amount of Installed System Memory, so that memory uses holding
It is steady controllable, and realized by allocation methods and be transferred to server-side for file as process parameter.Also, each fragment
After being transmitted, the coding work of next fragment can be carried out immediately, completed without waiting for entire message coding, thus
Improve message efficiency of transmission.
On the other hand, this method also runs the fragment size of user's self-setting RPC message, thus the system for being adapted to oneself
Reach optimum transport efficiency.For the data of file type, in coding just by the reading data in file into memory, from
And it can support the transmission of big file.This method is also provided with state encoding and decoding, and when RPC message fragment, record is current
Message coding or decoded position, so as to continue with next fragment based on the position.
Based on the above method provided by the embodiments of the present application and device, present invention also provides a kind of RPC equipment, referring to figure
The structural schematic diagram of RPC equipment shown in 3, the RPC equipment include memory 301 and processor 302, in which:
The memory 301 is for storing computer program;
The processor 302 is used to execute RPC method provided by the embodiments of the present application according to the computer program.
The embodiment of the present application also provides a kind of computer readable storage medium, the computer readable storage medium is for depositing
Computer program is stored up, the computer program is for executing RPC method described herein.
The embodiment of the present application also provides a kind of computer program products including computer-readable instruction, when the computer
When readable instruction is run on computers, so that computer executes remote procedure calling (PRC) method described in above-mentioned various aspects.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed device and method can pass through it
Its mode is realized.For example, the apparatus embodiments described above are merely exemplary, for example, the division of the unit, only
Only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components can be tied
Another system is closed or is desirably integrated into, or some features can be ignored or not executed.Another point, it is shown or discussed
Mutual coupling, direct-coupling or communication connection can be through some interfaces, the INDIRECT COUPLING or logical of device or unit
Letter connection can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It should be appreciated that in this application, " at least one (item) " refers to one or more, and " multiple " refer to two or two
More than a."and/or" indicates may exist three kinds of relationships, for example, " A and/or B " for describing the incidence relation of affiliated partner
It can indicate: only exist A, only exist B and exist simultaneously tri- kinds of situations of A and B, wherein A, B can be odd number or plural number.Word
Symbol "/" typicallys represent the relationship that forward-backward correlation object is a kind of "or"." at least one of following (a) " or its similar expression, refers to
Any combination in these, any combination including individual event (a) or complex item (a).At least one of for example, in a, b or c
(a) can indicate: a, b, c, " a and b ", " a and c ", " b and c ", or " a and b and c ", and wherein a, b, c can be individually, can also
To be multiple.
The above, above embodiments are only to illustrate the technical solution of the application, rather than its limitations;Although referring to before
Embodiment is stated the application is described in detail, those skilled in the art should understand that: it still can be to preceding
Technical solution documented by each embodiment is stated to modify or equivalent replacement of some of the technical features;And these
It modifies or replaces, the spirit and scope of each embodiment technical solution of the application that it does not separate the essence of the corresponding technical solution.
Claims (13)
1. a kind of remote procedure call device, which is characterized in that described device includes:
Message transmission module, message reception module, management module, network module, coding/decoding module and code generation module;
The network module for establishing connection with opposite equip., and safeguards the connection;
The code generation module, it is described for generating first code and second code according to remote procedure call message template
First code is used to the user data for meeting the remote procedure call message template being packaged into remote procedure call request, institute
It states second code and meets the remote procedure call message template for decoded remote procedure call message to be parsed into
User data;
The management module, for sending the remote procedure call request to the message transmission module;
The message transmission module is stored in message queue for the remote procedure call request to be packaged into data structure
In, when having message to need to handle in detecting the message queue, first is taken out remotely from the head of the message queue
Procedure call request, and the remote procedure call request is sent to the coding/decoding module;
The coding/decoding module is asked for encoding to the remote procedure call request, and in the remote procedure call
Length after seeking coding carries out fragment when being greater than preset length, each fragment has fragment flag bit, is for characterizing the fragment
The last one fragment in no all fragments for remote procedure call message, then according to fragment to the message transmission module
Data after sending coding, so that the message transmission module sends the volume to the opposite equip. by the network module
Data after code;
The management module is also used to the response of the if desired opposite equip., then registration message processor;
The message reception module receives the remote procedure call message for monitoring the remote procedure call message
When, call the coding/decoding module to be decoded, Xiang Suoshu management module sends decoded message, so that the management module
Decoded message is sent to corresponding Message Processing person according to the sequence number of the remote procedure call message.
2. remote procedure call device according to claim 1, which is characterized in that the coding/decoding module is specifically used for:
If the length after the remote procedure call request coding is less than or equal to preset length, to the message transmission module
Data after sending coding, and setting characterization current slice for the fragment flag bit is complete remote procedure call message
It is last a piece of in all fragments;
If the length after the remote procedure call request coding is greater than preset length, length in encoded reaches default length
When spending, i.e., the data after encoding are sent to the message transmission module, and set current point of characterization for the fragment flag bit
Piece be not it is last a piece of in all fragments of complete remote procedure call message, then proceed to execute the coding step, directly
When length after to coding is not more than the preset length, Xiang Suoshu message transmission module sends the data after coding, and by institute
It is last a piece of in all fragments of complete remote procedure call message for stating fragment flag bit and being set as characterization current slice.
3. remote procedure call device according to claim 1, which is characterized in that the coding/decoding module is specifically used for:
When the data structure is fixed-length data, it is encoded to data type and initial data;
When the data structure is non-fixed-length data, it is encoded to data type, data length and initial data.
4. remote procedure call device according to claim 1, which is characterized in that in the pre- first to file of coding/decoding module
Buffer area is deposited for the data after saving coding, the size of the internal memory cache region is the byte number and maximum fixed length according to fragment
Byte number after data encoding and determination.
5. device according to any one of claims 1 to 4, which is characterized in that described device further include:
Log module, for recording the remote procedure call message between local device and the opposite equip..
6. a kind of remote procedure calling (PRC) method, which is characterized in that be applied to such as long-range mistake described in any one of claim 1 to 5
Journey calling device, which comprises
According to the user data for meeting remote procedure call message template, the first code for calling code generation module to generate is generated
Remote procedure call request;
The remote procedure call request is packaged into data structure to be stored in message queue, is detecting the message queue
In when thering is message to need to handle, first remote procedure call request is taken out from the head of the message queue, to described long-range
Procedure call request is encoded;
Length after remote procedure call request coding carries out fragment when being greater than preset length, and sends and compile according to fragment
Data after code;
Wherein, each fragment have fragment flag bit, for characterize the fragment whether be the remote procedure call message institute
There is the last one fragment in fragment.
7. according to the method described in claim 6, it is characterized in that, the length after remote procedure call request coding is less than
Or when being equal to preset length, using the data after coding as a fragment, and characterization is set currently for the fragment flag bit
Fragment is last a piece of in all fragments of complete remote procedure call message;
When length after the remote procedure call request coding is greater than preset length, then length in encoded reaches default length
When spending, that is, the data after coding are sent, and setting characterization current slice for the fragment flag bit is not complete remote process
It is last a piece of in all fragments of calling message, it then proceedes to execute the coding step, until the length after coding is little
When the preset length, the data after encoding are sent, and it is complete for setting characterization current slice for the fragment flag bit
It is last a piece of in all fragments of remote procedure call message.
8. according to the method described in claim 6, it is characterized in that, being encoded to when the data structure is fixed-length data
Data type and initial data;
When the data structure is non-fixed-length data, it is encoded to data type, data length and initial data.
9. according to the method described in claim 6, it is characterized in that, the data after the coding are stored in core buffer, institute
Stating core buffer includes data field and pending district, and the byte number of the data field is equal to the byte number of fragment, described wait locate
The byte number for managing area is not less than the byte number after maximum fixed-length data coding;
Then it is described to the remote procedure call request carry out coding include:
If the pending district is stored with data, the data of the pending district are moved to the data field;
It is completed if being encoded before internal memory cache region is used up, sends encoded data, and set fragment flag bit to
It is last a piece of in all fragments of complete remote procedure call message for characterizing current slice;
It is remained unfulfilled if being encoded when internal memory cache region is used up, sends the coded data of designated length, the designated length
The institute that characterization current slice is not complete remote procedure call message is set as equal to the byte number of fragment, and by fragment flag bit
Have it is last a piece of in fragment, also, when the remaining space in data field is not enough to put down the last one data type, according to such as
Lower principle coding:
The last one described data are fixed length types, then complete the coding of this data, and the content beyond data field is put into be processed
Area;
The last one described data are elongated types, and when data field can accommodate the data type and data length of the data,
Data field then is written into the data type of the data and data length and the remaining data that still can be put into data field, and is recorded
Current coded data length, remaining data when encode next time continued to encode;
The last one described data are elongated types, and data field is not enough to accommodate the data type and data length of the data
When, then this fragment is no longer by this data encoding to data field.
10. according to the described in any item methods of claim 6 to 9, which is characterized in that the method also includes:
If desired the response of opposite end, then registration message processor;
The remote procedure call message is monitored, when receiving the remote procedure call message, decodes the remote process tune
Decoded message is sent to corresponding Message Processing person with message, and according to the sequence number of the remote procedure call message.
11. according to the described in any item methods of claim 6 to 9, which is characterized in that the method also includes:
Record the remote procedure call message between local terminal and opposite end.
12. a kind of remote procedure call equipment, which is characterized in that the equipment includes processor and memory:
The memory is for storing computer program;
The processor is used for the remote process tune according to any one of computer program perform claim requirement 6 to 11
Use method.
13. a kind of computer readable storage medium, which is characterized in that the computer readable storage medium is for storing computer
Program, the computer program is for remote procedure calling (PRC) method described in any one of perform claim requirement 6 to 11.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910271974.6A CN109981674B (en) | 2019-04-04 | 2019-04-04 | Remote procedure calling method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910271974.6A CN109981674B (en) | 2019-04-04 | 2019-04-04 | Remote procedure calling method, device, equipment and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109981674A true CN109981674A (en) | 2019-07-05 |
CN109981674B CN109981674B (en) | 2021-08-17 |
Family
ID=67083058
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910271974.6A Active CN109981674B (en) | 2019-04-04 | 2019-04-04 | Remote procedure calling method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109981674B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021128602A1 (en) * | 2019-12-24 | 2021-07-01 | 网宿科技股份有限公司 | Data transmission method and apparatus |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030140180A1 (en) * | 2002-01-23 | 2003-07-24 | International Business Machines Corporation | Multi-protocol object distribution |
CN1852209A (en) * | 2006-05-31 | 2006-10-25 | 北京和利时系统工程股份有限公司 | Remote process transfering method and system in distribution type control system |
CN102546612A (en) * | 2011-12-23 | 2012-07-04 | 华中科技大学 | Remote procedure call implementation method based on remote direct memory access (RDMA) protocol in user mode |
CN102594891A (en) * | 2012-02-17 | 2012-07-18 | 中国科学院计算技术研究所 | Method and system for processing remote procedure call request |
CN103440244A (en) * | 2013-07-12 | 2013-12-11 | 广东电子工业研究院有限公司 | Large-data storage and optimization method |
US9491261B1 (en) * | 2013-07-29 | 2016-11-08 | Amazon Technologies, Inc. | Remote messaging protocol |
CN106453250A (en) * | 2016-09-05 | 2017-02-22 | 掌阅科技股份有限公司 | Processing method of big data RPC (Remote Procedure Call Protocol) |
CN106534249A (en) * | 2016-09-21 | 2017-03-22 | 苏州市广播电视总台 | File transmission system based on file straight-through technology |
CN106648940A (en) * | 2017-03-13 | 2017-05-10 | 北京百悟科技有限公司 | Remote procedure call method and device |
-
2019
- 2019-04-04 CN CN201910271974.6A patent/CN109981674B/en active Active
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030140180A1 (en) * | 2002-01-23 | 2003-07-24 | International Business Machines Corporation | Multi-protocol object distribution |
CN1852209A (en) * | 2006-05-31 | 2006-10-25 | 北京和利时系统工程股份有限公司 | Remote process transfering method and system in distribution type control system |
CN102546612A (en) * | 2011-12-23 | 2012-07-04 | 华中科技大学 | Remote procedure call implementation method based on remote direct memory access (RDMA) protocol in user mode |
CN102594891A (en) * | 2012-02-17 | 2012-07-18 | 中国科学院计算技术研究所 | Method and system for processing remote procedure call request |
CN103440244A (en) * | 2013-07-12 | 2013-12-11 | 广东电子工业研究院有限公司 | Large-data storage and optimization method |
US9491261B1 (en) * | 2013-07-29 | 2016-11-08 | Amazon Technologies, Inc. | Remote messaging protocol |
CN106453250A (en) * | 2016-09-05 | 2017-02-22 | 掌阅科技股份有限公司 | Processing method of big data RPC (Remote Procedure Call Protocol) |
CN106534249A (en) * | 2016-09-21 | 2017-03-22 | 苏州市广播电视总台 | File transmission system based on file straight-through technology |
CN106648940A (en) * | 2017-03-13 | 2017-05-10 | 北京百悟科技有限公司 | Remote procedure call method and device |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021128602A1 (en) * | 2019-12-24 | 2021-07-01 | 网宿科技股份有限公司 | Data transmission method and apparatus |
US11303737B2 (en) | 2019-12-24 | 2022-04-12 | Wangsu Science & Technology Co., Ltd. | Method and device for data transmission |
Also Published As
Publication number | Publication date |
---|---|
CN109981674B (en) | 2021-08-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP3639770B2 (en) | Network control apparatus and method | |
CN107241221B (en) | Support the network management protocol data unified processing system and method for different network management protocols | |
CN103414579A (en) | Cross-platform monitoring system applicable to cloud computing and monitoring method thereof | |
US10360057B1 (en) | Network-accessible volume creation and leasing | |
CN109921986A (en) | A kind of multi-protocol data cut-in method, device, intelligent gateway and storage medium | |
CN114237937A (en) | Multithreading data transmission method and device | |
CN109522139A (en) | A kind of tables of data service creation call method, device, equipment and storage medium | |
CN105871819B (en) | Transfer control method and equipment | |
CN110096521A (en) | Log information processing method and device | |
CN113515320A (en) | Hardware acceleration processing method and device and server | |
CN111585963A (en) | Data acquisition method, system and storage medium | |
CN109379245A (en) | A kind of wifi report form generation method and system | |
CN109981674A (en) | A kind of remote procedure calling (PRC) method, device, equipment and medium | |
CN107094085B (en) | Signaling transmission method and device | |
CN113992600A (en) | Multi-rate mode data transmission control method and device based on cache queue | |
CN110401681A (en) | For data transmission, the method for data receiver and electronic equipment | |
CN109492384A (en) | Receiving entity access, method, encryption device and the entity for accessing encryption device | |
CN112911024A (en) | Method and system for collecting data of Internet of things, electronic device and storage medium | |
US11758017B2 (en) | Data acquisition method, service provider, service consumer and network functional entity | |
CN111190731A (en) | Cluster task scheduling system based on weight | |
CN110012003A (en) | A kind of cloud application grabs screen method and apparatus | |
CN110022323A (en) | A kind of method and system of the cross-terminal real-time, interactive based on WebSocket and Redux | |
CN109308288A (en) | Data processing method and device | |
CN109815081A (en) | The long range acquisition method and collection device of database performance | |
CN111469558B (en) | Multi-nozzle control system and control method thereof |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |