CN104281587A - Connection establishing method and device - Google Patents

Connection establishing method and device Download PDF

Info

Publication number
CN104281587A
CN104281587A CN201310277055.2A CN201310277055A CN104281587A CN 104281587 A CN104281587 A CN 104281587A CN 201310277055 A CN201310277055 A CN 201310277055A CN 104281587 A CN104281587 A CN 104281587A
Authority
CN
China
Prior art keywords
connection
database
resource group
virtual resource
target data
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
CN201310277055.2A
Other languages
Chinese (zh)
Other versions
CN104281587B (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.)
Advanced New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201310277055.2A priority Critical patent/CN104281587B/en
Publication of CN104281587A publication Critical patent/CN104281587A/en
Application granted granted Critical
Publication of CN104281587B publication Critical patent/CN104281587B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing

Landscapes

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

Abstract

The invention discloses a connection establishing method and device in order to solve the problems that in the prior art, when an APP has access to hot spot data, all connections in a database connection pool may be occupied, and resources of the database connection pool are wasted. The method comprises the steps that connections in a database connection pool of an APP are divided into at least two queues in advance, wherein each queue contains at least one connection; during target data access, the APP determines the queue corresponding to identification information of target data according to the identification information of the target data and the corresponding relationships between preset identification information and the queues, and through the spare connections in the determined connection, a user can have access to the target data in a database. Through the method, even if the APP occupies a plurality of connection access hot spot data at the same time, the APP can at most occupy all the connections in the queue corresponding to the identification information of the hot spot data, but will not occupy all the connections in the database connection pool, and therefore the resources in the database connection pool can be effectively saved.

Description

