CN111699479A - Log processing method, log processing device and computer-readable storage medium - Google Patents

Log processing method, log processing device and computer-readable storage medium Download PDF

Info

Publication number
CN111699479A
CN111699479A CN201980012096.4A CN201980012096A CN111699479A CN 111699479 A CN111699479 A CN 111699479A CN 201980012096 A CN201980012096 A CN 201980012096A CN 111699479 A CN111699479 A CN 111699479A
Authority
CN
China
Prior art keywords
client
shared memory
server
log
memory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201980012096.4A
Other languages
Chinese (zh)
Inventor
廖凯
邱桂添
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SZ DJI Technology Co Ltd
Original Assignee
SZ DJI Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SZ DJI Technology Co Ltd filed Critical SZ DJI Technology Co Ltd
Publication of CN111699479A publication Critical patent/CN111699479A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention provides a log processing method, log processing equipment and a computer readable storage medium, wherein the method comprises the following steps: the client sends a registration request to the server through a preset calling interface; the server receives a registration request sent by a client; the server side applies for sharing the memory for the client side according to the registration request; after the shared memory application is successful, the server side sends registration success information to the client side; when the client receives the registration success information fed back by the server, the log information of the client is written into the shared memory; and the server side acquires the log information from the shared memory and stores the log information to a preset storage path. The server can apply for the shared memory for the client corresponding to the thread according to the at least one thread of the at least one client, so that the method and the system can be suitable for high concurrency scenes, and can further effectively manage logs of multiple processes.

Description

