WO2016029790A1 - 数据传输方法及装置 - Google Patents
数据传输方法及装置 Download PDFInfo
- Publication number
- WO2016029790A1 WO2016029790A1 PCT/CN2015/086479 CN2015086479W WO2016029790A1 WO 2016029790 A1 WO2016029790 A1 WO 2016029790A1 CN 2015086479 W CN2015086479 W CN 2015086479W WO 2016029790 A1 WO2016029790 A1 WO 2016029790A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- client
- database
- data
- thread
- network event
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
Definitions
- the present invention relates to the field of computer technologies, and in particular, to a data transmission method and apparatus.
- a middleware (a data transfer device) is usually disposed between the database and the client to manage the connection interaction between the database and a large number of clients, and provide data services for each client, that is, the client.
- the data is transmitted between the terminal and the database through middleware.
- the middleware contains multiple threads that provide data services. Each thread is assigned to a client to provide data services for the client. When a thread receives a client's data request, the thread requests the data. Forward to the database and wait for the result of the database processing the data request, after which the thread feeds the result back to the client that issued the data request.
- the database will receive a large number of data requests, and the number of data requests processed in parallel is limited. That is, after the thread forwards the data request to the database, the data request may be in the waiting queue, and the database processes the data request itself. It takes a certain amount of time (a few seconds to tens of seconds), and it is not possible to generate processing results immediately. During this time, the thread will remain in a wait state (in this state, the thread cannot process other services) until receiving After the result of the processing of the feedback to the database, the result can be forwarded to the client, and then the data service can be provided to other clients or other services can be processed. Therefore, the waste of the thread resources is caused, and the thread utilization is also low.
- the present invention has been made in order to provide a data transmission method and apparatus that overcomes the above problems or at least partially solves the above problems, and can effectively save the existing client and database in the process of data communication. Threads that improve thread utilization.
- a data transmission method for data transmission between a client and a server through an intermediate device, the method comprising:
- the middleware allocates a first thread to the client and the database, so that the client and the database transmit data through the first thread;
- the middleware releases the first thread after the first thread completes the transmission of the data
- a data transmission apparatus for data transmission between a client and a server, the apparatus comprising: a first distribution module, a release module, a monitoring module, and a second distribution module, among them,
- the first allocating module is configured to allocate a first thread to the client and the database, so that the client and the database transmit data through the first thread;
- the releasing module is configured to release the first thread after the first thread completes the transmission of the data
- the monitoring module is configured to listen to network events of the client and the database
- the second allocation module is configured to re-allocate the second thread to the client and the database after listening to the specified network event.
- a computer program comprising computer readable code that, when executed on a computing device, causes the computing device to perform data transmission according to the above method.
- a computer readable medium storing the above computer program is provided.
- the middleware allocates the first thread to send data to the client or the database
- the first thread is released, and the first thread is turned into an idle state for allocation to other clients or processing.
- the middleware will re-allocate the second thread for the client and the database to transfer data after the specified network event occurs between the client and the database, thereby saving the limited amount of middleware.
- Thread resources provide data services for data transfer between the client and the database, and also effectively improve thread utilization.
- FIG. 1 is a schematic flow chart of a data transmission method according to an embodiment of the present invention.
- FIGS. 2 to 5 are schematic diagrams showing a connection structure of a client, a middleware, and a database in an actual application scenario according to an embodiment of the present invention
- FIG. 6 is a schematic structural diagram of a data transmission apparatus according to an embodiment of the present invention.
- Figure 7 is a schematic block diagram showing a computing device for performing a data transmission method in accordance with the present invention.
- Fig. 8 schematically shows a storage unit for holding or carrying program code implementing the data transmission method according to the present invention.
- FIG. 1 is a data transmission method according to an embodiment of the present invention.
- a client and a server are connected through a middleware, and the method may include the following steps:
- S101 The middleware allocates a first thread to the client and the database, so that the client and the database transmit data through the first thread.
- S103 Monitor network events of the client and the database.
- S104 Re-allocate the second thread to the client and the database after listening to the specified network event.
- the middleware after the middleware allocates the first thread to send data to the client or the database, the first thread is released, and the first thread is turned into an idle state for allocation to other clients or Processing other services, at the same time, the middleware will re-allocate the second thread for data transfer between the client and the database after listening to the specified network event between the client and the database, thereby saving not only the middleware.
- the thread resource provides data services for data transfer between the client and the database, and also effectively improves the utilization of the thread.
- the data includes: first data sent by the client to the database, or second data sent by the database to the client.
- the first data sent by the client may specifically be different types of data requests, such as: reading data requests and writing data requests, or file data uploaded to the database, backup data, and the like.
- the second data sent by the database may specifically be update data, file data, backup data, and the like pushed to the client.
- the first data and the second data are transmitted by the first thread allocated by the middleware.
- the first data needs to be processed.
- the same database may connect multiple clients at the same time through the middleware.
- the database will process multiple data sent by multiple clients at the same time, and the database is limited by the hardware conditions of the database itself.
- the limited amount of data processed in parallel causes the data to wait in the database.
- the processing of the second data also takes a certain time, which causes the second data to enter the waiting state in the client.
- step S102 in order to improve the data transmission efficiency, once the middleware monitors that the allocated first thread has sent the data to the database or the client, the middleware immediately releases the first thread, so that the middle thread The first thread is idle to handle other data traffic.
- the middleware after the middleware sends the first data to the database, or sends the second data to the client, the client or the database processes the received data, and after processing the data, A response is generated and the corresponding response data is sent, ie the corresponding network event occurs at the client or the database.
- the middleware needs to monitor the network events of the client and the database after completing the transmission of the first data and the second data.
- a plurality of network events occur in the client and the database, and not all network events are related to the middleware allocation thread.
- the network event that the client establishes a connection to the database is not caused by The middleware allocates threads to complete the establishment of the connection. Therefore, in the foregoing step S103, the middleware needs to listen to the specified network event related to the data transmission, where the specified network event includes: the database generates a network event of the first response data according to the first data, or The client generates a network event of the second response data according to the second data.
- a network event in which the database generates the first response data according to the first data when a network event in which the database generates the first response data according to the first data occurs, it indicates that the database has processed and generated a response after receiving the first data sent by the client.
- the client issues a download request (ie, the first data), and the first thread allocated by the middleware sends the download request to the database, and the database receives the download request.
- the data corresponding to the download request is retrieved, and the data is the response made by the database according to the download request, that is, the first response data.
- the network event of the second response data generated by the client according to the second data when the network event of the second response data generated by the client according to the second data occurs, it indicates that the client processes and generates a response after receiving the second data sent by the database, and the client generates a response.
- the data is the second response data.
- the first response data may be, for example, data corresponding to the first data generated by the database according to the first data sent by the client, such as: download data corresponding to the download request, query result data corresponding to the query request, and the like.
- the second response data may be, for example, data corresponding to the second data generated by the client according to the second data sent by the database, such as authentication data fed back by the client according to the security instruction data of the database.
- the method may include: when listening to the network event that the database generates the first response data according to the first data, the middleware is re-initiated as the client And the database allocates a second thread, so that the database transmits the first response data to the client by the redistributed second thread, or when the client is monitored to generate the according to the second data
- the middleware re-allocates the second thread to the client and the database, and causes the client to transmit the second response data to the database through the redistributed second thread.
- a storage space appears. (eg, cache) saturation, in this case, the client or database can no longer receive externally sent data, but need to wait for the current data processing to complete, then receive the data, then, if on the client or
- the middleware sends the first response data to the client or sends the second response data to the database, which will inevitably lead to the transmission failure. Therefore, the middleware also needs to monitor the storage space of the client or the database.
- the specified network event in the embodiment of the present invention includes: in addition to the network event that the database generates the first response data according to the first data and the network event that the client generates the second response data according to the second data, the method further includes: The client or database storage space is not saturated with network events.
- the method may include: when listening to the network event that the database generates the first response data according to the first data, and the storage space of the client is not saturated When the network event occurs, the middleware re-allocates the second thread to the client and the database, so that the database transmits the first response data to the client through the redistributed second thread, or when listening The customer And generating, by the terminal, a network event of the second response data according to the second data, and a network event in which the storage space of the database is not saturated, the middleware re-allocating the second thread to the client and the database, so that the The client transmits the second response data to the database through the reassigned second thread.
- the re-allocating the second thread to the client and the database in step S104 specifically includes: using the first thread used by the client and the database to transmit the data as the second thread, Reassigned to the client and database.
- the client, middleware and database connection architecture wherein the database is a MySQL database, the client C1 ⁇ C4 are simultaneously connected to the MySQL database through the middleware, the client C1 ⁇
- the data between C4 and the MySQL database is transmitted through the thread allocated by the middleware, and the connection between the client C1 and C4 and the middleware and the middleware and the MySQL database is based on the TCP protocol.
- the four clients C1 to C4 in the figure respectively perform data transmission with the MySQL database according to the numbering sequence, and the dotted line indicates that the connection has been established, but no data transmission is performed.
- client C1 wants to query the data in the MySQL database, including the steps:
- Step 1 The middleware allocates a thread TR1 to the client C1 and the MySQL database, and transmits a query request sent by the client C1 to the MySQL database through the thread TR1.
- Step 2 After the thread TR1 transmits the query request to the MySQL database, the middleware releases the thread TR1.
- Step 3 The middleware listens for the specified network event between the client C1 and the MySQL database.
- Step 4 When the MySQL database is listened to generate corresponding query result data according to the query request, and the storage space of the client C1 is not saturated, the middleware re-assigns the second thread to the client C1 and the MySQL database to make the MySQL database.
- the query result data is transmitted to the client C1 through the reassigned second thread.
- the query request sent by the client C1 is the first data, and the query request sent by the client C1 may be a query request based on a Structured Query Language (SQL), for example, if the client If C1 wants to query a certain data in a certain data table in the MySQL database, the query request of the client C1 adopts the statement of "SELECT data item name FROM data table name". Of course, this does not constitute a limitation of the present invention. .
- SQL Structured Query Language
- the middleware After the client C1 establishes a connection with the MySQL database, the middleware automatically allocates a thread to provide a data transmission service between the client C1 and the MySQL database, that is, transmits the first data sent by the client C1 to the MySQL database, or The second data sent by the MySQL database to the client C1.
- the thread allocated by the middleware is the first thread, that is, the thread TR1.
- the middleware can release the already allocated thread TR1, so that the thread TR1 is another client.
- the data transmission service is performed at the end.
- the middleware listens to the specified network event of the client C1 and the MySQL database.
- the middleware allocates the thread TR1 for the client C1 and the MySQL database to transmit data. .
- the middleware can dynamically set the time according to the number of idle threads that can be allocated, in the freely assignable When the number of threads is large, you can extend the time, otherwise shorten the time.
- the setting of time herein does not constitute a limitation of the present invention.
- the specified network event includes: a network event in which the MySQL database generates the query result data according to the query request sent by the client C1, and a network event in which the storage space of the client C1 is not saturated.
- the query result data here is the first response data.
- the second thread re-allocated between the client C1 and the MySQL database is still the thread TR1, because the thread TR1 is in the client C1.
- the thread TR1 is provided with parameters related to the client C1, such as the Internet Protocol (IP) address of the client C1, the transmission port number, etc., so the reallocation is reallocated.
- IP Internet Protocol
- the middleware selects any thread in the idle state as the second thread in the threads TR2 ⁇ 4, and reassigns it to the client C1 and MySQL database.
- client C2 wants to read data from the MySQL database, including the steps:
- Step 1 The middleware allocates a thread TR2 for the client C2 and the MySQL database, and transmits the read request issued by the client C2 to the MySQL database through the thread TR2.
- Step 2 After the thread TR2 transfers the read request to the MySQL database, the middleware releases Put the thread TR2.
- Step 3 The middleware listens for the specified network event between the client C2 and the MySQL database.
- Step 4 When the MySQL database is listened to generate a network event corresponding to the read result data according to the read request, but the network event of the client C2 storage space is not monitored, the middleware is not the client C2 and the MySQL database. Reassign the second thread and continue to listen for network events that are not saturated with client C2's storage space.
- Step 5 When monitoring the network event of the client C2 storage space is not saturated, the middleware re-allocates the second thread to the client C2 and the MySQL database, so that the MySQL database transmits the read result data through the redistributed second thread. To the client C2.
- the read request sent by the client C2 is the first data
- the read result data generated by the MySQL database according to the read request is the first response data.
- the specified network event includes: a network event in which the MySQL database generates the read result data according to the read request sent by the client C2, and a network event in which the storage space of the client C2 is not saturated.
- the MySQL database After the MySQL database generates the read result data according to the read request sent by the client C2, the MySQL database notifies the middleware that the read result data can be transmitted. However, if the storage space of the client C2 is saturated, the transmission of the read result data will fail. If the middleware does not listen to the network event of the client C2 whose storage space is not saturated, it indicates that the storage space of the client C2 is saturated and cannot receive the read result data of the transmission, so in the fourth step, the middleware is in the waiting state. And will not redistribute the second thread. Only when the middleware simultaneously listens to the above two network events, the second thread is re-allocated, and the read result data is transmitted to the client C2, that is, the above step 5.
- the second thread that the middleware reassigns between the client C2 and the MySQL database is still the thread TR2.
- the MySQL database sends the security command data to the client C3 to determine whether the client C3 is an authentication client, and the steps include:
- Step 1 The middleware allocates a thread TR3 for the MySQL database and the client C3, and transmits the security instruction data sent by the MySQL database to the client C3 through the thread TR3.
- Step 2 After the thread TR3 transmits the security instruction data to the client C3, the middleware releases the thread TR3.
- Step 3 The middleware listens to the specified network between the MySQL database and the client C3. Pieces.
- Step 4 When the client C3 is detected to generate the corresponding identity authentication data according to the security instruction data and the network event of the MySQL database storage space is not saturated, the middleware re-allocates the second thread to the MySQL database and the client C3, so that the client C3 transmits the authentication data to the MySQL database through the reassigned second thread.
- the security command data sent by the MySQL database is the second data
- the identity authentication data generated by the client C1 according to the security command data is the second response data.
- the specified network event includes: a network event in which the client C3 generates identity authentication data according to the security instruction data sent by the MySQL database, and a network event in which the storage space of the MySQL database is not saturated.
- the second thread that the middleware reassigns between the MySQL database and the client C3 is still the thread TR3.
- the MySQL database pushes the update data to the client C4, specifically including the steps:
- Step 1 The middleware allocates the thread TR4 to the MySQL database and the client C4, and transmits the updated data sent by the MySQL database to the client C4 through the thread TR4.
- Step 2 After the thread TR4 transmits the update data to the client C4, the middleware releases the thread TR4.
- Step 3 The middleware listens for the specified network event between the MySQL database and the client C4.
- Step 4 When the network time of the corresponding update feedback data is generated by the client C4 according to the update data, but the network event of the MySQL database storage space is not monitored, the middleware is not reallocated for the MySQL database and the client C4. The second thread continues to listen to MySQL database storage space for unsaturated network events.
- Step 5 When the network event of the MySQL database storage space is not saturated, the middleware re-allocates the second thread to the MySQL database and the client C4, so that the client C4 transmits the update feedback data to the second thread through the reassignment. MySQL database.
- the update data sent by the MySQL database is the second data
- the update feedback data generated by the client C1 according to the update data is the second response data.
- the specified network event includes: a network event in which the client C4 generates update feedback data according to the update data sent by the MySQL database, and a network event in which the storage space of the MySQL database is not saturated.
- the client C4 After the client C4 generates the update feedback data according to the update data sent by the MySQL database, the client C4 notifies the middleware that the update feedback data can be transmitted. However, if the storage space is saturated in the MySQL database, the transmission of the update feedback data will fail. The middleware does not listen to the MySQL database storage space is not saturated network events, it indicates that the MySQL database storage space is saturated, can not receive the transmitted update feedback data, so in the fourth step, the middleware is in a waiting state, nor The second thread is reassigned, and the second thread is reassigned only when the middleware simultaneously listens to the above two network events, and the update feedback data is transmitted to the MySQL database, that is, step 5 above.
- the second thread re-allocated between the middleware for the MySQL database and the client C4 is still the thread TR4.
- the client may suddenly go offline due to power failure, network congestion, etc. If the middleware detects such a situation, the client may be offline as a special cause.
- the network event is processed, that is, the client has transmitted the corresponding data through the thread allocated by the middleware, and then the middleware monitors that the client is suddenly offline, and continues to allocate the thread to transfer data according to the state of the data processing.
- the middleware monitors that the client is suddenly offline, and continues to allocate the thread to transfer data according to the state of the data processing.
- Figure 2 as an example: after the client C1 transmits the query request to the MySQL database through the thread TR1 allocated by the middleware, the MySQL database processes the query request, the middleware releases the thread TR1, and the middleware listens to the client C1. Network events between the MySQL database and the MySQL database.
- the middleware listens to the network event that the client C1 suddenly goes offline, and the MySQL database has generated the corresponding query result data according to the query request of the client C1, and the middleware also listens to the MySQL database to generate the query result data.
- the network event then, the middleware will still allocate a second thread, transfer the query result data to the middleware itself for caching, and then the middleware releases the second thread to listen to the network event that the client C1 is back online.
- the middleware reassigns the third thread to send the cached query result data to the client C1.
- the second thread and the third thread allocated by the above middleware are the first thread assigned to the client C1 and the MySQL database, that is, the thread TR1.
- the embodiment of the present invention further provides a data transmission apparatus, as shown in FIG. 6.
- the data transmission device in Figure 6 is set in the middleware for use on the client and server The data transmission is performed, and the device includes: a first distribution module 601, a release module 602, a monitoring module 603, and a second distribution module 604, where
- the first allocating module 601 is configured to allocate a first thread to the client and the database, so that the client and the database transmit data through the first thread.
- the releasing module 602 is configured to release the first thread after the first thread completes the transmission of the data.
- the monitoring module 603 is configured to listen to network events of the client and the database.
- the second allocation module 604 is configured to re-allocate the second thread to the client and the database after listening to the specified network event.
- the data includes: first data sent by the client to the database, or second data sent by the database to the client.
- the specified network event includes: the database generating a network event of the first response data according to the first data, or the client generating a network event of the second response data according to the second data.
- the second allocating module 604 is specifically configured to re-allocate the client and the database when the network event of the first response data is generated according to the first data is monitored. a thread, the database is caused to transmit the first response data to the client by a redistributed second thread, or when the client is monitored to generate the second response data according to the second data, Re-assigning the second thread to the client and the database, causing the client to transmit the second response data to the database through the reassigned second thread.
- the specifying a network event further comprises: a network event in which the storage space of the client or database is not saturated.
- the second allocation module 604 is specifically configured to: when listening to the network event that the database generates the first response data according to the first data, and a network event that is not saturated by the storage space of the client Re-allocating the second thread to the client and the database, causing the database to transmit the first response data to the client through the reassigned second thread, or when listening to the client according to the
- the second data generates a network event of the second response data, and when the storage space of the database is not saturated, re-allocating the second thread to the client and the database, so that the client passes the redistributed
- the second thread transmits the second response data to the database.
- the second allocation module 604 is specifically configured to: use the first thread used by the client and the database to transmit the data as a second thread, and Assigned to the client and database.
- An embodiment of the present invention provides a thread management method and apparatus. After the middleware allocates data to a client or a database, the middleware releases the first thread, and the first thread is turned into an idle state for allocation. Give other clients or handle other services. At the same time, the middleware will re-allocate the second thread for data transfer between the client and the database after listening to the specified network event between the client and the database.
- the limited thread resources in the middleware provide data services for data transmission between the client and the database, and also effectively improve the utilization of threads.
- modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
- the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
- any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
- Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
- the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
- a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some or all of the components of a data transmission device in accordance with embodiments of the present invention.
- the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
- a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
- Figure 7 illustrates a computing device that can implement a data transfer method.
- the computing device conventionally includes a processor 710 and a computer program product or computer readable medium in the form of a memory 720.
- Memory 720 can be an electronic memory such as a flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
- Memory 720 has a memory space 730 for program code 731 for performing any of the method steps described above.
- storage space 730 for program code may include various program code 731 for implementing various steps in the above methods, respectively.
- the program code can be read from or written to one or more computer program products.
- Such computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
- Such a computer program product is typically a portable or fixed storage unit as described with reference to FIG.
- the storage unit may have storage segments, storage spaces, and the like that are similarly arranged to memory 720 in the computing device of FIG.
- the program code can be compressed, for example, in an appropriate form.
- the storage unit includes computer readable code 731', ie, code readable by a processor, such as 710, that when executed by a computing device causes the computing device to perform each of the methods described above step.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
一种数据传输方法及装置,该方法包括:中间件为客户端和数据库分配第一线程,使所述客户端和数据库通过所述第一线程传输数据(S101);所述中间件在所述第一线程完成所述数据的传输后,释放该第一线程(S102);监听所述客户端和数据库的网络事件(S103);当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程(S104)。从而,不仅节省了中间件内有限的线程资源为客户端和数据库间的数据传输提供数据服务,也有效提升了线程的利用率。
Description
本发明涉及计算机技术领域,尤其涉及一种数据传输方法及装置。
随着信息技术的发展,用户通过客户端可以访问互联网以获取所需的各类数据。互联网中各类数据存储在不同的数据库(如MySQL数据库、Oracle数据库等)中,也就是说用户通过网络途径访问相应的数据库来获取所需的数据。
在现有技术中,通常在数据库和客户端之间设置有中间件(一种数据中转设备),以管理数据库与大量客户端之间的连接交互,并为各客户端提供数据服务,即客户端与数据库之间通过中间件进行数据传输。
中间件中含有多个提供数据服务的线程,每一个线程会被分配给一个客户端,为该客户端提供数据服务,当一个线程接收了一个客户端的数据请求后,该线程会将该数据请求转发至数据库,并等待数据库对该数据请求进行处理的结果,之后,该线程再把结果反馈至发出数据请求的客户端中。
但是,数据库会接收到大量的数据请求,并行处理数据请求的数量有限,也就是说,线程将数据请求转发给数据库后,数据请求可能处于等待队列中,而且,数据库对数据请求进行处理本身会需要一定的时间(几秒至几十秒不等),不能够立刻就生成处理结果,那么在这段时间中,线程会一直处于等待状态(该状态下,线程不能处理其他业务),直到接收到数据库反馈的处理的结果,再将该结果转发至客户端后,才能为其他客户端提供数据服务或处理其他业务,因此,造成了线程资源的浪费,也导致了线程利用率低。
发明内容
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的数据传输方法及装置,能够有效节约现有的客户端和数据库之间在进行数据通信的过程中所使用的线程,提升了线程的利用率。
根据本发明的一方面,提出一种数据传输方法,用于在客户端与服务器之间通过中间件进行数据传输,该方法包括:
所述中间件为所述客户端和数据库分配第一线程,使所述客户端和数据库通过所述第一线程传输数据;
所述中间件在所述第一线程完成所述数据的传输后,释放该第一线程;
监听所述客户端和数据库的网络事件;
当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程。
根据本发明的另一方面,还提出一种数据传输装置,用于在客户端和服务器之间进行数据传输,所述装置包括:第一分配模块、释放模块、监听模块以及第二分配模块,其中,
所述第一分配模块,用于为所述客户端和数据库分配第一线程,使所述客户端和数据库通过所述第一线程传输数据;
所述释放模块,用于在所述第一线程完成所述数据的传输后,释放该第一线程;
所述监听模块,用于监听所述客户端和数据库的网络事件;
所述第二分配模块,用于当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程。
根据本发明的又一方面,提供了一种计算机程序,其包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行根据上文所述的数据传输方法。
根据本发明的再一方面,提供了一种计算机可读介质,其中存储了上述的计算机程序。
本发明的有益效果为:
根据本发明提供的线程管理方法,中间件分配第一线程将数据发送至客户端或数据库之后,便释放该第一线程,使该第一线程转变为空闲状态,以便分配给其他客户端或处理其他业务,同时,中间件会在监听到客户端和数据库之间出现指定的网络事件后,为客户端和数据库重新分配第二线程以进行数据的传输,从而,不仅节省了中间件内有限的线程资源为客户端和数据库间的数据传输提供数据服务,也有效提升了线程的利用率。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1为依据本发明一个实施例的数据传输方法流程示意图;
图2至5分别为依据本发明一个实施例在实际应用场景中客户端、中间件以及数据库的连接架构示意图;
图6为依据本发明一个实施例的数据传输装置结构示意图;
图7示意性地示出了用于执行根据本发明的数据传输方法的计算设备的框图;以及
图8示意性地示出了用于保持或者携带实现根据本发明的数据传输方法的程序代码的存储单元。
下面结合附图和具体的实施方式对本发明作进一步的描述。
图1为依据本发明一个实施例的数据传输方法,该实施例中客户端与服务器通过中间件相连接,可以包括步骤:
S101:所述中间件为所述客户端和数据库分配第一线程,使所述客户端和数据库通过所述第一线程传输数据。
S102:所述中间件在所述第一线程完成所述数据的传输后,释放该第一线程。
S103:监听所述客户端和数据库的网络事件。
S104:当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程。
从上述可知,在该实施例中,中间件分配第一线程将数据发送至客户端或数据库之后,便释放该第一线程,使该第一线程转变为空闲状态,以便分配给其他客户端或处理其他业务,同时,中间件会在监听到客户端和数据库之间出现指定的网络事件后,为客户端和数据库重新分配第二线程以进行数据的传输,从而,不仅节省了中间件内有限的线程资源为客户端和数据库间的数据传输提供数据服务,也有效提升了线程的利用率。
依据本发明的一个实施例,所述数据包括:所述客户端向所数据库发送的第一数据,或,所述数据库向所述客户端发送的第二数据。其中,
客户端发出的第一数据具体可以是不同类型的数据请求,如:读数据请求和写数据请求,也可以是上传至数据库的文件数据、备份数据等。数据库发出的第二数据具体可以是推送至客户端的更新数据、文件数据、备份数据等。
所述的第一数据和第二数据由所述中间件分配的第一线程完成传输,在实际应用中,对于数据库而言,数据库在接收了第一数据后,对该第一数据进行处理需要一定的时间,另外,同一数据库可能会通过中间件同时连接多个客户端,在数据传输后,数据库将同时处理多个客户端发来的多个数据,而由于数据库自身硬件条件的限制,数据库同时并行处理数据的数量有限,就造成了数据在数据库中的等待状态。对于客户端而言,客户端在接收了第二数据后,对该第二数据的处理同样需要一定的时间,便造成了所述第二数据在该客户端中也进入等待状态。
所以,在上述步骤S102中,为了提升数据传输效率,一旦中间件监控到其所分配的第一线程已将数据发送至数据库或客户端中后,中间件便立即释放该第一线程,使该第一线程处于空闲状态,以便处理其他数据业务。
依据本发明的一个实施例,中间件将第一数据发送至数据库,或将第二数据发送至客户端后,客户端或数据库均会对接收到的数据进行处理,并且在对数据进行处理后产生响应,发送相应的响应数据,即此时客户端或数据库会出现相应的网络事件。如此一来,中间件就需要在完成第一数据和第二数据的传输后,对客户端和数据库的网络事件进行监听。
当然,依据本发明的一个实施例,客户端和数据库会出现多种网络事件,并不是所有的网络事件都与中间件分配线程有关,例如客户端向数据库建立连接的网络事件,并不会由中间件分配线程来完成连接的建立。所以在上述步骤S103中,中间件就需要监听与数据传输有关的指定网络事件,其中,所述指定网络事件包括:所述数据库根据所述第一数据生成第一响应数据的网络事件,或,所述客户端根据所述第二数据生成第二响应数据的网络事件。
具体的,当数据库根据所述第一数据生成第一响应数据的网络事件出现时,就表示数据库在接收到客户端发送的第一数据后进行了处理并产生了响应。例如:客户端发出下载请求(即第一数据),由中间件分配的第一线程将该下载请求发送至数据库,数据库在接收到该下载请求
后,调取出与该下载请求对应的数据,该数据就是数据库根据下载请求作出的响应,即第一响应数据。
同样,当客户端根据所述第二数据生成第二响应数据的网络事件出现时,就表示客户端在接收到数据库发送的第二数据后进行了处理并产生了响应,客户端作出响应而生成的数据便是第二响应数据。
其中,第一响应数据,例如可以是数据库根据客户端发出的第一数据而产生的与该第一数据对应的数据,如:与下载请求对应的下载数据、与查询请求对应的查询结果数据等。第二响应数据,例如可以是客户端根据数据库发出的第二数据而产生的与该第二数据对应的数据,如:客户端根据数据库的安全指令数据反馈的认证数据等。
依据本发明的一个实施例,对于步骤S104而言,可以包括:当监听到所述数据库根据所述第一数据生成所述第一响应数据的网络事件时,所述中间件重新为所述客户端和数据库分配第二线程,使所述数据库通过重新分配的第二线程将该第一响应数据传输至所述客户端,或者,当监听到所述客户端根据所述第二数据生成所述第二响应数据时,所述中间件重新为所述客户端和数据库分配第二线程,使所述客户端通过重新分配的第二线程将该第二响应数据传输至所述数据库。
依据本发明的另一实施例,客户端或数据库在同时处理数据时(如:数据库接收多个客户端发送的数据进行处理,或,客户端处理多个数据库发送的数据),会出现存储空间(如,缓存)饱和的情况,在这种情况下,客户端或数据库无法再接收外部发来的数据,而是需等待当前的数据处理完成后,再接收数据,那么,如果在客户端或数据库的存储空间处于饱和状态下,中间件向客户端发送第一响应数据或向数据库发送第二响应数据,必然会导致发送失败,所以,中间件还需要对客户端或数据库的存储空间进行监听。
所以,本发明实施例中所述的指定网络事件除了包括数据库根据第一数据生成第一响应数据的网络事件和客户端根据第二数据生成第二响应数据的网络事件以外,还包括:所述客户端或数据库的存储空间未饱和的网络事件。在这样的情况下,对于所述步骤S104而言,可以包括:当监听到所述数据库根据所述第一数据生成所述第一响应数据的网络事件,以及所述客户端的存储空间未饱和的网络事件时,所述中间件重新为所述客户端和数据库分配第二线程,使所述数据库通过重新分配的第二线程将该第一响应数据传输至所述客户端,或者,当监听到所述客户
端根据所述第二数据生成第二响应数据的网络事件,以及所述数据库的存储空间未饱和的网络事件时,所述中间件重新为所述客户端和数据库分配第二线程,使所述客户端通过重新分配的第二线程将该第二响应数据传输至所述数据库。
依据本发明的一个实施例,对于步骤S104中重新为所述客户端和数据库分配第二线程,具体包括:将所述客户端和数据库传输所述数据所使用的第一线程作为第二线程,重新分配给所述客户端和数据库。
结合图2至5,本发明所述的数据传输方法的具体实际应用如下:
图2至5,示出了在实际应用中,客户端、中间件以及数据库的连接架构,其中,数据库为MySQL数据库,客户端C1~C4分别通过中间件同时与MySQL数据库连接,客户端C1~C4和MySQL数据库之间的数据通过中间件分配的线程进行传输,并设定客户端C1~C4与中间件以及中间件与该MySQL数据库的连接都基于TCP协议。这里需要说明的是,图中四个客户端C1~C4分别按照编号顺序与该MySQL数据库进行数据传输,虚线表示已建立连接,但未进行数据传输。
在图2中,客户端C1想要在MySQL数据库进行数据查询,具体包括步骤:
步骤一:所述中间件为客户端C1和MySQL数据库分配线程TR1,将客户端C1发出的查询请求通过该线程TR1传输至MySQL数据库。
步骤二:线程TR1将查询请求传输至MySQL数据库后,中间件释放该线程TR1。
步骤三:中间件监听客户端C1和MySQL数据库之间的指定网络事件。
步骤四:当监听到MySQL数据库根据查询请求生成对应的查询结果数据,以及客户端C1的存储空间未饱和的网络事件时,中间件重新为客户端C1和MySQL数据库分配第二线程,使MySQL数据库通过重新分配的第二线程将查询结果数据传输至所述客户端C1。
对于上述客户端C1发出的查询请求,就是所述的第一数据,该客户端C1所发出的查询请求可以是基于结构化查询语言(Structured Query Language,SQL)的查询请求,如:若客户端C1想要查询MySQL数据库中某一数据表中的某一项数据,则该客户端C1的查询请求采用“SELECT数据项名称FROM数据表名称”的语句,当然,这里并不构成对本发明的限定。
中间件在该客户端C1与MySQL数据库建立连接后,就会自动分配一个线程为该客户端C1和MySQL数据库之间提供数据传输服务,即传输客户端C1向MySQL数据库发送的第一数据,或,该MySQL数据库向所述客户端C1发送的第二数据,此时,中间件分配的线程就是第一线程,也即线程TR1。
依据本发明的一个实施例,若客户端C1与MySQL数据库建立连接后,在预先设定的时间内并未进行传输数据,则中间件可以释放已经分配的线程TR1,使该线程TR1为其他客户端进行数据传输服务。中间件监听该客户端C1和MySQL数据库的指定网络事件,当监听到该客户端C1和MySQL数据库之间进行数据传输时,中间件再为该客户端C1和MySQL数据库分配线程TR1,以传输数据。对于上述预先设定的时间,将由中间件进行设定,而且,在一种可行的方式下,中间件可以根据可分配的空闲线程的数量对该时间进行动态的设定,在可分配的空闲线程数量较多时,可以延长该时间,否则缩短该时间。当然,这里对时间的设定并不构成对本发明的限定。
对于上述步骤三,指定的网络事件包括:MySQL数据库根据客户端C1发送的查询请求生成查询结果数据的网络事件,以及,客户端C1的存储空间未饱和的网络事件。其中,这里的查询结果数据就是第一响应数据。
这里需要说明的是,在步骤四中,作为一种优选方式,中间件为客户端C1和MySQL数据库之间重新分配的第二线程仍为线程TR1,这是因为该线程TR1在将客户端C1的查询数据传输至MySQL数据库的过程中,该线程TR1内设置有与该客户端C1相关的参数,如:客户端C1的互联网协议(Internet Protocol,IP)地址、传输端口号等,故重新分配该线程TR1时,无需再次设置相关的参数。但若该线程TR1在传输完查询请求释放后,分配给了其他客户端,则中间件会在线程TR2~4中选择任一处于空闲状态的线程作为第二线程,重新分配给客户端C1和MySQL数据库。
在图3中,客户端C2想要从MySQL数据库中进行数据读取,具体包括步骤:
步骤一:所述中间件为客户端C2和MySQL数据库分配线程TR2,将客户端C2发出的读取请求通过该线程TR2传输至MySQL数据库。
步骤二:线程TR2将读取请求传输至MySQL数据库后,中间件释
放该线程TR2。
步骤三:中间件监听客户端C2和MySQL数据库之间的指定网络事件。
步骤四:当监听到MySQL数据库根据读取请求生成对应的读取结果数据的网络事件,但未监听到客户端C2的存储空间未饱和的网络事件时,中间件不为客户端C2和MySQL数据库重新分配第二线程,并继续监听客户端C2的存储空间未饱和的网络事件。
步骤五:当监听到客户端C2的存储空间未饱和的网络事件时,中间件重新为客户端C2和MySQL数据库分配第二线程,使MySQL数据库通过重新分配的第二线程将读取结果数据传输至所述客户端C2。
上述客户端C2发出的读取请求,就是所述的第一数据,MySQL数据库根据该读取请求所生成的读取结果数据就是所述的第一响应数据。
对于上述步骤三,指定的网络事件包括:MySQL数据库根据客户端C2发送的读取请求生成读取结果数据的网络事件,以及,客户端C2的存储空间未饱和的网络事件。
在MySQL数据库根据客户端C2发送的读取请求生成读取结果数据后,MySQL数据库会通知中间件,表明该读取结果数据可以进行传输。但是若客户端C2出现存储空间饱和的情况,则将导致读取结果数据的传输失败。中间件未监听到客户端C2的存储空间未饱和的网络事件,就表明该客户端C2的存储空间已经饱和,不能再接收传输的读取结果数据,所以在步骤四中,中间件处于等待状态,也不会重新分配第二线程。只有在中间件同时监听到上述两种网络事件时,才会重新分配第二线程,将该读取结果数据传输至客户端C2,即上述步骤五。
对于上述步骤五,优选地,中间件为客户端C2和MySQL数据库之间重新分配的第二线程仍为线程TR2。
在图4中,客户端C3与MySQL数据库连接后,该MySQL数据库向该客户端C3发送安全指令数据,以确定该客户端C3是否为认证客户端,具体包括步骤:
步骤一:所述中间件为MySQL数据库和客户端C3分配线程TR3,将MySQL数据库发出的安全指令数据通过该线程TR3传输至客户端C3。
步骤二:线程TR3将安全指令数据传输至客户端C3后,中间件释放该线程TR3。
步骤三:中间件监听MySQL数据库和客户端C3之间的指定网络事
件。
步骤四:当监听到客户端C3根据安全指令数据生成对应的身份认证数据以及MySQL数据库的存储空间未饱和的网络事件时,中间件重新为MySQL数据库和客户端C3分配第二线程,使客户端C3通过重新分配的第二线程将身份认证数据传输至MySQL数据库。
上述MySQL数据库发出的安全指令数据,就是所述的第二数据,客户端C1根据该安全指令数据所生成的身份认证数据就是所述的第二响应数据。
对于上述步骤三,指定的网络事件包括:客户端C3根据MySQL数据库发送的安全指令数据生成身份认证数据的网络事件,以及,MySQL数据库的存储空间未饱和的网络事件。
对于上述步骤四,优选地,中间件为MySQL数据库和客户端C3之间重新分配的第二线程仍为线程TR3。
在图5中,客户端C4与MySQL数据库连接后,该MySQL数据库向该客户端C4推送更新数据,具体包括步骤:
步骤一:所述中间件为MySQL数据库和客户端C4分配线程TR4,将MySQL数据库发出的更新数据通过该线程TR4传输至客户端C4。
步骤二:线程TR4将更新数据传输至客户端C4后,中间件释放该线程TR4。
步骤三:中间件监听MySQL数据库和客户端C4之间的指定网络事件。
步骤四:当监听到客户端C4根据更新数据生成对应的更新反馈数据的网络时间,但未监听到MySQL数据库的存储空间未饱和的网络事件时,中间件不为MySQL数据库和客户端C4重新分配第二线程,并继续监听MySQL数据库的存储空间未饱和的网络事件。
步骤五,当监听到MySQL数据库的存储空间未饱和的网络事件时,中间件重新为MySQL数据库和客户端C4分配第二线程,使客户端C4通过重新分配的第二线程将更新反馈数据传输至MySQL数据库。
上述MySQL数据库发出的更新数据,就是所述的第二数据,客户端C1根据该更新数据所生成的更新反馈数据就是所述的第二响应数据。
对于上述步骤三,指定的网络事件包括:客户端C4根据MySQL数据库发送的更新数据生成更新反馈数据的网络事件,以及,MySQL数据库的存储空间未饱和的网络事件。
在客户端C4根据MySQL数据库发送的更新数据生成更新反馈数据后,客户端C4会通知中间件,表明该更新反馈数据可以进行传输。但是若MySQL数据库出现存储空间饱和的情况,则将导致更新反馈数据的传输失败。中间件未监听到MySQL数据库的存储空间未饱和的网络事件,就表明该MySQL数据库的存储空间已经饱和,不能再接收传输的更新反馈数据,所以在步骤四中,中间件处于等待状态,也不会重新分配第二线程,只有在中间件同时监听到上述两种网络事件时,才会重新分配第二线程,将该更新反馈数据传输至MySQL数据库,即上述步骤五。
对于上述步骤五,优选地,中间件为MySQL数据库和客户端C4之间重新分配的第二线程仍为线程TR4。
在上述实际应用场景中,可能会出现由于断电、网络拥塞等原因造成的客户端突然离线的情况,如果中间件监听到这样的情况出现,会将由此原因造成的客户端离线作为一种特殊的网络事件进行处理,即,客户端已将相应的数据通过中间件分配的线程进行传输,那么,中间件监听到该客户端突然离线,也会根据数据处理的状态继续分配线程传输数据。以图2为例:客户端C1通过中间件分配的线程TR1将查询请求传输至MySQL数据库后,MySQL数据库会对该查询请求进行处理,该中间件释放该线程TR1,中间件会监听客户端C1和MySQL数据库之间的网络事件。此时,中间件监听到该客户端C1突然离线的网络事件,而MySQL数据库已经根据该客户端C1的查询请求生成了对应的查询结果数据,中间件也会监听到MySQL数据库生成了查询结果数据的网络事件,那么,中间件仍会分配第二线程,将该查询结果数据传输至该中间件自身进行缓存,然后中间件再释放该第二线程,监听客户端C1重新上线的网络事件。一旦监听到该客户端C1重新上线,且连接到该中间件时,该中间件再分配第三线程将缓存的查询结果数据发送至客户端C1中。这样一来,即使客户端C1重新上线,也不需要向MySQL数据库发出请求重新获取查询结果数据,而是由中间件直接分配线程将查询结果数据传输至该客户端C1中,有效增加了数据传输的效率及便捷性。
当然,上述中间件分配的第二线程和第三线程,在优选方式下,是分配给该客户端C1和MySQL数据库的第一线程,即线程TR1。
以上为本发明实施例提供的数据传输方法,基于同样的思路,本发明实施例还提供一种数据传输装置,如图6所示。
图6中的数据传输装置,设置在中间件中,用于在客户端和服务器
之间进行数据传输,所述装置包括:第一分配模块601、释放模块602、监听模块603以及第二分配模块604,其中,
所述第一分配模块601,用于为所述客户端和数据库分配第一线程,使所述客户端和数据库通过所述第一线程传输数据。
所述释放模块602,用于在所述第一线程完成所述数据的传输后,释放该第一线程。
所述监听模块603,用于监听所述客户端和数据库的网络事件。
所述第二分配模块604,用于当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程。
在本发明的一个实施例中,所述数据包括:所述客户端向所数据库发送的第一数据,或,所述数据库向所述客户端发送的第二数据。所述指定网络事件包括:所述数据库根据所述第一数据生成第一响应数据的网络事件,或,所述客户端根据所述第二数据生成第二响应数据的网络事件。
具体地,所述第二分配模块604,具体用于:当监听到所述数据库根据所述第一数据生成所述第一响应数据的网络事件时,重新为所述客户端和数据库分配第二线程,使所述数据库通过重新分配的第二线程将该第一响应数据传输至所述客户端,或者,当监听到所述客户端根据所述第二数据生成所述第二响应数据时,重新为所述客户端和数据库分配第二线程,使所述客户端通过重新分配的第二线程将该第二响应数据传输至所述数据库。
在本发明的另一个实施例中,所述指定网络事件还包括:所述客户端或数据库的存储空间未饱和的网络事件。
具体地,所述第二分配模块604,具体用于:当监听到所述数据库根据所述第一数据生成所述第一响应数据的网络事件,以及所述客户端的存储空间未饱和的网络事件时,重新为所述客户端和数据库分配第二线程,使所述数据库通过重新分配的第二线程将该第一响应数据传输至所述客户端,或者,当监听到所述客户端根据所述第二数据生成第二响应数据的网络事件,以及所述数据库的存储空间未饱和的网络事件时,重新为所述客户端和数据库分配第二线程,使所述客户端通过重新分配的第二线程将该第二响应数据传输至所述数据库。
在本发明的一个实施例中,所述第二分配模块604具体用于:将所述客户端和数据库传输所述数据所使用的第一线程作为第二线程,重新
分配给所述客户端和数据库。
本发明实施例提供一种线程管理方法及装置,该方法中间件分配第一线程将数据发送至客户端或数据库之后,便释放该第一线程,使该第一线程转变为空闲状态,以便分配给其他客户端或处理其他业务,同时,中间件会在监听到客户端和数据库之间出现指定的网络事件后,为客户端和数据库重新分配第二线程以进行数据的传输,从而,不仅节省了中间件内有限的线程资源为客户端和数据库间的数据传输提供数据服务,也有效提升了线程的利用率。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术
人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的数据传输装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
例如,图7示出了可以实现数据传输方法的计算设备。该计算设备传统上包括处理器710和以存储器720形式的计算机程序产品或者计算机可读介质。存储器720可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器720具有用于执行上述方法中的任何方法步骤的程序代码731的存储空间730。例如,用于程序代码的存储空间730可以包括分别用于实现上面的方法中的各种步骤的各个程序代码731。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图8所述的便携式或者固定存储单元。该存储单元可以具有与图7的计算设备中的存储器720类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括计算机可读代码731’,即可以由例如诸如710之类的处理器读取的代码,这些代码当由计算设备运行时,导致该计算设备执行上面所描述的方法中的各个步骤。
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
此外,还应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。
Claims (12)
- 一种数据传输方法,用于在客户端与服务器之间通过中间件进行数据传输,所述方法包括:所述中间件为所述客户端和数据库分配第一线程,使所述客户端和数据库通过所述第一线程传输数据;所述中间件在所述第一线程完成所述数据的传输后,释放该第一线程;监听所述客户端和数据库的网络事件;当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程。
- 如权利要求1所述的方法,其中,所述数据包括:所述客户端向所述数据库发送的第一数据,或,所述数据库向所述客户端发送的第二数据;所述指定网络事件包括:所述数据库根据所述第一数据生成第一响应数据的网络事件,或,所述客户端根据所述第二数据生成第二响应数据的网络事件。
- 如权利要求2所述的方法,其中,当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程,具体包括:当监听到所述数据库根据所述第一数据生成所述第一响应数据的网络事件时,所述中间件重新为所述客户端和数据库分配第二线程,使所述数据库通过重新分配的第二线程将该第一响应数据传输至所述客户端;或者当监听到所述客户端根据所述第二数据生成所述第二响应数据时,所述中间件重新为所述客户端和数据库分配第二线程,使所述客户端通过重新分配的第二线程将该第二响应数据传输至所述数据库。
- 如权利要求2所述的方法,其中,所述指定网络事件还包括:所述客户端或数据库的存储空间未饱和的网络事件;当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程,具体包括:当监听到所述数据库根据所述第一数据生成所述第一响应数据的网络事件,以及所述客户端的存储空间未饱和的网络事件时,所述中间件重新为所述客户端和数据库分配第二线程,使所述数据库通过重新分配的第二线程将该第一响应数据传输至所述客户端;或者当监听到所述客户端根据所述第二数据生成第二响应数据的网络事件,以及所述数据库的存储空间未饱和的网络事件时,所述中间件重新为所述客户端和数据库分配第二线程,使所述客户端通过重新分配的第 二线程将该第二响应数据传输至所述数据库。
- 如权利要求1至4中任一所述的方法,其中,重新为所述客户端和数据库分配第二线程,具体包括:将所述客户端和数据库传输所述数据所使用的第一线程作为第二线程,重新分配给所述客户端和数据库。
- 一种数据传输装置,用于在客户端和服务器之间进行数据传输,所述装置包括:第一分配模块、释放模块、监听模块以及第二分配模块,其中,所述第一分配模块,用于为所述客户端和数据库分配第一线程,使所述客户端和数据库通过所述第一线程传输数据;所述释放模块,用于在所述线程完成所述数据的传输后,释放该第一线程;所述监听模块,用于监听所述客户端和数据库的网络事件;所述第二分配模块,用于当监听到指定网络事件后,重新为所述客户端和数据库分配第二线程。
- 如权利要求6所述的装置,其中,所述数据包括:所述客户端向所述数据库发送的第一数据,或,所述数据库向所述客户端发送的第二数据;所述指定网络事件包括:所述数据库根据所述第一数据生成第一响应数据的网络事件,或,所述客户端根据所述第二数据生成第二响应数据的网络事件。
- 如权利要求7所述的装置,其中,所述第二分配模块,具体用于:当监听到所述数据库根据所述第一数据生成所述第一响应数据的网络事件时,重新为所述客户端和数据库分配第二线程,使所述数据库通过重新分配的第二线程将该第一响应数据传输至所述客户端;或者当监听到所述客户端根据所述第二数据生成所述第二响应数据时,重新为所述客户端和数据库分配第二线程,使所述客户端通过重新分配的第二线程将该第二响应数据传输至所述数据库。
- 如权利要求7所述的装置,其中,所述指定网络事件还包括:所述客户端或数据库的存储空间未饱和的网络事件;所述第二分配模块,具体用于:当监听到所述数据库根据所述第一数据生成所述第一响应数据的网络事件,以及所述客户端的存储空间未饱和的网络事件时,重新为所述客户端和数据库分配第二线程,使所述数据库通过重新分配的第二线程将该第一响应数据传输至所述客户端;或者当监听到所述客户端根据所述第二数据生成第二响应数据的网络事件,以及所述数据库的存储空间未饱和的网络事件时,重新为所述客户 端和数据库分配第二线程,使所述客户端通过重新分配的第二线程将该第二响应数据传输至所述数据库。
- 如权利要求6至9中任一所述的装置,其中,所述第二分配模块,具体用于:将所述客户端和数据库传输所述数据所使用的第一线程作为第二线程,重新分配给所述客户端和数据库。
- 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行根据权利要求1至5任一项所述的数据传输方法。
- 一种计算机可读介质,其中存储了如权利要求11所述的计算机程序。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410433031.6 | 2014-08-28 | ||
CN201410433031.6A CN105373420B (zh) | 2014-08-28 | 2014-08-28 | 数据传输方法及装置 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2016029790A1 true WO2016029790A1 (zh) | 2016-03-03 |
Family
ID=55375645
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2015/086479 WO2016029790A1 (zh) | 2014-08-28 | 2015-08-10 | 数据传输方法及装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN105373420B (zh) |
WO (1) | WO2016029790A1 (zh) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112052227A (zh) * | 2020-09-25 | 2020-12-08 | 郑州阿帕斯数云信息科技有限公司 | 数据变更日志的处理方法、装置和电子设备 |
CN113296974A (zh) * | 2020-08-31 | 2021-08-24 | 阿里巴巴集团控股有限公司 | 数据库访问方法、装置、电子设备及可读存储介质 |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105978968A (zh) * | 2016-05-11 | 2016-09-28 | 山东合天智汇信息技术有限公司 | 一种海量数据的实时传输处理方法、服务器及处理*** |
CN106055367B (zh) * | 2016-06-01 | 2021-06-18 | 腾讯科技(深圳)有限公司 | 一种脚本文件载入方法及装置 |
CN107391539B (zh) * | 2017-04-28 | 2020-08-04 | 阿里巴巴集团控股有限公司 | 事务处理方法、服务器和存储介质 |
CN107256180B (zh) * | 2017-05-19 | 2019-04-26 | 腾讯科技(深圳)有限公司 | 数据处理方法、装置及终端 |
CN109977096A (zh) * | 2019-03-05 | 2019-07-05 | ***股份有限公司 | 一种数据库连接管理方法及装置 |
CN110134578B (zh) * | 2019-05-23 | 2023-04-28 | 浙江齐治科技股份有限公司 | 一种数据处理方法及装置 |
CN111782367B (zh) * | 2020-06-30 | 2023-08-08 | 北京百度网讯科技有限公司 | 分布式存储方法及装置、电子设备、计算机可读介质 |
CN113254182A (zh) * | 2021-06-08 | 2021-08-13 | 挂号网(杭州)科技有限公司 | 数据处理方法、装置、电子设备及存储介质 |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120066363A1 (en) * | 2010-09-15 | 2012-03-15 | Oracle International Corporation | System and method for using a gridlink data source to connect an application server with a clustered database |
CN103365929A (zh) * | 2012-04-10 | 2013-10-23 | 阿里巴巴集团控股有限公司 | 一种数据库连接的管理方法及*** |
CN103761240A (zh) * | 2013-12-12 | 2014-04-30 | 北京奇虎科技有限公司 | 数据库访问方法和装置 |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8930526B2 (en) * | 2009-10-30 | 2015-01-06 | International Business Machines Corporation | Processing network events |
CN101814077B (zh) * | 2009-12-04 | 2012-04-11 | 四川川大智胜软件股份有限公司 | 一种基于oci 9的数据库访问中间件 |
CN103577257A (zh) * | 2012-08-03 | 2014-02-12 | 杭州勒卡斯广告策划有限公司 | 一种rest服务方法、装置及*** |
CN103164347A (zh) * | 2013-02-18 | 2013-06-19 | 中国农业银行股份有限公司 | 数据缓存的方法和装置 |
-
2014
- 2014-08-28 CN CN201410433031.6A patent/CN105373420B/zh active Active
-
2015
- 2015-08-10 WO PCT/CN2015/086479 patent/WO2016029790A1/zh active Application Filing
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120066363A1 (en) * | 2010-09-15 | 2012-03-15 | Oracle International Corporation | System and method for using a gridlink data source to connect an application server with a clustered database |
CN103365929A (zh) * | 2012-04-10 | 2013-10-23 | 阿里巴巴集团控股有限公司 | 一种数据库连接的管理方法及*** |
CN103761240A (zh) * | 2013-12-12 | 2014-04-30 | 北京奇虎科技有限公司 | 数据库访问方法和装置 |
Non-Patent Citations (1)
Title |
---|
MA, SONG ET AL.: "Research and Construction of a Database Middleware Prototype on Intranet", JOURNAL OF SOFTWARE, vol. 10, no. 1, 31 January 1999 (1999-01-31), pages 87 - 90 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113296974A (zh) * | 2020-08-31 | 2021-08-24 | 阿里巴巴集团控股有限公司 | 数据库访问方法、装置、电子设备及可读存储介质 |
CN112052227A (zh) * | 2020-09-25 | 2020-12-08 | 郑州阿帕斯数云信息科技有限公司 | 数据变更日志的处理方法、装置和电子设备 |
Also Published As
Publication number | Publication date |
---|---|
CN105373420B (zh) | 2019-12-06 |
CN105373420A (zh) | 2016-03-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2016029790A1 (zh) | 数据传输方法及装置 | |
US20220124049A1 (en) | Distributed fair allocation of shared resources to constituents of a cluster | |
US11570272B2 (en) | Provisioning using pre-fetched data in serverless computing environments | |
CN107391629B (zh) | 集群间数据迁移方法、***、服务器及计算机存储介质 | |
US10430332B2 (en) | System and method for performance tuning of garbage collection algorithms | |
US20160011997A1 (en) | Enhanced I/O Performance in a Multi-Processor System Via Interrupt Affinity Schemes | |
US9497095B2 (en) | Dynamic control over tracing of messages received by a message broker | |
US9104501B2 (en) | Preparing parallel tasks to use a synchronization register | |
WO2019024508A1 (zh) | 资源分配方法、主装置、从装置和分布式计算*** | |
CN106790744B (zh) | Ip调度方法及*** | |
WO2016107340A1 (zh) | 业务请求处理方法和装置 | |
WO2020192649A1 (zh) | 一种数据中心管理*** | |
US11182217B2 (en) | Multilayered resource scheduling | |
US9807008B2 (en) | Tournament scheduling | |
WO2017181890A1 (zh) | 基于服务器集群的数据处理***及方法 | |
JP2006512688A5 (zh) | ||
US20160337470A1 (en) | Method and server for assigning relative order to message by using vector clock and delivering the message based on the assigned relative order under distributed environment | |
US8458702B1 (en) | Method for implementing user space up-calls on java virtual machine before/after garbage collection | |
US20210200765A1 (en) | Connection pools for parallel processing applications accessing distributed databases | |
CN110706148B (zh) | 人脸图像处理方法、装置、设备和存储介质 | |
JP2005092862A5 (zh) | ||
CN113114503A (zh) | 基于应用交付网络需求的部署方法及装置 | |
CN104731660A (zh) | 数据分配方法、装置和*** | |
US9432476B1 (en) | Proxy data storage system monitoring aggregator for a geographically-distributed environment | |
JP2014081765A (ja) | 負荷分散装置、負荷分散方法および負荷分散プログラム |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 15834990 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 15834990 Country of ref document: EP Kind code of ref document: A1 |