Data source configuration method, device, terminal, server and medium
By obtaining and parsing the configuration template, the data source connection is dynamically established, which solves the problem of high complexity of new data sources in the existing technology, and realizes the ability to dynamically add data sources without affecting the data reading and writing business.
Patent Information
- Application Number
- CN201911318285.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-12-19
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2039-12-19
AI Technical Summary
In the existing technology, when adding data sources in large-scale projects, the data reading and writing services of the terminal and server need to be suspended, and manual configuration and re-development of configuration files are required, resulting in high complexity of new data sources.
By obtaining the preset configuration template, parsing and displaying the configuration interface, receiving the data source type and attribute data input by the user, generating configuration information and sending it to the server, dynamically establishing data source connections, reducing dependence on configuration files and the need for redevelopment.
It realizes dynamically adding data source connections without pausing data reading and writing services, reducing the complexity of new data sources and improving the flexibility and efficiency of data reading and writing services.
Smart Images

Figure CN113010587B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a data source configuration method, device, terminal, server and medium. Background Art
[0002] At present, in some large projects, it is often necessary to read and write data in multiple data sources. When reading and writing data, the terminal reads a pre-defined configuration file and generates a list of available data sources, and then requests the server to read and write data from a specified data source in the available data sources, where the available data sources are the data sources connected to the server.
[0003] Since the available data source information is recorded in the terminal's configuration file, if the terminal needs to read or write data from a new data source, it is necessary to first suspend the terminal's service of reading and writing data in the data source, manually add the new data source information in the configuration file, and then run the service of reading and writing data after the configuration is completed. Moreover, before reading and writing data from a new data source, it is necessary to establish a connection between the server and the new data source, which requires manual configuration of the new data source information for the server and writing the new data source information into the server's configuration file so that the server can establish a connection with the new data source based on the new data source information.
[0004] It can be seen that when the terminal needs to read and write data in a new data source, it is necessary to suspend the data reading and writing services of the terminal and the server, and then develop the configuration files of the terminal and the server separately, making the method of adding a new data source in the data reading and writing service more complicated. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a data source configuration method, device, terminal, server and medium to reduce the complexity of adding a new data source in the data reading and writing business. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present invention provides a data source configuration method, which is applied to a terminal, and the method includes:
[0007] Get the preset configuration template;
[0008] Parsing the configuration template and displaying the configuration interface corresponding to the configuration template;
[0009] Receiving the type and attribute configuration data of the data source to be configured input by the user through the configuration interface;
[0010] The type and attribute configuration data of the data source to be configured are added to the configuration template, configuration information of the data source to be configured is obtained, and the configuration information is sent to the server, so that the server establishes a connection with the data source to be configured according to the configuration information.
[0011] Optionally, the method further includes:
[0012] Obtaining from the server an identifier of a data source for which the terminal has read and write permissions;
[0013] Displaying, in a preset display interface, identifiers of data sources for which the terminal has read and write permissions;
[0014] Identify the user's selection operation for reading and writing data sources;
[0015] Based on the selection operation, a read / write request is generated, wherein the read / write request includes an identifier of a data source to be read / written selected by a user;
[0016] Send the read / write request to the server.
[0017] In a second aspect, an embodiment of the present invention provides a data source configuration method, which is applied to a server, and the method includes:
[0018] receiving configuration information of a data source to be configured sent by a terminal;
[0019] Parsing the configuration information to obtain the type and attribute configuration data of the data source to be configured;
[0020] According to the type and attribute configuration data of the data source to be configured, a connection is established with the data source to be configured.
[0021] Optionally, the method further includes:
[0022] Receiving a read / write request sent by a terminal, wherein the read / write request includes an identifier of a data source to be read / written;
[0023] In response to the read / write request, a read / write operation is performed on the data source to be read / written corresponding to the identifier of the data source to be read / written.
[0024] Optionally, the performing a read / write operation on the data source to be read / written corresponding to the identifier of the data source to be read / written includes:
[0025] If a target connection between the server and the data source to be read or written exists in the data source connection pool, acquiring the target connection;
[0026] Based on the target connection, read and write operations are performed on the data source to be read and written.
[0027] Optionally, the performing a read / write operation on the data source to be read / written corresponding to the identifier of the data source to be read / written includes:
[0028] If the target connection between the server and the data source to be read or written does not exist in the data source connection pool, constructing the target connection between the server and the data source to be read or written according to the type and attribute configuration data corresponding to the identifier of the data source to be read or written;
[0029] Add the target connection to the data source connection pool, and obtain the target connection from the data source connection pool;
[0030] Based on the target connection, read and write operations are performed on the data source to be read and written.
[0031] Optionally, the data source connection pool includes connections between multiple data sources and the server, and the remaining effective time of each connection; the method further includes:
[0032] When the remaining effective time length of the connection between the data source and the server in the data source connection pool is zero, the connection with the remaining effective time length of zero is deleted from the data source connection pool.
[0033] Optionally, after configuring data according to the type and attributes of the data source to be configured and establishing a connection with the data source to be configured, the method further includes:
[0034] If the number of connections included in the data source connection pool does not reach a preset threshold, adding the connection established with the data source to be configured to the data source connection pool;
[0035] If the number of connections included in the data source connection pool reaches a preset threshold, the connection with the shortest remaining validity period in the data source connection pool is deleted, and the connection established with the data source to be configured is added to the data source connection pool.
[0036] In a third aspect, an embodiment of the present invention provides a data source configuration device, applied to a terminal, the device comprising:
[0037] The acquisition module is used to obtain the preset configuration template;
[0038] A parsing module, used to parse the configuration template obtained by the obtaining module and display a configuration interface corresponding to the configuration template;
[0039] A receiving module, used to receive the type and attribute configuration data of the data source to be configured input by the user through the configuration interface;
[0040] A sending module is used to add the type and attribute configuration data of the data source to be configured received by the receiving module to the configuration template, obtain the configuration information of the data source to be configured, and send the configuration information to the server so that the server establishes a connection with the data source to be configured according to the configuration information.
[0041] Optionally, the device further comprises: a display module, an identification module and a generation module;
[0042] The acquisition module is further used to acquire from the server the identifier of the data source for which the terminal has read and write permissions;
[0043] The display module is used to display the identifiers of the data sources for which the terminal has read and write permissions in a preset display interface;
[0044] The identification module is used to identify the user's selection operation on the data source to be read and written;
[0045] The generating module is used to generate a read / write request based on the selection operation identified by the identifying module, wherein the read / write request includes an identifier of a data source to be read / written selected by a user;
[0046] The sending module is also used to send the read-write request generated by the generating module to the server.
[0047] In a fourth aspect, an embodiment of the present invention provides a data source configuration device, which is applied to a server, and the device includes:
[0048] A receiving module, used for receiving configuration information of a data source to be configured sent by a terminal;
[0049] A parsing module, used to parse the configuration information received by the receiving module, and obtain the type and attribute configuration data of the data source to be configured;
[0050] An establishing module is used to establish a connection with the data source to be configured according to the type and attribute configuration data of the data source to be configured parsed by the parsing module.
[0051] Optionally, the device further comprises: a response module;
[0052] The receiving module is further used to receive a read / write request sent by a terminal, wherein the read / write request includes an identifier of a data source to be read / written;
[0053] The response module is used to perform read and write operations on the data source to be read and written corresponding to the identifier of the data source to be read and written in response to the read and write request received by the receiving module.
[0054] Optionally, the response module is specifically used to:
[0055] If a target connection between the server and the data source to be read or written exists in the data source connection pool, acquiring the target connection;
[0056] Based on the target connection, read and write operations are performed on the data source to be read and written.
[0057] Optionally, the response module is specifically used to:
[0058] If the target connection between the server and the data source to be read or written does not exist in the data source connection pool, constructing the target connection between the server and the data source to be read or written according to the type and attribute configuration data corresponding to the identifier of the data source to be read or written;
[0059] Add the target connection to the data source connection pool, and obtain the target connection from the data source connection pool;
[0060] Based on the target connection, read and write operations are performed on the data source to be read and written.
[0061] Optionally, the data source connection pool includes connections between multiple data sources and the server, and the remaining effective time of each connection; the device further includes: a deletion module;
[0062] The deleting module is used to delete the connection with the remaining effective time length of zero from the data source connection pool when the remaining effective time length of the connection between the data source and the server in the data source connection pool is zero.
[0063] Optionally, the device further comprises: a joining module;
[0064] The adding module is used for, after establishing a connection with the data source to be configured according to the type and attribute configuration data of the data source to be configured, if the number of connections included in the data source connection pool does not reach a preset threshold, adding the connection established with the data source to be configured to the data source connection pool;
[0065] The adding module is further used to delete the connection with the shortest remaining validity period in the data source connection pool if the number of connections included in the data source connection pool reaches a preset threshold, and add the connection established with the data source to be configured to the data source connection pool.
[0066] In a fifth aspect, an embodiment of the present invention provides a terminal, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus;
[0067] Memory, used to store computer programs;
[0068] The processor is used to implement the steps of the data source configuration method described in the first aspect when executing the program stored in the memory.
[0069] In a sixth aspect, an embodiment of the present invention provides a server, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0070] Memory, used to store computer programs;
[0071] The processor is used to implement the steps of the data source configuration method described in the second aspect when executing the program stored in the memory.
[0072] In a seventh aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data source configuration method described in the first aspect are performed.
[0073] In an eighth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data source configuration method described in the second aspect are performed.
[0074] In a ninth aspect, an embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the data source configuration method described in the first aspect above.
[0075] In a tenth aspect, an embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the data source configuration method described in the second aspect above.
[0076] The technical solution of the embodiment of the present invention can at least bring the following beneficial effects: the terminal can send a configuration template carrying the type and attribute configuration data of the data source to be configured to the server, and obtain configuration information, so that the server can establish a connection with the data source to be configured according to the configuration information. Since the type and attribute configuration data of the data source to be configured are recorded in the configuration information of the data source to be configured, the present invention can dynamically increase the connection between the server and the data source. When adding a new data source, there is no need to suspend the data reading and writing services of the terminal and the server, and there is no need to redevelop the configuration file, so that the embodiment of the present invention reduces the complexity of adding a new data source in the data reading and writing service.
[0077] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0079] Figure 1 A schematic diagram of the structure of a data source configuration system provided by an embodiment of the present invention;
[0080] Figure 2 A flow chart of a data source configuration method provided by an embodiment of the present invention;
[0081] Figure 3 A flow chart of another data source configuration method provided by an embodiment of the present invention;
[0082] Figure 4 A flow chart of another data source configuration method provided by an embodiment of the present invention;
[0083] Figure 5 A schematic diagram of the structure of a data source configuration device provided by an embodiment of the present invention;
[0084] Figure 6 A schematic diagram of the structure of another data source configuration device provided by an embodiment of the present invention;
[0085] Figure 7 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention;
[0086] Figure 8 A schematic diagram of the structure of a server provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0087] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0088] To dynamically configure the data source, see Figure 1 The embodiment of the present invention provides a data source configuration system, which includes: a terminal 101 and a server 102. The terminal 101 can be an electronic device such as a mobile phone, a tablet computer, a computer, or an executable application software or system installed in the electronic device that can realize a specific function. Figure 1 In the example, terminal 101 is taken as a mobile phone.
[0089] The terminal 101 is used to obtain and send configuration information of a data source to be configured to the server 102 .
[0090] The server 102 is used to receive the configuration information of the data source to be configured sent by the terminal 101, and establish a connection with the data source to be configured according to the configuration information.
[0091] Figure 1 The number of each device in the data source configuration system shown is only an example provided by the embodiment of the present invention. The embodiment of the present invention does not specifically limit the number of each device included in the data source configuration system.
[0092] See also Figure 2 The embodiment of the present invention provides a data source configuration method, which is applied to Figure 1 The terminal of the data source configuration system shown includes the following steps:
[0093] Step 201: Obtain a preset configuration template.
[0094] In one implementation, the preset configuration template may be stored in a server, and the terminal may request the server to obtain the configuration template.
[0095] Step 202: parse the configuration template and display the configuration interface corresponding to the configuration template.
[0096] It can be understood that the configuration template records the identifier of the information required to configure the data source. The terminal parses the configuration template and displays the identifier of the information required in the configuration interface, so that the user can input the required information through the display interface.
[0097] Step 203: receiving the type and attribute configuration data of the data source to be configured input by the user through the configuration interface.
[0098] For example, the type of data source may be: relational database management system (mySQL), Oracle database software, data warehouse tool (hive), cloud object storage (Cloud Object Storage, cos), etc.
[0099] The attribute configuration data may include: the Internet Protocol address of the data source to be configured, the port number of the data source to be configured, the account name with read and write permissions for the data source to be configured, the password of the account with read and write permissions for the data source to be configured, etc.
[0100] In one implementation, different data source types may correspond to different attribute configuration data. Therefore, after detecting that the user inputs the type of data source to be configured in the display interface, the identifier of the attribute configuration data required to configure this type of data source may be displayed, and the attribute configuration data input by the user may be received.
[0101] Step 204, adding the type and attribute configuration data of the data source to be configured to the configuration template, obtaining configuration information of the data source to be configured, and sending the configuration information to the server, so that the server establishes a connection with the data source to be configured according to the configuration information.
[0102] Optionally, the format of the configuration template and the configuration information may be in JavaScript Object Notation (JSON) format.
[0103] The technical solution of the embodiment of the present invention can at least bring the following beneficial effects: the terminal can send a configuration template carrying the type and attribute configuration data of the data source to be configured to the server, and obtain configuration information, so that the server can establish a connection with the data source to be configured according to the configuration information. Since the type and attribute configuration data of the data source to be configured are recorded in the configuration information of the data source to be configured, the present invention can dynamically increase the connection between the server and the data source. When adding a new data source, there is no need to suspend the data reading and writing services of the terminal and the server, and there is no need to redevelop the configuration file, so that the embodiment of the present invention reduces the complexity of adding a new data source in the data reading and writing service.
[0104] Optionally, the terminal may also request the server to read and write data in the data source, including the following steps:
[0105] Step 1: Obtain from the server the identifier of the data source for which the terminal has read and write permissions.
[0106] In one implementation, the terminal may send a data source identification acquisition request to the server, wherein the data source identification acquisition request carries the identification of the terminal's login user. In response to the data source identification acquisition request, the server sends the terminal the identification of the data source corresponding to the identification of the login user. The login user has read and write permissions for the data source corresponding to his identification.
[0107] Step 2: Display the identifiers of the data sources for which the terminal has read and write permissions in a preset display interface.
[0108] Step 3: Identify the user's selection operation on the read and write data source.
[0109] In one implementation, the display interface may include buttons corresponding to each data source for which the terminal has read and write permissions, and the terminal may detect a selection operation of one of the buttons by the user.
[0110] Step 4: Generate a read / write request based on the selection operation. The read / write request includes the identifier of the data source to be read / written selected by the user. The identifier of the data source to be read / written is selected by the user from the identifiers of the data sources for which the terminal has read / write permissions.
[0111] Step 5: Send a read / write request to the server.
[0112] In one implementation, when the terminal sends a read / write request to the server as a read data request, the server reads data from the data source to be read / written and then sends the read data to the terminal. At this time, the terminal can receive the data in the data source to be read / written sent by the server.
[0113] When the read / write request sent by the terminal to the server is a write data request, the server may write the data in the specified location to the data source to be read / written. Optionally, when the server successfully writes data to the data source to be read / written, it may send a prompt message to the terminal, wherein the prompt message is used to indicate that the data is successfully written to the data source to be read / written.
[0114] The technical solution provided by the embodiment of the present invention may also include the following beneficial effects: the terminal can perform read and write operations on a data source with read and write permissions through the server, so that the application scope of the embodiment of the present invention is wide.
[0115] See also Figure 3 The data source configuration method provided in the embodiment of the present invention can be applied to Figure 1 The data source configuration system server shown includes the following steps.
[0116] Step 301: receiving configuration information of a data source to be configured sent by a terminal.
[0117] Step 302: parse the configuration information to obtain the type and attribute configuration data of the data source to be configured.
[0118] Optionally, the data format in the configuration information may be in the form of a key-value pair, where the key is a data identifier and the value is a type or attribute configuration data, for example: type-mySQL, IP address-36.7.72.139.
[0119] Step 303: configure data according to the type and attribute of the data source to be configured, and establish a connection with the data source to be configured.
[0120] Optionally, the server may also determine the account name and password having read and write permissions for the data source to be configured according to the type and attribute configuration data of the data source to be configured, and store the identifier, account name and password of the data source to be configured accordingly.
[0121] Optionally, the server may also determine a read operation and / or a write operation corresponding to the data source to be configured according to the type and attribute configuration data of the data source to be configured.
[0122] The technical solution of the embodiment of the present invention can at least bring the following beneficial effects: the server can receive the configuration information sent by the terminal, parse the type and attribute configuration data of the data source to be configured from the configuration information, and establish a connection with the data source to be configured. Since the type and attribute configuration data of the data source to be configured are recorded in the configuration information of the data source to be configured, the present invention can dynamically increase the connection between the server and the data source. When adding a new data source, there is no need to suspend the data reading and writing services of the terminal and the server, and there is no need to redevelop the configuration file, so that the embodiment of the present invention reduces the complexity of adding a new data source in the data reading and writing service.
[0123] Optionally, the connection between the server and the data source to be configured established in step 303 may also be added to the data source connection pool (map). In one implementation, the connection between the server and the data source to be configured may be used as a value, the identifier of the data source to be configured may be used as a key, and the connection between the server and the data source to be configured and the identifier of the data source to be configured may be added to the map accordingly.
[0124] When the server needs to read and write data from the data source to be configured, it can use the connection in the data source connection pool to read and write data in the data source to be configured. The way to add the connection established in step 303 to the connection pool includes the following two situations:
[0125] In the embodiment of the present invention, the connection between the data source and the server can be a connection pool or a connection object. For example, the connection between mySQL and oracle and the server can be a database connection pool (druid), and the connection between cos and the server can be a connection object.
[0126] Case 1: If the number of connections included in the data source connection pool does not reach a preset threshold, the connection established between the server and the data source to be configured is added to the data source connection pool.
[0127] For example, the preset threshold may be 10.
[0128] Case 2: If the number of connections included in the data source connection pool reaches a preset threshold, the connection with the shortest remaining validity period in the data source connection pool is deleted, and the connection established between the server and the data source to be configured is added to the data source connection pool.
[0129] The data source connection pool includes connections between multiple data sources and servers, as well as the remaining validity period of each connection.
[0130] For example, the data source connection pool includes: connection A between data source A and the server, connection B between data source B and the server, and connection C between data source C and the server, wherein the remaining effective time of connection A is 50 seconds, the remaining effective time of connection B is 30 seconds, the remaining effective time of connection C is 20 seconds, and the preset threshold is 3. When connection D needs to be added to the data source connection pool, since the number of connections in the data source connection pool reaches the preset threshold, connection C with the shortest remaining effective time is deleted, and connection D is added to the data source connection pool.
[0131] In one implementation, the connection established between the server and the data source to be configured may be added to the data source connection pool in correspondence with the specified validity period, wherein the specified validity period may be the period input by the user in the configuration interface or may be a default period.
[0132] In the embodiment of the present invention, after a connection in the data source connection pool is added to the data source connection pool, the server can calculate the remaining effective time of the connection in real time.
[0133] The technical solution of the embodiment of the present invention can also bring the following beneficial effects: the connection between the server and the data source is stored in the data source connection pool, which facilitates the unified management of the established connections. Moreover, the data source connection pool in the embodiment of the present invention can be set to a fixed length, that is, the number of connections included does not exceed a preset threshold. This allows the number of connections in the data source to be controlled within a certain range, effectively saving resource occupation.
[0134] Optionally, the data source connection pool includes connections between multiple data sources and servers, and the remaining validity period of each connection.
[0135] When the remaining effective time of a connection between a data source and a server in the data source connection pool is zero, the connection with the remaining effective time of zero may be deleted from the data source connection pool.
[0136] The technical solution of the embodiment of the present invention can also bring the following beneficial effects: since the data source connection pool includes the remaining effective time of each connection, and the connections with zero remaining effective time in the data source connection pool can be deleted, the resources occupied by the connection between the data source and the server are reduced.
[0137] Optionally, when receiving a read / write request sent by the terminal, the server may also perform a read / write operation on the data source to be read / write, including the following steps.
[0138] Step 1: Receive a read / write request sent by a terminal, wherein the read / write request includes an identifier of a data source to be read / written.
[0139] Step 2: In response to the read / write request, perform a read / write operation on the data source to be read / written corresponding to the identifier of the data source to be read / written.
[0140] In one implementation, the manner in which the server performs read and write operations on the data source to be read and written may include the following two situations.
[0141] Case 1: If there is a target connection between the server and the data source to be read or written in the data source connection pool, the target connection is obtained. Then, based on the target connection, the read or write operation is performed on the data source to be read or written.
[0142] Case 2: If the target connection between the server and the data source to be read or written does not exist in the data source connection pool, the target connection between the server and the data source to be read or written is constructed according to the type and attribute configuration data corresponding to the identifier of the data source to be read or written. Then the target connection is added to the data source connection pool, and the target connection is obtained from the data source connection pool. Then, based on the target connection, the data source to be read or written is read or written.
[0143] It is understandable that the terminal can perform read and write operations on the data source with read and write permissions, so the data source to be read and written is pre-configured in the server, and the connection between the server and the data source to be read and written has been established, but the target connection between the server and the data source to be read and written does not exist in the data source connection pool, indicating that the target connection has been deleted from the data source connection pool.
[0144] Among them, the situations in which the target connection is deleted from the data source connection pool include: when the remaining effective time of the target connection is zero, the target connection is deleted from the data source connection pool; and when a new connection needs to be added to the data source connection pool, the remaining effective time of the target connection is the shortest, so the target connection is deleted from the data source connection pool and the new connection is added to the data source connection pool.
[0145] Since the server has pre-configured the data source to be read and written, the server stores the configuration information of the data source to be read and written. When the server establishes a connection with the data source to be read and written, it can parse and obtain the type and attribute configuration data of the data source to be read and written from the configuration information corresponding to the identifier of the data source to be read and written.
[0146] Optionally, after obtaining the target connection from the data source connection pool and performing read and write operations, the target connection can also be added to the data source connection pool with a specified validity period.
[0147] The technical solution of the embodiment of the present invention can also bring the following beneficial effects: since after a connection in the data source connection pool is acquired, when it is added to the data source connection pool again, the remaining effective time corresponding to the connection is the specified effective time. Therefore, the embodiment of the present invention increases the probability of frequently used connections being stored in the data source connection pool, reduces the probability of infrequently used connections being stored in the data source connection pool, and reduces the resources occupied by infrequently used connections.
[0148] In the related art, when responding to the read and write operations sent by the terminal, the server needs to establish a connection with the data source according to the configuration information, and disconnect the connection with the data source after performing the read and write operations on the data source. Since the server has to perform the above steps every time it performs a read and write operation on the data source, the frequently used data source is prone to crash due to access.
[0149] In the embodiment of the present invention, when the server needs to perform a read or write operation, it can obtain a connection between the server and the data to be read or written from the data source connection pool, thereby reducing the frequency of establishing and disconnecting the server from the data source.
[0150] In order to more clearly illustrate the data source configuration method provided by the embodiment of the present invention, see Figure 4 The method for the server to obtain a specified connection from a data source connection pool includes the following steps, where the specified connection can be a connection between any data source and the server.
[0151] Step 401, determine whether the data source connection pool includes the specified connection. If the data source connection pool includes the specified connection, execute step 402; if the data source connection pool does not include the specified connection, execute step 403.
[0152] Step 402: Get a specified connection from the data source connection pool.
[0153] Step 403: Acquire the type and attribute configuration data corresponding to the identifier of the specified data source.
[0154] Step 404: Establish a specified connection with the specified data source according to the type and attribute configuration data corresponding to the identifier of the specified data source.
[0155] Step 405 , adding the specified connection established between the server and the specified data source to the data source connection pool, and returning to step 402 .
[0156] Corresponding to the above method embodiment, see Figure 5 , an embodiment of the present invention provides a data source configuration device, which is applied to a terminal, and the device includes: an acquisition module 501, a parsing module 502, a receiving module 503 and a sending module 504;
[0157] The acquisition module 501 is used to acquire a preset configuration template;
[0158] The parsing module 502 is used to parse the configuration template obtained by the obtaining module 501 and display the configuration interface corresponding to the configuration template;
[0159] The receiving module 503 is used to receive the type and attribute configuration data of the data source to be configured input by the user through the configuration interface;
[0160] The sending module 504 is used to add the type and attribute configuration data of the data source to be configured received by the receiving module 503 to the configuration template, obtain the configuration information of the data source to be configured, and send the configuration information to the server so that the server establishes a connection with the data source to be configured according to the configuration information.
[0161] Optionally, the device may further include: a display module, an identification module and a generation module;
[0162] The acquisition module 501 is also used to obtain from the server the identifier of the data source for which the terminal has read and write permissions;
[0163] A display module, used to display the identifiers of data sources for which the terminal has read and write permissions in a preset display interface;
[0164] An identification module, used to identify the user's selection operation on the data source to be read and written;
[0165] A generating module, configured to generate a read / write request based on the selection operation identified by the identifying module, wherein the read / write request includes an identifier of a data source to be read / written selected by a user;
[0166] The sending module 504 is further used to send the read / write request generated by the generating module to the server.
[0167] Corresponding to the above method embodiment, see Figure 6 , an embodiment of the present invention provides a data source configuration device, which is applied to a server, and the device includes: a receiving module 601, a parsing module 602 and a establishing module 603;
[0168] The receiving module 601 is used to receive the configuration information of the data source to be configured sent by the terminal;
[0169] The parsing module 602 is used to parse the configuration information received by the receiving module 601 to obtain the type and attribute configuration data of the data source to be configured;
[0170] The establishing module 603 is used to establish a connection with the data source to be configured according to the type and attribute configuration data of the data source to be configured parsed by the parsing module 602 .
[0171] Optionally, the device may further include: a response module;
[0172] The receiving module 601 is further used to receive a read / write request sent by a terminal, wherein the read / write request includes an identifier of a data source to be read / written;
[0173] The response module is used to respond to the read / write request received by the receiving module 601 and perform read / write operations on the data source to be read / written corresponding to the identifier of the data source to be read / written.
[0174] Optionally, the response module can be used to:
[0175] If there is a target connection between the server and the data source to be read or written in the data source connection pool, obtain the target connection;
[0176] Based on the target connection, read and write operations are performed on the read and write data source.
[0177] Optionally, the response module can be used to:
[0178] If the target connection between the server and the data source to be read or written does not exist in the data source connection pool, then the target connection between the server and the data source to be read or written is constructed according to the type and attribute configuration data corresponding to the identifier of the data source to be read or written;
[0179] Add the target connection to the data source connection pool, and obtain the target connection from the data source connection pool;
[0180] Based on the target connection, read and write operations are performed on the read and write data source.
[0181] Optionally, the data source connection pool includes connections between multiple data sources and servers, and the remaining effective time of each connection; the device may also include: a deletion module;
[0182] The deleting module is used to delete the connection with the remaining effective time of zero from the data source connection pool when the remaining effective time of the connection between the data source and the server in the data source connection pool is zero.
[0183] Optionally, the device may further include: an adding module;
[0184] A adding module, configured to add the connection established with the data source to be configured into the data source connection pool after establishing a connection with the data source to be configured according to the type and attribute configuration data of the data source to be configured, if the number of connections included in the data source connection pool does not reach a preset threshold;
[0185] The adding module is also used to delete the connection with the shortest remaining validity period in the data source connection pool if the number of connections included in the data source connection pool reaches a preset threshold, and add the connection established with the data source to be configured to the data source connection pool.
[0186] The embodiment of the present invention further provides a terminal, such as Figure 7 As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.
[0187] Memory 703, used for storing computer programs;
[0188] The processor 701 is used to implement the steps performed by the terminal in the above method embodiment when executing the program stored in the memory 703.
[0189] The embodiment of the present invention also provides a server, such as Figure 8 As shown, it includes a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804.
[0190] Memory 803, used for storing computer programs;
[0191] The processor 801 is used to implement the steps performed by the server in the above method embodiment when executing the program stored in the memory 803.
[0192] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0193] The communication interface is used for communication between the above electronic device and other devices.
[0194] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0195] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0196] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of the data source configuration method executed by the terminal are implemented.
[0197] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of the data source configuration method executed by the server are implemented.
[0198] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the data source configuration method applied to a terminal in the above embodiment.
[0199] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the data source configuration method applied to the server in the above embodiment.
[0200] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0201] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0202] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0203] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A data source configuration method, characterized in that: Applied to a terminal, the method comprises: Obtaining a preset configuration template, wherein the configuration template records an identification of information required to be obtained for configuring a data source; Parsing the configuration template and displaying a configuration interface corresponding to the configuration template, wherein the configuration interface includes an identification of the information to be obtained; Receiving the type and attribute configuration data of the data source to be configured input by the user through the configuration interface; Add the type and attribute configuration data of the data source to be configured to the configuration template, obtain the configuration information of the data source to be configured, and send the configuration information to the server, so that the server establishes a connection with the data source to be configured according to the configuration information, and when the number of connections included in the data source connection pool does not reach a preset threshold, the connection established with the data source to be configured is added to the data source connection pool, or when the number of connections included in the data source connection pool reaches a preset threshold, the connection with the shortest remaining valid time in the data source connection pool is deleted, and the connection established with the data source to be configured is added to the data source connection pool; The method further comprises: Obtaining from the server an identifier of a data source for which the terminal has read and write permissions; Displaying, in a preset display interface, identifiers of data sources for which the terminal has read and write permissions; Identify the user's selection operation for reading and writing data sources; Based on the selection operation, a read / write request is generated, wherein the read / write request includes an identifier of a data source to be read / written selected by a user; Send the read / write request to the server.
2. A data source configuration method, characterized in that: Applied to a server, the method comprises: receiving configuration information of a data source to be configured sent by a terminal, the configuration information including the type and attribute configuration data of the data source to be configured input by a user through a configuration interface, the configuration interface being obtained by parsing a configuration template, the configuration template recording an identifier of information required to be obtained for configuring the data source, and the configuration interface including the identifier of the information required to be obtained; Parsing the configuration information to obtain the type and attribute configuration data of the data source to be configured; According to the type and attribute configuration data of the data source to be configured, a connection is established with the data source to be configured; If the number of connections included in the data source connection pool does not reach a preset threshold, adding the connection established with the data source to be configured to the data source connection pool; If the number of connections included in the data source connection pool reaches a preset threshold, the connection with the shortest remaining validity period in the data source connection pool is deleted, and the connection established with the data source to be configured is added to the data source connection pool; The method further includes: determining a read operation and / or a write operation corresponding to the data source to be configured according to the type and attribute configuration data of the data source to be configured.
3. The method according to claim 2, characterized in that The method further comprises: Receiving a read / write request sent by a terminal, wherein the read / write request includes an identifier of a data source to be read / written; In response to the read / write request, a read / write operation is performed on the data source to be read / written corresponding to the identifier of the data source to be read / written.
4. The method according to claim 3, characterized in that The performing a read / write operation on the data source to be read / written corresponding to the identifier of the data source to be read / written includes: If a target connection between the server and the data source to be read or written exists in the data source connection pool, acquiring the target connection; Based on the target connection, read and write operations are performed on the data source to be read and written.
5. The method according to claim 3, characterized in that: The performing a read / write operation on the data source to be read / written corresponding to the identifier of the data source to be read / written includes: If the target connection between the server and the data source to be read or written does not exist in the data source connection pool, constructing the target connection between the server and the data source to be read or written according to the type and attribute configuration data corresponding to the identifier of the data source to be read or written; Add the target connection to the data source connection pool, and obtain the target connection from the data source connection pool; Based on the target connection, read and write operations are performed on the data source to be read and written.
6. The method according to claim 4 or 5, characterized in that: The data source connection pool includes connections between multiple data sources and the server, and the remaining effective time of each connection; the method further includes: When the remaining effective time length of the connection between the data source and the server in the data source connection pool is zero, the connection with the remaining effective time length of zero is deleted from the data source connection pool.
7. A data source configuration device, characterized in that: Applied to a terminal, the device comprises: An acquisition module, used to acquire a preset configuration template, wherein the configuration template records an identifier of information required to be acquired for configuring a data source; A parsing module, used for parsing the configuration template acquired by the acquisition module, and displaying a configuration interface corresponding to the configuration template, wherein the configuration interface includes an identification of the information to be acquired; A receiving module, used to receive the type and attribute configuration data of the data source to be configured input by the user through the configuration interface; a sending module, configured to add the type and attribute configuration data of the data source to be configured received by the receiving module to the configuration template, obtain the configuration information of the data source to be configured, and send the configuration information to the server, so that the server establishes a connection with the data source to be configured according to the configuration information, and when the number of connections included in the data source connection pool does not reach a preset threshold, the connection established with the data source to be configured is added to the data source connection pool, or when the number of connections included in the data source connection pool reaches a preset threshold, the connection with the shortest remaining effective time in the data source connection pool is deleted, and the connection established with the data source to be configured is added to the data source connection pool; The device also includes: a display module, an identification module and a generation module; The acquisition module is further used to acquire from the server the identifier of the data source for which the terminal has read and write permissions; The display module is used to display the identifiers of the data sources for which the terminal has read and write permissions in a preset display interface; The identification module is used to identify the user's selection operation on the data source to be read and written; The generating module is used to generate a read / write request based on the selection operation identified by the identifying module, wherein the read / write request includes an identifier of a data source to be read / written selected by a user; The sending module is also used to send the read-write request generated by the generating module to the server.
8. A data source configuration device, characterized in that: Applied to a server, the device comprises: a receiving module, configured to receive configuration information of a data source to be configured sent by a terminal, wherein the configuration information includes the type and attribute configuration data of the data source to be configured input by a user through a configuration interface, wherein the configuration interface is obtained by parsing a configuration template, wherein the configuration template records an identifier of information required to be obtained for configuring the data source, and the configuration interface includes the identifier of the information required to be obtained; A parsing module, used to parse the configuration information received by the receiving module, and obtain the type and attribute configuration data of the data source to be configured; An establishing module, configured to establish a connection with the data source to be configured according to the type and attribute configuration data of the data source to be configured parsed by the parsing module; A adding module, configured to add the connection established with the data source to be configured to the data source connection pool after establishing a connection with the data source to be configured according to the type and attribute configuration data of the data source to be configured, if the number of connections included in the data source connection pool does not reach a preset threshold; The adding module is further configured to delete the connection with the shortest remaining validity period in the data source connection pool if the number of connections included in the data source connection pool reaches a preset threshold, and add the connection established with the data source to be configured to the data source connection pool; The device also includes: The determination module is used to determine the read operation and / or write operation corresponding to the data source to be configured according to the type of the data source to be configured and the attribute configuration data.
9. The device according to claim 8, characterized in that The device also includes: a response module; The receiving module is further used to receive a read / write request sent by a terminal, wherein the read / write request includes an identifier of a data source to be read / written; The response module is used to perform read and write operations on the data source to be read and written corresponding to the identifier of the data source to be read and written in response to the read and write request received by the receiving module.
10. The device according to claim 9, characterized in that The response module is specifically used for: If a target connection between the server and the data source to be read or written exists in the data source connection pool, acquiring the target connection; Based on the target connection, read and write operations are performed on the data source to be read and written.
11. The device according to claim 9, characterized in that The response module is specifically used for: If the target connection between the server and the data source to be read or written does not exist in the data source connection pool, constructing the target connection between the server and the data source to be read or written according to the type and attribute configuration data corresponding to the identifier of the data source to be read or written; Add the target connection to the data source connection pool, and obtain the target connection from the data source connection pool; Based on the target connection, read and write operations are performed on the data source to be read and written.
12. The device according to claim 10 or 11, characterized in that The data source connection pool includes connections between multiple data sources and the server, and the remaining effective time of each connection; the device also includes: a deletion module; The deleting module is used to delete the connection with the remaining effective time length of zero from the data source connection pool when the remaining effective time length of the connection between the data source and the server in the data source connection pool is zero.
13. A terminal, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor is used to implement the method steps described in claim 1 when executing the program stored in the memory.
14. A server, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 2 to 6 when executing a program stored in a memory.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 or 2-6 are implemented.
Citation Information
Patent Citations
Data collection method and system
CN109495347A
Data access method, device, equipment and medium
CN110555072A