A kind of method of connecting and device
Technical field
The application relates to communication technical field, particularly relates to a kind of method of connecting and device.
Background technology
At present, the information interaction applied between (Application, APP) and database has been prevalent in various application scenarios.
When APP and database carry out information interaction, first APP will be connected with Database, then carries out information interaction based on the connection of setting up and database.But, the process connected due to database and APP is more loaded down with trivial details, required time that connects is longer, and need to expend the more resource of database, therefore, in the prior art, presetting database connection pool in APP usually, APP is connected with Database by this database connection pool.
Concrete, in the prior art, for an APP, the connection of the some (as 10) of this APP and database can be set up in advance, and the connection of this some set up is kept in database connection pool, as APP and DataBase combining, then connection idle in database connection pool and database can be directly adopted to carry out information interaction.
But, when certain data in database are the higher hot spot datas of visit capacity, all connections that APP uses up in database connection pool are possibly in order to this hot spot data in accessing database, when causing APP will access other non-hot spot datas, in database connection pool, do not have idle connection available.And, in order to ensure the accuracy of the data in database, when APP carries out repeatedly renewal rewards theory by multiple connection to the same data in database, database is that serial performs for this multiple renewal rewards theory, therefore, even if all connections that APP occupies in database connection pool upgrade the same hot spot data in database simultaneously, database is also that serial performs facing to multiple renewal rewards theory, and this obviously wastes the resource in database connection pool.
Summary of the invention
The embodiment of the present application provides a kind of method of connecting and device, may take all connections in database connection pool, the problem of the resource of waste database connection pool in order to solve APP in prior art when accessing hot spot data.
A kind of method connected that the embodiment of the present application provides, comprising:
According to the identification information of target data, and the corresponding relation of individual queue in the identification information preset and database connection pool, determine queue corresponding with the identification information of described target data in described database connection pool, wherein, be at least two queues by the link division in described database connection pool in advance, comprise at least one in each queue and connect;
By the described target data in connected reference database idle in the queue determined.
A kind of method connected that the embodiment of the present application provides, comprising:
According to the identification information of target data, and the corresponding relation of the identification information preset and each virtual resource group, determine the virtual resource group that the identification information of described target data is corresponding;
Judge whether the quantity of the connection in the virtual resource group determined is less than the maximum number of connections preset for the described virtual resource group determined;
If, then by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool;
Otherwise, when waiting until that the quantity of the connection in the described virtual resource group determined is less than described maximum number of connections, by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool.
A kind of device connected that the embodiment of the present application provides, comprising:
Determination module, for the identification information according to target data, and the corresponding relation of individual queue in the identification information preset and database connection pool, determine queue corresponding with the identification information of described target data in described database connection pool, wherein, be at least two queues by the link division in described database connection pool in advance, comprise at least one in each queue and connect;
Link block, for the described target data in connected reference database idle in the queue determined by described determination module.
A kind of device connected that the embodiment of the present application provides, comprising:
Determination module, for the identification information according to target data, and the corresponding relation of the identification information preset and each virtual resource group, determine the virtual resource group that the identification information of described target data is corresponding;
Judge module, for judging whether the quantity of the connection in the virtual resource group that described determination module is determined is less than the maximum number of connections preset for the described virtual resource group determined;
Link block, for when the judged result of described judge module is for being, by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool; When the judged result of described judge module is no, when waiting until that the quantity of the connection in the described virtual resource group determined is less than described maximum number of connections, by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool.
The embodiment of the present application provides a kind of method of connecting and device, link division in the database connection pool of APP is at least two queues by the method in advance, comprise at least one in each queue to connect, when access destination data, APP is according to the corresponding relation of the identification information of target data and default identification information and individual queue, determine the queue that the identification information of this target data is corresponding, and by this target data in connected reference database idle in the queue determined.Pass through said method, even if APP takies multiple connected reference hot spot data simultaneously, APP at most also can only take all connections in queue corresponding to the identification information of this hot spot data, and all connections that can not take in database connection pool, therefore effectively can save the resource in database connection pool.
Accompanying drawing explanation
The first process connected that Fig. 1 provides for the embodiment of the present application;
What Fig. 2 provided for the embodiment of the present application is the schematic diagram of multiple queue by the link division in database connection pool;
The process that the second that Fig. 3 provides for the embodiment of the present application connects;
Each virtual resource group schematic diagram in the database connection pool that Fig. 4 provides for the embodiment of the present application;
The first apparatus structure schematic diagram connected that Fig. 5 provides for the embodiment of the present application;
The apparatus structure schematic diagram that the second that Fig. 6 provides for the embodiment of the present application connects.
Embodiment
Be at least two queues by the link division in the database connection pool of APP in advance in the embodiment of the present application, comprise at least one in each queue to connect, and the identification information of each data and the corresponding relation of individual queue in presetting database, when APP access destination data, corresponding queue can be determined according to the identification information of target data, and by connected reference target data idle in the queue determined.By said method, even if APP is simultaneously by the same data of multiple connected reference, all connections in database connection pool also can not all take by APP, and therefore can avoid wastes the resource in database connection pool.
Below in conjunction with Figure of description, the embodiment of the present application is described in detail.
The first process connected that Fig. 1 provides for the embodiment of the present application, specifically comprises the following steps:
S101: according to the identification information of target data, and the corresponding relation of individual queue in the identification information preset and database connection pool, determine queue corresponding with the identification information of target data in database connection pool.
In the embodiment of the present application, can for an APP, be at least two queues by the link division in the database connection pool of this APP in advance, comprise at least one in each queue and connect, and the identification information of each data and the corresponding relation of individual queue in presetting database, as shown in Figure 2.
What Fig. 2 provided for the embodiment of the present application is the schematic diagram of multiple queue by the link division in database connection pool.Suppose to comprise 10 connections in the database connection pool of APP altogether, these 10 connections are the connections of APP and the database set up in advance, then in fig. 2, be 4 queues, be respectively queue 1, queue 2, queue 3, queue 4 by these 10 link divisions.Wherein, in queue 1, there are 4 connections, in queue 2, queue 3, queue 4, respectively have 2 connections.
In presetting database in the identification information of each data and database connection pool during the corresponding relation of individual queue, queue corresponding for the identification information of hot spot data can be set to comprise the queue that the quantity of connection is maximum, the queue that the identification information of non-hot spot data is corresponding is set to other queues.Wherein, the identification information of data includes but not limited to the ID etc. of data.
Such as, in fig. 2, queue 1 can be set to the queue that the identification information of hot spot data is corresponding, queue 2, queue 3, queue 4 be set to the queue that the identification information of non-hot spot data is corresponding.
S102: by the target data in connected reference database idle in the queue determined.
After APP determines queue corresponding to the identification information of the target data that will access, then by the target data in connected reference database idle in the queue determined.
Continue along using example, suppose that the target data that APP will access is hot spot data, in database connection pool, the division of individual queue as shown in Figure 2, the queue having preset the identification information of hot spot data corresponding is queue 1, then in step S101, APP determines that the queue that the identification information of this target data is corresponding is queue 1, and in step S102, APP is by this target data of connected reference idle in queue 1.
Pass through said method, even if APP access is hot spot data, APP at most also can only take all connections in queue corresponding to the identification information of hot spot data, and the connection of other queues can not be taken, also all connections in database connection pool all would not be taken, therefore can effectively avoid wasting the resource in database connection pool.
Further, after APP to determine queue corresponding to the identification information of target data by above-mentioned steps S101, if there is not idle connection in the queue determined, then whether what can judge current foundation is less than default maximum quantity with the quantity of the connection of database.If current foundation be less than default maximum quantity with the quantity of the connection of database, then set up the connection with database, and the connected reference target data by setting up, also be, now APP do not set up in the connection pool of usage data storehouse with the connected reference target data of database, but newly-built one with the connection of database, and by this newly-built connected reference target data.If current foundation be not less than default maximum quantity with the quantity of the connection of database, then directly can return and set up failed message, also, this access destination data failure.
Continue to be described for Fig. 2, suppose that the queue that APP determines that the identification information of target data is corresponding is queue 1, but in now queue 1 and leisureless connection, then APP judges whether self is currently less than default maximum quantity with the quantity of the connection of Database, if, then APP newly-built one with the connection of database (do not use any one in queue 2, queue 3, queue 4 is idle to be connected), and by newly-built connected reference target data, otherwise, directly return the failed message that connects.
Except adopting above-mentioned disposal route, when there is not idle connection in the queue that the identification information of the target data that APP is determined by above-mentioned steps S101 is corresponding, the connection in queue to be determined also can be waited to be released, and to monitor the stand-by period.If the time span waited for is no more than predetermined time period, and the connection in the queue determined is released, then the connected reference target data by discharging in the queue determined.If the time span waited for reaches predetermined time period, but the connection in the queue determined is released not yet, then return the failed message that connects, also, this access destination data failure.
Continue to be described for Fig. 2, suppose that the queue that APP determines that the identification information of target data is corresponding is queue 1, but in now queue 1 and leisureless connection, connection then in APP waiting list 1 is released, if the time span waited for is no more than predetermined time period, and certain connection in queue 1 is released, then by d/d connected reference target data in queue 1, if the time span waited for reaches predetermined time period, but still do not connect in queue 1 and be released, then return the failed message that connects.
Be the first method connected that the embodiment of the present application provides above, in the first method connected above-mentioned, each connection in database connection pool is once be divided into multiple queue, then the connection in a queue just by other queue sharing, can not achieve the strict isolation of each connection.The method that the second that the following describes the embodiment of the present application provides connects, as shown in Figure 3.
The process that the second that Fig. 3 provides for the embodiment of the present application connects, specifically comprises the following steps:
S301: according to the identification information of target data, and the corresponding relation of the identification information preset and each virtual resource group, determine the virtual resource group that the identification information of target data is corresponding.
S302: judge if so, then to perform the maximum number of connections whether quantity of the connection in the virtual resource group determined is less than the virtual resource group determined for this and presets step S303, otherwise perform step S304.
S303: in the virtual resource group that link division idle in database connection pool is determined to this, target data in connected reference database idle in the virtual resource group determined by this, and after access destination data by the Connection Release that takies in database connection pool.
If the quantity of the connection in the virtual resource group determined is less than the maximum number of connections that the virtual resource group determined for this is preset, then APP is by database connection pool
S304: when waiting until that the quantity of the connection in this virtual resource group determined is less than maximum number of connections, in the virtual resource group that link division idle in database connection pool is determined to this, target data in connected reference database idle in the virtual resource group determined by this, and after access destination data by the Connection Release that takies in database connection pool.
In the embodiment of the present application, can for an APP, at least two virtual resource groups are preset in the database connection pool of this APP, corresponding maximum number of connections is preset for each virtual resource group, the maximum number of connections preset for a virtual resource group is less than the quantity of the connection in database connection pool, and the identification information of each data in presetting database and the corresponding relation of each virtual resource group.Wherein, the identification information of data includes but not limited to the ID etc. of data, as shown in Figure 4.
Each virtual resource group schematic diagram in the database connection pool that Fig. 4 provides for the embodiment of the present application, in the diagram, for a virtual resource group, when APP non-access identities information is the data of identification information corresponding to this virtual resource group, connection in database connection pool can not be divided in this virtual resource group, and when APP access identities information is the data of identification information corresponding to this virtual resource group, connection in database connection pool then can be divided in this virtual resource group, access these data for APP to use, wherein, the connection be divided in this virtual resource group is no more than at most the maximum number of connections preset for this virtual resource group.After APP visit data terminates, the connection in this virtual resource group used can be discharged in database connection pool again.
In the diagram, have 10 connections in database connection pool, in database connection pool, be provided with 4 virtual resource groups, be respectively resource group 1, resource group 2, resource group 3, resource group 4.Wherein, the maximum number of connections that the maximum number of connections preset for resource group 1 and resource group 2 is 5, preset for resource group 3 and resource group 4 is 3.
The method connected due to the second is different from the first method connected, virtual resource group is not that strict isolation is carried out in all connections in database connection pool, but when needing the connection in database connection pool (, when APP access identities information is the data of identification information corresponding to this virtual resource group), from database connection pool, take out a connection puts under in this virtual resource group, after this connection of use, again this connection is returned database connection pool from this virtual resource group, therefore, the maximum number of connections sum preset for each virtual resource group can be greater than the quantity of the connection in database connection pool, maximum number of connections sum as preset for each virtual resource group in Fig. 4 is 11, and the quantity of connection in database connection pool is 10.
Continue to be described for Fig. 4, suppose that the virtual resource group that the identification information of the target data that APP will access is corresponding is resource group 1, the maximum number of connections preset for resource group 1 is 5, then APP judges whether the quantity of the connection in Current resource group 1 is less than 5.If, then by an idle link division in database connection pool in resource group 1, and by being divided into the connected reference target data of the free time in resource group 1, after access destination data, then used connection is discharged in database connection pool from resource group 1.If the quantity of the connection in Current resource group 1 is not less than 5, when the quantity of connection that then APP waits until in resource group 1 is less than 5, again by an idle link division in database connection pool in resource group 1, and by being divided into the connected reference target data of the free time in resource group 1, after access destination data, then used connection is discharged in database connection pool from resource group 1.
Pass through said method, even if APP takies multiple connected reference hot spot data simultaneously, the quantity that APP accesses the connection shared by this hot spot data is no more than at most the maximum number of connections of virtual resource group corresponding to the identification information of this hot spot data, and all connections that can not take in database connection pool, therefore effectively can save the resource in database connection pool, the effect that the first method connected of providing with the embodiment of the present application is identical can be reached.
Further, after APP to determine virtual resource group corresponding to the identification information of target data by step S301, if the quantity of the connection in the virtual resource group determined is less than the maximum number of connections that the virtual resource group determined for this is preset, but do not have idle connection in current database connection pool, then APP can judge whether quantity that is that self set up and connection that is database is less than default maximum quantity.If be less than, then set up the connection with database, and the connected reference target data by setting up, also be, now APP do not set up in the connection pool of usage data storehouse with the connection of database, but newly-built one with the connection of database, and use newly-built connected reference target data.If be not less than, then APP directly can return the failed message that connects, also, and this access destination data failure.
Further, in step s 304, if the quantity of the connection in the virtual resource group determined is not less than the maximum number of connections preset for the described virtual resource group determined, then APP is when waiting for that the quantity of the connection in this virtual resource group determined is less than maximum number of connections, also can monitor the time span waited for.If the time waited for does not reach predetermined time period, and the quantity of connection in this virtual resource group determined is less than maximum number of connections, then in the virtual resource group determined to this by link division idle in database connection pool, and carry out subsequent step.If the time waited for reaches predetermined time period, but the quantity of connection in this virtual resource group determined is less than maximum number of connections not yet, then can return the failed message that connects, this access destination data failure.
Be the method connected that the embodiment of the present application provides above, based on same thinking, the embodiment of the present application also provides two kinds of devices connected, as shown in Figure 5 and Figure 6.
The first apparatus structure schematic diagram connected that Fig. 5 provides for the embodiment of the present application, specifically comprises:
Determination module 501, for the identification information according to target data, and the corresponding relation of individual queue in the identification information preset and database connection pool, determine queue corresponding with the identification information of described target data in described database connection pool, wherein, be at least two queues by the link division in described database connection pool in advance, comprise at least one in each queue and connect;
Link block 502, for the described target data in connected reference database idle in the queue determined by described determination module 501.
Described link block 502 also for, when there is not idle connection in the queue determined, and current foundation be less than default maximum quantity with the quantity of the connection of described database time, to set up and the connection of described database, and by target data described in the connected reference of setting up; When there is not idle connection in the queue determined, and current foundation be not less than default maximum quantity with the quantity of the connection of described database time, return the failed message that connects.
Described link block 502 also for, when there is not idle connection in the queue determined, wait for that the connection in the described queue determined is released; If the time span waited for is no more than predetermined time period, and the connection in the described queue determined is released, then the described target data of connected reference database by discharging in the described queue determined; If the time span waited for reaches predetermined time period, and the connection in the described queue determined is not released, then return the failed message that connects.
Concrete the first device connected above-mentioned corresponds to the first method connected that the embodiment of the present application provides.
The apparatus structure schematic diagram that the second that Fig. 6 provides for the embodiment of the present application connects, specifically comprises:
Determination module 601, for the identification information according to target data, and the corresponding relation of the identification information preset and each virtual resource group, determine the virtual resource group that the identification information of described target data is corresponding;
Judge module 602, for judging whether the quantity of the connection in the virtual resource group that described determination module 601 is determined is less than the maximum number of connections preset for the described virtual resource group determined;
Link block 603, for when the judged result of described judge module 602 is for being, by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool; When the judged result of described judge module 602 is no, when waiting until that the quantity of the connection in the described virtual resource group determined is less than described maximum number of connections, by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool.
Described link block 603 also for, when the judged result of described judge module 602 be yes and there is no idle connection in described database connection pool and current foundation be less than default maximum quantity with the quantity of the connection of described database time, set up and the connection of described database, and by target data described in the connected reference of setting up; When the judged result of described judge module 602 be yes and there is no idle connection in described database connection pool and current foundation be not less than default maximum quantity with the quantity of the connection of described database time, return the failed message that connects.
Described link block 603 also for, when the judged result of described judge module 602 is no, before link division idle in described database connection pool is in the described virtual resource group determined, determine that the time that the quantity of the connection waited in the described virtual resource group determined is less than described maximum number of connections does not reach predetermined time period.
The method that the second that the device that concrete above-mentioned the second connects corresponds to the embodiment of the present application to be provided connects.
The embodiment of the present application provides a kind of method of connecting and device, link division in the database connection pool of APP is at least two queues by the method in advance, comprise at least one in each queue to connect, when access destination data, APP is according to the corresponding relation of the identification information of target data and default identification information and individual queue, determine the queue that the identification information of this target data is corresponding, and by this target data in connected reference database idle in the queue determined.Pass through said method, even if APP takies multiple connected reference hot spot data simultaneously, APP at most also can only take all connections in queue corresponding to the identification information of this hot spot data, and all connections that can not take in database connection pool, therefore effectively can save the resource in database connection pool.
Those skilled in the art should understand, the embodiment of the application can be provided as method, system or computer program.Therefore, the application can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the application can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disk memory, CD-ROM, optical memory etc.) of computer usable program code.
In one typically configuration, computing equipment comprises one or more processor (CPU), input/output interface, network interface and internal memory.
Internal memory may comprise the volatile memory in computer-readable medium, and the forms such as random access memory (RAM) and/or Nonvolatile memory, as ROM (read-only memory) (ROM) or flash memory (flash RAM).Internal memory is the example of computer-readable medium.
Computer-readable medium comprises permanent and impermanency, removable and non-removable media can be stored to realize information by any method or technology.Information can be computer-readable instruction, data structure, the module of program or other data.The example of the storage medium of computing machine comprises, but be not limited to phase transition internal memory (PRAM), static RAM (SRAM), dynamic RAM (DRAM), the random access memory (RAM) of other types, ROM (read-only memory) (ROM), Electrically Erasable Read Only Memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc ROM (read-only memory) (CD-ROM), digital versatile disc (DVD) or other optical memory, magnetic magnetic tape cassette, tape magnetic rigid disk stores or other magnetic storage apparatus or any other non-transmitting medium, can be used for storing the information can accessed by computing equipment.According to defining herein, computer-readable medium does not comprise non-temporary computer readable media (transitory media), as data-signal and the carrier wave of modulation.
The application describes with reference to according to the process flow diagram of the method for the embodiment of the present application, equipment (system) and computer program and/or block scheme.Should understand can by the combination of the flow process in each flow process in computer program instructions realization flow figure and/or block scheme and/or square frame and process flow diagram and/or block scheme and/or square frame.These computer program instructions can being provided to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, making the instruction performed by the processor of computing machine or other programmable data processing device produce device for realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be stored in can in the computer-readable memory that works in a specific way of vectoring computer or other programmable data processing device, the instruction making to be stored in this computer-readable memory produces the manufacture comprising command device, and this command device realizes the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be loaded in computing machine or other programmable data processing device, make on computing machine or other programmable devices, to perform sequence of operations step to produce computer implemented process, thus the instruction performed on computing machine or other programmable devices is provided for the step realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
Although described the preferred embodiment of the application, those skilled in the art once obtain the basic creative concept of cicada, then can make other change and amendment to these embodiments.So claims are intended to be interpreted as comprising preferred embodiment and falling into all changes and the amendment of the application's scope.
Obviously, those skilled in the art can carry out various change and modification to the embodiment of the present application and not depart from the spirit and scope of the embodiment of the present application.Like this, if these amendments of the embodiment of the present application and modification belong within the scope of the application's claim and equivalent technologies thereof, then the application is also intended to comprise these change and modification.

Claims (12)

1. the method connected, is characterized in that, comprising:
According to the identification information of target data, and the corresponding relation of individual queue in the identification information preset and database connection pool, determine queue corresponding with the identification information of described target data in described database connection pool, wherein, be at least two queues by the link division in described database connection pool in advance, comprise at least one in each queue and connect;
By the described target data in connected reference database idle in the queue determined.
2. the method for claim 1, is characterized in that, described method also comprises:
When there is not idle connection in the queue determined, and current foundation be less than default maximum quantity with the quantity of the connection of described database time, set up the connection with described database, and by target data described in the connected reference of setting up;
When there is not idle connection in the queue determined, and current foundation be not less than default maximum quantity with the quantity of the connection of described database time, return the failed message that connects.
3. the method for claim 1, is characterized in that, described method also comprises:
When there is not idle connection in the queue determined, wait for that the connection in the described queue determined is released;
If the time span waited for is no more than predetermined time period, and the connection in the described queue determined is released, then the described target data of connected reference database by discharging in the described queue determined;
If the time span waited for reaches predetermined time period, and the connection in the described queue determined is not released, then return the failed message that connects.
4. the method connected, is characterized in that, comprising:
According to the identification information of target data, and the corresponding relation of the identification information preset and each virtual resource group, determine the virtual resource group that the identification information of described target data is corresponding;
Judge whether the quantity of the connection in the virtual resource group determined is less than the maximum number of connections preset for the described virtual resource group determined;
If, then by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool;
Otherwise, when waiting until that the quantity of the connection in the described virtual resource group determined is less than described maximum number of connections, by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool.
5. method as claimed in claim 4, it is characterized in that, described method also comprises:
When the quantity of the connection in the described virtual resource group determined be less than the maximum number of connections preset for the described virtual resource group determined and there is no idle connection in described database connection pool and current foundation be less than default maximum quantity with the quantity of the connection of described database time, set up and the connection of described database, and by target data described in the connected reference of setting up;
When the quantity of the connection in the described virtual resource group determined be less than the maximum number of connections preset for the described virtual resource group determined and there is no idle connection in described database connection pool and current foundation be not less than default maximum quantity with the quantity of the connection of described database time, return the failed message that connects.
6. method as claimed in claim 4, it is characterized in that, when the quantity of the connection in the described virtual resource group determined is not less than the maximum number of connections preset for the described virtual resource group determined, before link division idle in described database connection pool is in the described virtual resource group determined, described method also comprises:
Determine that the time that the quantity of the connection waited in the described virtual resource group determined is less than described maximum number of connections does not reach predetermined time period.
7. the device connected, is characterized in that, comprising:
Determination module, for the identification information according to target data, and the corresponding relation of individual queue in the identification information preset and database connection pool, determine queue corresponding with the identification information of described target data in described database connection pool, wherein, be at least two queues by the link division in described database connection pool in advance, comprise at least one in each queue and connect;
Link block, for the described target data in connected reference database idle in the queue determined by described determination module.
8. device as claimed in claim 7, it is characterized in that, described link block also for, when there is not idle connection in the queue determined, and current foundation be less than default maximum quantity with the quantity of the connection of described database time, set up and the connection of described database, and by target data described in the connected reference of setting up; When there is not idle connection in the queue determined, and current foundation be not less than default maximum quantity with the quantity of the connection of described database time, return the failed message that connects.
9. device as claimed in claim 7, is characterized in that, described link block also for, when there is not idle connection in the queue determined, wait for that the connection in the described queue determined is released; If the time span waited for is no more than predetermined time period, and the connection in the described queue determined is released, then the described target data of connected reference database by discharging in the described queue determined; If the time span waited for reaches predetermined time period, and the connection in the described queue determined is not released, then return the failed message that connects.
10. the device connected, is characterized in that, comprising:
Determination module, for the identification information according to target data, and the corresponding relation of the identification information preset and each virtual resource group, determine the virtual resource group that the identification information of described target data is corresponding;
Judge module, for judging whether the quantity of the connection in the virtual resource group that described determination module is determined is less than the maximum number of connections preset for the described virtual resource group determined;
Link block, for when the judged result of described judge module is for being, by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool; When the judged result of described judge module is no, when waiting until that the quantity of the connection in the described virtual resource group determined is less than described maximum number of connections, by link division idle in described database connection pool in the described virtual resource group determined, by the described target data in connected reference database idle in the described virtual resource group determined, and after the described target data of access by the Connection Release that takies in described database connection pool.
11. devices as claimed in claim 10, it is characterized in that, described link block also for, when the judged result of described judge module be yes and there is no idle connection in described database connection pool and current foundation be less than default maximum quantity with the quantity of the connection of described database time, set up and the connection of described database, and by target data described in the connected reference of setting up; When the judged result of described judge module be yes and there is no idle connection in described database connection pool and current foundation be not less than default maximum quantity with the quantity of the connection of described database time, return the failed message that connects.
12. devices as claimed in claim 10, it is characterized in that, described link block also for, when the judged result of described judge module is no, before link division idle in described database connection pool is in the described virtual resource group determined, determine that the time that the quantity of the connection waited in the described virtual resource group determined is less than described maximum number of connections does not reach predetermined time period.
CN201310277055.2A 2013-07-03 2013-07-03 A kind of method and device for establishing connection Active CN104281587B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310277055.2A CN104281587B (en) 2013-07-03 2013-07-03 A kind of method and device for establishing connection

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310277055.2A CN104281587B (en) 2013-07-03 2013-07-03 A kind of method and device for establishing connection

Publications (2)

Publication Number Publication Date
CN104281587A true CN104281587A (en) 2015-01-14
CN104281587B CN104281587B (en) 2018-05-11

Family

ID=52256468

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310277055.2A Active CN104281587B (en) 2013-07-03 2013-07-03 A kind of method and device for establishing connection

Country Status (1)

Country Link
CN (1) CN104281587B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108183833A (en) * 2017-11-29 2018-06-19 努比亚技术有限公司 A kind of response processing method, device and computer readable storage medium
CN109977096A (en) * 2019-03-05 2019-07-05 中国银联股份有限公司 A kind of database connection management method and device
CN111026794A (en) * 2019-11-26 2020-04-17 山东中创软件商用中间件股份有限公司 Data management method, device, equipment and medium based on data source
CN112732441A (en) * 2021-01-07 2021-04-30 山东众阳健康科技集团有限公司 Connection method, device and system of multi-element dynamic connection pool

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020161748A1 (en) * 2001-02-28 2002-10-31 International Business Machines Corporation Data loading from a remote data source
CN101408899A (en) * 2008-11-21 2009-04-15 北京中企开源信息技术有限公司 Method and apparatus for switching website multiple data sources
CN102024008A (en) * 2009-09-09 2011-04-20 浙江省电力公司 Limitation method of Web server concurrent number

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020161748A1 (en) * 2001-02-28 2002-10-31 International Business Machines Corporation Data loading from a remote data source
CN101408899A (en) * 2008-11-21 2009-04-15 北京中企开源信息技术有限公司 Method and apparatus for switching website multiple data sources
CN102024008A (en) * 2009-09-09 2011-04-20 浙江省电力公司 Limitation method of Web server concurrent number

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108183833A (en) * 2017-11-29 2018-06-19 努比亚技术有限公司 A kind of response processing method, device and computer readable storage medium
CN108183833B (en) * 2017-11-29 2021-08-10 努比亚技术有限公司 Response processing method and device and computer readable storage medium
CN109977096A (en) * 2019-03-05 2019-07-05 中国银联股份有限公司 A kind of database connection management method and device
CN111026794A (en) * 2019-11-26 2020-04-17 山东中创软件商用中间件股份有限公司 Data management method, device, equipment and medium based on data source
CN112732441A (en) * 2021-01-07 2021-04-30 山东众阳健康科技集团有限公司 Connection method, device and system of multi-element dynamic connection pool

