CN112347141A - Data access control method, system, device and medium - Google Patents

Data access control method, system, device and medium Download PDF

Info

Publication number
CN112347141A
CN112347141A CN202011211196.0A CN202011211196A CN112347141A CN 112347141 A CN112347141 A CN 112347141A CN 202011211196 A CN202011211196 A CN 202011211196A CN 112347141 A CN112347141 A CN 112347141A
Authority
CN
China
Prior art keywords
connection
target
state
command primitive
stateful
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011211196.0A
Other languages
Chinese (zh)
Other versions
CN112347141B (en
Inventor
李昕辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Transwarp Technology Shanghai Co Ltd
Original Assignee
Transwarp Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Transwarp Technology Shanghai Co Ltd filed Critical Transwarp Technology Shanghai Co Ltd
Priority to CN202011211196.0A priority Critical patent/CN112347141B/en
Publication of CN112347141A publication Critical patent/CN112347141A/en
Application granted granted Critical
Publication of CN112347141B publication Critical patent/CN112347141B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24558Binary matching operations
    • G06F16/2456Join operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a data access control method, a system, equipment and a medium. The data access control method comprises the following steps: determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request; the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases; and if the condition of sending the command primitives is determined to be met according to the state of at least one flag bit of the current session and the type of the database request, sending the matched command primitives to each target connection manager respectively. The technical scheme of the embodiment of the invention solves the problem that the life cycle of the connection cannot be flexibly managed based on the service SQL in the prior art, and can realize the effect of saving connection resources in a high-concurrency scene.

Description

Data access control method, system, device and medium
Technical Field
Embodiments of the present invention relate to computer technologies, and in particular, to a method, a system, a device, and a medium for controlling data access.
Background
With the rapid development of information technology, data in various forms such as characters, images, videos and the like which need to be stored in a database are exponentially increased, so that the pressure of the database is easily overlarge, and a distributed database is produced.
The distributed database can decompose a service request SQL (Structured Query Language), process the SQL on a plurality of sub-databases, and summarize a final result to a client, where time and resource overhead for establishing a connection between the client and the sub-databases are large when accessing each sub-database, and therefore, existing distributed database middleware generally uses a connection pool technology to cache and multiplex existing connections. However, in actual services, different services have different database access modes and life cycles, a more complex context life cycle is generated between service requests SQL, and the existing connection pool technology cannot flexibly manage the connection life cycle.
Disclosure of Invention
Embodiments of the present invention provide a data access control method, device, and medium, which manage a lifecycle of a stateful connection through a connection manager, and can achieve an effect of saving connection resources in a high-concurrency scenario.
In a first aspect, an embodiment of the present invention provides a data access control method, where the method is applied in a session manager, and includes:
determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request;
the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases;
if the condition of sending command primitives is determined to be met according to the state of at least one flag bit of the current session and the type of the database request, sending matched command primitives to each target connection manager respectively;
the command primitive is used for indicating the connection manager to acquire the target stateful connection in the stateful connection pool to perform state adjustment, and/or using the target stateful connection to perform data access on the matched sub-database.
In a second aspect, an embodiment of the present invention provides a data access control method, where the method is applied in a connection manager, and includes:
receiving a command primitive sent by a session manager;
and acquiring target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
In a third aspect, an embodiment of the present invention provides a data access control system, where the system includes: at least two sub-databases, a connection manager respectively corresponding to each sub-database, and at least one session manager; each sub-database is in communication connection with the corresponding connection manager, and each session manager is in communication connection with each connection manager; the connection manager comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases;
the session manager is used for determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request, and if the condition of sending the command primitive is determined to be met according to at least one flag bit state of the current session and the type of the database request, the session manager respectively sends the matched command primitive to each target connection manager;
the connection manager is used for receiving the command primitive sent by the session manager, obtaining the target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
In a fourth aspect, an embodiment of the present invention further provides a computer device, including a processor and a memory, where the memory is used to store instructions that, when executed, cause the processor to:
determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request;
the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases;
if the condition of sending command primitives is determined to be met according to the state of at least one flag bit of the current session and the type of the database request, sending matched command primitives to each target connection manager respectively;
the command primitive is used for indicating the connection manager to acquire the target stateful connection in the stateful connection pool to perform state adjustment, and/or using the target stateful connection to perform data access on the matched sub-database.
Or for performing:
receiving a command primitive sent by a session manager;
and acquiring target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
In a fifth aspect, an embodiment of the present invention further provides a storage medium, where the storage medium is configured to store instructions for performing:
determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request;
the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases;
if the condition of sending command primitives is determined to be met according to the state of at least one flag bit of the current session and the type of the database request, sending matched command primitives to each target connection manager respectively;
the command primitive is used for indicating the connection manager to acquire the target stateful connection in the stateful connection pool to perform state adjustment, and/or using the target stateful connection to perform data access on the matched sub-database.
Or for performing:
receiving a command primitive sent by a session manager;
and acquiring target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
According to the technical scheme of the embodiment of the invention, a session manager determines at least one command primitive and a target connection manager matched with the command primitive according to an analysis result of a database request and the type of the database request, wherein the connection manager is associated with a sub-database, the connection manager comprises a state connection pool, state connection in the state connection pool is connection pointing to the sub-database, and if the condition that the sending condition of the command primitive is met is determined according to at least one flag bit state of the current session and the type of the database request, the matched command primitives are respectively sent to each target connection manager, so that the problem that the life cycle of connection cannot be flexibly managed based on SQL service in the prior art is solved, and the effect of saving connection resources can be realized under a high-concurrency scene.
Drawings
Fig. 1 is a flowchart of a data access control method according to a first embodiment of the present invention;
fig. 2a is a flowchart of a data access control method according to a second embodiment of the present invention;
fig. 2b is a flowchart of determining whether a command primitive is sent according to a second embodiment of the present invention;
fig. 3a is a flowchart of a data access control method in a third embodiment of the present invention;
FIG. 3b is a flowchart of the connection manager acquiring a stateful connection according to the third embodiment of the present invention;
FIG. 3c is a flowchart of a connection processing thread executing a Begin command primitive according to a third embodiment of the present invention;
FIG. 3d is a flowchart illustrating a connection processing thread executing a Reserved command primitive according to a third embodiment of the present invention;
FIG. 3e is a flowchart illustrating a connection processing thread executing an Execute command primitive according to a third embodiment of the present invention;
FIG. 3f is a flowchart of a connection processing thread executing a Conclude command primitive in the third embodiment of the present invention;
FIG. 3g is a flowchart illustrating a connection processing thread executing a Release command primitive according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a data access control system in a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of a data access control apparatus in a fifth embodiment of the present invention;
fig. 6 is a schematic structural diagram of a data access control apparatus in a sixth embodiment of the present invention;
fig. 7 is a schematic structural diagram of a computer device according to a seventh embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
The term "session manager" is used herein to manage the state of the client for establishing a session, and parse and split the database request sent by the client, and generate at least one command primitive, which is sent to the corresponding connection manager.
The term "connection manager" is used herein to manage the lifetime of a connection in a stateful connection pool to its corresponding child data according to command primitives sent by the session manager.
As used herein, the term "stateful connection pool" stores at least one stateful connection, each stateful connection being a connection that points to a sub-database corresponding to the current connection manager.
The term "database request" as used herein is an SQL request sent by a client to the session manager, including management SQL with stateful connections, and/or specific business SQL that accesses a database.
As used herein, the term "command primitive" is a connection manager-oriented instruction generated by the session manager according to a database request sent by a client, and is used to instruct the connection manager to obtain a target stateful connection in the stateful connection pool for performing state adjustment, and/or to perform data access on a matching sub-database using the target stateful connection.
Example one
Fig. 1 is a flowchart of a data access control method in an embodiment of the present invention, where the technical solution of this embodiment is suitable for a case where a connection manager manages a connection lifecycle of a sub-database, and the method may be executed by a data access control device, where the data access control device may be implemented by software and/or hardware, and may be integrated in various general-purpose computer devices, and specifically includes the following steps:
step 110, determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request; the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases.
When a session is established between the client and the distributed database, the session manager starts a session processing thread to process a database request sent by the current client, wherein the database request is an SQL request sent by the client to the session manager. The session manager analyzes the database request sent by the client, determines the business SQL contained in the currently sent database request, and determines the type of the currently sent database request according to the influence on the context life cycle. Of course, if a plurality of clients send database requests to the same session manager at the same time, the session manager opens a plurality of session processing threads to process the database requests sent by the plurality of clients at the same time. The business SQL refers to specific SQL of types such as query data or write data, and the types of database requests can be classified into the following 4 types:
1) TRANSACTION open SQL, usually denoted by BEGIN or START TRANSACTION;
2) transaction end SQL, e.g., COMMIT (COMMIT) or ROLLBACK (ROLLBACK);
3) the session level resource acquisition SQL comprises any SQL with the life cycle of session level, including acquiring a named lock (get _ lock), creating a temporary table and the like;
4) other SQL.
In this embodiment, after receiving a database request sent by a client, a session manager firstly analyzes and classifies the database request, specifically, the session manager opens a session processing thread for a session established by the current client, analyzes the received database request, determines a service SQL included in the current database request, and determines which of the above 4 types the type of the current database request is according to the influence of the database request on a subsequent context life cycle.
After the analysis result of the database request and the type of the database request are obtained, a command primitive sent to the connection manager is determined according to the analysis result of the database request and the type of the database request, specifically, a command primitive interface can be determined according to the type of the database request, service SQL contained in the analysis result of the database request is used as a parameter of the command primitive, and finally the command primitive is composed of the command primitive interface and the parameter of the command primitive, wherein the connection processor can externally provide the command primitive interface contained in the table 1 for the call of the session manager.
TABLE 1
Interface name Parameter list List of returned values
Begin connID (optional) connID,error
Reserve connID (optional) connID,error
Execute connID (optional), sql (must) resultSet,error
Conclude connID (must), sql (must) connID,error
Release connID (must) error
And after the command primitive is determined, determining a connection manager corresponding to the target sub-database as a target connection manager according to the target sub-database contained in the analysis result. Specifically, the analysis result of the database request includes that the service SQL is "Select × from T1 where age is 10", that is, the current service SQL needs to perform data query from the table T1, which sub-database the table T1 is stored in may be looked up from the metadata database connected to the session manager, and the sub-database is used as the target sub-database, and the connection manager corresponding to the target sub-database is used as the target connection manager.
The connection manager comprises a status connection pool, at least one status connection is stored in the status connection pool, and each status connection refers to the connection of the subdata corresponding to the current connection manager.
Step 120, if it is determined that the command primitive sending condition is satisfied according to at least one flag bit state of the current session and the type of the database request, sending the matched command primitive to each target connection manager respectively;
the command primitive is used for indicating the connection manager to acquire the target stateful connection in the stateful connection pool to perform state adjustment, and/or using the target stateful connection to perform data access on the matched sub-database.
In this embodiment, after determining the command primitive and the target connection manager, it is determined whether a command primitive sending condition is satisfied according to at least one flag bit state of the current session and a type of the database request, and the command primitive is sent to the target connection manager when the command primitive sending condition is satisfied.
Specifically, an execution plan is generated according to the analysis result of the database request, the execution plan specifically includes a corresponding relation between a command primitive and a sub-database, then a plurality of threads are started according to the execution plan by taking the sub-database as a unit, each thread determines whether a sending condition of the command primitive is met or not according to the state of at least one flag bit of the current session and the type of the data request, and if the sending condition of the command primitive is met, the command primitive is sent to a corresponding connection manager.
Illustratively, when the database request sent by the client is of type 3 described in step 110, that is, the session-level resource acquisition SQL, first determines, according to the target sub-database corresponding to the current thread, a reserved flag bit state for the stateful connection of the current session in at least one stateful connection pointing to the target sub-database, if the reserved flag bit state is false and the reserved flag bit state of the current session is true, the session manager calls a Reserve command primitive, so that the connection manager updates the flag bit state of the target stateful connection according to the Reserve command primitive, that is, updates the reserved flag bit state of the target stateful connection to true, and meanwhile, the session manager receives an identifier of the target stateful connection fed back by the connection manager and stores the identifier of the target stateful connection and the updated state of the target stateful connection.
According to the technical scheme of the embodiment of the invention, a session manager determines at least one command primitive and a target connection manager matched with the command primitive according to an analysis result of a database request and the type of the database request, wherein the connection manager is associated with a sub-database, the connection manager comprises a state connection pool, state connection in the state connection pool is connection pointing to the sub-database, and if the condition that the sending condition of the command primitive is met is determined according to at least one flag bit state of the current session and the type of the database request, the matched command primitives are respectively sent to each target connection manager, so that the problem that the life cycle of connection cannot be flexibly managed based on SQL service in the prior art is solved, and the effect of saving connection resources can be realized under a high-concurrency scene.
Example two
Fig. 2a is a flowchart of a data access control method in a second embodiment of the present invention, which is further refined on the basis of the above embodiments and provides specific steps of determining at least one command primitive and a target connection manager matched with the command primitive according to a parsing result of a database request and a type of the database request, and determining that a command primitive sending condition is satisfied according to a flag bit state of a current session and the type of the database request. A data access control method provided by a second embodiment of the present invention is described below with reference to fig. 2a, including the following steps:
step 210, when the type of the database request of the client meets the session state updating condition, updating at least one flag bit state of the current session according to the type of the database request.
When the client establishes a session with the distributed database, the session manager will open a session processing thread and process the database request of the session. In each session processing thread, a core data structure describing one session is described by taking the C + + language as an example as follows:
typedef struct Session{
a borolntransaction; // whether the session is currently in a multi-row transaction
A boul in reserved; whether the session has SQL to obtain the session-level resource
vector < sessionsharp > shares; // list of connection description information to involved sub-databases
}Session;
Wherein, the flag bits of the session include an untraction flag bit for identifying whether the current session is in a multi-row transaction, and an inReserved flag bit for identifying whether the current session has acquired a session-level resource, and in addition, the data structure further includes a connection description information list of sub-data related to the current session, that is, the sessionsharp list, which includes at least one connection pointing to at least one sub-database related to the current session, and specifically, the data structure of the sessionsharp is as follows:
typedef struct SessionShard{
Target*target;
conn_id_t connID;
bool inTransaction;
bool inReserved;
}SessionShard;
wherein, target represents the target sub-database corresponding to the current sessionsharp, connID represents the identifier of the target sub-database for the target stateful connection of the current session, untraction flag bit is used for representing whether the target stateful connection is in the transaction, and inReserved flag bit is used for representing whether the target stateful connection is in the reserved state.
In this embodiment, after the database request sent by the client is analyzed and the type of the database request is determined, it is determined whether the type of the current database request meets the session state update condition, and if so, at least one flag bit state of the current session is updated according to the type of the database request. That is, it is determined whether the currently received database request needs to change the flag state of the current session according to the type of the database request. Illustratively, when the type of the database request belongs to the transaction open SQL, it is determined that a session state update condition is satisfied, at this time, an untraction flag bit in the session state needs to be set to true, and when the type of the database request belongs to the session level resource acquisition SQL, it is determined that the session state update condition is satisfied, at this time, an inReserved flag bit in the session state needs to be set to true.
Step 220, if the identification of the target stateful connection is stored currently, determining a command primitive interface according to the type of the database request, taking the analysis result of the database request and the identification of the target stateful connection as parameters of a command primitive, forming the command primitive by the command primitive interface and the parameters of the command primitive together, and finally determining a target connection manager matched with the command primitive according to the analysis result.
In this embodiment, if the session processing thread opened by session management stores an identifier of a target stateful connection, a command primitive interface is determined according to the type of the database request, then an analysis result of the database request and the identifier of the target stateful connection are used as parameters of the command primitive, and finally the command primitive is composed of the command primitive interface and the parameters of the command primitive. And in addition, when the current session processing thread stores an identifier pointing to the target sub-database with state connection, the identifier of the target with state connection is used as the parameter of the command primitive and is sent to the connection manager together to indicate the connection manager to acquire the target with state connection and update the flag bit state of the target with state connection. The identifier of the target stateful connection stored in the session processing thread is fed back by the connection manager when a Begin or Reserve command primitive is sent to the connection manager. Further, the session processing thread determines at least one target sub-database related to the current database request according to the data description information stored in the metadata database, so that a connection manager corresponding to the at least one target sub-database is used as a target connection manager. Where the metadata database stores data description information for each sub-database, e.g., the current database request requires the lookup table T1, the session manager may look up the table T1 from the source data in which sub-databases to store.
Illustratively, a command primitive interface may be determined according to a correspondence between a type of the database request and the command primitive interface, and specifically, when the type of the database request is the transaction open SQL, the command primitive interface is determined to be Begin; when the type of the database request is that the session level resources acquire SQL, determining that a command primitive interface is Reserve; when the type of the database request is specific service SQL, determining a command primitive interface as Execute; when the type of the database request is the transaction end SQL, determining that a command primitive interface is Conclude; when the client closes the session, the command primitive interface is determined to be Release.
Step 230, if the identifier of the target with the status connection is not stored currently, determining a command primitive interface according to the type of the database request, taking the analysis result of the database request as the parameter of the command primitive, forming the command primitive by the command primitive interface and the parameter of the command primitive, and finally determining the target connection manager matched with the command primitive according to the analysis result.
In this embodiment, if the session processing thread does not currently store the identifier of the stateful connection of the target, the command primitive interface is first determined according to the type of the database request, which is the same as that in step 220 and is not described herein again, then the analysis result of the database request is used as the command primitive parameter, and the command primitive is formed by the command primitive interface and the command primitive parameter. Further, the session processing thread determines at least one target sub-database related to the current database request according to the data description information stored in the metadata database, so that a connection manager corresponding to the at least one target sub-database is used as a target connection manager.
Step 240, acquiring at least one flag bit state of the currently stored target with state connection; the target stateful connection is a stateful connection of the current session to the target sub-database.
In this embodiment, after determining the command primitive directed to the target connection manager in the database request, the session processing thread further obtains at least one flag bit state of the target stateful connection stored in the session processing thread, to determine whether to send the command primitive to the target connection manager according to the flag bit state, where the target stateful connection is a stateful connection directed to the current session in at least one stateful connection directed to the target sub-database managed by the target connection manager. Illustratively, the target connection manager includes 10 stateful connections facing the target sub-database, and the stateful connection corresponding to the current session in the 10 connections is taken as the target stateful connection.
Step 250, determining whether the command primitive sending condition is satisfied according to the incidence relation between the flag bit states of the current session and the flag bit states of the target stateful connection and the type of the database request.
In this embodiment, the current session processing thread respectively starts a thread by taking each sub-database related to the current session as a unit, each thread judges whether a sending condition of a command primitive is satisfied according to an association relationship between a flag bit state of the current session and each flag bit state of a target stateful connection and a type of a database request, a specific judgment process is shown in fig. 2b, first, whether an inReserve flag bit of the current session is true and an inReserve flag bit of the target stateful connection is false is judged, if yes, the sending condition of the command primitive of the interface being Reserve is determined to be satisfied, then, whether an inTransaction flag bit of the current session is true and an inTransaction flag bit of the target stateful connection is false is judged, if yes, the sending condition of the command primitive of the interface being Begin is determined to be satisfied, further, whether the type of the current database request is a transaction end SQL is judged, if so, determining that the command primitive sending condition with the interface being the Conclude is met, finally judging whether the type of the current database request is the session level resource acquisition SQL or other SQL, and if so, determining that the command primitive sending condition with the interface being the Execute is met.
And step 260, when the command primitive sending condition is met, sending the matched command primitive to each target connection manager respectively.
In this embodiment, according to the judgment process in step 250, when the command primitive sending condition is satisfied, the command primitive is sent to the target connection manager. Illustratively, when a command primitive sending condition with an interface of Reserve is met, sending the command primitive with the interface of Reserve to the target connection manager; when the command primitive sending condition with the interface being Begin is met, sending the command primitive with the interface being Begin to the target connection manager; when a command primitive sending condition with the interface being the Conclude is met, sending the command primitive with the interface being the Conclude to the target connection manager, wherein the command primitive comprises a parameter in a form of SQL (for example, COMMIT or ROLLBACK) for ending the transaction; and when a command primitive sending condition that the interface is Execute is met, sending the command primitive of which the interface is Execute to the target connection manager, wherein the command primitive comprises specific service SQL, for example, Select from T1.
Step 270, after the target connection manager performs status adjustment on the target stateful connection according to the command primitive, the flag bit status of the currently stored target stateful connection is updated.
In this embodiment, when the session processing thread sends a command primitive to the target connection manager, and the target connection manager performs state adjustment on the target stateful connection according to the command primitive, the flag bit state of the target stateful connection stored in the current connection processing thread is updated. Illustratively, the target connection manager updates the inReserved flag bit of the target stateful connection to true according to the command primitive, and the session processing thread updates the state of the inReserved flag bit of the target stateful connection stored currently to true, so that the state of the target stateful connection flag bit stored in the thread under session processing is consistent with the true state of the flag bit.
Optionally, when the client initiates a session closing operation, the session manager receives a session closing instruction sent by the client, traverses each target stateful connection corresponding to each target sub-database related to the current session, and obtains at least one flag bit state of each target stateful connection;
sending a command primitive for ending the transaction to a connection manager corresponding to the target stateful connection with the true state of the open transaction flag bit;
and sending a command primitive for releasing the connection to the connection manager corresponding to the target stateful connection with the state of the reserved connection flag bit being true.
In this optional embodiment, when the client initiates a session closing operation, the session manager sends a command primitive to the connection manager to perform a connection Release operation, specifically, the session manager receives a session closing instruction sent by the client, traverses each target stateful connection corresponding to each target sub-database related to the current session, obtains at least one flag bit state of each target stateful connection, then sends a command primitive for ending a transaction, that is, a command primitive whose interface is concude, to the connection manager corresponding to the target stateful connection whose state is true by starting a transaction flag bit (inTransaction flag bit), and simultaneously sends a command primitive for releasing the connection, that is, a command primitive whose interface is Release, to the connection manager corresponding to the target stateful connection whose state is true by reserving a connection flag bit (inReserved flag bit).
According to the technical scheme of the embodiment of the invention, a session manager determines at least one command primitive and a target connection manager matched with the command primitive according to an analysis result of a database request and the type of the database request, wherein the connection manager is associated with a sub-database, the connection manager comprises a state connection pool, state connection in the state connection pool is connection pointing to the sub-database, and if the condition that the sending condition of the command primitive is met is determined according to at least one flag bit state of the current session and the type of the database request, the matched command primitives are respectively sent to each target connection manager, so that the problem that the life cycle of connection cannot be flexibly managed based on SQL service in the prior art is solved, and the effect of saving connection resources can be realized under a high-concurrency scene.
EXAMPLE III
Fig. 3a is a flowchart of a data access control method in a third embodiment of the present invention, where the technical solution of this embodiment is suitable for a case where a connection manager manages a connection lifecycle of a sub-database, and the method can be executed by a data access control device, and the device can be implemented by software and/or hardware and can be integrated in various general-purpose computer devices, and the following describes, with reference to fig. 3a, a data access control method provided in the third embodiment of the present invention, and includes the following steps:
step 310, receiving a command primitive sent by the session manager.
The connection manager comprises a state connection pool for managing the state connection according to the command primitive sent by the session manager, wherein the state connection pool comprises at least one state connection pointing to the subdata corresponding to the current connection manager, and the data structure of the stored content in the state connection pool is as follows;
typedef struct StatefulPool{
map<conn_id_t,StatefulConn*>ConnMap;
vector<conn_id_t>idleList;
}StatefulPool;
wherein ConnMap refers to a stateful connection mapping list, which stores all stateful connections in the lifecycle, and stores the relationship between the stateful connection identifier and the specific stateful connection object; idleList refers to a free connection list in which the identities of all stateful connections in the free state are maintained. The data structure of the stateful connection object is as follows:
typedef struct StatefulConn{
conn_id_t connID;
DBConn*dbConn;
bool inTransaction;
bool inReserved;
}StatefulConn;
wherein connID refers to the identifier of the current stateful connection, dbConn refers to the sub-database corresponding to the current stateful connection, an untraction flag bit used for indicating whether the current stateful connection opens a transaction, and an inReserved flag bit used for indicating whether the current stateful connection needs to be preserved.
In this embodiment, the connection manager receives the command primitive sent by the session manager, so as to execute a corresponding database access operation according to the command primitive, and perform management of the lifecycle of the stateful connection, that is, perform status update of the stateful connection according to the status of the flag bit of the current session.
And step 320, acquiring the target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
In this embodiment, after receiving the command primitive sent by the session manager, the connection manager first obtains the target stateful connection from the stateful connection pool, and then performs state adjustment on the target stateful connection according to the command primitive, and/or performs data access on the matched sub-database by using the target stateful connection.
Specifically, in order to implement the execution flow of the command primitive, the connection manager first calls a sub function for obtaining a target stateful connection, and obtains the target stateful connection from the stateful connection pool, where the specific obtaining manner is shown in fig. 3b, the connection manager first determines whether the command primitive sent by the session manager includes a stateful connection identifier, and when the command primitive includes a stateful connection identifier, directly obtains a stateful connection object from a stateful connection mapping table (a data structure of the stateful connection object includes the stateful connection identifier, a sub database corresponding to the stateful connection, and at least one flag bit state of the stateful connection, as described in step 310), and then returns the stateful connection object to the session manager; when the command primitive does not contain the identifier of the state connection, the connection manager can judge whether the idle connection list contains at least one stateful connection identifier, if so, randomly select a stateful connection identifier from the idle connection list, acquire a stateful connection object from the stateful connection mapping list according to the stateful connection identifier, delete the stateful connection identifier from the idle connection list, if not, create a new database connection, wrap the new stateful connection object, use the connection number returned by the database as the identifier of the new stateful connection, finally place the new stateful connection object in the stateful connection list, and return the stateful connection object to the session manager.
After the connection object with the state is obtained, each connection processing thread started by the connection manager can respectively carry out state adjustment on the target connection with the state according to the command primitive sent by the session management thread, and/or carry out data access on the matched sub-database by using the target connection with the state.
When the connection processing line executes the command primitive with the command primitive interface being Begin, the execution flow is as shown in fig. 3c, first, a subfunction for acquiring the target stateful connection is called, the target stateful connection is acquired, then, the START transfer command is executed through the database connection in the target stateful connection, and the TRANSACTION flag bit of the target stateful connection is marked as true.
When the connection processing thread executes the command primitive with the command primitive interface being Reserved, the execution flow is as shown in fig. 3d, firstly, a subfunction for acquiring the target stateful connection is called, the target stateful connection is acquired, and then, an inReserved flag bit of the target stateful connection is marked as true.
When the connection processing thread executes the command primitive with the command primitive interface being Execute, the execution flow is as shown in fig. 3e, first, a subfunction for acquiring the target stateful connection is called, the target stateful connection is acquired, and then, the specific service SQL contained in the command primitive is executed through the database connection in the target stateful connection.
When the connection processing thread executes the command primitive with the command primitive interface being the command primitive of the concclude, the execution flow is as shown in fig. 3f, firstly, a subfunction for acquiring the target stateful connection is called, the target stateful connection is acquired, then, the specific service SQL contained in the command primitive is executed through the database connection in the target stateful connection, further, the transaction flag bit of the target stateful connection is marked as false, whether the inReserved flag bit is true or not is judged, if yes, the identifier of the target stateful connection is put into an idle connection list, and if not, the execution flow is ended.
When the connection processing thread executes the command primitive with the command primitive interface being Release, the execution flow is as shown in fig. 3g, first, a subfunction for acquiring the target stateful connection is called, the target stateful connection is acquired, then, the database connection in the target stateful connection is disconnected, and further, the target stateful connection is deleted from the stateful connection mapping list.
According to the technical scheme of the embodiment of the invention, the connection manager firstly receives the command primitive sent by the session manager, then obtains the target stateful connection in the stateful connection pool according to the command primitive, and performs state adjustment on the target stateful connection, and/or performs data access on the matched sub-database by using the target stateful connection, so that the problem that the life cycle of the connection cannot be flexibly managed based on the service SQL in the prior art is solved, and the effect of saving connection resources can be realized in a high-concurrency scene.
Example four
Fig. 4 is a schematic structural diagram of a data access control system in a fourth embodiment of the present invention, and a data access control system provided in the fourth embodiment of the present invention is described below with reference to fig. 4:
the data access control system comprises at least two sub-databases 1, connection managers 2 respectively corresponding to the sub-databases 1, and at least one session manager 3; each sub-database 1 is connected with the corresponding connection manager 2 in a communication way, and each session manager 3 is connected with each connection manager 2 in a communication way; the connection manager 2 comprises a status connection pool 21, and the status connection in the status connection pool 21 is a connection pointing to the sub-database;
in this embodiment, the data access control system includes at least two sub-databases 1, each sub-database 1 is configured with a corresponding connection manager 2 and at least one session manager 3, where the connection manager 2 is configured to manage a lifecycle of a stateful connection directed to the sub-database 1 corresponding to the connection manager, specifically, the connection manager includes a stateful connection pool 21, and the stateful connection pool 21 stores a stateful connection directed to the sub-database corresponding to the current connection manager; the session manager 3 may be deployed in multiple different machines, the client terminal may be connected to any one session manager 3 through a database connection protocol, that is, a session is established, the client terminal may send a database request to the session manager 3, the session manager 3 is configured to manage a state of session establishment by the client terminal, split the database request sent by the user in units of sub-databases, generate command primitives according to the split sub-requests, and send the command primitives to at least one connection manager 2, so as to instruct the connection manager 2 to obtain a target stateful connection in a stateful connection pool according to the command primitives for performing state adjustment, and/or perform data access to a matched sub-database 1 by using the target stateful connection.
The session manager 3 is configured to determine at least one command primitive according to an analysis result of a database request and a type of the database request, and a target connection manager 2 matched with the command primitive, and if it is determined that a command primitive sending condition is satisfied according to at least one flag bit state of a current session and the type of the database request, send the matched command primitive to each target connection manager 2 respectively.
In this embodiment, the session manager 3 is specifically configured to parse a database request sent by a client, determine at least one command primitive according to a parsing result of the database request and a type of the database request, and determine at least one sub-database 1 related to a current database request according to the parsing result and data description information stored in a metadata database, so as to determine that a connection manager 2 corresponding to the sub-database 1 matched with the current command primitive is a target connection manager. The data description information stored in the metadata database includes storage distribution information of data in each sub-database 1, for example, if the table T1 has partitions in the sub-database a and the sub-database B, when the database request is analyzed and the table T1 needs to be queried, it may be determined that the sub-database related to the current database request includes the sub-database a and the sub-database B according to the data description information stored in the metadata database.
Further, the session manager 3 determines whether the currently generated command primitive satisfies the sending condition according to at least one flag bit state of the current session and the type of the database request, and if so, sends the matched command primitive to each target connection manager 2 respectively.
The connection manager 2 is configured to receive a command primitive sent by the session manager 3, obtain a target stateful connection in the stateful connection pool 21 according to the command primitive, perform state adjustment on the target stateful connection, and/or perform data access on the matched sub-database 1 by using the target stateful connection.
In this embodiment, the connection manager 2 is specifically configured to run at least one connection processing thread according to a command primitive sent by at least one session processing thread running in the session manager 3, obtain a target stateful connection matched with the current session in the stateful connection pool 21 according to the command primitive, perform state adjustment on the target stateful connection, and/or perform data access on the matched sub-database 1 by using the target stateful connection.
According to the technical scheme of the embodiment of the invention, a session manager determines at least one command primitive and a target connection manager matched with the command primitive according to an analysis result of a database request and the type of the database request, wherein the connection manager is associated with a sub-database, the connection manager comprises a state connection pool, state connection in the state connection pool is connection pointing to the sub-database, and if the condition that the sending condition of the command primitive is met is determined according to at least one flag bit state of the current session and the type of the database request, the matched command primitives are respectively sent to each target connection manager, so that the problem that the life cycle of connection cannot be flexibly managed based on SQL service in the prior art is solved, and the effect of saving connection resources can be realized under a high-concurrency scene.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a data access control device according to a fifth embodiment of the present invention, where the data access control device includes: a command primitive determining module 510 and a command primitive sending module 520.
A command primitive determining module 510, configured to determine at least one command primitive and a target connection manager matching the command primitive according to a parsing result of the database request and a type of the database request;
the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases;
a command primitive sending module 520, configured to send a matched command primitive to each target connection manager if it is determined that a command primitive sending condition is met according to at least one flag bit state of a current session and a type of a database request;
the command primitive is used for indicating the connection manager to acquire the target stateful connection in the stateful connection pool to perform state adjustment, and/or using the target stateful connection to perform data access on the matched sub-database.
According to the technical scheme of the embodiment of the invention, a session manager determines at least one command primitive and a target connection manager matched with the command primitive according to an analysis result of a database request and the type of the database request, wherein the connection manager is associated with a sub-database, the connection manager comprises a state connection pool, state connection in the state connection pool is connection pointing to the sub-database, and if the condition that the sending condition of the command primitive is met is determined according to at least one flag bit state of the current session and the type of the database request, the matched command primitives are respectively sent to each target connection manager, so that the problem that the life cycle of connection cannot be flexibly managed based on SQL service in the prior art is solved, and the effect of saving connection resources can be realized under a high-concurrency scene.
Optionally, the data access control apparatus further includes:
and the session flag bit updating module is used for updating at least one flag bit state of the current session according to the type of the database request when the type of the database request of the client meets a session state updating condition before determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request.
Optionally, the command primitive sending module 520 includes:
the connection zone bit acquisition unit is used for acquiring at least one zone bit state of the currently stored target with state connection; the target stateful connection is stateful connection of the current session aiming at the target sub-database;
and the sending condition judging unit is used for determining whether command primitive sending conditions are met according to the incidence relation between the flag bit states of the current session and the flag bit states of the target stateful connection and the type of the database request.
Optionally, the command primitive determining module 510 includes:
the system comprises a first command primitive constructing unit, a second command primitive constructing unit and a third command primitive constructing unit, wherein the first command primitive constructing unit is used for determining a command primitive interface according to the type of a database request if the identifier of the target stateful connection is stored currently, taking the analysis result of the database request and the identifier of the target stateful connection as the parameters of a command primitive, forming the command primitive by the command primitive interface and the parameters of the command primitive together, and finally determining a target connection manager matched with the command primitive according to the analysis result;
and the second command primitive constructing unit is used for determining a command primitive interface according to the type of the database request if the identifier of the target with the state connection is not stored at present, taking the analysis result of the database request as the parameter of the command primitive, forming the command primitive by the command primitive interface and the parameter of the command primitive, and finally determining the target connection manager matched with the command primitive according to the analysis result.
Optionally, the data access control apparatus further includes:
and the connection zone bit updating module is used for updating the zone bit state of the current storage target stateful connection after the target connection manager performs state adjustment on the target stateful connection according to the command primitive.
Optionally, the data access control apparatus further includes:
the connection zone bit obtaining module is used for receiving a session closing instruction sent by a client, traversing the state connection of each target corresponding to each target sub-database related to the current session, and obtaining at least one zone bit state of the state connection of each target;
an ending primitive sending module, configured to send a command primitive for ending the transaction to a connection manager corresponding to the target stateful connection whose open transaction flag bit state is true;
and the release primitive sending module is used for sending a command primitive for releasing the connection to the connection manager corresponding to the target stateful connection with the true reserved connection flag bit state.
The data access control device provided by the embodiment of the invention can execute the data access control method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE six
Fig. 6 is a schematic structural diagram of a data access control device according to a sixth embodiment of the present invention, where the data access control device includes: a command primitive receiving module 610 and a command primitive executing module 620.
A command primitive receiving module 610, configured to receive a command primitive sent by the session manager;
and a command primitive executing module 620, configured to obtain a target stateful connection in the stateful connection pool according to the command primitive, perform state adjustment on the target stateful connection, and/or perform data access on the matched sub-database by using the target stateful connection.
According to the technical scheme of the embodiment of the invention, the connection manager firstly receives the command primitive sent by the session manager, then obtains the target stateful connection in the stateful connection pool according to the command primitive, and performs state adjustment on the target stateful connection, and/or performs data access on the matched sub-database by using the target stateful connection, so that the problem that the life cycle of the connection cannot be flexibly managed based on the service SQL in the prior art is solved, and the effect of saving connection resources can be realized in a high-concurrency scene.
Optionally, the command primitive executing module 620 includes:
a connection obtaining unit, configured to, when the command primitive includes an identifier of a target stateful connection, obtain the target stateful connection in the stateful connection pool according to the target stateful connection identifier;
the list query unit is used for querying an idle connection list when the command primitive does not contain the identifier of the target with the state connection;
a connection selection unit, configured to randomly select a stateful connection identifier when at least one stateful connection identifier exists in the idle connection list, and obtain a stateful connection in a stateful connection pool according to the stateful connection identifier, where the stateful connection is used as a target stateful connection;
and the connection establishing unit is used for establishing new stateful connection as target stateful connection when the stateful connection identifier does not exist in the idle connection list.
The data access control device provided by the embodiment of the invention can execute the data access control method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE seven
Fig. 7 is a schematic structural diagram of a computer apparatus according to a seventh embodiment of the present invention, as shown in fig. 7, the apparatus includes a processor 70, a memory 71, an input device 72, and an output device 73; the number of processors 70 in the device may be one or more, and one processor 70 is taken as an example in fig. 7; the processor 70, the memory 71, the input device 72 and the output device 73 of the apparatus may be connected by a bus or other means, as exemplified by the bus connection in fig. 7.
The memory 71 serves as a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the data access control method in the embodiment of the present invention (for example, the command primitive determining module 510 and the command primitive transmitting module 520, or the command primitive receiving module 610 and the command primitive executing module 620, in the data access control apparatus). The processor 70 executes various functional applications of the device and data processing, i.e., implements the above-described task method, by executing software programs, instructions, and modules stored in the memory 71.
The memory 71 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 71 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 71 may further include memory located remotely from the processor 70, which may be connected to the device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The processor 70 executes various functional applications and data processing by executing instructions stored in the memory 71, for example, to: determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request; the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases; if the condition of sending command primitives is determined to be met according to the state of at least one flag bit of the current session and the type of the database request, sending matched command primitives to each target connection manager respectively; the command primitive is used for indicating the connection manager to acquire the target stateful connection in the stateful connection pool to perform state adjustment, and/or using the target stateful connection to perform data access on the matched sub-database.
On the basis of the above embodiments, the processor 70 is configured to update the flag state of the current session by: and when the type of the database request of the client meets the session state updating condition, updating at least one flag bit state of the current session according to the type of the database request.
On the basis of the above embodiments, the processor 70 is configured to determine that the command primitive sending condition is satisfied by: acquiring at least one flag bit state of the currently stored target with state connection; the target stateful connection is stateful connection of the current session aiming at the target sub-database; and determining whether command primitive sending conditions are met or not according to the incidence relation between the flag bit states of the current session and the flag bit states of the target stateful connection and the type of the database request.
On the basis of the above embodiments, the processor 70 is configured to determine the command primitive by: if the target connection-with-state identifier is stored currently, determining a command primitive interface according to the type of the database request, taking the analysis result of the database request and the target connection-with-state identifier as the parameters of a command primitive, forming the command primitive by the command primitive interface and the parameters of the command primitive, and finally determining a target connection manager matched with the command primitive according to the analysis result; if the identification of the target with the state connection is not stored at present, determining a command primitive interface according to the type of the database request, taking the analysis result of the database request as the parameter of the command primitive, forming the command primitive by the command primitive interface and the parameter of the command primitive together, and finally determining a target connection manager matched with the command primitive according to the analysis result.
On the basis of the above embodiments, the processor 70 is configured to update the flag bit state of the current storage target with a status connection by: and after the target connection manager carries out state adjustment on the target stateful connection according to the command primitive, updating the flag bit state of the current storage target stateful connection.
On the basis of the above embodiments, the processor 70 is configured to reset the connection flag bit state by: receiving a session closing instruction sent by a client, traversing state connection of each target corresponding to each target sub database related to the current session, and acquiring at least one flag bit state of the state connection of each target; sending a command primitive for ending the transaction to a connection manager corresponding to the target stateful connection with the true state of the open transaction flag bit; and sending a command primitive for releasing the connection to the connection manager corresponding to the target stateful connection with the state of the reserved connection flag bit being true.
The processor 70 executes various functional applications and data processing by executing instructions stored in the memory 71, and for example, may also perform the following operations: receiving a command primitive sent by a session manager; and acquiring target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
On the basis of the above embodiments, the processor 70 is configured to obtain the target stateful connection by: when the command primitive comprises an identifier of target stateful connection, acquiring the target stateful connection in the stateful connection pool according to the target stateful connection identifier; when the command primitive does not contain the identifier of the object with the state connection, inquiring an idle connection list; when at least one stateful connection identifier exists in the idle connection list, randomly selecting one stateful connection identifier, and acquiring a stateful connection in a stateful connection pool according to the stateful connection identifier to be used as a target stateful connection; and when the idle connection list does not have the status connection identifier, creating a new status connection as a target status connection.
Example eight
An eighth embodiment of the present invention further provides a computer storage medium storing a computer program, which is used to execute the data access control method according to any one of the above-described embodiments of the present invention when executed by a computer processor.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM) or flash Memory), an optical fiber, a portable compact disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, Radio Frequency (RF), etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (18)

