CN-121985041-A - Client monitoring management method, system, device, terminal equipment and storage medium
Abstract
The application is applicable to the technical field of intelligent terminals and provides a client monitoring management method, a system, a device, terminal equipment and a storage medium, wherein the method comprises the steps of receiving a registration request which is sent by a client and comprises a process identifier and a callback interface; the method comprises the steps of creating a callback wrapper corresponding to a client according to a process identifier and a callback interface, registering death monitoring aiming at the client process based on the callback interface, storing a mapping relation between the process identifier and the callback wrapper into a callback set, triggering the callback wrapper to execute resource cleaning operation of the client when the death of the client process is known through notification triggered by the death monitoring, wherein the resource cleaning operation comprises the steps of removing the mapping relation corresponding to the process identifier from the callback set, and relieving the death monitoring aiming at the client process. The method and the system can enable the server to automatically sense the process state of the client, optimize the resource management efficiency of the server, improve the stability of cross-process communication and avoid resource leakage of the server.
Inventors
- JIA KELI
Assignees
- 深圳市鸿合创新信息技术有限责任公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251231
Claims (10)
- 1. The client monitoring and managing method is characterized by being applied to a server and comprising the following steps: receiving a registration request sent by a client, wherein the registration request comprises a process identifier of the client and a callback interface corresponding to the client; creating a callback wrapper corresponding to the client according to the process identifier and the callback interface, wherein the callback wrapper is used for packaging the association relation between the process identifier and the callback interface and is called back when the client process dies; registering death interception aiming at the client process based on the callback interface, wherein the death interception is used for triggering notification when the client process dies; storing the mapping relation between the process identifier and the callback wrapper into a callback set, wherein the callback set is used for maintaining registration information of all active clients; when the death of the client process is known through the notice of the death monitoring trigger, triggering the callback wrapper to execute the resource cleaning operation of the client, wherein the resource cleaning operation comprises the steps of removing the mapping relation corresponding to the process identifier from the callback set and releasing the death monitoring of the client process.
- 2. The method according to claim 1, wherein the method further comprises: when a message needs to be sent to a registered client, traversing all mapping relations in the callback set; For each mapping relation, sending a message to a corresponding registered client through a callback interface encapsulated by a callback wrapper of the mapping relation; and if an abnormality indicating communication failure is captured in the sending process of the message, executing the resource cleaning operation aiming at the registered client.
- 3. The method of claim 2, wherein the performing the resource cleaning operation for the registered client comprises: executing a differential cleaning strategy aiming at the registered client according to the type of the abnormality; If the exception is a remote call exception, immediately executing the resource cleaning operation; and if the abnormality is authority abnormality or runtime abnormality, executing the resource cleaning operation after recording an abnormality log.
- 4. The method of claim 1, further comprising, prior to the creating a callback wrapper: inquiring the callback set according to the process identifier, and judging whether a history callback wrapper associated with the process identifier exists in the callback set; And if so, based on the history callback wrapper, removing the history death monitoring aiming at the client process, and removing the history mapping relation between the process identification and the history callback wrapper from the callback set.
- 5. The method according to claim 1, wherein the method further comprises: after the server is restarted, receiving service connection restarted by the client; after the service connection is reestablished, receiving a registration request resent by the client to reestablish the mapping relation between the process identifier and the new callback wrapper, and registering new death monitoring for the client process.
- 6. The method according to any one of claims 1 to 5, further comprising, prior to said receiving a registration request sent by a client: Acquiring and storing a role mode of the client, wherein the role mode is used for indicating that the client is a host application or a common client application; And determining a communication mode for sending the message to the client based on the role mode.
- 7. The client monitoring and managing system is characterized by comprising a server and at least one client, wherein: The client is used for acquiring a self role mode, binding the client to an inter-process communication service provided by the server according to the role mode, and sending a registration request comprising a self process identifier and a callback interface to the server after successful binding; The method comprises the steps of receiving a registration request sent by a client, wherein the registration request comprises a process identifier of the client and a callback interface corresponding to the client, creating a callback wrapper corresponding to the client according to the process identifier and the callback interface, wherein the callback wrapper is used for packaging an association relation between the process identifier and the callback interface and is called back when the client process dies, registering death monitoring aiming at the client process based on the callback interface, triggering notification when the client process dies, storing a mapping relation between the process identifier and the callback wrapper into a callback set, wherein the callback set is used for maintaining registration information of all active clients, and triggering the callback wrapper to execute resource cleaning operation of the client when the client process dies through the notification triggered by the death monitoring, wherein the resource cleaning operation comprises removing the mapping relation corresponding to the process identifier from the callback set and releasing the monitoring aiming at the death of the client process.
- 8. A client monitoring and management apparatus, comprising: The system comprises a request receiving unit, a request sending unit and a receiving unit, wherein the request receiving unit is used for receiving a registration request sent by a client, and the registration request comprises a process identifier of the client and a callback interface corresponding to the client; The wrapper creation unit is used for creating a callback wrapper corresponding to the client according to the process identifier and the callback interface, and the callback wrapper is used for wrapping the association relation between the process identifier and the callback interface and is called back when the client process dies; a monitoring registration unit, configured to register, based on the callback interface, a death monitoring for the client process, where the death monitoring is used to trigger a notification when the client process dies; The relation storage unit is used for storing the mapping relation between the process identifier and the callback wrapper into a callback set, and the callback set is used for maintaining registration information of all active clients; And the monitoring management unit is used for triggering the callback wrapper to execute the resource cleaning operation of the client when the death of the client process is known through the notification triggered by the death monitoring, wherein the resource cleaning operation comprises the steps of removing the mapping relation corresponding to the process identifier from the callback set and relieving the death monitoring of the client process.
- 9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the client monitoring management method according to any of claims 1 to 6 when executing the computer program.
- 10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the client monitoring management method according to any one of claims 1 to 6.
Description
Client monitoring management method, system, device, terminal equipment and storage medium Technical Field The present application relates to the field of intelligent terminals, and in particular, to a method, a system, an apparatus, a terminal device, and a storage medium for monitoring and managing a client. Background In application development based on an android system, cross-process communication generally builds an interaction channel between a server and a client based on an interface definition language, the server externally provides a specific implementation of a communication interface, and the client obtains an interface proxy object through a binding service so as to realize data exchange and message communication between processes. However, in the existing cross-process communication architecture, the server lacks effective sensing and resource management capability for the survival state of the client process, when the client application exits for various reasons, the server cannot process related resources corresponding to the client in time, so that the resource management problem of the server can be caused for a long time, not only can the resource leakage of the server be caused, but also communication abnormality can be caused when the server sends a message to the client, meanwhile, the operation burden of the server can be increased, and the stability of the cross-process communication is adversely affected. In view of this, how to enable the server to automatically sense the process state of the client, optimize the resource management efficiency of the server, promote the stability of cross-process communication, avoid the resource leakage of the server, and is a problem to be solved at present. Disclosure of Invention The embodiment of the application provides a client monitoring management method, a system, a device, terminal equipment and a storage medium, which can enable a server to automatically sense the process state of the client, optimize the resource management efficiency of the server, promote the stability of cross-process communication and avoid the resource leakage of the server. In a first aspect, an embodiment of the present application provides a client monitoring and management method, which is applied to a server, and includes: receiving a registration request sent by a client, wherein the registration request comprises a process identifier of the client and a callback interface corresponding to the client; creating a callback wrapper corresponding to the client according to the process identifier and the callback interface, wherein the callback wrapper is used for packaging the association relation between the process identifier and the callback interface and is called back when the client process dies; registering death interception aiming at the client process based on the callback interface, wherein the death interception is used for triggering notification when the client process dies; storing the mapping relation between the process identifier and the callback wrapper into a callback set, wherein the callback set is used for maintaining registration information of all active clients; when the death of the client process is known through the notice of the death monitoring trigger, triggering the callback wrapper to execute the resource cleaning operation of the client, wherein the resource cleaning operation comprises the steps of removing the mapping relation corresponding to the process identifier from the callback set and releasing the death monitoring of the client process. In a possible implementation manner of the first aspect, the method further includes: when a message needs to be sent to a registered client, traversing all mapping relations in the callback set; For each mapping relation, sending a message to a corresponding registered client through a callback interface encapsulated by a callback wrapper of the mapping relation; and if an abnormality indicating communication failure is captured in the sending process of the message, executing the resource cleaning operation aiming at the registered client. In a possible implementation manner of the first aspect, the performing the resource cleaning operation for the registered client includes: executing a differential cleaning strategy aiming at the registered client according to the type of the abnormality; If the exception is a remote call exception, immediately executing the resource cleaning operation; and if the abnormality is authority abnormality or runtime abnormality, executing the resource cleaning operation after recording an abnormality log. In a possible implementation manner of the first aspect, before the creating a callback wrapper, the method further includes: inquiring the callback set according to the process identifier, and judging whether a history callback wrapper associated with the process identifier exists in the callback set; And if so, based on the history callback wrappe