Also Published As

Publication number Publication date
CN104281587B (en) 2018-05-11

Similar Documents

Publication Publication Date Title
CN107251486B (en) Method, device and system for expanding linkage
CN109886693B (en) Consensus realization method, device, equipment and medium for block chain system
CN103500073A (en) Method and device for data block migration
CN106897299B (en) Database access method and device
CN104113576A (en) Method and device for updating client
CN105704188A (en) Deployment method and apparatus of applications and services
CN110750336B (en) OpenStack virtual machine memory hot-expanding method
CN112583625B (en) Network resource management method, system, network device and readable storage medium
CN110162396A (en) Method for recovering internal storage, device, system and storage medium
CN113760543A (en) Resource management method and device, electronic equipment and computer readable storage medium
CN104281587A (en) Connection establishing method and device
CN113010265A (en) Pod scheduling method, scheduler, memory plug-in and system
CN105630576A (en) Data processing method and apparatus in virtualization platform
CN112948050A (en) Method and device for deploying pod
CN103841562A (en) Time slot resource occupation processing method and time slot resource occupation processing device
CN113849260A (en) Instance processing core allocation method and device
CN111767139A (en) Cross-region multi-data-center resource cloud service modeling method and system
CN110795202A (en) Resource allocation method and device of virtualized cluster resource management system
CN111400032A (en) Resource allocation method and device
CN105512091A (en) Memory allocation method and device
CN115328608A (en) Kubernetes container vertical expansion adjusting method and device
CN115408328A (en) Many-core system, processing method and processing unit
CN103634344A (en) Method and apparatus for unit operation multiple MySQL database examples
CN109257201B (en) License sending method and device
CN108255820B (en) Method and device for data storage in distributed system and electronic equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20191209

Address after: P.O. Box 31119, grand exhibition hall, hibiscus street, 802 West Bay Road, Grand Cayman, Cayman Islands

Patentee after: Innovative advanced technology Co., Ltd

Address before: Cayman Islands Grand Cayman capital building, a four storey No. 847 mailbox

Patentee before: Alibaba Group Holding Co., Ltd.

TR01 Transfer of patent right