1. A data access control method applied to a session manager is characterized by comprising the following steps:
determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request;
the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases;
if the condition of sending command primitives is determined to be met according to the state of at least one flag bit of the current session and the type of the database request, sending matched command primitives to each target connection manager respectively;
the command primitive is used for indicating the connection manager to acquire the target stateful connection in the stateful connection pool to perform state adjustment, and/or using the target stateful connection to perform data access on the matched sub-database.
2. The method of claim 1, further comprising, before determining at least one command primitive and a target connection manager matching the command primitive according to a result of the parsing of the database request and a type of the database request:
and when the type of the database request of the client meets the session state updating condition, updating at least one flag bit state of the current session according to the type of the database request.
3. The method of claim 1, wherein determining that the command primitive sending condition is satisfied according to the flag bit state of the current session and the type of the database request comprises:
acquiring at least one flag bit state of the currently stored target with state connection; the target stateful connection is stateful connection of the current session aiming at the target sub-database;
and determining whether command primitive sending conditions are met or not according to the incidence relation between the flag bit states of the current session and the flag bit states of the target stateful connection and the type of the database request.
4. The method of claim 1, wherein determining at least one command primitive according to the resolution result of the database request and the type of the database request, and a target connection manager matching the command primitive comprises:
if the target connection-with-state identifier is stored currently, determining a command primitive interface according to the type of the database request, taking the analysis result of the database request and the target connection-with-state identifier as the parameters of a command primitive, forming the command primitive by the command primitive interface and the parameters of the command primitive, and finally determining a target connection manager matched with the command primitive according to the analysis result;
if the identification of the target with the state connection is not stored at present, determining a command primitive interface according to the type of the database request, taking the analysis result of the database request as the parameter of the command primitive, forming the command primitive by the command primitive interface and the parameter of the command primitive together, and finally determining a target connection manager matched with the command primitive according to the analysis result.
5. The method as claimed in claim 1, further comprising, after sending the matched command primitive to each of the target connection managers respectively:
and after the target connection manager carries out state adjustment on the target stateful connection according to the command primitive, updating the flag bit state of the current storage target stateful connection.
6. The method of claim 1, further comprising:
receiving a session closing instruction sent by a client, traversing state connection of each target corresponding to each target sub database related to the current session, and acquiring at least one flag bit state of the state connection of each target;
sending a command primitive for ending the transaction to a connection manager corresponding to the target stateful connection with the true state of the open transaction flag bit;
and sending a command primitive for releasing the connection to the connection manager corresponding to the target stateful connection with the state of the reserved connection flag bit being true.
7. A data access control method applied to a connection manager is characterized by comprising the following steps:
receiving a command primitive sent by a session manager;
and acquiring target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
8. The method of claim 7, wherein obtaining the target stateful connection in a stateful connection pool based on the command primitive comprises:
when the command primitive comprises an identifier of target stateful connection, acquiring the target stateful connection in the stateful connection pool according to the target stateful connection identifier;
when the command primitive does not contain the identifier of the object with the state connection, inquiring an idle connection list;
when at least one stateful connection identifier exists in the idle connection list, randomly selecting one stateful connection identifier, and acquiring a stateful connection in a stateful connection pool according to the stateful connection identifier to be used as a target stateful connection;
and when the idle connection list does not have the status connection identifier, creating a new status connection as a target status connection.
9. A data access control system is characterized by comprising at least two sub-databases, connection managers respectively corresponding to the sub-databases and at least one session manager; each sub-database is in communication connection with the corresponding connection manager, and each session manager is in communication connection with each connection manager; the connection manager comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases;
the session manager is used for determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request, and if the condition of sending the command primitive is determined to be met according to at least one flag bit state of the current session and the type of the database request, the session manager respectively sends the matched command primitive to each target connection manager;
the connection manager is used for receiving the command primitive sent by the session manager, obtaining the target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
10. A computer device comprising a processor and a memory, the memory to store instructions that, when executed, cause the processor to: determining at least one command primitive and a target connection manager matched with the command primitive according to the analysis result of the database request and the type of the database request; the connection manager is associated with the sub-databases and comprises a state connection pool, and state connections in the state connection pool are connections pointing to the sub-databases; if the condition of sending command primitives is determined to be met according to the state of at least one flag bit of the current session and the type of the database request, sending matched command primitives to each target connection manager respectively; the command primitive is used for indicating the connection manager to acquire the target stateful connection in the stateful connection pool to perform state adjustment, and/or using the target stateful connection to perform data access on the matched sub-database.
11. The computer device of claim 10, wherein the processor is configured to update the flag state of the current session by: and when the type of the database request of the client meets the session state updating condition, updating at least one flag bit state of the current session according to the type of the database request.
12. The computer device of claim 10, wherein the processor is configured to determine that a command primitive sending condition is satisfied by: acquiring at least one flag bit state of the currently stored target with state connection; the target stateful connection is stateful connection of the current session aiming at the target sub-database; and determining whether command primitive sending conditions are met or not according to the incidence relation between the flag bit states of the current session and the flag bit states of the target stateful connection and the type of the database request.
13. The computer device of claim 10, wherein the processor is configured to determine a command primitive by: if the target connection-with-state identifier is stored currently, determining a command primitive interface according to the type of the database request, taking the analysis result of the database request and the target connection-with-state identifier as the parameters of a command primitive, forming the command primitive by the command primitive interface and the parameters of the command primitive, and finally determining a target connection manager matched with the command primitive according to the analysis result; if the identification of the target with the state connection is not stored at present, determining a command primitive interface according to the type of the database request, taking the analysis result of the database request as the parameter of the command primitive, forming the command primitive by the command primitive interface and the parameter of the command primitive together, and finally determining a target connection manager matched with the command primitive according to the analysis result.
14. The computer device of claim 10, wherein the processor is configured to update the flag bit status of the current storage target stateful connection by: and after the target connection manager carries out state adjustment on the target stateful connection according to the command primitive, updating the flag bit state of the current storage target stateful connection.
15. The computer device of claim 10, wherein the processor is configured to reset the connection flag state by: receiving a session closing instruction sent by a client, traversing state connection of each target corresponding to each target sub database related to the current session, and acquiring at least one flag bit state of the state connection of each target; sending a command primitive for ending the transaction to a connection manager corresponding to the target stateful connection with the true state of the open transaction flag bit; and sending a command primitive for releasing the connection to the connection manager corresponding to the target stateful connection with the state of the reserved connection flag bit being true.
16. A computer device comprising a processor and a memory, the memory to store instructions that, when executed, cause the processor to: receiving a command primitive sent by a session manager; and acquiring target stateful connection in the stateful connection pool according to the command primitive, performing state adjustment on the target stateful connection, and/or performing data access on the matched sub-database by using the target stateful connection.
17. The computer device of claim 16, wherein the processor is configured to obtain the target stateful connection by: when the command primitive comprises an identifier of target stateful connection, acquiring the target stateful connection in the stateful connection pool according to the target stateful connection identifier; when the command primitive does not contain the identifier of the object with the state connection, inquiring an idle connection list; when at least one stateful connection identifier exists in the idle connection list, randomly selecting one stateful connection identifier, and acquiring a stateful connection in a stateful connection pool according to the stateful connection identifier to be used as a target stateful connection; and when the idle connection list does not have the status connection identifier, creating a new status connection as a target status connection.
18. A storage medium for storing instructions for performing a data access control method as claimed in any one of claims 1 to 6 or claims 7 to 8.
CN202011211196.0A 2020-11-03 2020-11-03 Data access control method, system, device and medium Active CN112347141B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011211196.0A CN112347141B (en) 2020-11-03 2020-11-03 Data access control method, system, device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011211196.0A CN112347141B (en) 2020-11-03 2020-11-03 Data access control method, system, device and medium

