CN111796936A - Request processing method and device, electronic equipment and medium - Google Patents
Request processing method and device, electronic equipment and medium Download PDFInfo
- Publication number
- CN111796936A CN111796936A CN202010610717.3A CN202010610717A CN111796936A CN 111796936 A CN111796936 A CN 111796936A CN 202010610717 A CN202010610717 A CN 202010610717A CN 111796936 A CN111796936 A CN 111796936A
- Authority
- CN
- China
- Prior art keywords
- request
- processed
- requests
- determining
- processing method
- 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.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 31
- 238000012545 processing Methods 0.000 claims abstract description 50
- 238000000034 method Methods 0.000 claims abstract description 34
- 230000004044 response Effects 0.000 claims abstract description 26
- 230000008569 process Effects 0.000 claims abstract description 20
- 238000005516 engineering process Methods 0.000 claims abstract description 8
- 238000012795 verification Methods 0.000 claims description 17
- 238000012544 monitoring process Methods 0.000 claims description 10
- 238000001514 detection method Methods 0.000 claims description 5
- 230000010354 integration Effects 0.000 claims description 4
- 238000004590 computer program Methods 0.000 description 14
- 230000006870 function Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 5
- 230000001960 triggered effect Effects 0.000 description 4
- 230000005540 biological transmission Effects 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 239000003999 initiator Substances 0.000 description 2
- 238000013507 mapping Methods 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
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/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/958—Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
-
- 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/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5061—Partitioning or combining of resources
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Storage Device Security (AREA)
Abstract
The invention relates to data processing and provides a request processing method, a request processing device, electronic equipment and a medium. The method comprises the steps of determining a request type of a request to be processed when the request to be processed is received, selecting a target thread pool based on a basic service type when the request type is the basic service type, detecting whether the request to be processed needs to be split, splitting the request to be processed to obtain a plurality of sub-requests when the request to be processed needs to be split, calling all idle threads in the target thread pool to process the sub-requests to obtain request results corresponding to the sub-requests, and integrating the request results to obtain response results of the request to be processed. The invention improves the processing efficiency of the request to be processed. In addition, the invention also relates to a block chain technology, and the response result can be stored in the block chain.
Description
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a request processing method and apparatus, an electronic device, and a medium.
Background
With the development of the internet, the number of requests is increased, and the requirement of a user on the request processing efficiency is also improved, however, currently, in the process of processing the request, a single-thread processing mode is still adopted for the same request, and the problem of low efficiency exists in the mode. Especially, when the amount of requested data is large, the efficiency of processing the request by a single thread cannot meet the requirement of the user.
Disclosure of Invention
In view of the above, it is desirable to provide a request processing method, apparatus, electronic device and medium, which can improve the processing efficiency of the pending request.
A method of request processing, the method comprising:
when a request to be processed is received, determining the request type of the request to be processed;
when the request type is a basic service type, selecting a target thread pool based on the basic service type;
detecting whether the request to be processed needs to be split;
when the to-be-processed request is detected to be split, splitting the to-be-processed request to obtain a plurality of sub-requests;
calling all idle threads in the target thread pool to process the sub-requests to obtain request results corresponding to the sub-requests;
and integrating the request result to obtain a response result of the request to be processed.
According to the preferred embodiment of the present invention, the request processing method further includes:
verifying whether the request to be processed is legal or not to obtain a verification result;
when the verification result is legal, acquiring all first interface parameters in the request to be processed, matching each first interface parameter with a second interface parameter in a configuration library, determining the unmatched first interface parameters as redundant interface parameters, and deleting the redundant interface parameters in the request to be processed; or
And when the verification result is illegal, discarding the request to be processed.
According to the preferred embodiment of the present invention, after selecting the target thread pool based on the basic service type, the request processing method further includes:
adding the request to be processed into a message queue of the target thread pool, and monitoring the message queue;
and locking the request to be processed when the condition that the preemption state of the request to be processed is modified to be preempted or the request to be processed is read is monitored.
According to a preferred embodiment of the present invention, the detecting whether the pending request needs to be split includes:
detecting whether the data length of the request to be processed is larger than or equal to a preset value or not, and detecting whether all data in the request to be processed have a dependency relationship or not;
when the data length of the request to be processed is detected to be larger than or equal to the preset value and all data in the request to be processed do not have dependency relationships, determining that the request to be processed needs to be split; or
And when the data length of the request to be processed is smaller than the preset value or all the data in the request to be processed have dependency relationship, determining that the request to be processed does not need to be split.
According to a preferred embodiment of the present invention, the splitting the request to be processed to obtain a plurality of sub-requests includes:
splitting the requests to be processed according to the sequence of the data sequence numbers of all the data from small to large to obtain a plurality of first requests and the execution sequence of the first requests;
acquiring a dependency relationship among the plurality of first requests;
merging the first requests with the dependency relationship according to the execution sequence of the first requests to obtain a plurality of second requests;
determining idle threads of the target thread pool, and calculating the target number of all idle threads in the target thread pool;
when the number of the plurality of second requests is larger than the target number, acquiring a target data volume of each second request in the plurality of second requests;
and merging the plurality of second requests according to the target data volume until the merged request number is equal to the target number to obtain the plurality of sub-requests.
According to a preferred embodiment of the present invention, the determining idle threads of the target thread pool includes:
acquiring request records of all thread processing requests in the target thread pool;
determining the calling failure times of all the threads in a preset time period according to the request record;
when the calling failure times of any thread are detected to be less than or equal to a threshold value, determining the any thread as a normal thread;
detecting whether the request queue of the normal thread is empty;
and when the request queue of the normal thread is empty, determining that the normal thread is the idle thread.
According to the preferred embodiment of the present invention, after obtaining the response result of the request to be processed, the request processing method further includes:
acquiring a request number of the request to be processed;
generating prompt information according to the request number and the response result;
encrypting the prompt information by adopting a symmetric encryption technology to obtain a ciphertext;
and sending the ciphertext to the terminal equipment of the appointed contact person.
A request processing apparatus, the apparatus comprising:
the device comprises a determining unit, a judging unit and a processing unit, wherein the determining unit is used for determining the request type of a request to be processed when the request to be processed is received;
the selecting unit is used for selecting a target thread pool based on the basic service type when the request type is the basic service type;
the detection unit is used for detecting whether the request to be processed needs to be split or not;
the splitting unit is used for splitting the request to be processed to obtain a plurality of sub-requests when the request to be processed is detected to be split;
the processing unit is used for calling all idle threads in the target thread pool to process the sub-requests to obtain request results corresponding to the sub-requests;
and the integration unit is used for integrating the request result to obtain a response result of the request to be processed.
According to a preferred embodiment of the present invention, the request processing apparatus further includes:
the verification unit is used for verifying whether the request to be processed is legal or not to obtain a verification result;
the execution unit is used for acquiring all first interface parameters in the request to be processed when the verification result is legal, matching each first interface parameter with a second interface parameter in a configuration library, determining the unmatched first interface parameters as redundant interface parameters, and deleting the redundant interface parameters in the request to be processed; or
The execution unit is further configured to discard the to-be-processed request when the verification result is illegal.
According to a preferred embodiment of the present invention, the request processing apparatus further includes:
the monitoring unit is used for adding the request to be processed into a message queue of the target thread pool after selecting the target thread pool based on the basic service type and monitoring the message queue;
and the locking unit is used for locking the request to be processed when the condition that the preemption state of the request to be processed is modified into preempted state or the request to be processed is read is monitored.
According to a preferred embodiment of the present invention, the detection unit is specifically configured to:
detecting whether the data length of the request to be processed is larger than or equal to a preset value or not, and detecting whether all data in the request to be processed have a dependency relationship or not;
when the data length of the request to be processed is detected to be larger than or equal to the preset value and all data in the request to be processed do not have dependency relationships, determining that the request to be processed needs to be split; or
And when the data length of the request to be processed is smaller than the preset value or all the data in the request to be processed have dependency relationship, determining that the request to be processed does not need to be split.
According to a preferred embodiment of the present invention, the splitting unit splits the request to be processed to obtain a plurality of sub-requests, including:
splitting the requests to be processed according to the sequence of the data sequence numbers of all the data from small to large to obtain a plurality of first requests and the execution sequence of the first requests;
acquiring a dependency relationship among the plurality of first requests;
merging the first requests with the dependency relationship according to the execution sequence of the first requests to obtain a plurality of second requests;
determining idle threads of the target thread pool, and calculating the target number of all idle threads in the target thread pool;
when the number of the plurality of second requests is larger than the target number, acquiring a target data volume of each second request in the plurality of second requests;
and merging the plurality of second requests according to the target data volume until the merged request number is equal to the target number to obtain the plurality of sub-requests.
According to a preferred embodiment of the present invention, the determining, by the splitting unit, idle threads of the target thread pool includes:
acquiring request records of all thread processing requests in the target thread pool;
determining the calling failure times of all the threads in a preset time period according to the request record;
when the calling failure times of any thread are detected to be less than or equal to a threshold value, determining the any thread as a normal thread;
detecting whether the request queue of the normal thread is empty;
and when the request queue of the normal thread is empty, determining that the normal thread is the idle thread.
According to a preferred embodiment of the present invention, the request processing apparatus further includes:
the acquiring unit is used for acquiring the request number of the request to be processed after the response result of the request to be processed is obtained;
the generating unit is used for generating prompt information according to the request number and the response result;
the encryption unit is used for encrypting the prompt message by adopting a symmetric encryption technology to obtain a ciphertext;
and the sending unit is used for sending the ciphertext to the terminal equipment of the appointed contact person.
An electronic device, the electronic device comprising:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the request processing method.
A computer-readable storage medium having stored therein at least one instruction, the at least one instruction being executable by a processor in an electronic device to implement the request processing method.
According to the technical scheme, the target thread pool is selected based on the basic service type, the thread suitable for processing the request to be processed can be selected according to the corresponding request type, whether the request to be processed needs to be split can be determined by detecting whether the request to be processed meets the splitting condition, the request to be processed is split when the request to be processed needs to be split, the request to be processed can be split into a plurality of sub-requests, all idle threads in the target thread pool are called to process the plurality of sub-requests, and the processing efficiency of the request to be processed can be improved.
Drawings
FIG. 1 is a flow chart of a request processing method according to a preferred embodiment of the present invention.
FIG. 2 is a functional block diagram of a preferred embodiment of a request processing device according to the present invention.
Fig. 3 is a schematic structural diagram of an electronic device implementing a request processing method according to a preferred embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
FIG. 1 is a flow chart of a request processing method according to a preferred embodiment of the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The request processing method is applied to a smart government scene, so that the construction of a smart city is promoted. The request processing method is applied to one or more electronic devices, which are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and the hardware thereof includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive Internet Protocol Television (IPTV), a smart wearable device, and the like.
The electronic device may also include a network device and/or a user device. The network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a cloud computing (cloud computing) based cloud consisting of a large number of hosts or network servers.
The network in which the electronic device is located includes, but is not limited to: the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
S10, when a request to be processed is received, determining the request type of the request to be processed.
In at least one embodiment of the present invention, the pending request may be triggered by an initiator of the pending request, or may be triggered automatically by the system within a preset time.
The preset time may be a time point or a time period, which is not limited in the present invention.
In at least one embodiment of the present invention, the information carried by the pending request includes, but is not limited to: a request identification, etc. For example: the request identification may be: cx.
In at least one embodiment of the present invention, the request type may include a basic service type and a specific service type, and further, the basic service type may include, but is not limited to: data query, data transfer, etc. The characteristic service type refers to a request type which is not processed by the electronic equipment.
In at least one embodiment of the present invention, the electronic device determining the request type of the pending request includes:
analyzing the request head of the request to be processed to obtain data information carried by the request head;
acquiring a preset label, and acquiring information corresponding to the preset label from the data information as the request identifier;
and determining the request type according to the request identifier.
The preset tag refers to a predefined identifier, for example, the preset tag may be a name.
The request identifier can be accurately determined through the mapping relation between the preset label and the request identifier, and then the request type can be accurately determined.
In at least one embodiment of the invention, the method further comprises:
verifying whether the request to be processed is legal or not to obtain a verification result;
when the verification result is legal, acquiring all first interface parameters in the request to be processed, matching each first interface parameter with a second interface parameter in a configuration library, determining the unmatched first interface parameters as redundant interface parameters, and deleting the redundant interface parameters in the request to be processed; or
And when the verification result is illegal, discarding the request to be processed.
Through the embodiment, the legitimacy of the to-be-processed request for subsequent processing can be ensured, and the redundant interface parameters are not included in the to-be-processed request for subsequent processing.
S11, when the request type is a basic service type, selecting a target thread pool based on the basic service type.
In at least one embodiment of the invention, the method further comprises:
and when the request type is the characteristic service type, the electronic equipment creates a thread pool corresponding to the characteristic service type.
Through the implementation mode, the thread pool suitable for the special service type can be created, and the situation that the thread pool cannot be processed when the request of the special service type is received is avoided.
In at least one embodiment of the present invention, the selecting, by the electronic device, a target thread pool based on the basic service type includes:
acquiring a type identification code of the basic service type;
acquiring a thread pool name corresponding to the type identification code from a preset library;
and determining the target thread pool according to the thread pool name.
Through the implementation mode, the target thread pool corresponding to the basic service type can be accurately determined.
In at least one embodiment of the invention, after selecting the target thread pool based on the basic service type, the method further comprises:
adding the request to be processed into a message queue of the target thread pool, and monitoring the message queue;
and locking the request to be processed when the condition that the preemption state of the request to be processed is modified to be preempted or the request to be processed is read is monitored.
By monitoring the message queue, the preemption state of the to-be-processed request can be accurately determined, the to-be-processed request which is preempted successfully is subjected to locking processing, and the to-be-processed request can be prevented from being processed repeatedly.
Specifically, the electronic device starts a preset plug-in, and performs tick selection on the to-be-processed request that is successfully preempted, so as to complete locking of the to-be-processed request.
S12, detecting whether the request to be processed needs to be split.
In at least one embodiment of the present invention, the electronic device detecting whether the pending request needs to be split includes:
detecting whether the data length of the request to be processed is larger than or equal to a preset value or not, and detecting whether all data in the request to be processed have a dependency relationship or not;
when the data length of the request to be processed is detected to be larger than or equal to the preset value and all data in the request to be processed do not have dependency relationships, determining that the request to be processed needs to be split; or
And when the data length of the request to be processed is smaller than the preset value or all the data in the request to be processed have dependency relationship, determining that the request to be processed does not need to be split.
Through the implementation method, the to-be-processed request can be split when the data length of the to-be-processed request is larger than or equal to the preset value and all data in the to-be-processed request do not have a dependency relationship.
In other embodiments, when the pending request does not need to be split, the electronic device invokes any thread in the target thread pool to process the pending request.
S13, when detecting that the request to be processed needs to be split, splitting the request to be processed to obtain a plurality of sub-requests.
In at least one embodiment of the present invention, the splitting, by the electronic device, the to-be-processed request to obtain a plurality of sub-requests includes:
splitting the requests to be processed according to the sequence of the data sequence numbers of all the data from small to large to obtain a plurality of first requests and the execution sequence of the first requests;
acquiring a dependency relationship among the plurality of first requests;
merging the first requests with the dependency relationship according to the execution sequence of the first requests to obtain a plurality of second requests;
determining idle threads of the target thread pool, and calculating the target number of all idle threads in the target thread pool;
when the number of the plurality of second requests is larger than the target number, acquiring a target data volume of each second request in the plurality of second requests;
and merging the plurality of second requests according to the target data volume until the merged request number is equal to the target number to obtain the plurality of sub-requests.
Through the implementation mode, the to-be-processed request can be reasonably split, so that the processing efficiency of the to-be-processed request is improved.
Specifically, the determining, by the electronic device, an idle thread of the target thread pool includes:
acquiring request records of all thread processing requests in the target thread pool;
determining the calling failure times of all the threads in a preset time period according to the request record;
when the calling failure times of any thread are detected to be less than or equal to a threshold value, determining the any thread as a normal thread;
detecting whether the request queue of the normal thread is empty;
and when the request queue of the normal thread is empty, determining that the normal thread is the idle thread.
Wherein the request queue is empty, which indicates that no unprocessed task is contained in the request queue.
By the above embodiment, it can be ensured that the idle thread can successfully process the plurality of sub-requests.
S14, all idle threads in the target thread pool are called to process the sub-requests, and request results corresponding to the sub-requests are obtained.
In at least one embodiment of the present invention, it is prior art that the electronic device invokes all idle threads to process the plurality of sub-requests, and this is not described in detail herein.
S15, integrating the request result to obtain the response result of the request to be processed.
It is emphasized that, in order to further ensure the privacy and security of the response result, the response result may also be stored in a node of a block chain.
In at least one embodiment of the present invention, after obtaining the response result of the to-be-processed request, the electronic device performs unlocking processing on the to-be-processed request.
In at least one embodiment of the present invention, after obtaining the response result of the pending request, the method further includes:
acquiring a request number of the request to be processed;
generating prompt information according to the request number and the response result;
encrypting the prompt information by adopting a symmetric encryption technology to obtain a ciphertext;
and sending the ciphertext to the terminal equipment of the appointed contact person.
Through the implementation mode, the corresponding contact person can be timely reminded after the request to be processed is successfully executed, in addition, the prompt information is encrypted, the prompt information can be prevented from being tampered, and therefore the safety of the prompt information is improved.
According to the technical scheme, the target thread pool is selected based on the basic service type, the thread suitable for processing the request to be processed can be selected according to the corresponding request type, whether the request to be processed needs to be split can be determined by detecting whether the request to be processed meets the splitting condition, the request to be processed is split when the request to be processed needs to be split, the request to be processed can be split into a plurality of sub-requests, all idle threads in the target thread pool are called to process the plurality of sub-requests, and the processing efficiency of the request to be processed can be improved.
FIG. 2 is a functional block diagram of a request processing device according to a preferred embodiment of the present invention. The request processing device 11 includes a determining unit 110, a selecting unit 111, a detecting unit 112, a splitting unit 113, a processing unit 114, an integrating unit 115, a verifying unit 116, an executing unit 117, a monitoring unit 118, a locking unit 119, an obtaining unit 120, a generating unit 121, an encrypting unit 122, and a sending unit 123. The module/unit referred to in the present invention refers to a series of computer program segments that can be fetched by the processor 13 and that can perform a fixed function, and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
When a pending request is received, the determining unit 110 determines a request type of the pending request.
In at least one embodiment of the present invention, the pending request may be triggered by an initiator of the pending request, or may be triggered automatically by the system within a preset time.
The preset time may be a time point or a time period, which is not limited in the present invention.
In at least one embodiment of the present invention, the information carried by the pending request includes, but is not limited to: a request identification, etc. For example: the request identification may be: cx.
In at least one embodiment of the present invention, the request type may include a basic service type and a specific service type, and further, the basic service type may include, but is not limited to: data query, data transfer, etc. The characteristic service type refers to a request type which is not processed by the electronic equipment.
In at least one embodiment of the present invention, the determining unit 110 determines the request type of the pending request, including:
analyzing the request head of the request to be processed to obtain data information carried by the request head;
acquiring a preset label, and acquiring information corresponding to the preset label from the data information as the request identifier;
and determining the request type according to the request identifier.
The preset tag refers to a predefined identifier, for example, the preset tag may be a name.
The request identifier can be accurately determined through the mapping relation between the preset label and the request identifier, and then the request type can be accurately determined.
In at least one embodiment of the present invention, the verifying unit 116 verifies whether the request to be processed is legal, so as to obtain a verification result;
when the verification result is legal, the execution unit 117 obtains all the first interface parameters in the request to be processed, matches each first interface parameter with the second interface parameter in the configuration library, determines the unmatched first interface parameter as a redundant interface parameter, and deletes the redundant interface parameter in the request to be processed; or
When the verification result is illegal, the execution unit 117 discards the pending request.
Through the embodiment, the legitimacy of the to-be-processed request for subsequent processing can be ensured, and the redundant interface parameters are not included in the to-be-processed request for subsequent processing.
When the request type is a basic service type, the selecting unit 111 selects a target thread pool based on the basic service type.
In at least one embodiment of the invention, when the request type is the characteristic service type, the execution unit 117 creates a thread pool corresponding to the characteristic service type.
Through the implementation mode, the thread pool suitable for the special service type can be created, and the situation that the thread pool cannot be processed when the request of the special service type is received is avoided.
In at least one embodiment of the present invention, the selecting unit 111 selects the target thread pool based on the basic service type, including:
acquiring a type identification code of the basic service type;
acquiring a thread pool name corresponding to the type identification code from a preset library;
and determining the target thread pool according to the thread pool name.
Through the implementation mode, the target thread pool corresponding to the basic service type can be accurately determined.
In at least one embodiment of the present invention, after selecting a target thread pool based on the basic service type, the monitoring unit 118 adds the pending request to a message queue of the target thread pool, and monitors the message queue;
when it is monitored that the preemption state of the pending request is modified to be preempted, or the pending request is read, the locking unit 119 locks the pending request.
By monitoring the message queue, the preemption state of the to-be-processed request can be accurately determined, the to-be-processed request which is preempted successfully is subjected to locking processing, and the to-be-processed request can be prevented from being processed repeatedly.
Specifically, the locking unit 119 starts a preset plug-in, and performs checking on the to-be-processed request that is successfully preempted, so as to complete locking of the to-be-processed request.
The detection unit 112 detects whether the pending request needs to be split.
In at least one embodiment of the present invention, the detecting unit 112 detects whether the pending request needs to be split includes:
detecting whether the data length of the request to be processed is larger than or equal to a preset value or not, and detecting whether all data in the request to be processed have a dependency relationship or not;
when the data length of the request to be processed is detected to be larger than or equal to the preset value and all data in the request to be processed do not have dependency relationships, determining that the request to be processed needs to be split; or
And when the data length of the request to be processed is smaller than the preset value or all the data in the request to be processed have dependency relationship, determining that the request to be processed does not need to be split.
Through the implementation method, the to-be-processed request can be split when the data length of the to-be-processed request is larger than or equal to the preset value and all data in the to-be-processed request do not have a dependency relationship.
In other embodiments, when the pending request does not need to be split, any thread in the target thread pool is invoked to process the pending request.
When it is detected that the to-be-processed request needs to be split, the splitting unit 113 splits the to-be-processed request to obtain a plurality of sub-requests.
In at least one embodiment of the present invention, the splitting unit 113 splits the to-be-processed request to obtain a plurality of sub-requests, including:
splitting the requests to be processed according to the sequence of the data sequence numbers of all the data from small to large to obtain a plurality of first requests and the execution sequence of the first requests;
acquiring a dependency relationship among the plurality of first requests;
merging the first requests with the dependency relationship according to the execution sequence of the first requests to obtain a plurality of second requests;
determining idle threads of the target thread pool, and calculating the target number of all idle threads in the target thread pool;
when the number of the plurality of second requests is larger than the target number, acquiring a target data volume of each second request in the plurality of second requests;
and merging the plurality of second requests according to the target data volume until the merged request number is equal to the target number to obtain the plurality of sub-requests.
Through the implementation mode, the to-be-processed request can be reasonably split, so that the processing efficiency of the to-be-processed request is improved.
Specifically, the determining, by the splitting unit 113, idle threads of the target thread pool includes:
acquiring request records of all thread processing requests in the target thread pool;
determining the calling failure times of all the threads in a preset time period according to the request record;
when the calling failure times of any thread are detected to be less than or equal to a threshold value, determining the any thread as a normal thread;
detecting whether the request queue of the normal thread is empty;
and when the request queue of the normal thread is empty, determining that the normal thread is the idle thread.
Wherein the request queue is empty, which indicates that no unprocessed task is contained in the request queue.
By the above embodiment, it can be ensured that the idle thread can successfully process the plurality of sub-requests.
The processing unit 114 calls all idle threads in the target thread pool to process the sub-requests, and obtains request results corresponding to the sub-requests.
In at least one embodiment of the present invention, it is prior art that the processing unit 114 invokes all idle threads to process the plurality of sub-requests, and this is not described in detail herein.
The integration unit 115 integrates the request result to obtain the response result of the pending request.
It is emphasized that, in order to further ensure the privacy and security of the response result, the response result may also be stored in a node of a block chain.
In at least one embodiment of the present invention, after obtaining the response result of the pending request, the locking unit 119 performs unlocking processing on the pending request.
In at least one embodiment of the present invention, after obtaining the response result of the to-be-processed request, the obtaining unit 120 obtains the request number of the to-be-processed request;
the generating unit 121 generates prompt information according to the request number and the response result;
the encryption unit 122 encrypts the prompt message by using a symmetric encryption technology to obtain a ciphertext;
the sending unit 123 sends the ciphertext to the terminal device of the designated contact.
Through the implementation mode, the corresponding contact person can be timely reminded after the request to be processed is successfully executed, in addition, the prompt information is encrypted, the prompt information can be prevented from being tampered, and therefore the safety of the prompt information is improved.
According to the technical scheme, the target thread pool is selected based on the basic service type, the thread suitable for processing the request to be processed can be selected according to the corresponding request type, whether the request to be processed needs to be split can be determined by detecting whether the request to be processed meets the splitting condition, the request to be processed is split when the request to be processed needs to be split, the request to be processed can be split into a plurality of sub-requests, all idle threads in the target thread pool are called to process the plurality of sub-requests, and the processing efficiency of the request to be processed can be improved.
Fig. 3 is a schematic structural diagram of an electronic device implementing a request processing method according to a preferred embodiment of the invention.
In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and a computer program, such as a request processing program, stored in the memory 12 and executable on the processor 13.
It will be appreciated by a person skilled in the art that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation of the electronic device 1, and that it may comprise more or less components than shown, or some components may be combined, or different components, e.g. the electronic device 1 may further comprise an input output device, a network access device, a bus, etc.
The Processor 13 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The processor 13 is an operation core and a control center of the electronic device 1, and is connected to each part of the whole electronic device 1 by various interfaces and lines, and executes an operating system of the electronic device 1 and various installed application programs, program codes, and the like.
The processor 13 executes an operating system of the electronic device 1 and various installed application programs. The processor 13 executes the application program to implement the steps in the various request processing method embodiments described above, such as the steps shown in fig. 1.
Alternatively, the processor 13, when executing the computer program, implements the functions of the modules/units in the above device embodiments, for example:
when a request to be processed is received, determining the request type of the request to be processed;
when the request type is a basic service type, selecting a target thread pool based on the basic service type;
detecting whether the request to be processed needs to be split;
when the to-be-processed request is detected to be split, splitting the to-be-processed request to obtain a plurality of sub-requests;
calling all idle threads in the target thread pool to process the sub-requests to obtain request results corresponding to the sub-requests;
and integrating the request result to obtain a response result of the request to be processed.
Illustratively, the computer program may be divided into one or more modules/units, which are stored in the memory 12 and executed by the processor 13 to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into a determination unit 110, a selection unit 111, a detection unit 112, a splitting unit 113, a processing unit 114, an integration unit 115, a verification unit 116, an execution unit 117, a monitoring unit 118, a locking unit 119, an acquisition unit 120, a generation unit 121, an encryption unit 122, and a transmission unit 123.
The memory 12 can be used for storing the computer programs and/or modules, and the processor 13 implements various functions of the electronic device 1 by running or executing the computer programs and/or modules stored in the memory 12 and calling data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the electronic device, and the like. Further, the memory 12 may include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other non-volatile solid state storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the memory 12 may be a memory having a physical form, such as a memory stick, a TF Card (Trans-flash Card), or the like.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
In conjunction with fig. 1, the memory 12 in the electronic device 1 stores a plurality of instructions to implement a request processing method, and the processor 13 can execute the plurality of instructions to implement:
when a request to be processed is received, determining the request type of the request to be processed;
when the request type is a basic service type, selecting a target thread pool based on the basic service type;
detecting whether the request to be processed needs to be split;
when the to-be-processed request is detected to be split, splitting the to-be-processed request to obtain a plurality of sub-requests;
calling all idle threads in the target thread pool to process the sub-requests to obtain request results corresponding to the sub-requests;
and integrating the request result to obtain a response result of the request to be processed.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the instruction, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims (10)
1. A request processing method, characterized in that the request processing method comprises:
when a request to be processed is received, determining the request type of the request to be processed;
when the request type is a basic service type, selecting a target thread pool based on the basic service type;
detecting whether the request to be processed needs to be split;
when the to-be-processed request is detected to be split, splitting the to-be-processed request to obtain a plurality of sub-requests;
calling all idle threads in the target thread pool to process the sub-requests to obtain request results corresponding to the sub-requests;
and integrating the request result to obtain a response result of the request to be processed.
2. The request processing method of claim 1, wherein the request processing method further comprises:
verifying whether the request to be processed is legal or not to obtain a verification result;
when the verification result is legal, acquiring all first interface parameters in the request to be processed, matching each first interface parameter with a second interface parameter in a configuration library, determining the unmatched first interface parameters as redundant interface parameters, and deleting the redundant interface parameters in the request to be processed; or
And when the verification result is illegal, discarding the request to be processed.
3. The request processing method of claim 1, wherein after selecting a target thread pool based on the base service type, the request processing method further comprises:
adding the request to be processed into a message queue of the target thread pool, and monitoring the message queue;
and locking the request to be processed when the condition that the preemption state of the request to be processed is modified to be preempted or the request to be processed is read is monitored.
4. The request processing method of claim 1, wherein the detecting whether the pending request requires splitting comprises:
detecting whether the data length of the request to be processed is larger than or equal to a preset value or not, and detecting whether all data in the request to be processed have a dependency relationship or not;
when the data length of the request to be processed is detected to be larger than or equal to the preset value and all data in the request to be processed do not have dependency relationships, determining that the request to be processed needs to be split; or
And when the data length of the request to be processed is smaller than the preset value or all the data in the request to be processed have dependency relationship, determining that the request to be processed does not need to be split.
5. The request processing method of claim 4, wherein splitting the pending request to obtain a plurality of sub-requests comprises:
splitting the requests to be processed according to the sequence of the data sequence numbers of all the data from small to large to obtain a plurality of first requests and the execution sequence of the first requests;
acquiring a dependency relationship among the plurality of first requests;
merging the first requests with the dependency relationship according to the execution sequence of the first requests to obtain a plurality of second requests;
determining idle threads of the target thread pool, and calculating the target number of all idle threads in the target thread pool;
when the number of the plurality of second requests is larger than the target number, acquiring a target data volume of each second request in the plurality of second requests;
and merging the plurality of second requests according to the target data volume until the merged request number is equal to the target number to obtain the plurality of sub-requests.
6. The request processing method of claim 5, wherein the determining idle threads of the target thread pool comprises:
acquiring request records of all thread processing requests in the target thread pool;
determining the calling failure times of all the threads in a preset time period according to the request record;
when the calling failure times of any thread are detected to be less than or equal to a threshold value, determining the any thread as a normal thread;
detecting whether the request queue of the normal thread is empty;
and when the request queue of the normal thread is empty, determining that the normal thread is the idle thread.
7. The request processing method of claim 1, wherein after obtaining a response result of the pending request, the request processing method further comprises:
acquiring a request number of the request to be processed;
generating prompt information according to the request number and the response result;
encrypting the prompt information by adopting a symmetric encryption technology to obtain a ciphertext;
and sending the ciphertext to the terminal equipment of the appointed contact person.
8. A request processing apparatus, characterized in that the request processing apparatus comprises:
the device comprises a determining unit, a judging unit and a processing unit, wherein the determining unit is used for determining the request type of a request to be processed when the request to be processed is received;
the selecting unit is used for selecting a target thread pool based on the basic service type when the request type is the basic service type;
the detection unit is used for detecting whether the request to be processed needs to be split or not;
the splitting unit is used for splitting the request to be processed to obtain a plurality of sub-requests when the request to be processed is detected to be split;
the processing unit is used for calling all idle threads in the target thread pool to process the sub-requests to obtain request results corresponding to the sub-requests;
and the integration unit is used for integrating the request result to obtain a response result of the request to be processed.
9. An electronic device, characterized in that the electronic device comprises:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the request processing method of any of claims 1 to 7.
10. A computer-readable storage medium characterized by: the computer-readable storage medium has stored therein at least one instruction that is executed by a processor in an electronic device to implement the request processing method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010610717.3A CN111796936A (en) | 2020-06-29 | 2020-06-29 | Request processing method and device, electronic equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010610717.3A CN111796936A (en) | 2020-06-29 | 2020-06-29 | Request processing method and device, electronic equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111796936A true CN111796936A (en) | 2020-10-20 |
Family
ID=72809781
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010610717.3A Pending CN111796936A (en) | 2020-06-29 | 2020-06-29 | Request processing method and device, electronic equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111796936A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113157437A (en) * | 2021-03-03 | 2021-07-23 | 北京澎思科技有限公司 | Data processing method and device, electronic equipment and storage medium |
CN115185677A (en) * | 2022-06-24 | 2022-10-14 | 湖南长银五八消费金融股份有限公司 | Business data merging general ledger method, device, computer equipment and medium |
CN117472597A (en) * | 2023-12-28 | 2024-01-30 | 苏州元脑智能科技有限公司 | Input/output request processing method, system, electronic device and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105117283A (en) * | 2015-08-26 | 2015-12-02 | 深圳市华验防伪科技有限公司 | Task splitting method and system |
CN105893156A (en) * | 2016-04-20 | 2016-08-24 | 北京云宏信达信息科技有限公司 | Request processing method of storage and computing system and storage and computing system |
CN106716367A (en) * | 2014-09-25 | 2017-05-24 | 甲骨文国际公司 | System and method for supporting dynamic thread pool sizing in distributed data grid |
CN108628636A (en) * | 2017-03-24 | 2018-10-09 | 北京京东尚科信息技术有限公司 | Method, apparatus, electronic equipment and the readable storage medium storing program for executing of system business isolation |
CN110765157A (en) * | 2019-09-06 | 2020-02-07 | 中国平安财产保险股份有限公司 | Data query method and device, computer equipment and storage medium |
CN110851276A (en) * | 2019-11-07 | 2020-02-28 | 深圳乐信软件技术有限公司 | Service request processing method, device, server and storage medium |
-
2020
- 2020-06-29 CN CN202010610717.3A patent/CN111796936A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106716367A (en) * | 2014-09-25 | 2017-05-24 | 甲骨文国际公司 | System and method for supporting dynamic thread pool sizing in distributed data grid |
CN105117283A (en) * | 2015-08-26 | 2015-12-02 | 深圳市华验防伪科技有限公司 | Task splitting method and system |
CN105893156A (en) * | 2016-04-20 | 2016-08-24 | 北京云宏信达信息科技有限公司 | Request processing method of storage and computing system and storage and computing system |
CN108628636A (en) * | 2017-03-24 | 2018-10-09 | 北京京东尚科信息技术有限公司 | Method, apparatus, electronic equipment and the readable storage medium storing program for executing of system business isolation |
CN110765157A (en) * | 2019-09-06 | 2020-02-07 | 中国平安财产保险股份有限公司 | Data query method and device, computer equipment and storage medium |
CN110851276A (en) * | 2019-11-07 | 2020-02-28 | 深圳乐信软件技术有限公司 | Service request processing method, device, server and storage medium |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113157437A (en) * | 2021-03-03 | 2021-07-23 | 北京澎思科技有限公司 | Data processing method and device, electronic equipment and storage medium |
CN115185677A (en) * | 2022-06-24 | 2022-10-14 | 湖南长银五八消费金融股份有限公司 | Business data merging general ledger method, device, computer equipment and medium |
CN117472597A (en) * | 2023-12-28 | 2024-01-30 | 苏州元脑智能科技有限公司 | Input/output request processing method, system, electronic device and storage medium |
CN117472597B (en) * | 2023-12-28 | 2024-03-15 | 苏州元脑智能科技有限公司 | Input/output request processing method, system, electronic device and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112035258B (en) | Data processing method, device, electronic equipment and medium | |
US11258612B2 (en) | Method, apparatus, and electronic device for blockchain-based recordkeeping | |
CN108900464B (en) | Electronic device, block chain-based data processing method, and computer storage medium | |
CN111694840A (en) | Data synchronization method, device, server and storage medium | |
CN111698088B (en) | Key alternation method, key alternation device, electronic equipment and medium | |
WO2022179115A1 (en) | User authentication method and apparatus, server and storage medium | |
CN112287329B (en) | Service instance verification method and device, electronic equipment and storage medium | |
CN111796936A (en) | Request processing method and device, electronic equipment and medium | |
CN112541009B (en) | Data query method, device, electronic equipment and storage medium | |
CN113050900B (en) | Screen sharing method, device, equipment and storage medium | |
CN111797351A (en) | Page data management method and device, electronic equipment and medium | |
CN111814441A (en) | Report generation method and device, electronic equipment and storage medium | |
CN111641678A (en) | Task scheduling method and device, electronic equipment and medium | |
CN111984601A (en) | Log file deleting method and device, electronic equipment and storage medium | |
CN111277626B (en) | Server upgrading method and device, electronic equipment and medium | |
CN110209347B (en) | Traceable data storage method | |
CN112711696A (en) | Request access method, device, electronic equipment and storage medium | |
CN112163036A (en) | Block chain information construction and query method and related device | |
CN112395319B (en) | Cache sharing method and device, server and storage medium | |
CN114979109A (en) | Behavior track detection method and device, computer equipment and storage medium | |
CN112685706A (en) | Request authentication method and related equipment | |
CN112311551A (en) | Securing provable resource ownership | |
CN113722684A (en) | Data tracing method and device, electronic equipment and computer readable storage medium | |
CN112015759B (en) | Policy detection method, device, electronic equipment and medium | |
CN112667659B (en) | Feature processing method and related equipment |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20201020 |
|
RJ01 | Rejection of invention patent application after publication |