Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a gateway executing method based on MySQL protocol.
The technical scheme of the invention is as follows:
the gateway execution method based on MySQL protocol comprises the following steps:
each time a connection is established, performing initialization of Session and Session context;
performing ReqContext object and Listener object initialization each time a request is received, and binding ReqId and ReqContext, listener object instances in a SessionContext object according to connID; pressing the same connID bound requests into a request queue through a dispatcher to generate sequential increment IDs; and when the received more than two requests have no context relation, executing SQL concurrently to obtain an execution result.
Preferably, the method further comprises a write-back method, wherein the write-back is performed according to the request arrival time sequence, the execution results are cached in a dispatcher response queue, and the response is performed one by one according to the request queue sequence.
Preferably, listener objects include a connection monitor object, a Session monitor object, and a request monitor object that are independent of each other.
Preferably, the method further comprises executing serially, and when the received two or more requests have a context, then the serial execution is marked in the SessionContext object.
The invention also provides a gateway executing device based on MySQL protocol, comprising the following structure:
a connection initializing unit for connecting the client and executing initialization of Session and Session context each time connection is established;
a request initializing unit for receiving a user request, performing ReqContext object and Listener object initialization each time the request is received, and binding ReqId and ReqContext, listener instances according to connID in a SessionContext object;
a dispatcher unit for pushing the bound request into a request queue, generating a sequential increment ID;
And the execution unit is used for sequentially increasing the IDs to execute the corresponding SQL.
Preferably, the Listener objects include a connection monitor object, a Session monitor object, and a request monitor object that are independent of each other.
Preferably, the execution unit comprises a concurrent execution unit and a serial execution unit, and the serial execution unit is used for executing the corresponding SQL in series according to the serial execution mark in the SessionContext object when the received more than two requests have data dependency.
Preferably, the apparatus further comprises a write-back unit for executing a sequential write-back procedure, the sequential write-back procedure comprising sequential write-back according to the request arrival time, the execution results being cached in a dispatcher response queue, and responding one by one according to the request queue order.
The invention also provides a computer storage medium which stores a computer program, and the computer program is called by a processor to realize a gateway concurrency execution method based on MySQL protocol.
The invention also provides electronic equipment, which comprises a memory and a processor, wherein the memory is used for storing one or more computer instructions, and the one or more computer instructions are executed by the processor to realize a gateway concurrency execution method based on MySQL protocol.
The invention has the beneficial effects that by configuring system parameters, the allowed Connection and request Req can have 1: n (N is more than or equal to 1), and monitors are configured for each request, namely concurrent execution is supported, so that the execution efficiency is improved, and the accuracy of the request and the accuracy of data are ensured.
Detailed Description
The present invention will be described in further detail with reference to the following examples, which are illustrative of the present invention and are not intended to limit the present invention thereto. Any changes or substitutions within the technical scope of the present disclosure should be covered in the scope of the present disclosure.
Noun interpretation:
ConnId, connection identifier, which generates a globally unique identification ID each time a new connection is established
ReqContext, requesting a context for storing the requested context;
Session, namely, a Session is started from the connection of the client to the server, and the Session is ended from the disconnection of the client and the server;
SessionContext, a Session context, for storing a Session context;
ConnectionContext, connect context;
listener objects, snoop objects.
It should be noted that, since the references to terms such as "session", "session context", etc. may be ambiguous in the actual operation, english may still be the object of description in order to better illustrate the solution of the present application.
Example 1
A gateway concurrency execution method based on MySQL protocol is disclosed, and referring to FIG. 1 and FIG. 2, the method comprises the following steps:
each time a connection is established, performing initialization of a session and a session context;
Executing initialization of a request context object and a monitoring object when receiving a request each time, and binding a request ID, a request context and a monitoring object instance in a session context object according to a connection ID;
Pressing the requests bound by the same connection ID into a request queue through a dispatcher to generate sequential increment IDs; the above processes are all completed at the connection level, namely, at the protocol level;
After the initialization, when the received more than two requests have no data dependency relationship, SQL is executed concurrently.
More precisely described, the method comprises the following steps:
By configuring system parameters, allowing Connection with request Req may have 1: n (N. Gtoreq.1);
each time a connection is established, performing initialization of Session and Session context;
Performing ReqContext object and monitoring object initialization each time a request is received, and binding ReqId and ReqContext, listener object instances in a SessionContext object according to connID;
Pressing the same connID bound requests into a request queue through a dispatcher to generate sequential increment IDs; the above processes are all completed at the connection level, namely, at the protocol level;
After the initialization, when the received more than two requests have no data dependency relationship or context relationship, SQL is executed concurrently.
The method further comprises the step of configuring a write-back program, wherein the write-back program comprises the step of writing back according to the arrival time sequence of the requests, and the execution results are cached into a dispatcher response queue and responded one by one according to the sequence of the request queue as shown in fig. 3.
For example: and in one connection established by the user, the Select and Insert operations are performed through the concurrency means, but serial write-back is performed according to the request sequence in the response stage, namely, write-back packet.
The method for executing the corresponding SQL comprises concurrent execution and serial execution, and when the received more than two requests have data dependency relationships, the serial execution is marked in the SessionContext object.
The Listener object instances comprise a connection monitoring object instance, a Session monitoring object instance and a request monitoring object instance which are independent from each other. I.e. each phase has a separate proprietary Listener object, as shown in fig. 2, connectionContext is configured with perceived connection-dependent ConnectionContext Listener; sessionContext is configured with Session change-related SessionContext Listener; reqContext are configured with a perceived request data correlation REQ LISTENER.
Each request has a separate proprietary Listener object; specifically, the Session and Session context are initialized synchronously at each connection establishment, the private attribute and data of each connection are maintained, the initialization of ReqContext objects and Listener objects is performed at each request, specifically including the initialization of each requested proprietary Listener object, and the binding of ReqId and ReqContext, listener instances (each requested proprietary Listener object) is performed according to connId in the Session context object.
Example 2: the utility model discloses a gateway concurrency executive device based on MySQL protocol, which comprises the following structures:
a connection initializing unit for connecting the client and executing initialization of Session and Session context each time connection is established;
A request initializing unit, which is used for receiving the user request, executing ReqContext object and monitoring object initialization each time the request is received, and binding ReqId and ReqContext, listener instances according to connID in the SessionContext object;
a dispatcher unit for pushing the bound request into a request queue, generating a sequential increment ID;
And the execution unit is used for sequentially increasing the IDs to execute the corresponding SQL.
Wherein the monitoring object comprises mutually independent connection monitoring, session monitoring and request monitoring
The execution unit comprises a concurrent execution unit and a serial execution unit, wherein the serial execution unit is used for executing corresponding SQL in series according to a serial execution mark in a SessionContext object when more than two received requests have data dependency.
The device also comprises a write-back unit for executing a sequential write-back program, wherein the sequential write-back program comprises write-back according to the request arrival time sequence, and the execution results are cached in a dispatcher response queue and responded one by one according to the request queue sequence.
The invention also provides electronic equipment, which comprises a memory and a processor, wherein the memory is used for storing one or more computer instructions, and the one or more computer instructions are executed by the processor to realize a gateway concurrency execution method based on MySQL protocol.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted, or not performed.
The units may or may not be physically separate, and the components shown as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a readable storage medium.
Based on such understanding, the technical solution of the embodiments of the present invention may be essentially or partly contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product, and the present invention proposes a computer storage medium, where the software product is stored in a storage medium, and includes several instructions to cause a device (may be a single-chip microcomputer, a chip or the like) or a processor (processor) to execute a gateway concurrent execution method based on MySQL protocol. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.