Dynamic management method and device of connection, terminal equipment and storage medium

By detecting the number changes in the service nodes in the gRPC framework in real time and dynamically updating the connection collection, the problem that the traditional static configuration connection management method cannot adapt to the number of service nodes is solved, and resource utilization efficiency and connection effectiveness are improved.

CN119211320AInactive Publication Date: 2024-12-27NINETECH INFORMATION TECH (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411708197.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2024-12-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The traditional static configuration connection management method cannot flexibly adapt to the dynamic changes in the number of service nodes, resulting in waste of resources or communication needs that cannot be met.

Method used

By performing information collection operations on the accessed service nodes, obtaining node information collection, and maintaining and updating the connection collection in the connection pool, detecting changes in the number of service nodes in real time, and dynamically adjusting the information collection operations to ensure that the connection collection in the connection pool is The current service node status remains consistent.

Benefits of technology

It effectively avoids the problems of waste of resources and unmet communication requirements, ensures that the connections in the connection pool are always up-to-date and effective, and improves resource utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119211320A_ABST
    Figure CN119211320A_ABST
Patent Text Reader

Abstract

The invention is suitable for the field of data processing, and discloses a dynamic management method and device of connection, terminal equipment and a storage medium. The connection dynamic management method comprises the steps that information collection operation is executed on an accessed service node, a node information set is obtained, the node information set comprises at least one piece of target node information, and the target node information comprises a target IP address and a target port number; according to the node information set, maintaining a connection set corresponding to the node information set in a connection pool; and if it is detected that the number of the accessed service nodes is changed, returning to the step of executing the information acquisition operation on the accessed service nodes to obtain the node information set. The problem that resources are wasted or communication requirements cannot be met is effectively avoided. By dynamically updating the connection set, the connection in the connection pool can be ensured to be newest and effective all the time, and the resource utilization efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of data processing, and in particular relates to a method, an apparatus, a terminal device and a storage medium for dynamically managing a connection. Background Art

[0002] In the gRPC framework, connection management is crucial for efficient and stable remote communication. gRPC is a modern, high-performance RPC framework that supports multi-language and multi-environment operation.

[0003] The traditional static configuration connection management method has limitations and cannot flexibly adapt to the dynamic changes in the number of service nodes, resulting in resource waste or unmet communication needs. A new technical means is needed to solve the above technical problems. Summary of the invention

[0004] In view of this, the embodiments of the present invention provide a method, apparatus, terminal device and storage medium for dynamic management of connections, which can solve the problem of low stability of traditional connection management methods in related technologies.

[0005] A first aspect of the present invention provides a method for dynamic management of connections, comprising: Performing information collection operations on the connected service nodes to obtain a node information set, wherein the node information set includes at least one target node information, and the target node information includes a target IP address and a target port number; According to the node information set, maintaining a connection set corresponding to the node information set in a connection pool; If it is detected that the number of the connected service nodes has changed, the process returns to the step of performing information collection operations on the connected service nodes to obtain a node information set.

[0006] Optionally, in a first implementation manner of the first aspect of the present invention, the step of maintaining a connection set corresponding to the node information set in a connection pool according to the node information set includes: If the number in the connection pool is empty, the connection set corresponding to the node information set is created in the connection pool according to the node information set.

[0007] Optionally, in a second implementation of the first aspect of the present invention, the step of maintaining a connection set corresponding to the node information set in a connection pool according to the node information set includes: According to the node information set, an incremental update operation is performed on the current connection in the connection pool to maintain the connection set corresponding to the node information set.

[0008] Optionally, in a third implementation manner of the first aspect of the present invention, after the step of maintaining, in a connection pool, a connection set corresponding to the node information set according to the node information set, the method further includes: Using a heartbeat connection algorithm, detecting whether there is a target connection with an abnormal connection status in the connection set; If the target connection appears in the connection set, temporarily disable the target connection.

[0009] Optionally, in a fourth implementation manner of the first aspect of the present invention, after the step of detecting whether there is a target connection with an abnormal connection status in the connection set by a heartbeat connection algorithm, the method further includes: If the target connection appears in the connection set, counting the number of abnormal times corresponding to the target connection; If the abnormal number of times is a preset number of times, the target connection is deleted from the connection pool.

[0010] Optionally, in a fifth implementation of the first aspect of the present invention, if it is detected that the number of the connected service nodes has changed, returning to perform the information collection operation on the connected service nodes includes: Detecting the number of service nodes of the connected service node, and storing the number of service nodes; If there is a historical number of service nodes, judging whether the number of the connected service nodes has changed according to the historical number of service nodes and the number of service nodes; If the number of the connected service nodes changes, the process returns to the step of performing information collection operations on the connected service nodes.

[0011] Optionally, in a sixth implementation manner of the first aspect of the present invention, the step of performing an information collection operation on the connected service node to obtain a node information set includes: Periodically perform information collection operations on the connected service nodes to obtain a node information set.

[0012] In a second aspect, an embodiment of the present invention provides a dynamic management device for a connection, including: A collection module, used to perform information collection operations on the connected service nodes to obtain a node information set, wherein the node information set includes at least one target node information, and the target node information includes a target IP address and a target port number; A maintaining module, used for maintaining a connection set corresponding to the node information set in a connection pool according to the node information set; The loop module is used to return to the step of performing information collection operation on the connected service nodes to obtain a node information set if it is detected that the number of the connected service nodes has changed.

[0013] In a third aspect, an embodiment of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned dynamic management method of connections when executing the computer program.

[0014] In a fourth aspect, an embodiment of the present invention 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 above-mentioned dynamic management method of connections are implemented.

[0015] In a fifth aspect, an embodiment of the present invention provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the above-mentioned dynamic connection management method.

[0016] The beneficial effects of the embodiments of the present invention compared with the prior art are: performing information collection operations on the connected service nodes to obtain a node information set, the node information set includes at least one target node information, the target node information includes a target IP address and a target port number; according to the node information set, maintaining the connection set corresponding to the node information set in the connection pool; if it is detected that the number of the connected service nodes has changed, returning to perform the information collection operation on the connected service nodes to obtain the step of obtaining the node information set. By real-time detection of changes in the number of connected service nodes and dynamically adjusting the information collection operation, it can be ensured that the connection set in the connection pool is always consistent with the status of the current service node. It solves the limitation that the traditional static configuration connection management method cannot flexibly adapt to the dynamic changes in the number of service nodes, and effectively avoids the problem of resource waste or communication needs not being met. By dynamically updating the connection set, it can be ensured that the connections in the connection pool are always the latest and valid, and improve resource utilization efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 labor.

[0018] Figure 1 A schematic diagram of an embodiment of a method for dynamic management of connections in an embodiment of the present invention; Figure 2 It is a schematic diagram of a specific embodiment after step S102 of the dynamic connection management method in an embodiment of the present invention; Figure 3It is a schematic diagram of a specific embodiment after step S201 of the dynamic management method of connections in an embodiment of the present invention; Figure 4 A schematic diagram of an embodiment of a dynamic management device connected in an embodiment of the present invention; Figure 5 The figure is a schematic diagram of an embodiment of a terminal device in an embodiment of the present invention. DETAILED DESCRIPTION

[0019] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are protected by the present invention.

[0020] It should be noted that the terms "include", "comprises" and "have" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, terminal, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices. In the claims, specifications and drawings of the present invention, relational terms such as "first" and "second" are merely used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such real-time relationship or order between these entities / operations / objects.

[0021] Reference to an "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0022] In the gRPC framework, connection management is crucial for efficient and stable remote communication. gRPC is a modern, high-performance RPC framework that supports multi-language and multi-environment operation.

[0023] The traditional static configuration connection management method has limitations and cannot flexibly adapt to the dynamic changes in the number of service nodes, resulting in resource waste or unmet communication needs. A new technical means is needed to solve the above technical problems.

[0024] In view of this, the embodiments of the present invention provide a method, apparatus, terminal device and storage medium for dynamic management of connections. By real-time detection of changes in the number of connected service nodes and dynamic adjustment of information collection operations, it is possible to ensure that the connection set in the connection pool is always consistent with the status of the current service node. This solves the limitation that the traditional static configuration connection management method cannot flexibly adapt to the dynamic changes in the number of service nodes, and effectively avoids the problem of resource waste or unmet communication needs. By dynamically updating the connection set, it can be ensured that the connections in the connection pool are always the latest and valid, and improve resource utilization efficiency.

[0025] In order to illustrate the technical solution of the present invention, specific embodiments are provided below for illustration.

[0026] Figure 1 The present invention provides a schematic diagram of a dynamic connection management method implementation process, which can be applied to a terminal device, such as a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, etc.

[0027] Specifically, the above-mentioned dynamic management method of connection may include the following steps S101 to S103.

[0028] Step S101, performing information collection operation on the connected service node to obtain a node information set, wherein the node information set includes at least one target node information, and the target node information includes a target IP address and a target port number.

[0029] In the implementation manner of the present invention, relevant parameters of information collection are configured, such as collection period, collection target (ie, service node), etc.

[0030] After the configuration is complete, start one or more information collection tasks. Information collection tasks are responsible for collecting information about service nodes periodically or on demand.

[0031] The information collection task will send query requests to the service node according to the configured parameters, or directly read information from a data source (such as a configuration file, database, etc.).

[0032] Through the information collection operation, a set of node information will be collected. This information usually includes the node's unique identifier (such as IP address and port number), status information (such as whether it is online, load status, etc.), and other possible configuration information. The collected node information will be organized into a node information set for use in subsequent steps.

[0033] Step S102: maintaining a connection set corresponding to the node information set in a connection pool according to the node information set.

[0034] In an embodiment of the present invention, before maintaining the connection pool, the current state of the connection pool is checked first, including the number of established connections, idle connections, and the state of the connection (such as whether it is valid, whether it has timed out, etc.).

[0035] Create new connections or update existing connections in the connection pool based on the node information set. This includes establishing a TCP / IP connection for the target node and configuring the relevant parameters of the connection (such as timeout, read / write buffer size, etc.). The connection set contains all the established connection instances corresponding to the nodes in the node information set. The connection instance is the channel for interacting with the actual service node.

[0036] By creating or updating connections, the connections in the connection pool are kept synchronized with the currently connected service nodes. This ensures that when the service nodes change (such as new nodes joining or existing nodes leaving), the connection pool will also be updated accordingly.

[0037] The program will set up a monitoring mechanism to continuously monitor the number of connected service nodes. For example, a timer is set to regularly check the number of nodes, or a notification mechanism (such as heartbeat packets, event callbacks, etc.) is used to receive real-time notifications of node status changes.

[0038] The monitoring mechanism will record the number of currently connected service nodes and save it in a data structure (such as variables, databases, etc.).

[0039] Periodically or on demand, compare the number of nodes currently recorded with the number of nodes last recorded. This can be achieved by comparing values.

[0040] If the number of nodes currently recorded is different from the number of nodes recorded last time, it indicates that the number of nodes connected to the service has changed.

[0041] Optionally, if the number in the connection pool is empty, then according to the node information set, the connection set corresponding to the node information set is created in the connection pool. When the connection pool is empty (such as when the system is started or the connection pool is cleared), necessary connections are established according to the latest node information, which can improve the startup speed and response capability; by creating connections only when the connection pool is empty, resource utilization is optimized and unnecessary resource consumption is reduced; at the same time, a fault recovery mechanism is provided, which can quickly reestablish connections after a fault, thereby enhancing service continuity.

[0042] Optionally, based on the node information set, an incremental update operation is performed on the current connection in the connection pool to maintain the connection set corresponding to the node information set. In the incremental update process, connections that become invalid due to server disconnection are detected and deleted. This helps to avoid invalid connections occupying connection pool resources and ensure that the connections in the connection pool are valid and available.

[0043] Step S103: if it is detected that the number of the connected service nodes has changed, return to the step of performing information collection operations on the connected service nodes to obtain a node information set.

[0044] In the implementation mode of the present invention, a change in the number of nodes is detected, triggering the re-execution of the information collection task, that is, the program will return to the information collection start-up phase to re-collect the latest node information.

[0045] By re-executing the information collection operation, the program will collect the latest node information and update the node information set.

[0046] The above steps form a loop. The program will repeat these steps to ensure that the connections in the connection pool always match the latest service node status. The loop process will continue until a certain exit condition is met (such as system shutdown, receiving a stop command, etc.). Before exiting, perform cleanup work, such as closing connections, releasing resources, etc.

[0047] The beneficial effects of the embodiments of the present invention compared with the prior art are: performing information collection operations on the connected service nodes to obtain a node information set, the node information set includes at least one target node information, the target node information includes a target IP address and a target port number; according to the node information set, maintaining the connection set corresponding to the node information set in the connection pool; if it is detected that the number of the connected service nodes has changed, returning to perform the information collection operation on the connected service nodes to obtain the step of obtaining the node information set. By real-time detection of changes in the number of connected service nodes and dynamically adjusting the information collection operation, it can be ensured that the connection set in the connection pool is always consistent with the status of the current service node. It solves the limitation that the traditional static configuration connection management method cannot flexibly adapt to the dynamic changes in the number of service nodes, and effectively avoids the problem of resource waste or communication needs not being met. By dynamically updating the connection set, it can be ensured that the connections in the connection pool are always the latest and valid, and improve resource utilization efficiency.

[0048] Traditional connection management methods usually rely on static connection configuration and simple error handling mechanisms. These methods often seem powerless when faced with dynamically changing network environments and service requirements. For example, when a service node is disconnected due to network failure, hardware failure, or software error, the traditional connection management method cannot detect this change in time, causing the system to continue to try to use the disconnected connection for data transmission or service request processing, which will waste system resources. Based on this, this embodiment provides an optional embodiment.

[0049] Figure 2 This is a schematic diagram of a specific embodiment after step S102 of the dynamic connection management method in an embodiment of the present invention. Step S102 also includes the following specific implementation methods.

[0050] Step S201: Using a heartbeat connection algorithm, detect whether there is a target connection with an abnormal connection status in the connection set.

[0051] In an embodiment of the present invention, a heartbeat connection mechanism is started, which is a method of regularly sending heartbeat packets to detect the connection status. The heartbeat packet usually contains simple information, such as a timestamp or a sequence number, to confirm that both parties of the connection are online and responding normally.

[0052] The heartbeat connection algorithm continuously detects the connection status of each connection in the connection set. This includes checking the sending and receiving of heartbeat packets and handling possible timeouts or error responses.

[0053] If it is detected that a connection (target connection) fails to respond to the heartbeat packet within the specified time, or the response does not meet expectations, the connection status is judged to be abnormal.

[0054] Step S202: If the target connection appears in the connection set, temporarily disable the target connection.

[0055] In the embodiment of the present invention, it is confirmed that the connection state is abnormal, and the target connection is temporarily disabled to prevent it from continuing to participate in data transmission or service request processing. Information of the target connection, such as abnormal time, abnormal type, etc., is recorded for subsequent analysis or processing. At the same time, the status of other connections is continuously monitored, and corresponding processing is performed as needed.

[0056] In the embodiment of the present invention, by timely detecting and processing the target connection, service interruption or data loss caused by connection interruption or error can be avoided, thereby improving the overall stability of the application scenario. Temporarily disabling the target connection can also release system resources occupied by these connections, such as memory, bandwidth, etc.

[0057] Traditional connection management methods usually rely on simple error handling mechanisms, such as retrying connections, recording error logs, etc. However, these methods often seem powerless when faced with frequent abnormalities or unstable connections. For example, when a connection frequently becomes abnormal due to network problems or server failures, traditional connection management methods may continue to try to use the connection for data transmission or service request processing, resulting in service interruption or data loss and other problems. Based on this, this embodiment provides an optional embodiment.

[0058] Figure 3 This is a schematic diagram of a specific embodiment after step S201 of the dynamic connection management method in an embodiment of the present invention. Step S201 also includes the following specific implementation methods.

[0059] Step S203: If the target connection appears in the connection set, count the number of abnormal times corresponding to the target connection.

[0060] In an embodiment of the present invention, if a connection fails to respond to a heartbeat packet on time, or the response content does not meet expectations, the connection is identified as a target connection.

[0061] Temporarily disable the identified target connection to prevent it from continuing to participate in data transmission or service request processing. Then start counting the number of abnormal times for the target connection, that is, the number of times it fails to correctly respond to heartbeat packets.

[0062] Step S204: if the abnormal number of times is a preset number of times, the target connection is deleted from the connection pool.

[0063] In the embodiment of the present invention, a counter is set for each abnormal target connection to count the number of times the connection is abnormal.

[0064] Each time a target connection anomaly is detected, the counter is incremented by one.

[0065] Periodically or when the counter reaches a certain value, check the counter for each target connection.

[0066] If the counter of a target connection reaches the preset threshold (preset number of times), the connection is deleted from the connection pool. After deleting the target connection, all resources related to the connection, such as network connection, memory, etc., are released.

[0067] In the embodiment of the present invention, by timely deleting connections that frequently have abnormalities, service interruption or data loss caused by these unstable connections can be avoided, thereby improving the overall stability of the application scenario.

[0068] When the number of service nodes changes, the traditional method takes a long time to realize this and update the connection pool accordingly. This may cause communication delays or interruptions. Based on this, this embodiment provides an optional embodiment.

[0069] Step S103 also includes the following specific implementation methods.

[0070] Step S1031, detecting the number of service nodes of the connected service node, and storing the number of service nodes.

[0071] In an embodiment of the present invention, the number of currently connected service nodes is detected and the detected number of service nodes is stored.

[0072] Step S1032: If there is a historical service node number, determine whether the number of the connected service nodes has changed according to the historical service node number and the service node number.

[0073] In an embodiment of the present invention, it is checked whether there is a previously stored historical number of service nodes, so as to compare the current number with the historical number to determine whether a change has occurred.

[0074] If the two are different, it is determined that the number of connected service nodes has changed.

[0075] Step S1033: if the number of the connected service nodes changes, return to the step of performing information collection operations on the connected service nodes.

[0076] In the embodiment of the present invention, when the number of service nodes changes, the connection pool can be quickly updated to ensure that the communication with all service nodes is kept up to date, thereby improving the system's response speed to node changes.

[0077] Figure 4 The structure diagram of a dynamic management device for connection provided by an embodiment of the present invention is shown. The dynamic management device for connection 400 may be configured on a terminal device. Specifically, the dynamic management device for connection 400 may include: The collection module 401 is used to perform information collection operations on the connected service nodes to obtain a node information set, wherein the node information set includes at least one target node information, and the target node information includes a target IP address and a target port number; A maintaining module 402, configured to maintain a connection set corresponding to the node information set in a connection pool according to the node information set; The loop module 403 is used to return to the step of performing information collection operation on the connected service nodes to obtain a node information set if it is detected that the number of the connected service nodes has changed.

[0078] The beneficial effects of the embodiments of the present invention compared with the prior art are: performing information collection operations on the connected service nodes to obtain a node information set, the node information set includes at least one target node information, the target node information includes a target IP address and a target port number; according to the node information set, maintaining the connection set corresponding to the node information set in the connection pool; if it is detected that the number of the connected service nodes has changed, returning to perform the information collection operation on the connected service nodes to obtain the step of obtaining the node information set. By real-time detection of changes in the number of connected service nodes and dynamically adjusting the information collection operation, it can be ensured that the connection set in the connection pool is always consistent with the status of the current service node. It solves the limitation that the traditional static configuration connection management method cannot flexibly adapt to the dynamic changes in the number of service nodes, and effectively avoids the problem of resource waste or communication needs not being met. By dynamically updating the connection set, it can be ensured that the connections in the connection pool are always the latest and valid, and improve resource utilization efficiency.

[0079] In some embodiments of the present invention, the maintaining module 402 is further used for: If the number in the connection pool is empty, the connection set corresponding to the node information set is created in the connection pool according to the node information set.

[0080] In some embodiments of the present invention, the maintaining module 402 is further used for: According to the node information set, an incremental update operation is performed on the current connection in the connection pool to maintain the connection set corresponding to the node information set.

[0081] In some embodiments of the present invention, the dynamic management device 400 for connection further includes a detection module for: Using a heartbeat connection algorithm, detecting whether there is a target connection with an abnormal connection status in the connection set; In some embodiments of the present invention, the dynamic management device 400 for connection further includes a statistical module for: If the target connection appears in the connection set, counting the number of abnormal times corresponding to the target connection; If the abnormal number of times is a preset number of times, the target connection is deleted from the connection pool.

[0082] In some embodiments of the present invention, the above-mentioned circulation module 403 is also used for: Detecting the number of service nodes of the connected service node, and storing the number of service nodes; If there is a historical number of service nodes, judging whether the number of the connected service nodes has changed according to the historical number of service nodes and the number of service nodes; If the number of the connected service nodes changes, the process returns to the step of performing information collection operations on the connected service nodes.

[0083] In some embodiments of the present invention, the acquisition module 401 is further used for: Periodically perform information collection operations on the connected service nodes to obtain a node information set.

[0084] like Figure 5 As shown, it is a schematic diagram of a terminal device provided by an embodiment of the present invention. The terminal device 5 may include: a processor 501, a memory 502, and a computer program 503 stored in the memory 502 and executable on the processor 501, such as a dynamic management program for connections. When the processor 501 executes the computer program 503, the steps in the above-mentioned dynamic management embodiments of connections are implemented. Alternatively, when the processor 501 executes the computer program 503, the functions of each module / unit in the above-mentioned device embodiments are implemented.

[0085] The computer program may be divided into one or more modules / units, one or more modules / units are stored in the memory 502 and executed by the processor 501 to complete the present invention. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.

[0086] The terminal device may include, but is not limited to, a processor 501 and a memory 502. Those skilled in the art will appreciate that Figure 5 It is only an example of a terminal device and does not constitute a limitation of the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.

[0087] The processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0088] The memory 502 may be an internal storage unit of the terminal device, such as a hard disk or memory of the terminal device. The memory 502 may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device. Further, the memory 502 may also include both an internal storage unit of the terminal device and an external storage device. The memory 502 is used to store computer programs and other programs and data required by the terminal device. The memory 502 may also be used to temporarily store data that has been output or is to be output.

[0089] It should be noted that, for the convenience and brevity of description, the structure of the above-mentioned terminal device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.

[0090] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0091] An embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned dynamic management method of connections can be implemented.

[0092] An embodiment of the present invention provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned dynamic connection management method when executing the computer program product.

[0093] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0094] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0095] In the embodiments provided by the present invention, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0096] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0097] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0098] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0099] The above-described embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above-described embodiments, a person skilled in the art should understand that the technical solutions described in the above-described embodiments can still be modified, or some of the technical features can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims

1. A method for dynamic management of connections, characterized in that: include: Performing information collection operations on the connected service nodes to obtain a node information set, wherein the node information set includes at least one target node information, and the target node information includes a target IP address and a target port number; According to the node information set, maintaining a connection set corresponding to the node information set in a connection pool; If it is detected that the number of the connected service nodes has changed, the process returns to the step of performing information collection operations on the connected service nodes to obtain a node information set.

2. The method for dynamic connection management according to claim 1, characterized in that: The step of maintaining a connection set corresponding to the node information set in a connection pool according to the node information set comprises: If the number in the connection pool is empty, the connection set corresponding to the node information set is created in the connection pool according to the node information set.

3. The method for dynamic connection management according to claim 1, characterized in that: The step of maintaining a connection set corresponding to the node information set in a connection pool according to the node information set comprises: According to the node information set, an incremental update operation is performed on the current connection in the connection pool to maintain the connection set corresponding to the node information set.

4. The method for dynamic connection management according to claim 1, characterized in that: After the step of maintaining, in a connection pool, a connection set corresponding to the node information set according to the node information set, the method further comprises: Using a heartbeat connection algorithm, detecting whether there is a target connection with an abnormal connection status in the connection set; If the target connection appears in the connection set, temporarily disable the target connection.

5. The method for dynamic management of connections according to claim 4, characterized in that: After the step of detecting whether there is a target connection with an abnormal connection status in the connection set by a heartbeat connection algorithm, the method further includes: If the target connection appears in the connection set, counting the number of abnormal times corresponding to the target connection; If the abnormal number of times is a preset number of times, the target connection is deleted from the connection pool.

6. The method for dynamic management of connections according to claim 1, characterized in that: If it is detected that the number of the connected service nodes has changed, returning to the step of performing the information collection operation on the connected service nodes comprises: Detecting the number of service nodes of the connected service node, and storing the number of service nodes; If there is a historical number of service nodes, judging whether the number of the connected service nodes has changed according to the historical number of service nodes and the number of service nodes; If the number of the connected service nodes changes, the process returns to the step of performing information collection operations on the connected service nodes.

7. The method for dynamic management of connections according to claim 1, characterized in that: The step of performing information collection operation on the connected service node to obtain a node information set includes: Periodically perform information collection operations on the connected service nodes to obtain a node information set.

8. A dynamic management device for connection, characterized in that: include: A collection module, used to perform information collection operations on the connected service nodes to obtain a node information set, wherein the node information set includes at least one target node information, and the target node information includes a target IP address and a target port number; A maintaining module, used for maintaining a connection set corresponding to the node information set in a connection pool according to the node information set; The loop module is used to return to the step of performing information collection operation on the connected service nodes to obtain a node information set if it is detected that the number of the connected service nodes has changed.

9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for dynamic management of connections as claimed in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for dynamic connection management according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Connection method and apparatus between client and service node, computing device and storage medium

    CN109274641A

  • Information updating method and device, storage medium and electronic equipment

    CN112506610A

  • Google remote procedure call load balancing system and method, equipment and medium

    CN117311979A

  • Service routing method and device and electronic equipment

    CN118869571A