Log processing method, log processing device and computer-readable storage medium
Technical Field
The present invention relates to the field of communications, and in particular, to a log processing method and apparatus, and a computer-readable storage medium.
Background
Network devices, systems, and service programs, etc. generate log logs during their operation, each log recording a description of the operation of the date, time, user, and action. In practical application, a large number of logs are often generated in a large software project, and because the number of the logs is large, how to quickly realize communication and storage of the logs becomes an urgent problem to be solved.
In the prior art, the storage of the log is generally realized by a Syslog logging system. Specifically, the Syslog system supports local and remote log storage services by providing a calling interface, a configuration file and a daemon, and the remote log storage service can acquire logs by monitoring a fixed port.
However, when the method is used for log storage, two sockets are needed to realize bidirectional data interaction, which is not suitable for high concurrency scenarios and cannot separately manage logs of multiple processes.
Disclosure of Invention
The embodiment of the invention provides a log processing method, log processing equipment and a computer readable storage medium, which are used for solving the technical problems that the existing log processing method is not suitable for high-concurrency scenes and can not manage logs of multiple processes.
A first aspect of an embodiment of the present invention provides a log processing method, including:
the client sends a registration request to the server through a preset calling interface;
the server receives a registration request sent by a client;
the server side applies for sharing the memory for the client side according to the registration request;
after the shared memory application is successful, the server side sends registration success information to the client side;
when the client receives the registration success information fed back by the server, the log information of the client is written into the shared memory;
and the server side acquires the log information from the shared memory and stores the log information to a preset storage path.
A second aspect of the embodiments of the present invention provides a log processing method, which is applied to a client, and the method includes:
sending a registration request to a server through a preset calling interface
And when the registration success information fed back by the server is received, writing the log information of the client into the shared memory of the client and the server.
A third aspect of the embodiments of the present invention provides a log processing method, which is applied to a server, and the method includes:
receiving a registration request sent by a client;
applying for sharing the memory for the client according to the registration request;
after the shared memory application is successful, sending registration success information to the client;
and acquiring the log information of the client from the shared memory of the client and the server, and storing the log information to a preset storage path.
A fourth aspect of embodiments of the present invention provides a log processing system, including
One or more processors;
one or more memories;
the memory is used for storing program codes;
the processor, configured to invoke the program code, when the program code is executed, is configured to perform the following:
sending a registration request to a server through a calling interface preset by a client;
receiving a registration request sent by a client through the server;
applying for a shared memory for the client by the server according to the registration request;
after the shared memory application is successful, sending registration success information to the client through the server;
when the registration success information fed back by the server side is received, the log information of the client side is written into the shared memory through the client side;
and acquiring the log information from the shared memory through the server and storing the log information to a preset storage path.
A fifth aspect of an embodiment of the present invention is to provide a client terminal device, where the terminal device includes:
a memory and a processor;
the memory is used for storing program codes;
the processor, invoking the program code, when executed, is configured to:
sending a registration request to a server through a preset calling interface
And when the registration success information fed back by the server is received, writing the log information into the shared memory of the client and the server.
A sixth aspect of the embodiments of the present invention provides a service terminal apparatus, including: a memory and a processor;
the memory is used for storing program codes;
the processor, invoking the program code, when executed, is configured to:
receiving a registration request sent by a client;
applying for sharing the memory for the client according to the registration request;
after the shared memory application is successful, sending registration success information to the client;
and acquiring the log information of the client from the shared memory and storing the log information to a preset storage path.
A seventh aspect of embodiments of the present invention is to provide a computer-readable storage medium, on which a computer program is stored, the computer program being executed by a processor to implement the method of the first aspect, the second aspect or the third aspect.
The log processing method, the log processing device, and the computer-readable storage medium provided in this embodiment send a registration request to the server through a preset call interface, so that the server applies for a shared memory for the client according to the registration request, and feeds back registration success information to the client after the shared memory is successfully applied, where the client and the server share the shared memory. After the successful registration information fed back by the server is received, the log information generated by the client is written into the shared memory, so that the server can acquire the log information written by the client from the shared memory and store the log information into a preset storage path. The server side can apply for sharing the memory according to at least one thread of at least one client side, so that the method and the system are suitable for high concurrency scenes, and can further effectively manage logs of multiple processes.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
Fig. 1 is a schematic flowchart of a log processing method according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a log processing method according to a second embodiment of the present invention;
fig. 3 is a schematic flowchart of a log processing method according to a third embodiment of the present invention;
fig. 4 is a schematic flowchart of a log processing method according to a fourth embodiment of the present invention;
fig. 5 is a schematic flowchart of a log processing method according to a fifth embodiment of the present invention;
fig. 6 is a schematic flowchart of a log processing method according to a sixth embodiment of the present invention;
fig. 7 is a schematic flowchart of a log processing method according to a seventh embodiment of the present invention;
fig. 8 is a schematic flowchart of a log processing method according to an eighth embodiment of the present invention;
fig. 9 is a schematic flowchart of a log processing method according to a ninth embodiment of the present invention;
fig. 10 is a schematic structural diagram of a client terminal device according to a tenth embodiment of the present invention;
fig. 11 is a schematic structural diagram of a service terminal device according to an eleventh embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described clearly below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It will be understood that when an element is referred to as being "secured to" another element, it can be directly on the other element or intervening elements may also be present. When a component is referred to as being "connected" to another component, it can be directly connected to the other component or intervening components may also be present.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
Some embodiments of the invention are described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
In order to solve the technical problems that the existing log processing method is not suitable for a high-concurrency scene and logs of multiple processes cannot be managed, the invention provides a log processing method, log processing equipment and a computer readable storage medium.
Fig. 1 is a schematic flowchart of a log processing method according to an embodiment of the present invention, and as shown in fig. 1, the log processing method includes:
step 101, a client sends a registration request to a server through a preset calling interface;
102, the server receives a registration request sent by a client;
step 103, the server applies for a shared memory for the client according to the registration request;
step 104, after the shared memory application is successful, the server side sends registration success information to the client side;
step 105, when receiving the registration success information fed back by the server, the client writes the log information of the client into the shared memory;
and step 106, the server side acquires the log information from the shared memory and stores the log information to a preset storage path.
The execution subject of this embodiment is a log processing system, wherein the log processing system includes a client and a server. In order to realize the storage of the log information, the client can send a registration request to the server through a preset calling interface. Accordingly, after receiving the registration request, the server may determine whether to apply for the shared memory for the client according to the registration request. For example, if the current storage space of the server is insufficient and the processing capability is weak, the server may not apply for the shared memory for the client according to the registration request; if the current storage space of the server is more and the processing capacity is stronger, the server can apply for the shared memory for the client according to the registration request. The client and the server share the shared memory, specifically, the client can write the generated log information into the shared memory, and the server can take the log information out of the shared memory. Further, after the server determines that the shared memory can be applied for the client according to the registration request, the server may feed back registration success information to the client, so that the client can know the state of the current registration request in time. When receiving the registration success information sent by the server, the client can write the log information to be stored into the shared memory. The registration success information may include a storage address of the shared memory, and the registration success information may be sent to the client by the server through a preset or newly added call interface. Therefore, the server can obtain the log information stored by the client from the shared memory and store the log information to a preset storage path.
Optionally, on the basis of any of the foregoing embodiments, the shared memory is a lock queue instance.
Further, in any of the above embodiments, the registration request is sent by one of the threads of the client.
In this embodiment, the registration request may be specifically sent by one of the threads in the client. Because the client has a plurality of threads, each thread can send a registration request to the server, and correspondingly, the server can respectively apply for the shared memory for the client where the thread is located according to the registration requests sent by the threads. The shared memory is applied for the multiple threads of the client side respectively, so that log storage under the high concurrency condition can be realized.
In the log processing method provided by this embodiment, the client sends a registration request to the server through a preset call interface; a server receives a registration request sent by a client; the server side applies for sharing the memory for the client side according to the registration request; after the shared memory application is successful, the server side sends registration success information to the client side; when receiving the registration success information fed back by the server, the client writes the log information of the client into the shared memory; and the server acquires the log information from the shared memory and stores the log information to a preset storage path. The server can apply for the shared memory for the client corresponding to the thread according to the at least one thread of the at least one client, so that the method and the system can be suitable for high concurrency scenes, and can further effectively manage logs of multiple processes.
Further, in any of the above embodiments, the shared memory is a lock-free queue instance.
In this embodiment, the shared memory may specifically be a lock-free queue instance, which may be a lock-free queue instance implemented by a Compare and replace (CAS) mechanism, or a lock-free queue instance implemented by any other mechanism, which is not limited herein. The lock-free queue instance can save the lock overhead on the basis of improving the log processing efficiency.
According to the log processing method provided by the embodiment, the lock-free queue instance is used as the shared memory, so that the log processing effect can be improved, and further the log processing under a multi-process high-concurrency scene can be realized.
Further, on the basis of any of the above embodiments, the writing the log information of the client into the shared memory includes:
and writing the log of each thread in the client into the shared memory according to a preset thread storage sequence.
In this embodiment, in order to improve the log processing efficiency, a thread storage order may be preset, where the thread storage order may be determined by one or more of the factors such as the priority, the urgency, the data size, and the sending time of each thread, and may also be adjusted by the user in real time according to the current requirement, which is not limited herein. After receiving multiple registration requests sent by multiple threads in the client and applying for the shared memory, the log information written by each thread can be written into the shared memory according to the thread storage sequence.
According to the log processing method provided by the embodiment, the log of each thread in the client is written into the shared memory according to the preset thread storage sequence, so that the efficiency of log processing can be effectively improved.
Further, on the basis of any of the above embodiments, the writing the log information of the client into the shared memory includes:
and storing the log information with the priority higher than the preset first printing level into the shared memory.
In this embodiment, the number of log information written by the client is large, and different log information has different priorities. Therefore, in order to optimize the quality of the log information and reduce the storage space, after receiving the written log information, the priority of the log information may be determined first, and the log information with the priority higher than a preset first printing level is written into the shared memory, where the first printing level may be set by a user according to an actual requirement or may be a printing level preset by a system, and the present invention is not limited herein.
Specifically, on the basis of any of the above embodiments, the print levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
According to the log processing method provided by the embodiment, the log information with the priority higher than the preset first printing level is stored in the shared memory, so that the log processing efficiency can be improved on the basis of optimizing the quality of the log information and reducing the storage space.
Further, on the basis of any of the above embodiments, the writing the log information of the client into the shared memory includes:
and the client writes the log information of the client into the shared memory in an asynchronous storage mode.
In this embodiment, because the existing log processing method generally waits for the server to feed back the successful storage of the log information after the client writes the log information in the server, and performs the subsequent log writing operation, it often takes time, and the log processing efficiency is low. In order to improve the log processing efficiency, the log information of the client can be written into the shared memory in an asynchronous storage mode. Specifically, after the client writes the log information into the shared memory, the subsequent log writing operation can be performed without waiting for the successful storage information fed back by the server.
According to the log processing method provided by the embodiment, the log information of the client is written into the shared memory in an asynchronous storage mode, so that the log writing speed can be effectively increased, and the log processing efficiency can be further improved. In addition, different from the technical scheme of ZLog log storage in the prior art, log information is stored in an asynchronous storage mode, the problem that IO blocking is easily caused by synchronous ZLog storage in the prior art can be effectively solved, and the method is suitable for systems with high real-time requirements.
Further, on the basis of any of the above embodiments, before sending the registration request to the server through the call interface preset by the client, the method further includes:
and the client generates the registration request according to preset log write-in configuration.
In this embodiment, before sending the registration request to the server, the log write configuration may be determined first. The log write configuration may be specifically input by a user according to current requirements, or may be a default write configuration, which is not limited herein. And generating a registration request according to the log write-in configuration, and sending the registration request to the server, so that the server can apply for the shared memory by the client according to the log write-in configuration. The log writing configuration comprises at least one of the size of a memory to be occupied, a storage mode, a storage position, the division of a stored subfolder and the size of the stored subfolder. Optionally, the different priorities may correspond to different log write configurations, for example, the log write configuration with the lower priority may only include the size of the memory to be occupied, and the log write configuration of the client with the higher priority may also include other personalized requirement parameters.
According to the log processing method provided by the embodiment, the registration request is generated according to the preset log writing configuration, so that the personalized requirements of the client in the log writing process can be met on the basis of improving the log processing efficiency.
Fig. 2 is a flowchart of a log processing method according to a second embodiment of the present invention, where on the basis of any one of the foregoing embodiments, as shown in fig. 2, after the log information of the client is written into the shared memory when the registration success information fed back by the server is received, the method further includes:
step 201, the client obtains the number of connections of the shared memory;
step 202, the client determines whether the server is disconnected from the shared memory according to the connection number.
In this embodiment, in order to successfully write and fetch the log information, the client and the server need to be connected to the shared memory at the same time. Therefore, in order to ensure that the server does not drop during the log processing, the number of connections of the shared memory can be acquired. It should be noted that, when there is no server drop, the total connection amount of the shared memory is the total number of the server and the client currently connected to the shared memory, and therefore, the current state of the server can be determined according to the connection amount. After the connection number is determined, whether the server is disconnected from the shared memory can be determined according to the connection number.
In the log processing method provided in this embodiment, whether the server and the shared memory are disconnected is determined according to the connection number by obtaining the connection number of the shared memory. Therefore, the effectiveness of log writing can be ensured, and the efficiency of log processing is further improved.
Further, on the basis of any of the above embodiments, the determining whether the server is disconnected from the shared memory according to the connection number includes:
if the client side is connected with the shared memory and the connection number is smaller than the preset connection total amount, judging that the server side is disconnected with the shared memory; wherein, the total connection amount is the connection number of the shared memory in a normal log storage state;
and if the client side and the shared memory are kept connected and the connection number is not less than the preset total connection amount, judging that the server side and the shared memory are not disconnected.
In this embodiment, if the client is currently connected to the shared memory and the connection number is smaller than a preset connection total amount, it may be determined that the server is disconnected from the shared memory, where the connection total amount is the connection number of the shared memory in a normal log storage state. Otherwise, if the client is currently connected with the shared memory and the connection number is not less than the preset connection total amount, it may be determined that the server is not disconnected currently. For example, in practical applications, if a client and a server are currently connected to the shared memory, the number of connections of the shared memory is 2. If the client detects that the current connection number of the shared memory is 2, it can be determined that the current server normally operates without disconnection, and correspondingly, if the client detects that the current connection number of the shared memory is 1, it can be determined that the server is disconnected, and at this time, in order to ensure normal processing of log information, the server needs to be reminded.
In the log processing method provided by this embodiment, if the client is connected to the shared memory and the connection number is smaller than a preset connection total amount, it is determined that the server is disconnected from the shared memory; and if the client keeps connection with the shared memory and the connection number is not less than the preset connection total amount, judging that the server is not disconnected with the shared memory. Therefore, the effectiveness of log writing can be ensured, and the efficiency of log processing is further improved.
Fig. 3 is a schematic flow chart of a log processing method according to a third embodiment of the present invention, where on the basis of any of the foregoing embodiments, as shown in fig. 3, the method further includes:
step 301, when the server is judged to be disconnected, sending a reconnection request to the server according to a preset frequency;
step 302, when the server receives a reconnection request sent by the client, the server reconnects with the shared memory according to the reconnection request.
In this embodiment, if it is detected through the connection number that the server is currently disconnected from the shared memory, the representation server cannot acquire and store the log information from the shared memory in time, which results in low log processing efficiency and overlong time for the client to occupy the shared memory. Therefore, when the server is determined to be disconnected, a reconnection request can be sent to the server according to a preset frequency, so that the server can establish communication connection with the shared memory again according to the reconnection request. The preset frequency may be a preset frequency, or may be set according to an actual requirement, for example, if the priority corresponding to the client is higher, the reconnection request may be sent according to the higher frequency; if the shared memory occupied by the client is large, the reconnection request may also be sent at a high frequency, which is not limited herein.
According to the log processing method provided by the embodiment, when the server is judged to be disconnected, the reconnection request is sent to the server according to the preset frequency, and the server can be connected with the shared memory according to the reconnection request, so that the log writing effectiveness can be ensured, and the log processing efficiency is further improved.
Further, on the basis of any of the above embodiments, the registration success information includes an identification code that is assigned to the client by the server; the reconnection request includes the identification code; the server reconnects with the shared memory according to the reconnection request, including:
and the server is connected to the shared memory according to the identification code in the reconnection request.
In this embodiment, after the server successfully applies for the shared memory, the server may send registration success information to the client, where the registration success information includes an identification code allocated by the server to the client. When the client detects that the server is disconnected from the shared memory, a reconnection request including the identification code can be sent to the server, so that the server can be reconnected to the shared memory according to the identification code.
In the log processing method provided by this embodiment, the identification code in the received registration success information is placed in the reconnection request and sent to the server, so that the server can reconnect to the shared memory according to the identification code, and the log processing efficiency can be further improved on the basis of ensuring the validity of log writing.
Further, on the basis of any of the above embodiments, the obtaining, by the server, the log information from the shared memory, and storing the log information to a preset storage path includes:
and the server side acquires the log information with the priority higher than a preset second printing level from the shared memory and stores the log information to a preset storage path.
In this embodiment, the number of log information written by the client is large, and different log information has different priorities. Therefore, in order to optimize the quality of the log information and reduce the storage space, when the server side acquires the log information from the shared memory, the priority of the log information needs to be determined first, and the log information with the priority higher than the preset second printing level needs to be stored in the preset storage path. The second printing level may be set by the user according to actual requirements, or may be a printing level preset by the system, which is not limited herein.
Specifically, on the basis of any of the above embodiments, the print levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
According to the log processing method provided by the embodiment, the log information with the priority higher than the preset second printing level is acquired from the shared memory and is stored to the preset storage path, so that the log processing efficiency can be improved on the basis of optimizing the quality of the log information and reducing the storage space.
Further, on the basis of any of the above embodiments, the obtaining, by the server, the log information from the shared memory, and storing the log information to a preset storage path includes:
and the server acquires the log information from the shared memory in a single-thread mode and stores the log information into a preset storage path.
In this embodiment, in order to improve the log processing efficiency, after the client writes the log information into the shared memory, the server may obtain the log information from the shared memory in a single process and store the log information into a preset storage path.
According to the log processing method provided by the embodiment, the log information is acquired from the shared memory in a single-thread mode and is stored in the preset storage path, so that the log writing speed can be effectively increased, and the log processing efficiency can be further improved.
Further, on the basis of any of the above embodiments, the applying for the shared memory for the client according to the registration request, where the registration request includes an amount of memory to be occupied, includes:
determining the current memory surplus of the server;
and the server side applies for the shared memory for the client side according to the memory surplus and the memory amount to be occupied.
In this embodiment, the registration request may include the amount of memory to be occupied. Specifically, when the client sends the registration request to the server, the client may determine the amount of the memory to be occupied, and generate the registration request according to the amount of the memory to be occupied. After receiving the registration request, the server may first determine the current remaining amount of the memory, and apply for the shared memory for the client according to the remaining amount of the memory and the amount of the memory to be occupied.
Specifically, on the basis of any of the above embodiments, the applying for the shared memory by the client according to the remaining memory amount and the memory amount to be occupied includes:
if the amount of the memory to be occupied is smaller than the residual amount of the memory, applying for a shared memory corresponding to the amount of the memory to be occupied for the client;
and if the amount of the memory to be occupied is not less than the residual amount of the memory, refusing to apply for the shared memory for the client.
In this embodiment, if it is detected that the amount of the memory to be occupied is less than the remaining amount of the memory, a shared memory corresponding to the amount of the memory to be occupied may be applied for the client; on the contrary, if the amount of the memory to be occupied is not less than the remaining amount of the memory, the server side is represented that the current remaining memory is insufficient to apply for the shared memory by the client side, and at this time, the client side can be refused to apply for the shared memory.
According to the log processing method provided by the embodiment, the current memory surplus of the server is determined, and the shared memory is applied to the client according to the memory surplus and the memory amount to be occupied, so that the shared memory can be rapidly applied to the client, and the log processing efficiency is improved.
Further, on the basis of any of the above embodiments, the registration request further includes a process identifier of the client;
correspondingly, the applying for the shared memory for the client according to the registration request includes:
judging whether a preset process blacklist comprises the process identification or not;
if not, applying for the shared memory for the client;
and if so, refusing to apply for the shared memory for the client.
In this embodiment, the registration request further includes a process identifier for an actual application, for example, some clients may have an operation of writing a log maliciously, and the like. Therefore, after receiving the registration request including the process identifier, the server may detect whether the blacklist includes the process identifier, and if so, the server may refuse to apply for the shared memory for the client, otherwise, the server may apply for the shared memory for the client according to the registration request. Optionally, log information generated by some clients may be more important or priorities of some clients may be higher, and the like, and therefore, the server may also generate a white list according to historical experience, where the white list includes the process identifier. Therefore, after receiving the registration request including the process identifier, the server may detect whether the white list includes the process identifier, and if so, may provide a larger shared memory for the client corresponding to the process identifier, or may store log information with a lower priority for the client corresponding to the process identifier.
As an implementation manner, different clients have different priorities, and the server may provide different services for the clients according to the different priorities. Therefore, after receiving the registration request including the process identifier, the server may first determine the priority corresponding to the process identifier, and provide the service corresponding to the priority for the client according to the priority.
According to the log processing method provided by the embodiment, whether the process identifier is included in the preset process blacklist is judged, if not, the shared memory is applied for the process, and if so, the shared memory is refused to be applied for the process, so that the server can selectively apply for the client to apply for the shared memory, and the safety of the server can be guaranteed on the basis of guaranteeing the log processing efficiency.
Further, on the basis of any of the above embodiments, the registration request is generated according to a preset log write configuration;
applying for the shared memory for the client according to the registration request includes:
and the server side applies for the shared memory for the client side according to the log write-in configuration.
In this embodiment, before sending the registration request to the server, the client may first determine a log write configuration, and generate the registration request according to the log write configuration. The log write configuration may be specifically input by a user according to current requirements, or may be a default write configuration, which is not limited herein. The server can configure the client to apply for the shared memory according to the log writing. The log writing configuration comprises at least one of the size of a memory to be occupied, a storage mode, a storage position, the division of a stored subfolder and the size of the stored subfolder. The stored subfolders are used for dividing the stored subfolders according to different functions of threads and dividing the stored subfolders according to different types of logs. Optionally, the different priorities may correspond to different log write configurations, for example, the log write configuration with the lower priority may only include the size of the memory to be occupied, and the log write configuration of the client with the higher priority may also include other personalized requirement parameters.
According to the log processing method provided by the embodiment, the client applies for the shared memory according to the log write configuration, so that the personalized requirements of the client in the log write process can be met on the basis of improving the log processing efficiency.
Further, on the basis of any of the above embodiments, after applying for the shared memory for the client according to the registration request, the method further includes:
and the server side carries out initialization operation on the shared memory to obtain a lock-free queue instance.
In this embodiment, after the server applies for the shared memory for the client according to the registration request, the server may perform initialization operation on the shared memory to obtain a lock-free queue instance. The lock-free queue instance may be a lock-free queue instance implemented by a Compare and replace (CAS) mechanism, or may be implemented by any other mechanism, and the present invention is not limited herein. The lock-free queue instance can save the lock overhead on the basis of improving the log processing efficiency.
According to the log processing method provided by the embodiment, the lock-free queue instance is obtained by initializing the shared memory, so that the log processing effect can be improved, and further the log processing under a multi-process high-concurrency scene can be realized.
Optionally, on the basis of any of the above embodiments, after applying for the shared memory for the client according to the registration request, the method further includes:
and initializing the shared memory to obtain a locked queue instance.
Further, on the basis of any of the above embodiments, after the server sends the registration success information to the client, the method further includes:
and the server monitors the log writing condition in the shared memory and manages and controls the client according to the monitoring result.
In this embodiment, after receiving the registration success information, the client may write log information into the shared memory. In order to further improve the log processing efficiency, the server may monitor the log writing state in the shared memory, and manage and control the client according to the monitoring result. For example, whether the client is a malicious client, whether the client is currently failed, and the like can be determined according to the log writing state.
According to the log processing method provided by the embodiment, the log writing condition in the shared memory is monitored, and the client is controlled according to the monitoring result, so that the client can be effectively controlled on the basis of improving the log processing efficiency.
Further, on the basis of any of the above embodiments, the monitoring, by the server, a log writing status in the shared memory, and managing and controlling the client according to a monitoring result includes:
the server side judges whether the speed of the client side for writing the log exceeds a preset speed threshold value;
and if so, judging that the client fails.
In this embodiment, the speed at which the client currently writes the log may be determined, and the state of the client may be determined according to the speed. Specifically, if it is detected that the speed of writing the log into the client exceeds a preset speed threshold, it may be determined that the client fails currently, and if the speed is positive, it represents that the client operates normally.
Optionally, on the basis of any of the above embodiments, the monitoring the log writing status in the shared memory, and controlling the client according to a monitoring result includes:
judging whether the number of the logs written by the client exceeds a preset number threshold;
and if so, judging that the client fails.
In this embodiment, the number of logs currently written by the client may be determined, and the state of the client may be determined according to the number. Specifically, if it is detected that the number of logs written by the client exceeds a preset number threshold, it may be determined that the client fails currently, and otherwise, it represents that the current client operates normally.
It should be noted that the two embodiments described above may be implemented individually or in combination. When the method is combined and implemented, whether the number of the logs written by the client currently exceeds a preset number threshold and whether the speed of the logs written by the client currently exceeds a preset speed threshold can be determined according to the number and the speed of the logs written by the client currently, if yes, the client is judged to be in fault currently, and if not, the current client is represented to be in normal operation.
According to the log processing method provided by the embodiment, whether the client fails currently is determined by judging whether the number and/or the speed of the logs written by the client currently exceed the preset number and/or speed threshold, so that the client can be effectively monitored.
Further, on the basis of any of the above embodiments, after determining that the client fails, the method further includes:
the server side determines authority information corresponding to the client side according to the process identification of the client side;
and the server manages and controls the log information written in by the client according to the authority information.
In this embodiment, after it is determined that the client fails, permission information corresponding to the client may be determined according to the process identifier of the client, and log information written by the client is managed and controlled according to the permission information. For example, in practical applications, if the priority of the client currently writing in the log is high, when detecting that the number and/or speed of the currently written log of the client exceeds a preset number and/or speed threshold, all log information can be stored; correspondingly, if the priority of the client currently writing in the log is low, when detecting that the number and/or the speed of the currently written log of the client exceed the preset number and/or speed threshold, the log information written by the client can be partially stored, or the client can be refused to continue to provide the shared memory.
According to the log processing method provided by the embodiment, the authority information corresponding to the client is determined according to the process identifier, and the log information written in by the client is controlled according to the authority information, so that the client can be effectively controlled.
Further, on the basis of any of the above embodiments, the method comprises:
and the server side acquires the log information from the shared memory and issues the log information.
In this embodiment, the client writes the log information into the shared memory, and the server may obtain the log information from the shared memory and perform the publishing process.
Fig. 4 is a schematic flowchart of a log processing method provided by the fourth embodiment of the present invention, which is applied to a client, and as shown in fig. 4, the method includes:
step 401, sending a registration request to a server through a preset calling interface.
The execution subject of this embodiment is a client, where the client may be an application program, a process, or a terminal device. In order to realize the storage of the log information, the client can send a registration request to the server through a preset calling interface. Accordingly, after receiving the registration request, the server may determine whether to apply for the shared memory for the client according to the registration request. For example, if the current storage space of the server is insufficient and the processing capability is weak, the server may not apply for the shared memory for the client according to the registration request; if the current storage space of the server is more and the processing capacity is stronger, the server can apply for the shared memory for the client according to the registration request. The client and the server share the shared memory, specifically, the client can write the generated log information into the shared memory, and the server can take the log information out of the shared memory. Further, after the server determines that the shared memory can be applied for the client according to the registration request, the server may feed back registration success information to the client, so that the client can know the state of the current registration request in time.
Further, in any of the above embodiments, the registration request is sent by one of the threads of the client.
In this embodiment, the registration request may be specifically sent by one of the threads in the client. Because the client has a plurality of threads, each thread can send a registration request to the server, and correspondingly, the server can respectively apply for the shared memory for the client where the thread is located according to the registration requests sent by the threads. The shared memory is applied for the multiple threads of the client side respectively, so that log storage under the high concurrency condition can be realized.
Step 402, when the registration success information fed back by the server is received, writing the log information of the client into the shared memory.
In this embodiment, when receiving the registration success information sent by the server, the client may write the log information that needs to be stored into the shared memory. The registration success information may include a storage address of the shared memory, and the registration success information may be sent to the client by the server through a preset or newly added call interface. Therefore, the server can obtain the log information stored by the client from the shared memory and store the log information to a preset storage path.
In the log processing method provided by this embodiment, a registration request is sent to a server through a preset call interface, so that the server applies for a shared memory for a client according to the registration request, and feeds back registration success information to the client after the shared memory is successfully applied, where the client and the server share the shared memory. After the successful registration information fed back by the server is received, the log information generated by the client is written into the shared memory, so that the server can acquire the log information written by the client from the shared memory and store the log information into a preset storage path. The server side can apply for sharing the memory according to at least one thread of at least one client side, so that the method and the system are suitable for high concurrency scenes, and can further effectively manage logs of multiple processes.
Further, in any of the above embodiments, the shared memory is a lock-free queue instance.
In this embodiment, the shared memory may specifically be a lock-free queue instance, which may be a lock-free queue instance implemented by a Compare and replace (CAS) mechanism, or a lock-free queue instance implemented by any other mechanism, which is not limited herein. The lock-free queue instance can save the lock overhead on the basis of improving the log processing efficiency.
According to the log processing method provided by the embodiment, the lock-free queue instance is used as the shared memory, so that the log processing effect can be improved, and further the log processing under a multi-process high-concurrency scene can be realized.
Optionally, on the basis of any of the foregoing embodiments, the shared memory is a lock queue instance.
Further, on the basis of any of the above embodiments, the writing the log information of the client into the shared memory includes:
and writing the log of each thread in the client into the shared memory according to a preset thread storage sequence.
In this embodiment, in order to improve the log processing efficiency, a thread storage order may be preset, where the thread storage order may be determined by one or more of the factors such as the priority, the urgency, the data size, and the sending time of each thread, and may also be adjusted by the user in real time according to the current requirement, which is not limited herein. After receiving multiple registration requests sent by multiple threads in the client and applying for the shared memory, the log information written by each thread can be written into the shared memory according to the thread storage sequence.
According to the log processing method provided by the embodiment, the log of each thread in the client is written into the shared memory according to the preset thread storage sequence, so that the efficiency of log processing can be effectively improved.
Further, on the basis of any of the above embodiments, the writing the log information of the client into the shared memory includes:
and storing the log information with the priority higher than the preset first printing level into the shared memory.
In this embodiment, the number of log information written by the client is large, and different log information has different priorities. Therefore, in order to optimize the quality of the log information and reduce the storage space, after receiving the written log information, the priority of the log information may be determined first, and the log information with the priority higher than a preset first printing level is written into the shared memory, where the first printing level may be set by a user according to an actual requirement or may be a printing level preset by a system, and the present invention is not limited herein.
Specifically, on the basis of any of the above embodiments, the print levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
According to the log processing method provided by the embodiment, the log information with the priority higher than the preset first printing level is stored in the shared memory, so that the log processing efficiency can be improved on the basis of optimizing the quality of the log information and reducing the storage space.
Further, on the basis of any of the above embodiments, the writing the log information of the client into the shared memory includes:
and writing the log information of the client into the shared memory in an asynchronous storage mode.
In this embodiment, because the existing log processing method generally waits for the server to feed back the successful storage of the log information after the client writes the log information in the server, and performs the subsequent log writing operation, it often takes time, and the log processing efficiency is low. In order to improve the log processing efficiency, the log information of the client can be written into the shared memory in an asynchronous storage mode. Specifically, after the client writes the log information into the shared memory, the subsequent log writing operation can be performed without waiting for the successful storage information fed back by the server.
According to the log processing method provided by the embodiment, the log information of the client is written into the shared memory in an asynchronous storage mode, so that the log writing speed can be effectively increased, and the log processing efficiency can be further improved. In addition, different from the technical scheme of ZLog log storage in the prior art, log information is stored in an asynchronous storage mode, the problem that IO blocking is easily caused by synchronous ZLog storage in the prior art can be effectively solved, and the method is suitable for systems with high real-time requirements.
Further, on the basis of any of the above embodiments, the registration information further includes a process identifier of a process that sends the registration request, so that the server can determine whether to provide the memory information for the process according to the process identifier.
In this embodiment, the registration information further includes a process identifier of the process that sent the registration request. For example, in practical applications, some clients may have operations of maliciously writing a log, and the like, and therefore, the server may generate a blacklist according to historical experience, where the blacklist includes process identifiers. Therefore, after receiving the registration request including the process identifier, the server may detect whether the blacklist includes the process identifier, and if so, the server may refuse to apply for the shared memory for the client, otherwise, the server may apply for the shared memory for the client according to the registration request. Optionally, log information generated by some clients may be more important or priorities of some clients may be higher, and the like, and therefore, the server may also generate a white list according to historical experience, where the white list includes the process identifier. Therefore, after receiving the registration request including the process identifier, the server may detect whether the white list includes the process identifier, and if so, may provide a larger shared memory for the client corresponding to the process identifier, or may store log information with a lower priority for the client corresponding to the process identifier.
As an implementation manner, different clients have different priorities, and the server may provide different services for the clients according to the different priorities. Therefore, after receiving the registration request including the process identifier, the server may first determine the priority corresponding to the process identifier, and provide the service corresponding to the priority for the client according to the priority.
According to the log processing method provided by the embodiment, the registration information further comprises the process identifier of the process sending the registration request, so that the server can selectively apply for the shared memory for the client, and the safety of the server can be guaranteed on the basis of ensuring the log processing efficiency.
Further, on the basis of any of the above embodiments, before sending the registration request to the server through the call interface preset by the client, the method further includes:
and generating the registration request according to a preset log write configuration.
In this embodiment, before sending the registration request to the server, the log write configuration may be determined first. The log write configuration may be specifically input by a user according to current requirements, or may be a default write configuration, which is not limited herein. And generating a registration request according to the log write-in configuration, and sending the registration request to the server, so that the server can apply for the shared memory by the client according to the log write-in configuration. The log writing configuration comprises at least one of the size of a memory to be occupied, a storage mode, a storage position, the division of a stored subfolder and the size of the stored subfolder. Optionally, the different priorities may correspond to different log write configurations, for example, the log write configuration with the lower priority may only include the size of the memory to be occupied, and the log write configuration of the client with the higher priority may also include other personalized requirement parameters.
According to the log processing method provided by the embodiment, the registration request is generated according to the preset log writing configuration, so that the personalized requirements of the client in the log writing process can be met on the basis of improving the log processing efficiency.
Fig. 5 is a flowchart of a log processing method according to a fifth embodiment of the present invention, where on the basis of any one of the foregoing embodiments, as shown in fig. 5, after the log information of the client is written into the shared memory when the registration success information fed back by the server is received, the method further includes:
step 501, acquiring the connection number of the shared memory;
step 502, determining whether the server is disconnected from the shared memory according to the connection number.
In this embodiment, in order to successfully write and fetch the log information, the client and the server need to be connected to the shared memory at the same time. Therefore, in order to ensure that the server does not drop during the log processing, the number of connections of the shared memory can be acquired. It should be noted that, when there is no server drop, the total connection amount of the shared memory is the total number of the server and the client currently connected to the shared memory, and therefore, the current state of the server can be determined according to the connection amount. After the connection number is determined, whether the server is disconnected from the shared memory can be determined according to the connection number.
In the log processing method provided in this embodiment, whether the server and the shared memory are disconnected is determined according to the connection number by obtaining the connection number of the shared memory. Therefore, the effectiveness of log writing can be ensured, and the efficiency of log processing is further improved.
Further, on the basis of any of the above embodiments, the determining whether the server is disconnected from the shared memory according to the connection number includes:
if the client side is connected with the shared memory and the connection number is smaller than the preset connection total amount, judging that the server side is disconnected with the shared memory; the total connection amount is the connection number of the shared memory in a normal log storage state;
and if the client side and the shared memory are kept connected and the connection number is not less than the preset total connection amount, judging that the server side and the shared memory are not disconnected.
In this embodiment, if the client is currently connected to the shared memory and the connection number is smaller than a preset connection total amount, it may be determined that the server is disconnected from the shared memory, where the connection total amount is the connection number of the shared memory in a normal log storage state. Otherwise, if the client is currently connected with the shared memory and the connection number is not less than the preset connection total amount, it may be determined that the server is not disconnected currently. For example, in practical applications, if a client and a server are currently connected to the shared memory, the number of connections of the shared memory is 2. If the client detects that the current connection number of the shared memory is 2, it can be determined that the current server normally operates without disconnection, and correspondingly, if the client detects that the current connection number of the shared memory is 1, it can be determined that the server is disconnected, and at this time, in order to ensure normal processing of log information, the server needs to be reminded.
In the log processing method provided by this embodiment, if the client is connected to the shared memory and the connection number is smaller than a preset connection total amount, it is determined that the server is disconnected from the shared memory; and if the client keeps connection with the shared memory and the connection number is not less than the preset connection total amount, judging that the server is not disconnected with the shared memory. Therefore, the effectiveness of log writing can be ensured, and the efficiency of log processing is further improved.
Further, on the basis of any of the above embodiments, the method further includes:
and when the disconnection of the server is judged, sending a reconnection request to the server according to a preset frequency.
In this embodiment, if it is detected through the connection number that the server is currently disconnected from the shared memory, the representation server cannot acquire and store the log information from the shared memory in time, which results in low log processing efficiency and overlong time for the client to occupy the shared memory. Therefore, when the server is determined to be disconnected, a reconnection request can be sent to the server according to a preset frequency, so that the server can establish communication connection with the shared memory again according to the reconnection request. The preset frequency may be a preset frequency, or may be set according to an actual requirement, for example, if the priority corresponding to the client is higher, the reconnection request may be sent according to the higher frequency; if the shared memory occupied by the client is large, the reconnection request may also be sent at a high frequency, which is not limited herein.
According to the log processing method provided by the embodiment, when the server is judged to be disconnected, the reconnection request is sent to the server according to the preset frequency, so that the server can be connected with the shared memory according to the reconnection request, the log writing effectiveness can be ensured, and the log processing efficiency is further improved.
Further, on the basis of any of the above embodiments, the registration success information includes an identification code that is assigned to the client by the server; the reconnection request comprises the identification code; the identification code is used for enabling the server to be connected to the shared memory according to the identification code in the reconnection request.
In this embodiment, after the server successfully applies for the shared memory, the server may send registration success information to the client, where the registration success information includes an identification code allocated by the server to the client. When the client detects that the server is disconnected from the shared memory, a reconnection request including the identification code can be sent to the server, so that the server can be reconnected to the shared memory according to the identification code.
In the log processing method provided by this embodiment, the identification code in the received registration success information is placed in the reconnection request and sent to the server, so that the server can reconnect to the shared memory according to the identification code, and the log processing efficiency can be further improved on the basis of ensuring the validity of log writing.
Fig. 6 is a schematic flowchart of a log processing method provided by a sixth embodiment of the present invention, which is applied to a server, and as shown in fig. 6, the method includes:
601, receiving a registration request sent by a client;
step 602, applying for a shared memory for the client according to the registration request;
step 603, after the shared memory application is successful, sending registration success information to the client;
and step 604, acquiring the log information from the shared memory, and storing the log information to a preset storage path.
The execution subject of this embodiment is a server, where the server may be an application, a process, or a terminal device, and in order to implement storage of log information, the client may send a registration request to the server through a preset call interface. Accordingly, the server can receive a registration request sent by the client, and apply for the shared memory for the client according to the registration request. For example, if the current storage space of the server is insufficient and the processing capability is weak, the server may not apply for the shared memory for the client according to the registration request; if the current storage space of the server is more and the processing capacity is stronger, the server can apply for the shared memory for the client according to the registration request. After the client successfully applies for the shared memory, the registration success information can be sent to the client. When receiving the registration success information sent by the server, the client may write the log information that needs to be stored into the shared memory, where the registration success information may include a storage address of the shared memory. Because the client and the server are connected to the shared memory at the same time, after the client writes the log information into the shared memory, the server can obtain the log information from the shared memory and store the log information into a preset storage path.
Further, the registration request is sent by one of the threads of the client.
In this embodiment, the registration request may be specifically sent by one of the threads in the client. Because the client has a plurality of threads, each thread can send a registration request to the server, and accordingly, the server can apply for the shared memory for the client corresponding to the thread according to the registration request sent by each thread. The shared memory is applied for the multiple threads of the client side respectively, so that log storage under the high concurrency condition can be realized.
Further, when the client completes writing of all log information, the client is disconnected from the shared memory, and the server can recycle the shared memory currently used by the client, so that no other client applies for the next time.
In the log processing method provided by this embodiment, a registration request sent by a client is received, a shared memory is applied for the client according to the registration request, and after the shared memory is successfully applied, registration success information is sent to the client, so that the client writes log information into the shared memory according to the registration success information, acquires the log information from the shared memory, and stores the log information to a preset storage path. The server side can apply for the shared memory according to at least one thread of at least one client side, and the log information generated by all processes in the client side can be stored in the shared memory, so that the method and the system are suitable for the condition that multiple threads in one application program are highly concurrent, and can further effectively manage the logs of multiple processes.
Further, on the basis of any of the above embodiments, the acquiring the log information from the shared memory and storing the log information to a preset storage path includes:
and obtaining the log information with the priority higher than a preset second printing level from the shared memory, and storing the log information to a preset storage path.
In this embodiment, the number of log information written by the client is large, and different log information has different priorities. Therefore, in order to optimize the quality of the log information and reduce the storage space, when the server side acquires the log information from the shared memory, the priority of the log information needs to be determined first, and the log information with the priority higher than the preset second printing level needs to be stored in the preset storage path. The second printing level may be set by the user according to actual requirements, or may be a printing level preset by the system, which is not limited herein.
Specifically, on the basis of any of the above embodiments, the print levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
According to the log processing method provided by the embodiment, the log information with the priority higher than the preset second printing level is acquired from the shared memory and is stored to the preset storage path, so that the log processing efficiency can be improved on the basis of optimizing the quality of the log information and reducing the storage space.
Further, on the basis of any of the above embodiments, the obtaining, by the server, the log information from the shared memory and storing the log information in a preset storage path includes:
and the server acquires the log information from the shared memory in a single-thread mode and stores the log information into a preset storage path.
In this embodiment, in order to improve the log processing efficiency, after the client writes the log information into the shared memory, the server may obtain the log information from the shared memory in a single process and store the log information into a preset storage path.
According to the log processing method provided by the embodiment, the log information is acquired from the shared memory in a single-thread mode and is stored in the preset storage path, so that the log writing speed can be effectively increased, and the log processing efficiency can be further improved.
Fig. 7 is a flowchart of a log processing method according to a seventh embodiment of the present invention, where on the basis of any one of the embodiments, as shown in fig. 7, the registration request includes an amount of memory to be occupied, and the applying for a shared memory for the client according to the registration request includes:
step 701, determining the current memory surplus of the server;
step 702, applying for a shared memory by the client according to the memory surplus and the memory amount to be occupied.
In this embodiment, the registration request may include the amount of memory to be occupied. Specifically, when the client sends the registration request to the server, the client may determine the amount of the memory to be occupied, and generate the registration request according to the amount of the memory to be occupied. After receiving the registration request, the server may first determine the current remaining amount of the memory, and apply for the shared memory for the client according to the remaining amount of the memory and the amount of the memory to be occupied.
Specifically, on the basis of any of the above embodiments, the applying for the shared memory by the client according to the remaining memory amount and the memory amount to be occupied includes:
if the amount of the memory to be occupied is smaller than the residual amount of the memory, applying for a shared memory corresponding to the amount of the memory to be occupied for the client;
and if the amount of the memory to be occupied is not less than the residual amount of the memory, refusing to apply for the shared memory for the client.
In this embodiment, if it is detected that the amount of the memory to be occupied is less than the remaining amount of the memory, a shared memory corresponding to the amount of the memory to be occupied may be applied for the client; on the contrary, if the amount of the memory to be occupied is not less than the remaining amount of the memory, the server side is represented that the current remaining memory is insufficient to apply for the shared memory by the client side, and at this time, the client side can be refused to apply for the shared memory.
According to the log processing method provided by the embodiment, the current memory surplus of the server is determined, and the shared memory is applied to the client according to the memory surplus and the memory amount to be occupied, so that the shared memory can be rapidly applied to the client, and the log processing efficiency is improved.
Fig. 8 is a schematic flowchart of a log processing method according to an eighth embodiment of the present invention, where on the basis of any of the foregoing embodiments, as shown in fig. 8, the registration request further includes the process identifier; correspondingly, the applying for the shared memory for the client according to the registration request includes:
step 801, judging whether a preset process blacklist includes the process identifier;
step 802, if the shared memory does not exist, applying for the process to share the memory;
and 803, if so, refusing to apply for the process to share the memory.
In this embodiment, the registration request further includes a process identifier for an actual application, for example, some clients may have an operation of writing a log maliciously, and the like. Therefore, after receiving the registration request including the process identifier, the server may detect whether the blacklist includes the process identifier, and if so, the server may refuse to apply for the shared memory for the client, otherwise, the server may apply for the shared memory for the client according to the registration request. Optionally, log information generated by some clients may be more important or priorities of some clients may be higher, and the like, and therefore, the server may also generate a white list according to historical experience, where the white list includes the process identifier. Therefore, after receiving the registration request including the process identifier, the server may detect whether the white list includes the process identifier, and if so, may provide a larger shared memory for the client corresponding to the process identifier, or may store log information with a lower priority for the client corresponding to the process identifier.
As an implementation manner, different clients have different priorities, and the server may provide different services for the clients according to the different priorities. Therefore, after receiving the registration request including the process identifier, the server may first determine the priority corresponding to the process identifier, and provide the service corresponding to the priority for the client according to the priority.
According to the log processing method provided by the embodiment, whether the process identifier is included in the preset process blacklist is judged, if not, the shared memory is applied for the process, and if so, the shared memory is refused to be applied for the process, so that the server can selectively apply for the client to apply for the shared memory, and the safety of the server can be guaranteed on the basis of guaranteeing the log processing efficiency.
Further, on the basis of any of the above embodiments, the registration request is generated according to a preset log write configuration;
applying for the shared memory for the client according to the registration request includes:
and according to the log write-in configuration, the client applies for sharing the memory.
In this embodiment, before sending the registration request to the server, the client may first determine a log write configuration, and generate the registration request according to the log write configuration. The log write configuration may be specifically input by a user according to current requirements, or may be a default write configuration, which is not limited herein. The server can configure the client to apply for the shared memory according to the log writing. The log writing configuration comprises at least one of the size of a memory to be occupied, a storage mode, a storage position, the division of a stored subfolder and the size of the stored subfolder. The stored subfolders are used for dividing the stored subfolders according to different functions of threads, and the stored subfolders can also be divided according to different types of logs. Optionally, the different priorities may correspond to different log write configurations, for example, the log write configuration with the lower priority may only include the size of the memory to be occupied, and the log write configuration of the client with the higher priority may also include other personalized requirement parameters.
According to the log processing method provided by the embodiment, the client applies for the shared memory according to the log write configuration, so that the personalized requirements of the client in the log write process can be met on the basis of improving the log processing efficiency.
Further, on the basis of any of the above embodiments, after applying for the shared memory for the client according to the registration request, the method further includes:
and initializing the shared memory to obtain a lock-free queue instance.
In this embodiment, after the server applies for the shared memory for the client according to the registration request, the server may perform initialization operation on the shared memory to obtain a lock-free queue instance. The lock-free queue instance may be a lock-free queue instance implemented by a Compare and replace (CAS) mechanism, or may be implemented by any other mechanism, and the present invention is not limited herein. The lock-free queue instance can save the lock overhead on the basis of improving the log processing efficiency.
According to the log processing method provided by the embodiment, the lock-free queue instance is obtained by initializing the shared memory, so that the log processing effect can be improved, and further the log processing under a multi-process high-concurrency scene can be realized.
Optionally, on the basis of any of the above embodiments, after applying for the shared memory for the client according to the registration request, the method further includes:
and initializing the shared memory to obtain a locked queue instance.
Further, on the basis of any of the above embodiments, the method further includes:
and when a reconnection request sent by the client is received, reconnecting with the shared memory according to the reconnection request.
In this embodiment, in order to successfully write and fetch the log information, the client and the server need to be connected to the shared memory at the same time. Therefore, when the client detects that the server is disconnected from the shared memory, a reconnection request can be sent to the server. Accordingly, after the server receives the reconnection request, the server may reestablish the communication connection with the shared memory according to the reconnection request.
In the log processing method provided by this embodiment, when a reconnection request sent by the client is received, the shared memory is reconnected according to the reconnection request. Therefore, the effectiveness of log writing can be ensured, and the efficiency of log processing is further improved.
Further, on the basis of any of the above embodiments, the registration success information includes an identification code that is assigned to the client by the server; the reconnection request comprises the identification code; the reconnecting with the shared memory according to the reconnection request includes:
and connecting to the shared memory according to the identification code in the reconnection request.
In this embodiment, after the server successfully applies for the shared memory, the server may send registration success information to the client, where the registration success information includes an identification code allocated by the server to the client. When the client detects that the server is disconnected from the shared memory, a reconnection request including the identification code can be sent to the server, so that the server can be reconnected to the shared memory according to the identification code.
According to the log processing method provided by the embodiment, the server can be reconnected to the shared memory according to the identification code in the reconnection request by connecting to the shared memory according to the identification code, so that the efficiency of log processing can be further improved on the basis of ensuring the validity of log writing.
Further, on the basis of any of the above embodiments, after sending the registration success information to the client, the method further includes:
and monitoring the log writing condition in the shared memory, and managing and controlling the client according to a monitoring result.
In this embodiment, after receiving the registration success information, the client may write log information into the shared memory. In order to further improve the log processing efficiency, the server may monitor the log writing state in the shared memory, and manage and control the client according to the monitoring result. For example, whether the client is a malicious client, whether the client is currently failed, and the like can be determined according to the log writing state.
According to the log processing method provided by the embodiment, the log writing condition in the shared memory is monitored, and the client is controlled according to the monitoring result, so that the client can be effectively controlled on the basis of improving the log processing efficiency.
Further, on the basis of any of the above embodiments, the monitoring the log writing status in the shared memory, and controlling the client according to the monitoring result includes:
judging whether the speed of the client for writing in the log exceeds a preset speed threshold value or not;
and if so, judging that the client fails.
In this embodiment, the speed at which the client currently writes the log may be determined, and the state of the client may be determined according to the speed. Specifically, if it is detected that the speed of writing the log into the client exceeds a preset speed threshold, it may be determined that the client fails currently, and if the speed is positive, it represents that the client operates normally.
Optionally, on the basis of any of the above embodiments, the monitoring the log writing status in the shared memory, and controlling the client according to a monitoring result includes:
judging whether the number of the logs written by the client exceeds a preset number threshold;
and if so, judging that the client fails.
In this embodiment, the number of logs currently written by the client may be determined, and the state of the client may be determined according to the number. Specifically, if it is detected that the number of logs written by the client exceeds a preset number threshold, it may be determined that the client fails currently, and otherwise, it represents that the current client operates normally.
It should be noted that the two embodiments described above may be implemented individually or in combination. When the method is combined and implemented, whether the number of the logs written by the client currently exceeds a preset number threshold and whether the speed of the logs written by the client currently exceeds a preset speed threshold can be determined according to the number and the speed of the logs written by the client currently, if yes, the client is judged to be in fault currently, and if not, the current client is represented to be in normal operation.
According to the log processing method provided by the embodiment, whether the client fails currently is determined by judging whether the number and/or the speed of the logs written by the client currently exceed the preset number and/or speed threshold, so that the client can be effectively monitored.
Fig. 9 is a schematic flowchart of a log processing method according to a ninth embodiment of the present invention, where on the basis of any one of the foregoing embodiments, as shown in fig. 9, after determining that the client fails, the method further includes:
step 901, determining authority information corresponding to the client according to the process identifier;
and 902, managing and controlling the log information written in by the client according to the authority information.
In this embodiment, after it is determined that the client fails, permission information corresponding to the client may be determined according to the process identifier of the client, and log information written by the client is managed and controlled according to the permission information. For example, in practical applications, if the priority of the client currently writing in the log is high, when detecting that the number and/or speed of the currently written log of the client exceeds a preset number and/or speed threshold, all log information can be stored; correspondingly, if the priority of the client currently writing in the log is low, when detecting that the number and/or the speed of the currently written log of the client exceed the preset number and/or speed threshold, the log information written by the client can be partially stored, or the client can be refused to continue to provide the shared memory.
According to the log processing method provided by the embodiment, the authority information corresponding to the client is determined according to the process identifier, and the log information written in by the client is controlled according to the authority information, so that the client can be effectively controlled.
Further, on the basis of any of the above embodiments, the method further includes: and acquiring the log information from the shared memory, and issuing the log information.
In this embodiment, the client writes the log information into the shared memory, and the server may obtain the log information from the shared memory and perform the publishing process.
Fig. 10 is a schematic structural diagram of a client terminal device according to a tenth embodiment of the present invention, and as shown in fig. 10, the terminal device includes:
a memory 111 and a processor 112;
the memory 111 is used for storing program codes;
the processor 112, invoking the program code, is configured to perform the following when the program code is executed:
sending a registration request to a server through a preset calling interface;
and when the registration success information fed back by the server is received, writing the log information of the client into the shared memory.
Further, in any of the above embodiments, the shared memory is a lock-free queue instance.
Further, on the basis of any of the above embodiments, the shared memory is a lock queue instance.
Further, in any of the above embodiments, the registration request is sent by one of the threads of the client.
Further, on the basis of any of the above embodiments, when writing the log information of the client into the shared memory, the processor is configured to:
and writing the log of each thread in the client into the shared memory according to a preset thread storage sequence.
Further, on the basis of any of the above embodiments, when writing the log information of the client into the shared memory, the processor is configured to:
and storing the log information with the priority higher than the preset first printing level into the shared memory.
Further, on the basis of any of the above embodiments, the printing levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
Further, on the basis of any of the above embodiments, when writing the log information of the client into the shared memory, the processor is configured to:
and writing the log information of the client into the shared memory in an asynchronous storage mode.
Further, on the basis of any of the above embodiments, the registration information further includes a process identifier of a process that sends the registration request, so that the server can determine whether to provide the memory information for the process according to the process identifier.
Further, on the basis of any of the above embodiments, before sending the registration request to the server through the call interface preset by the client, the processor is further configured to:
and generating the registration request according to a preset log write configuration.
Further, on the basis of any of the above embodiments, the log write configuration includes at least one of a size of a memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
Further, on the basis of any of the above embodiments, after the processor writes the log information of the client into the shared memory when receiving the registration success information fed back by the server, the processor is further configured to:
acquiring the connection number of the shared memory;
and determining whether the server is disconnected with the shared memory or not according to the connection number.
Further, on the basis of any of the above embodiments, when determining whether the server is disconnected from the shared memory according to the connection number, the processor is configured to:
if the client side is connected with the shared memory and the connection number is smaller than the preset connection total amount, judging that the server side is disconnected with the shared memory; the total connection amount is the connection number of the shared memory in a normal log storage state;
and if the client side and the shared memory are kept connected and the connection number is not less than the preset total connection amount, judging that the server side and the shared memory are not disconnected.
Further, on the basis of any of the above embodiments, the processor is further configured to:
and when the disconnection of the server is judged, sending a reconnection request to the server according to a preset frequency.
Further, on the basis of any of the above embodiments, the registration success information includes an identification code that is assigned to the client by the server; the reconnection request comprises the identification code; the identification code is used for enabling the server to be connected to the shared memory according to the identification code in the reconnection request.
Fig. 11 is a schematic structural diagram of a service terminal device according to an eleventh embodiment of the present invention, and as shown in fig. 11, the service terminal device includes: a memory 121 and a processor 122;
the memory 121 is used for storing program codes;
the processor 122, invoking the program code, when executed, is configured to:
receiving a registration request sent by a client;
applying for sharing the memory for the client according to the registration request;
after the shared memory application is successful, sending registration success information to the client, so that the client writes log information into the shared memory according to the registration success information, wherein the registration success information comprises the shared memory;
and acquiring the log information from the shared memory and storing the log information to a preset storage path.
Further, on the basis of any of the above embodiments, when the processor acquires the log information from the shared memory and stores the log information to a preset storage path, the processor is configured to:
and obtaining the log information with the priority higher than a preset second printing level from the shared memory, and storing the log information to a preset storage path.
Further, on the basis of any of the above embodiments, the printing levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
Further, on the basis of any of the above embodiments, when the server obtains the log information from the shared memory and stores the log information in a preset storage path, the processor is configured to:
and the server acquires the log information from the shared memory in a single-thread mode and stores the log information into a preset storage path.
Further, on the basis of any of the above embodiments, the registration request includes an amount of memory to be occupied, and the processor, when applying for the shared memory for the client according to the registration request, is configured to:
determining the current memory surplus of the server;
and applying for the shared memory for the client according to the memory surplus and the memory amount to be occupied.
Further, on the basis of any of the above embodiments, when the processor applies for the shared memory by the client according to the remaining memory amount and the memory amount to be occupied, the processor is configured to:
if the amount of the memory to be occupied is smaller than the residual amount of the memory, applying for a shared memory corresponding to the amount of the memory to be occupied for the client;
and if the amount of the memory to be occupied is not less than the residual amount of the memory, refusing to apply for the shared memory for the client.
Further, on the basis of any of the above embodiments, the registration request further includes the process identifier;
correspondingly, when the processor applies for the shared memory for the client according to the registration request, the processor is configured to:
judging whether a preset process blacklist comprises the process identification or not;
if not, applying for the process to share the memory;
and if so, refusing to apply for the process to share the memory.
Further, on the basis of any of the above embodiments, the registration request is generated according to a preset log write configuration;
the processor, when applying for a shared memory for the client according to the registration request, is configured to:
and according to the log write-in configuration, the client applies for sharing the memory.
Further, on the basis of any of the above embodiments, the log write configuration includes at least one of a size of a memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
Further, on the basis of any of the above embodiments, after applying for the shared memory for the client according to the registration request, the processor is further configured to:
and initializing the shared memory to obtain a lock-free queue instance.
Further, on the basis of any of the above embodiments, the shared memory is initialized to obtain a locked queue instance.
Further, on the basis of any of the above embodiments, the processor is further configured to:
and when a reconnection request sent by the client is received, reconnecting with the shared memory according to the reconnection request.
Further, on the basis of any of the above embodiments, the registration success information includes an identification code that is assigned to the client by the server; the reconnection request comprises the identification code; when reconnecting with the shared memory according to the reconnection request, the processor is configured to:
and connecting to the shared memory according to the identification code in the reconnection request.
Further, on the basis of any of the above embodiments, after sending the registration success information to the client, the processor is further configured to:
and monitoring the log writing condition in the shared memory, and managing and controlling the client according to a monitoring result.
Further, on the basis of any of the above embodiments, when the processor monitors the log writing condition in the shared memory and manages and controls the client according to the monitoring result, the processor is configured to:
judging whether the speed of the client for writing in the log exceeds a preset speed threshold value or not;
and if so, judging that the client fails.
Further, on the basis of any of the above embodiments, when the processor monitors the log writing condition in the shared memory and manages and controls the client according to the monitoring result, the processor is configured to:
judging whether the number of the logs written by the client exceeds a preset number threshold;
and if so, judging that the client fails.
Further, on the basis of any of the above embodiments, after determining that the client fails, the processor is further configured to:
determining authority information corresponding to the client according to the process identifier;
and managing and controlling the log information written in by the client according to the authority information.
Further, on the basis of any of the above embodiments, the processor is further configured to: and acquiring the log information from the shared memory, and issuing the log information.
The invention also provides a log processing system, which comprises
One or more processors;
one or more memories;
the memory is used for storing program codes;
the processor, configured to invoke the program code, when the program code is executed, is configured to perform the following:
sending a registration request to a server through a calling interface preset by a client;
the server receives a registration request sent by a client;
the server side applies for sharing the memory for the client side according to the registration request;
after the shared memory application is successful, the server side sends registration success information to the client side;
when the client receives the registration success information fed back by the server, the log information of the client is written into the shared memory;
and the server side acquires the log information from the shared memory and stores the log information to a preset storage path.
It should be noted that the above method may be performed by one processor, or may be performed by multiple servers. When implemented by a processor, both the client program and the server program are located in the same device. When the server is completed by multiple servers, the client program is executed by corresponding to one processor, the server program is executed by corresponding to one processor, and the client program and the server program may be set in the same device or in two independent devices.
Further, in any of the above embodiments, the shared memory is a lock-free queue instance.
Further, on the basis of any of the above embodiments, the shared memory is a lock queue instance.
Further, in any of the above embodiments, the registration request is sent by one of the threads of the client.
Further, on the basis of any of the above embodiments, when the log information of the client is written into the shared memory by the client, the processor is configured to:
and writing the log of each thread in the client into the shared memory according to a preset thread storage sequence through the client.
Further, on the basis of any of the above embodiments, when the log information of the client is written into the shared memory by the client, the processor is configured to:
and storing the log information with the priority higher than a preset first printing level into the shared memory through the client.
Further, on the basis of any of the above embodiments, the printing levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
Further, on the basis of any of the above embodiments, when the log information of the client is written into the shared memory by the client, the processor is configured to:
and writing the log information of the client into the shared memory in an asynchronous storage mode through the client.
Further, on the basis of any of the above embodiments, before sending the registration request to the server through the call interface preset by the client, the processor is further configured to:
and generating the registration request according to preset log write-in configuration by the client.
Further, on the basis of any of the above embodiments, the log write configuration includes at least one of a size of a memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
Further, on the basis of any of the above embodiments, after the processor writes the log information of the client into the shared memory through the client when receiving the registration success information fed back by the server, the processor is further configured to:
acquiring the connection number of the shared memory through the client;
and determining whether the server is disconnected with the shared memory or not according to the connection number through the client.
Further, on the basis of any of the above embodiments, when determining, by the client, whether the server is disconnected from the shared memory according to the connection number, the processor is configured to:
if the client side is connected with the shared memory and the connection number is smaller than the preset connection total amount, the client side judges that the server side is disconnected with the shared memory; wherein, the total connection amount is the connection number of the shared memory in a normal log storage state;
and if the client side and the shared memory are kept connected and the connection number is not less than the preset total connection amount, judging that the server side and the shared memory are not disconnected through the client side.
Further, on the basis of any of the above embodiments, the processor is further configured to:
when the server is judged to be disconnected, sending a reconnection request to the server through the client according to a preset frequency;
and when the server receives a reconnection request sent by the client, the server is reconnected with the shared memory according to the reconnection request.
Further, on the basis of any of the above embodiments, the registration success information includes an identification code that is assigned to the client by the server; the reconnection request includes the identification code; when the processor is reconnected with the shared memory according to the reconnection request through the server, the processor is configured to:
and connecting to the shared memory through the server according to the identification code in the reconnection request.
Further, on the basis of any of the above embodiments, when the processor obtains the log information from the shared memory through the server and stores the log information to a preset storage path, the processor is configured to:
and acquiring log information with the priority higher than a preset second printing level from the shared memory through the server, and storing the log information to a preset storage path.
Further, on the basis of any of the above embodiments, the printing levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
Further, on the basis of any of the above embodiments, when the processor obtains the log information from the shared memory through the server and stores the log information to a preset storage path, the processor is configured to:
and acquiring the log information from the shared memory by the server in a single-thread mode and storing the log information into a preset storage path.
Further, on the basis of any of the above embodiments, the registration request includes an amount of memory to be occupied, and the processor, when applying for the shared memory for the client through the server according to the registration request, is configured to:
determining the current memory surplus of the server;
and applying for the shared memory for the client by the server according to the memory surplus and the memory amount to be occupied.
Further, on the basis of any of the above embodiments, when the processor applies for the shared memory by the client according to the remaining memory amount and the memory amount to be occupied by the server, the processor is configured to:
if the amount of the memory to be occupied is smaller than the residual amount of the memory, applying for a shared memory corresponding to the amount of the memory to be occupied for the client;
and if the amount of the memory to be occupied is not less than the residual amount of the memory, refusing to apply for the shared memory for the client.
Further, on the basis of any of the above embodiments, the registration request further includes a process identifier of the client;
correspondingly, when the processor applies for the shared memory for the client through the server according to the registration request, the processor is configured to:
judging whether a preset process blacklist comprises the process identification or not;
if not, applying for the shared memory for the client;
and if so, refusing to apply for the shared memory for the client.
Further, on the basis of any of the above embodiments, the registration request is generated according to a preset log write configuration;
the processor, when applying for the shared memory for the client through the server according to the registration request, is configured to:
and the server side applies for the shared memory for the client side according to the log write-in configuration.
Further, on the basis of any of the above embodiments, the log write configuration includes at least one of a size of a memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
Further, on the basis of any of the above embodiments, after receiving, by the server, a registration request sent by a client, the processor further includes:
and initializing the shared memory through the server to obtain a locked queue instance.
Further, on the basis of any of the above embodiments, after receiving, by the server, a registration request sent by a client, the processor further includes:
and initializing the shared memory through the server to obtain a locked queue instance.
Further, on the basis of any of the above embodiments, after the processor sends the registration success information to the client through the server, the processor further includes:
and monitoring the log writing condition in the shared memory through the server, and managing and controlling the client according to the monitoring result.
Further, on the basis of any of the above embodiments, when the processor monitors the log writing condition in the shared memory through the server and manages and controls the client according to a monitoring result, the processor is configured to:
the server side judges whether the speed of the client side for writing the log exceeds a preset speed threshold value;
and if so, judging that the client fails.
Further, on the basis of any of the above embodiments, when the processor monitors the log writing condition in the shared memory through the server and manages and controls the client according to a monitoring result, the processor is configured to:
the server side judges whether the number of the logs written by the client side exceeds a preset number threshold value or not;
and if so, judging that the client fails.
Further, on the basis of any of the above embodiments, after determining that the client fails, the processor is further configured to:
the server side determines authority information corresponding to the client side according to the process identification of the client side;
and the server manages and controls the log information written in by the client according to the authority information.
Further, on the basis of any of the above embodiments, the processor is configured to:
and the server side acquires the log information from the shared memory and issues the log information.
In addition, the present embodiment also provides a computer-readable storage medium on which a computer program is stored, the computer program being executed by a processor to implement the log processing method described in the above embodiment.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
It is obvious to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to perform all or part of the above described functions. For the specific working process of the device described above, reference may be made to the corresponding process in the foregoing method embodiment, which is not described herein again.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (125)