Publications (2)

Publication Number Publication Date
CN112347141A true CN112347141A (en) 2021-02-09
CN112347141B CN112347141B (en) 2021-09-24

Family

ID=74356876

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011211196.0A Active CN112347141B (en) 2020-11-03 2020-11-03 Data access control method, system, device and medium

Country Status (1)

Country Link
CN (1) CN112347141B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101408899A (en) * 2008-11-21 2009-04-15 北京中企开源信息技术有限公司 Method and apparatus for switching website multiple data sources
CN104252485A (en) * 2013-06-29 2014-12-31 北京新媒传信科技有限公司 Database management platform
CN105468619A (en) * 2014-09-03 2016-04-06 阿里巴巴集团控股有限公司 Resource distribution method and device used for database connection pool
CN106484882A (en) * 2016-10-14 2017-03-08 腾讯科技(深圳)有限公司 A kind of management method of database connection pool and device
CN110008681A (en) * 2019-03-12 2019-07-12 阿里巴巴集团控股有限公司 Access control method, equipment and system
CN111680069A (en) * 2020-06-02 2020-09-18 北京深演智能科技股份有限公司 Database access method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101408899A (en) * 2008-11-21 2009-04-15 北京中企开源信息技术有限公司 Method and apparatus for switching website multiple data sources
CN104252485A (en) * 2013-06-29 2014-12-31 北京新媒传信科技有限公司 Database management platform
CN105468619A (en) * 2014-09-03 2016-04-06 阿里巴巴集团控股有限公司 Resource distribution method and device used for database connection pool
CN106484882A (en) * 2016-10-14 2017-03-08 腾讯科技(深圳)有限公司 A kind of management method of database connection pool and device
CN110008681A (en) * 2019-03-12 2019-07-12 阿里巴巴集团控股有限公司 Access control method, equipment and system
CN111680069A (en) * 2020-06-02 2020-09-18 北京深演智能科技股份有限公司 Database access method and device

Also Published As

Publication number Publication date
CN112347141B (en) 2021-09-24

Similar Documents

Publication Publication Date Title
WO2022022477A1 (en) Management operation and maintenance platform and data processing method
CN109995859A (en) A kind of dispatching method, dispatch server and computer readable storage medium
US7366738B2 (en) Method and system for object cache synchronization
US20210117231A1 (en) Task processing method and apparatus
US6496825B1 (en) Systems and methods for the detection of a loop-back of a transaction
CN111309374A (en) Micro-service system and service calling method in micro-service system
CN106021315B (en) Log management method and system for application program
CN108509523A (en) Structuring processing method, equipment and the readable storage medium storing program for executing of block chain data
CN109643305A (en) Data query method, application and database server, middleware and system
CN111984849A (en) Information query method, device, equipment and medium
CN110417876A (en) Node server and main control device in session method, distributed system
CN113590433B (en) Data management method, data management system, and computer-readable storage medium
CN113726662B (en) Micro-service routing and management system
CN109818948A (en) Using dispositions method, device, system, equipment and medium
CN112347141B (en) Data access control method, system, device and medium
CN111813529B (en) Data processing method, device, electronic equipment and storage medium
CN113067844B (en) Service discovery method and device and HNRF
CN107968798B (en) Network management resource label obtaining method, cache synchronization method, device and system
CN113297148B (en) Method, device and equipment for collecting service log data and readable storage medium
US20060117321A1 (en) Interface for application components
CN113326033B (en) Key-value storage system with multi-language API
CN115686497A (en) Business development data management method, development engine, electronic device, and storage medium
CN113727138A (en) HLS intranet source returning method
CN110389966B (en) Information processing method and device
US11153388B2 (en) Workflow engine framework for cross-domain extension

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