1. A log processing method, comprising:
the client sends a registration request to the server through a preset calling interface;
the server receives a registration request sent by a client;
the server side applies for sharing the memory for the client side according to the registration request;
after the shared memory application is successful, the server side sends registration success information to the client side;
when the client receives the registration success information fed back by the server, the log information of the client is written into the shared memory;
and the server side acquires the log information from the shared memory and stores the log information to a preset storage path.
2. The method of claim 1, wherein the shared memory is a lock-free queue instance.
3. The method of claim 1, wherein the shared memory is a locked queue instance.
4. The method of claim 1, wherein the registration request is sent by one of the threads of the client.
5. The method of claim 4, wherein writing the log information of the client into the shared memory comprises:
and writing the log of each thread in the client into the shared memory according to a preset thread storage sequence.
6. The method according to any one of claims 1 to 5, wherein the writing the log information of the client into the shared memory comprises:
and storing the log information with the priority higher than the preset first printing level into the shared memory.
7. The method according to any one of claims 1 to 5, wherein the printing levels of the log information include an OFF level, a FATAL level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
8. The method according to any one of claims 1-5, wherein the writing the log information of the client into the shared memory comprises:
and the client writes the log information of the client into the shared memory in an asynchronous storage mode.
9. The method according to claim 1, before sending the registration request to the server through the call interface preset by the client, further comprising:
and the client generates the registration request according to preset log write-in configuration.
10. The method of claim 9, wherein the log write configuration comprises at least one of a size of memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
11. The method according to any one of claims 1 to 5 and 9 to 10, wherein after the writing the log information of the client into the shared memory when receiving the registration success information fed back by the server, the method further comprises:
the client acquires the connection number of the shared memory;
and the client determines whether the server is disconnected with the shared memory according to the connection number.
12. The method according to claim 11, wherein the determining whether the server is disconnected from the shared memory according to the connection number comprises:
if the client side is connected with the shared memory and the connection number is smaller than the preset connection total amount, judging that the server side is disconnected with the shared memory; wherein, the total connection amount is the connection number of the shared memory in a normal log storage state;
and if the client side and the shared memory are kept connected and the connection number is not less than the preset total connection amount, judging that the server side and the shared memory are not disconnected.
13. The method of claim 12, further comprising:
when the server is judged to be disconnected, a reconnection request is sent to the server according to a preset frequency;
and when the server receives a reconnection request sent by the client, the server is reconnected with the shared memory according to the reconnection request.
14. The method according to claim 13, wherein the registration success information includes an identification code assigned to the client by the server; the reconnection request includes the identification code; the server reconnects with the shared memory according to the reconnection request, including:
and the server is connected to the shared memory according to the identification code in the reconnection request.
15. The method of claim 1, wherein the step of the server obtaining the log information from the shared memory and storing the log information to a preset storage path comprises:
and the server side acquires the log information with the priority higher than a preset second printing level from the shared memory and stores the log information to a preset storage path.
16. The method as claimed in claim 15, wherein the printing levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are prioritized in order from high to low.
17. The method according to claim 15 or 16, wherein the step of the server obtaining the log information from the shared memory and storing the log information to a preset storage path comprises:
and the server acquires the log information from the shared memory in a single-thread mode and stores the log information into a preset storage path.
18. The method according to claim 15 or 16, wherein the registration request includes an amount of memory to be occupied, and the applying for the shared memory for the client according to the registration request includes:
determining the current memory surplus of the server;
and the server side applies for the shared memory for the client side according to the memory surplus and the memory amount to be occupied.
19. The method according to claim 18, wherein the applying for the shared memory for the client according to the remaining amount of the memory and the amount of the memory to be occupied comprises:
if the amount of the memory to be occupied is smaller than the residual amount of the memory, applying for a shared memory corresponding to the amount of the memory to be occupied for the client;
and if the amount of the memory to be occupied is not less than the residual amount of the memory, refusing to apply for the shared memory for the client.
20. The method according to any of claims 15-16, 19, wherein the registration request further comprises a process identification of the client;
correspondingly, the applying for the shared memory for the client according to the registration request includes:
judging whether a preset process blacklist comprises the process identification or not;
if not, applying for the shared memory for the client;
and if so, refusing to apply for the shared memory for the client.
21. The method according to any of claims 15-16, 19, wherein the registration request is generated according to a preset log write configuration;
applying for the shared memory for the client according to the registration request includes:
and the server side applies for the shared memory for the client side according to the log write-in configuration.
22. The method of claim 21, wherein the log write configuration comprises at least one of a size of memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
23. The method according to any one of claims 15-16, 19, and 22, wherein after applying for the shared memory for the client according to the registration request, further comprising:
and the server side carries out initialization operation on the shared memory to obtain a lock-free queue instance.
24. The method according to any one of claims 15-16, 19, and 22, wherein after applying for the shared memory for the client according to the registration request, further comprising:
and the server side carries out initialization operation on the shared memory to obtain a locked queue instance.
25. The method according to any one of claims 15-16, 19, and 22, wherein after the server sends the registration success information to the client, the method further comprises:
and the server monitors the log writing condition in the shared memory and manages and controls the client according to the monitoring result.
26. The method according to claim 25, wherein the server monitors a log writing status in the shared memory, and manages and controls the client according to a monitoring result, including:
the server side judges whether the speed of the client side for writing the log exceeds a preset speed threshold value;
and if so, judging that the client fails.
27. The method according to claim 25, wherein the server monitors a log writing status in the shared memory, and manages and controls the client according to a monitoring result, including:
the server side judges whether the number of the logs written by the client side exceeds a preset number threshold value or not;
and if so, judging that the client fails.
28. The method according to claim 26 or 27, wherein after determining that the client fails, further comprising:
the server side determines authority information corresponding to the client side according to the process identification of the client side;
and the server manages and controls the log information written in by the client according to the authority information.
29. The method according to claim 1, characterized in that it comprises:
and the server side acquires the log information from the shared memory and issues the log information.
30. A log processing method is applied to a client, and is characterized by comprising the following steps:
sending a registration request to a server through a preset calling interface
And when the registration success information fed back by the server is received, writing the log information of the client into the shared memory of the client and the server.
31. The method of claim 30, wherein the shared memory is a lock-free queue instance.
32. The method of claim 30, wherein the shared memory is a locked queue instance.
33. The method of claim 30, wherein the registration request is sent by one of the threads of the client.
34. The method of claim 33, wherein writing the log information of the client to the shared memory comprises:
and writing the log of each thread in the client into the shared memory according to a preset thread storage sequence.
35. The method according to any one of claims 30 to 34, wherein the writing the log information of the client to the shared memory comprises:
and storing the log information with the priority higher than the preset first printing level into the shared memory.
36. The method as claimed in any one of claims 30 to 34, wherein the printing levels of the log information include an OFF level, a talk level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level and an ALL level, which are arranged in order of priority from high to low.
37. The method according to any one of claims 30-34, wherein writing the log information of the client into the shared memory comprises:
and writing the log information of the client into the shared memory in an asynchronous storage mode.
38. The method of claim 30, wherein the registration information further comprises a process identification of a process sending the registration request.
39. The method according to claim 30, before sending the registration request to the server through the call interface preset by the client, further comprising:
and generating the registration request according to a preset log write configuration.
40. The method of claim 39, wherein the log write configuration comprises at least one of a size of memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
41. The method according to any one of claims 30 to 34 and 38 to 39, wherein after the writing the log information of the client into the shared memory when the registration success information fed back by the server is received, the method further comprises:
acquiring the connection number of the shared memory;
and determining whether the server is disconnected with the shared memory or not according to the connection number.
42. The method according to claim 41, wherein said determining whether the server is disconnected from the shared memory according to the number of connections comprises:
if the client side is connected with the shared memory and the connection number is smaller than the preset connection total amount, judging that the server side is disconnected with the shared memory; wherein, the total connection amount is the connection number of the shared memory in a normal log storage state;
and if the client side and the shared memory are kept connected and the connection number is not less than the preset total connection amount, judging that the server side and the shared memory are not disconnected.
43. The method of claim 42, further comprising:
and when the disconnection of the server is judged, sending a reconnection request to the server according to a preset frequency.
44. The method of claim 43, wherein the registration success information comprises an identification code assigned to the client by the server; the reconnection request includes the identification code; the identification code is used for enabling the server to be connected to the shared memory according to the identification code in the reconnection request.
45. A log processing method is applied to a server side, and is characterized by comprising the following steps:
receiving a registration request sent by a client;
applying for sharing the memory for the client according to the registration request;
after the shared memory application is successful, sending registration success information to the client;
and acquiring the log information of the client from the shared memory of the client and the server, and storing the log information to a preset storage path.
46. The method of claim 45, wherein the obtaining the log information from the shared memory and storing the log information to a preset storage path comprises:
and obtaining the log information with the priority higher than a preset second printing level from the shared memory, and storing the log information to a preset storage path.
47. The method as claimed in claim 46, wherein the printing levels of the log information include an OFF level, a FATAL level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level and an ALL level, which are arranged in order of priority from high to low.
48. The method according to any one of claims 45 to 47, wherein the step of the server obtaining the log information from the shared memory and storing the log information in a preset storage path comprises:
and the server acquires the log information from the shared memory in a single-thread mode and stores the log information into a preset storage path.
49. The method according to any one of claims 45 to 47, wherein the registration request includes an amount of memory to be occupied, and the applying for the shared memory for the client according to the registration request includes:
determining the current memory surplus of the server;
and applying for the shared memory for the client according to the memory surplus and the memory amount to be occupied.
50. The method according to claim 49, wherein the applying for the shared memory for the client according to the remaining amount of the memory and the amount of the memory to be occupied comprises:
if the amount of the memory to be occupied is smaller than the residual amount of the memory, applying for a shared memory corresponding to the amount of the memory to be occupied for the client;
and if the amount of the memory to be occupied is not less than the residual amount of the memory, refusing to apply for the shared memory for the client.
51. The method of any of claims 45-47, 50, wherein the registration request further comprises a process identification of the client;
correspondingly, the applying for the shared memory for the client according to the registration request includes:
judging whether a preset process blacklist comprises the process identification or not;
if not, applying for the shared memory for the client;
and if so, refusing to apply for the shared memory for the client.
52. The method of any of claims 45-47, wherein the registration request is generated according to a preset log write configuration;
applying for the shared memory for the client according to the registration request includes:
and according to the log write-in configuration, the client applies for sharing the memory.
53. The method of claim 52, wherein the log write configuration comprises at least one of a size of memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
54. The method according to any one of claims 45-47, 50, 53, wherein after applying for the shared memory for the client according to the registration request, further comprising:
and initializing the shared memory to obtain a lock-free queue instance.
55. The method according to any one of claims 45-47, 50, 53, wherein after applying for the shared memory for the client according to the registration request, further comprising:
and initializing the shared memory to obtain a locked queue instance.
56. The method of any one of claims 45-47, 50, 53, further comprising:
and when a reconnection request sent by the client is received, reconnecting with the shared memory according to the reconnection request.
57. The method according to claim 56, wherein the registration success information includes an identification code assigned to the client by the server; the reconnection request comprises the identification code; the reconnecting with the shared memory according to the reconnection request includes:
and connecting to the shared memory according to the identification code in the reconnection request.
58. The method according to any of claims 45-47, 50, 53, 57, wherein after sending the registration success information to the client, further comprising:
and monitoring the log writing condition in the shared memory, and managing and controlling the client according to a monitoring result.
59. The method according to claim 58, wherein the monitoring the log writing status in the shared memory, and controlling the client according to the monitoring result comprises:
judging whether the speed of the client for writing in the log exceeds a preset speed threshold value or not;
and if so, judging that the client fails.
60. The method according to claim 58, wherein the monitoring the log writing status in the shared memory, and controlling the client according to the monitoring result comprises:
judging whether the number of the logs written by the client exceeds a preset number threshold;
and if so, judging that the client fails.
61. The method according to claim 59 or 60, wherein after determining that the client has failed, further comprising:
determining authority information corresponding to the client according to the process identifier of the client;
and managing and controlling the log information written in by the client according to the authority information.
62. The method of claim 45, further comprising:
and acquiring the log information from the shared memory, and issuing the log information.
63. A log processing system, comprising
One or more processors;
one or more memories;
the memory is used for storing program codes;
the processor, configured to invoke the program code, when the program code is executed, is configured to perform the following:
sending a registration request to a server through a calling interface preset by a client;
receiving a registration request sent by a client through the server;
applying for a shared memory for the client by the server according to the registration request;
after the shared memory application is successful, sending registration success information to the client through the server;
when the registration success information fed back by the server side is received, the log information of the client side is written into the shared memory through the client side;
and acquiring the log information from the shared memory through the server and storing the log information to a preset storage path.
64. The log processing system of claim 63 wherein the shared memory is a lock-free queue instance.
65. The log processing system of claim 63 wherein the shared memory is a locked queue instance.
66. A log processing system as defined in claim 63, wherein the registration request is sent by one of the threads of the client.
67. The log processing system of claim 66 wherein the processor, when writing log information of the client to the shared memory by the client, is configured to:
and writing the log of each thread in the client into the shared memory according to a preset thread storage sequence through the client.
68. A log processing system as claimed in any one of claims 63 to 67, wherein said processor, when writing log information of the client to said shared memory by the client, is configured to:
and storing the log information with the priority higher than a preset first printing level into the shared memory through the client.
69. A log processing system as defined in any of claims 63 to 67 wherein the print levels of the log information include an OFF level, a FATAL level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level and an ALL level, ALL of which are prioritized in order from high to low.
70. A log processing system as claimed in any one of claims 63 to 67, wherein said processor, when writing log information of the client to said shared memory by the client, is configured to:
and writing the log information of the client into the shared memory in an asynchronous storage mode through the client.
71. The log processing system of claim 63, wherein the processor, prior to sending the registration request to the server via the call interface preset by the client, is further configured to:
and generating the registration request according to preset log write-in configuration by the client.
72. The log processing system of claim 71 wherein the log write configuration comprises at least one of a size of memory to be occupied, a storage mode, a storage location, a division of subfolders stored, and a size of subfolders stored.
73. A log processing system according to any of claims 63-67 and 71-72, wherein the processor, after writing, by the client, the log information of the client into the shared memory when receiving the registration success information fed back by the server, is further configured to:
acquiring the connection number of the shared memory through the client;
and determining whether the server is disconnected with the shared memory or not according to the connection number through the client.
74. The log processing system of claim 73, wherein the processor, when determining, by the client, whether the server is disconnected from the shared memory based on the number of connections, is configured to:
if the client side is connected with the shared memory and the connection number is smaller than the preset connection total amount, the client side judges that the server side is disconnected with the shared memory; wherein, the total connection amount is the connection number of the shared memory in a normal log storage state;
and if the client side and the shared memory are kept connected and the connection number is not less than the preset total connection amount, judging that the server side and the shared memory are not disconnected through the client side.
75. The log processing system of claim 74, wherein said processor is further configured to:
when the server is judged to be disconnected, sending a reconnection request to the server through the client according to a preset frequency;
and when the server receives a reconnection request sent by the client, the server is reconnected with the shared memory according to the reconnection request.
76. The log processing system of claim 75 wherein said registration success information includes an identification code assigned by said server to said client; the reconnection request includes the identification code; when the processor is reconnected with the shared memory according to the reconnection request through the server, the processor is configured to:
and connecting to the shared memory through the server according to the identification code in the reconnection request.
77. The log processing system of claim 63, wherein the processor, when obtaining the log information from the shared memory through the server and storing the log information to a preset storage path, is configured to:
and acquiring log information with the priority higher than a preset second printing level from the shared memory through the server, and storing the log information to a preset storage path.
78. A log processing system as defined in claim 77, wherein the print levels of the log information include an OFF level, a FATAL level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are prioritized in order from high to low.
79. The log processing system of claim 77 or 78, wherein the processor, when obtaining the log information from the shared memory through the server and storing the log information to a preset storage path, is configured to:
and acquiring the log information from the shared memory by the server in a single-thread mode and storing the log information into a preset storage path.
80. A log processing system according to claim 77 or 78, wherein the registration request includes an amount of memory to be occupied, and the processor is configured to, when applying for the shared memory for the client according to the registration request through the server:
determining the current memory surplus of the server;
and applying for the shared memory for the client by the server according to the memory surplus and the memory amount to be occupied.
81. The log processing system of claim 80, wherein the processor, when applying for the shared memory by the client according to the remaining memory amount and the memory amount to be occupied by the server, is configured to:
if the amount of the memory to be occupied is smaller than the residual amount of the memory, applying for a shared memory corresponding to the amount of the memory to be occupied for the client;
and if the amount of the memory to be occupied is not less than the residual amount of the memory, refusing to apply for the shared memory for the client.
82. A log processing system as claimed in any of claims 77 to 78, 81, wherein the registration request further comprises an identity of a process of the client;
correspondingly, when the processor applies for the shared memory for the client through the server according to the registration request, the processor is configured to:
judging whether a preset process blacklist comprises the process identification or not;
if not, applying for the shared memory for the client;
and if so, refusing to apply for the shared memory for the client.
83. A log processing system as claimed in any one of claims 77 to 78, 81, wherein the registration request is generated in accordance with a preset log write configuration;
the processor, when applying for the shared memory for the client through the server according to the registration request, is configured to:
and the server side applies for the shared memory for the client side according to the log write-in configuration.
84. The log processing system of claim 83 wherein the log write configuration comprises at least one of a size of memory to be occupied, a storage mode, a storage location, a division of subfolders stored, and a size of subfolders stored.
85. A log processing system as in any of claims 77-78, 81 or 84, wherein the processor, after receiving a registration request sent by a client via the server, further comprises:
and initializing the shared memory through the server to obtain a locked queue instance.
86. A log processing system as in any of claims 77-78, 81 or 84, wherein the processor, after receiving a registration request sent by a client via the server, further comprises:
and initializing the shared memory through the server to obtain a locked queue instance.
87. A log processing system as in any of claims 77-78, 81 or 84, wherein the processor, after sending registration success information to the client via the server, further comprises:
and monitoring the log writing condition in the shared memory through the server, and managing and controlling the client according to the monitoring result.
88. The log processing system of claim 87, wherein the processor, when monitoring the log writing status in the shared memory through the server and managing and controlling the client according to the monitoring result, is configured to:
the server side judges whether the speed of the client side for writing the log exceeds a preset speed threshold value;
and if so, judging that the client fails.
89. The log processing system of claim 87, wherein the processor, when monitoring the log writing status in the shared memory through the server and managing and controlling the client according to the monitoring result, is configured to:
the server side judges whether the number of the logs written by the client side exceeds a preset number threshold value or not;
and if so, judging that the client fails.
90. A log processing system as claimed in claim 88 or 89, wherein the processor, after determining that the client has failed, is further configured to:
the server side determines authority information corresponding to the client side according to the process identification of the client side;
and the server manages and controls the log information written in by the client according to the authority information.
91. The log processing system of claim 63, wherein the processor is configured to:
and the server side acquires the log information from the shared memory and issues the log information.
92. A client terminal device, characterized in that the terminal device comprises:
a memory and a processor;
the memory is used for storing program codes;
the processor, invoking the program code, when executed, is configured to:
sending a registration request to a server through a preset calling interface
And when the registration success information fed back by the server is received, writing the log information into the shared memory of the client and the server.
93. The terminal device of claim 92, wherein the shared memory is a lock-free queue instance.
94. The terminal device of claim 92, wherein the shared memory is a locked queue instance.
95. The terminal device of claim 92, wherein the registration request is sent by one of the threads of the client.
96. The terminal device of claim 95, wherein the processor, when writing the log information of the client into the shared memory, is configured to:
and writing the log of each thread in the client into the shared memory according to a preset thread storage sequence.
97. The terminal device of any one of claims 92-96, wherein the processor, when writing the log information of the client to the shared memory, is configured to:
and storing the log information with the priority higher than the preset first printing level into the shared memory.
98. The terminal device according to any of claims 92-96, wherein the printing levels of the log information comprise an OFF level, a talk level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are prioritized in order from high to low.
99. The terminal device of any one of claims 92-96, wherein the processor, when writing the log information of the client to the shared memory, is configured to:
and writing the log information of the client into the shared memory in an asynchronous storage mode.
100. The terminal device of claim 92, wherein the registration information further comprises a process identifier of a process sending the registration request.
101. The terminal device of claim 92, wherein the processor, before sending the registration request to the server via the call interface preset by the client, is further configured to:
and generating the registration request according to a preset log write configuration.
102. The terminal device of claim 101, wherein the log write configuration comprises at least one of a size of memory to be occupied, a storage mode, a storage location, a division of subfolders stored, and a size of subfolders stored.
103. The terminal device as recited in any one of claims 92-96 and 100-101, wherein the processor is further configured to, after writing the log information of the client into the shared memory when receiving the registration success information fed back by the server, further:
acquiring the connection number of the shared memory;
and determining whether the server is disconnected with the shared memory or not according to the connection number.
104. The terminal device of claim 103, wherein when determining whether the server is disconnected from the shared memory according to the connection number, the processor is configured to:
if the client side is connected with the shared memory and the connection number is smaller than the preset connection total amount, judging that the server side is disconnected with the shared memory; wherein, the total connection amount is the connection number of the shared memory in a normal log storage state;
and if the client side and the shared memory are kept connected and the connection number is not less than the preset total connection amount, judging that the server side and the shared memory are not disconnected.
105. The terminal device of claim 104, wherein the processor is further configured to:
and when the disconnection of the server is judged, sending a reconnection request to the server according to a preset frequency.
106. The terminal device according to claim 105, wherein the registration success information includes an identification code assigned by the server to the client; the reconnection request includes the identification code; the identification code is used for enabling the server to be connected to the shared memory according to the identification code in the reconnection request.
107. A service terminal device, characterized in that the service terminal device comprises: a memory and a processor;
the memory is used for storing program codes;
the processor, invoking the program code, when executed, is configured to:
receiving a registration request sent by a client;
applying for sharing the memory for the client according to the registration request;
after the shared memory application is successful, sending registration success information to the client;
and acquiring the log information of the client from the shared memory and storing the log information to a preset storage path.
108. The service terminal device of claim 107, wherein the processor, when obtaining the log information from the shared memory and storing the log information to a preset storage path, is configured to:
and obtaining the log information with the priority higher than a preset second printing level from the shared memory, and storing the log information to a preset storage path.
109. The service terminal apparatus of claim 108, wherein the printing levels of the log information include an OFF level, a false level, an ERROR level, a WARN level, an INFO level, a DEBUG level, a TRACE level, and an ALL level, which are arranged in order of priority from high to low.
110. The service terminal device as recited in any one of claims 107-109, wherein the processor, when acquiring the log information from the shared memory and storing the log information in a preset storage path, is configured to:
and the server acquires the log information from the shared memory in a single-thread mode and stores the log information into a preset storage path.
111. The service terminal device as recited in any one of claims 107-109, wherein the registration request includes an amount of memory to be occupied, and the processor, when applying for the shared memory for the client according to the registration request, is configured to:
determining the current memory surplus of the server;
and applying for the shared memory for the client according to the memory surplus and the memory amount to be occupied.
112. The service terminal device of claim 111, wherein when the processor applies for the shared memory for the client according to the remaining memory amount and the memory amount to be occupied, the processor is configured to:
if the amount of the memory to be occupied is smaller than the residual amount of the memory, applying for a shared memory corresponding to the amount of the memory to be occupied for the client;
and if the amount of the memory to be occupied is not less than the residual amount of the memory, refusing to apply for the shared memory for the client.
113. The service terminal device as recited in any one of claims 107-109 and 112, wherein the registration request further comprises a process id of the client;
correspondingly, when the processor applies for the shared memory for the client according to the registration request, the processor is configured to:
judging whether a preset process blacklist comprises the process identification or not;
if not, applying for the shared memory for the client;
and if so, refusing to apply for the shared memory for the client.
114. The service terminal device as recited in any one of claims 107-109, wherein the registration request is generated according to a preset log write configuration;
the processor, when applying for a shared memory for the client according to the registration request, is configured to:
and according to the log write-in configuration, the client applies for sharing the memory.
115. The service end device of claim 114, wherein the log write configuration comprises at least one of a size of memory to be occupied, a storage mode, a storage location, a stored subfolder partition, and a stored subfolder size.
116. The service terminal device as recited in any one of claims 107, 109, 112 and 115, wherein the processor is further configured to, after applying for the shared memory for the client according to the registration request:
and initializing the shared memory to obtain a lock-free queue instance.
117. The service terminal device as recited in any one of claims 107, 109, 112 and 115, wherein the processor is further configured to, after applying for the shared memory for the client according to the registration request:
and initializing the shared memory to obtain a locked queue instance.
118. The service terminal device as recited in any one of claims 107, 109, 112 and 115, wherein the processor is further configured to:
and when a reconnection request sent by the client is received, reconnecting with the shared memory according to the reconnection request.
119. The service end device of claim 118, wherein the registration success information includes an identification code assigned by the service end to the client; the reconnection request comprises the identification code; when reconnecting with the shared memory according to the reconnection request, the processor is configured to:
and connecting to the shared memory according to the identification code in the reconnection request.
120. The service end device as recited in any one of claims 107, 109, 112, 115 and 119, wherein the processor, after sending the registration success information to the client, is further configured to:
and monitoring the log writing condition in the shared memory, and managing and controlling the client according to a monitoring result.
121. The service terminal device of claim 120, wherein the processor, when monitoring a log writing status in the shared memory and managing and controlling the client according to a monitoring result, is configured to:
judging whether the speed of the client for writing in the log exceeds a preset speed threshold value or not;
and if so, judging that the client fails.
122. The service terminal device of claim 120, wherein the processor, when monitoring a log writing status in the shared memory and managing and controlling the client according to a monitoring result, is configured to:
judging whether the number of the logs written by the client exceeds a preset number threshold;
and if so, judging that the client fails.
123. The service end device of claim 121 or 122, wherein the processor, after determining that the client terminal is out of order, is further configured to:
determining authority information corresponding to the client according to the process identifier of the client;
and managing and controlling the log information written in by the client according to the authority information.
124. The serving terminal device of claim 107, wherein the processor is further configured to:
and acquiring the log information from the shared memory, and issuing the log information.
125. A computer-readable storage medium, having stored thereon a computer program for execution by a processor to perform the method of any one of claims 1-29 or 30-44 or 45-62.
CN201980012096.4A 2019-06-20 2019-06-20 Log processing method, log processing device and computer-readable storage medium Pending CN111699479A (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/091998 WO2020252724A1 (en) 2019-06-20 2019-06-20 Log processing method and device, and computer-readable storage medium

Publications (1)

Publication Number Publication Date
CN111699479A true CN111699479A (en) 2020-09-22

Family

ID=72476455

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201980012096.4A Pending CN111699479A (en) 2019-06-20 2019-06-20 Log processing method, log processing device and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN111699479A (en)
WO (1) WO2020252724A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527614A (en) * 2020-12-08 2021-03-19 广东小天才科技有限公司 Intelligent device log quantity early warning system and method
CN113051243A (en) * 2021-03-31 2021-06-29 上海阵量智能科技有限公司 Log processing method, device, system, chip, equipment and storage medium
CN114172946A (en) * 2021-12-06 2022-03-11 京东科技信息技术有限公司 Request result sending method and device, electronic equipment and computer readable medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103514053A (en) * 2013-09-22 2014-01-15 中国科学院信息工程研究所 Shared-memory-based method for conducting communication among multiple processes
CN106648931A (en) * 2016-12-12 2017-05-10 贵阳朗玛信息技术股份有限公司 Log information recording method and device
CN107066405A (en) * 2017-03-31 2017-08-18 联想(北京)有限公司 A kind of sharing method of memory device, interconnection subsystem and internal memory
CN107241335A (en) * 2017-06-16 2017-10-10 上海闻泰信息技术有限公司 The method and device of information sharing
CN107491355A (en) * 2017-08-17 2017-12-19 山东浪潮商用系统有限公司 Funcall method and device between a kind of process based on shared drive
CN109508246A (en) * 2018-06-25 2019-03-22 广州多益网络股份有限公司 Log recording method, system and computer readable storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6219672B1 (en) * 1997-12-11 2001-04-17 Kabushiki Kaisha Toshiba Distributed shared memory system and method of controlling distributed shared memory
JP2002287999A (en) * 2001-03-26 2002-10-04 Duaxes Corp Server duplexing method, duplex server system, and duplex database server
CN102420814A (en) * 2011-11-21 2012-04-18 航天科工深圳(集团)有限公司 Data access method and device, and server
CN107579864B (en) * 2017-10-16 2021-01-08 深圳大宇无限科技有限公司 Request monitoring method and device and server
CN108566552B (en) * 2018-04-20 2021-05-25 四川长虹网络科技有限责任公司 Multimedia playing method and system suitable for digital set top box
CN109471743A (en) * 2018-11-12 2019-03-15 深圳前海微众银行股份有限公司 Log collecting method, device and computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103514053A (en) * 2013-09-22 2014-01-15 中国科学院信息工程研究所 Shared-memory-based method for conducting communication among multiple processes
CN106648931A (en) * 2016-12-12 2017-05-10 贵阳朗玛信息技术股份有限公司 Log information recording method and device
CN107066405A (en) * 2017-03-31 2017-08-18 联想(北京)有限公司 A kind of sharing method of memory device, interconnection subsystem and internal memory
CN107241335A (en) * 2017-06-16 2017-10-10 上海闻泰信息技术有限公司 The method and device of information sharing
CN107491355A (en) * 2017-08-17 2017-12-19 山东浪潮商用系统有限公司 Funcall method and device between a kind of process based on shared drive
CN109508246A (en) * 2018-06-25 2019-03-22 广州多益网络股份有限公司 Log recording method, system and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
阮厦城: "分布式环境下通用日志系统的设计与实现" *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527614A (en) * 2020-12-08 2021-03-19 广东小天才科技有限公司 Intelligent device log quantity early warning system and method
CN113051243A (en) * 2021-03-31 2021-06-29 上海阵量智能科技有限公司 Log processing method, device, system, chip, equipment and storage medium
CN114172946A (en) * 2021-12-06 2022-03-11 京东科技信息技术有限公司 Request result sending method and device, electronic equipment and computer readable medium

Also Published As

Publication number Publication date
WO2020252724A1 (en) 2020-12-24

Similar Documents

Publication Publication Date Title
CN111699479A (en) Log processing method, log processing device and computer-readable storage medium
US20140026000A1 (en) Highly available server system based on cloud computing
CN109960634B (en) Application program monitoring method, device and system
CN111209110B (en) Task scheduling management method, system and storage medium for realizing load balancing
CN111385296B (en) Business process restarting method, device, storage medium and system
US20210406127A1 (en) Method to orchestrate a container-based application on a terminal device
US9092396B2 (en) Standby system device, a control method, and a program thereof
CA3138764A1 (en) Data processing method, device, computer equipment and storage medium
CN113467873A (en) Virtual machine scheduling method and device, electronic equipment and storage medium
US11252121B2 (en) Message sending method and terminal device
CN110569124A (en) Task allocation method and device
CN115794317B (en) Processing method, device, equipment and medium based on virtual machine
US11836528B2 (en) Throttling thread resources of service computing platform
WO2023001020A1 (en) Orthogonal architecture-based service board starting method, service board, and orthogonal device
CN114138371B (en) Configuration dynamic loading method and device, computer equipment and storage medium
CN113992630B (en) Network resource conflict processing method, device, equipment and storage medium
CN106453118B (en) Flow control method and flow control system
CN105939278B (en) Traffic processing method and device
CN114143728A (en) Message processing method, communication system, electronic device, and storage medium
CN109634721B (en) Method and related device for starting communication between virtual machine and host
CN108021459B (en) Method and device for sending dotting logs across processes
CN108632151B (en) Cluster router board card access method and device and cluster router
CN109257201B (en) License sending method and device
CN117472516B (en) Virtual resource scheduling method, device, cluster system, electronic equipment and medium
CN113612514B (en) Media resource processing system, method and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination