[go: up one dir, main page]

WO2019072212A1 - Log processing method and device and server - Google Patents

Log processing method and device and server Download PDF

Info

Publication number
WO2019072212A1
WO2019072212A1 PCT/CN2018/109880 CN2018109880W WO2019072212A1 WO 2019072212 A1 WO2019072212 A1 WO 2019072212A1 CN 2018109880 W CN2018109880 W CN 2018109880W WO 2019072212 A1 WO2019072212 A1 WO 2019072212A1
Authority
WO
WIPO (PCT)
Prior art keywords
log
sliding window
space
segment
write
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.)
Ceased
Application number
PCT/CN2018/109880
Other languages
French (fr)
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Publication of WO2019072212A1 publication Critical patent/WO2019072212A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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

Definitions

  • the present application relates to the field of information technology, and in particular, to a log processing method and apparatus, and a server.
  • the log system applies for a log segment on the disk, and the log segment includes a plurality of log spaces arranged in sequence.
  • the external device sends a log write request carrying the log to the log system, and the log system receives the log.
  • the log is stored in the log space on the log side.
  • the external device sends a plurality of log write requests to the log system, and the log system writes the logs carried by the multiple log write requests to the log space of the log segment concurrently, for any of the log segments.
  • the log system does not send an acknowledgment (ACK) to the external device in the other log space in front of the log space, the log system cannot Sending an ACK to an external device, the log system must wait until the other log space located in front of the log space sends an acknowledgment message ACK to the external device, in order to send an acknowledgment message ACK to the external device for the log space.
  • the above setting ensures that when the log segment is read later, the log of the first write failure is read, and the other log space of the log segment is stopped, thereby ensuring high efficiency. Read the log segment.
  • the ACK message ACK can be sent to the external device for the specific log space, which results in The loss of write concurrency affects the performance of the write log. If the dependency between the ACKs is removed, then the log segment may have a successful write log and a write failed log stored in the log segment, so When reading the log segment, if you want to get a valid log, you must traverse the entire log segment, which makes the log read inefficient.
  • the embodiment of the invention provides a log processing method and device, and a server, which can ensure the efficiency of log reading and reduce the loss of write concurrency.
  • an embodiment of the present invention provides a log processing method, including:
  • the log segment includes M log spaces arranged in order;
  • N logs concurrently to M log spaces, where N ⁇ M, and N logs are generated by an external device
  • the first confirmation information is used to notify the external device that the log writing is successful.
  • the sliding window since the sliding window is used, and the first confirmation information is sent to the external device for the log space in the writing completion state in the sliding window, the log is in the writing completion state for the sliding window.
  • the space does not send the first confirmation message to the external device, and since the sliding window covers a larger range with respect to a single log space, the loss of write concurrency can be reduced. Further, since the log space before the sliding window is in the write success state, the efficiency of the log reading can be ensured.
  • the sliding window is used to slide from the starting log space of the log segment to the end log space, which specifically includes:
  • the sliding window is swiped to the end log space of the log segment until the new starting log space of the sliding window is in a state other than the non-writing success state.
  • the sliding window is swiped in the above manner to ensure that the log space before the sliding window is in a successful writing state.
  • the method further includes:
  • the method further includes:
  • Each log space of the log segment is read one by one from the log space of the log segment to the log space at the end of the log segment;
  • K-1 log spaces located after the log space with invalid data are read one by one.
  • an embodiment of the present invention provides a log processing apparatus, including:
  • the log segment application module is used to apply for a log segment, and the log segment includes M log spaces arranged in order;
  • a log writing module configured to concurrently write N logs to the M log spaces, where N ⁇ M, and N logs are generated by an external device;
  • a sliding window module configured to slide from a starting log space of a log segment to a log space at a end of the log segment by using a sliding window, wherein the sliding window covers K log spaces, K ⁇ M;
  • the confirmation information sending module is configured to separately send the first confirmation information to the external device for each log space in the write completion state in the sliding window, so that each log space in the write completion state in the sliding window is in a write success state. , the first confirmation information is not sent to the external device for each log space in the write completion state outside the sliding window;
  • the first confirmation information is used to notify the external device that the log writing is successful.
  • the implementation of the second aspect or the second aspect is the system implementation corresponding to the first aspect or the implementation manner of any one of the first aspect, and the description in any one of the first aspect or the first aspect is applicable to the second aspect. Or any implementation of the second aspect, and details are not described herein again.
  • the sliding window module is specifically configured to:
  • the sliding window is swiped to the end log space of the log segment until the new starting log space of the sliding window is in a state other than the non-writing success state.
  • the confirmation information sending module is further configured to:
  • the log processing apparatus further includes a log reading module, and a log reading module, configured to:
  • Each log space of the log segment is read one by one from the log space of the log segment to the log space at the end of the log segment;
  • K-1 log spaces located after the log space with invalid data are read one by one.
  • an embodiment of the present invention provides a server, including a memory and a processor, where the memory stores program instructions, and the processor executes the program instructions to cause the server to perform the functions of the log processing apparatus.
  • the present application provides a computer readable storage medium having instructions stored therein that, when run on a computer, cause the computer to perform any of the first aspect or the first aspect described above The method described in the implementation.
  • the present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method described in the first aspect or any of the possible implementations of the first aspect.
  • FIG. 1 is a schematic structural diagram of a log processing system according to an embodiment of the present invention.
  • FIG. 2 is a flowchart of a log processing method according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a log segment in a first state according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of concurrently writing a log in a log segment according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of a log segment in a second state according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a log segment in a third state according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a log segment in a fourth state according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of a log segment in a fifth state according to an embodiment of the present invention.
  • FIG. 9 is a schematic diagram of a log segment in a sixth state according to an embodiment of the present invention.
  • FIG. 10 is another flowchart of a log processing method according to an embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of an apparatus of a log processing apparatus according to an embodiment of the present invention.
  • FIG. 12 is a schematic structural diagram of an apparatus of a server according to an embodiment of the present invention.
  • FIG. 1 is a schematic structural diagram of a log processing system according to an embodiment of the present invention.
  • the log processing system includes a server 10, a network 20, and external devices 201, 202, and 203, and the server 10 passes through a network. 20 is connected to external devices 201, 202, 203.
  • the server 10 specifically includes a log processing device 100, an operating system 102, and hardware 101.
  • the hardware 101 specifically includes a magnetic disk 1011, a network card 1012, a CPU 1013, and a memory 1014.
  • the log processing device 100 runs on the operating system 102, and controls the network card 1012 to receive the log-writing request written by the external device 201, 202, 203 from the network 20 through the operating system 102, and can send a confirmation via the network 20.
  • the information is to the external devices 201, 202, 203.
  • the log processing apparatus 100 can apply for the disk 1011 space to the disk 1011 as a log segment through the operating system 102, wherein the log segment includes a plurality of sequentially arranged log spaces, and the log space is used to store the log.
  • a log space stores a log carried by a log write request.
  • FIG. 2 is a flowchart of a log processing method according to an embodiment of the present invention. As shown in FIG. 2, a log processing method according to an embodiment of the present invention includes the following steps:
  • Step S101 The log processing device 100 applies for the log segment 300, and sets the sliding window 200 to the starting position of the log segment 300.
  • the log segment 300 includes M log spaces arranged in order, and the sliding window 200 covers K log spaces. K ⁇ M.
  • FIG. 3 is a schematic diagram of a log segment 300 in a first state according to an embodiment of the present invention.
  • the starting log space of the sliding window 200 coincides with the starting log space of the log segment 300, so that the sliding window 200 is set at the starting position of the log segment 300.
  • each log space of the log segment 300 is in an unwritten state.
  • Step S102 The log processing apparatus 100 concurrently writes N logs to the M log spaces, where N ⁇ M, and N logs are generated by the external device 201.
  • each log space is correspondingly written with one log, and N logs are synchronously written into the first N log spaces of the M log spaces.
  • FIG. 4 is a schematic diagram of concurrently writing logs in the log segment 300 according to an embodiment of the present invention.
  • Step S103 The log processing apparatus 100 separately transmits the first confirmation information to each external space 201 for each log space in the write completion state in the sliding window 200, and does not transmit for each log space in the write completion state outside the sliding window 200.
  • the first confirmation information is sent to the external device 201, wherein the first confirmation information is used to notify the external device 201 that the log writing is successful.
  • FIG. 5 is a schematic diagram of a log segment 300 in a second state
  • FIG. 6 is a log segment 300 in a third state, in accordance with an embodiment of the present invention. schematic diagram.
  • the log spaces 1, 2, 3, 5, 8, 10, 11, and 13 are all in the write completion state, and the log spaces 4, 6, 7, 9, 12, 14, 15, and 16 are all in the Write status.
  • log space 4, 6, 7, 9, 12 is in the unwritten state is that the log is being written, or the log writing fails, and the log spaces 14, 15 and 16 are in the unwritten state because Log writes were not made for these log spaces.
  • the log processing apparatus 100 transmits the first confirmation information to the external device 201 for each of the log spaces 1, 2, 3, and 5 in the write completion state in the sliding window 200, and is written outside the sliding window 200.
  • Each of the log spaces 8, 10, 11, and 13 of the completion status does not transmit the first confirmation information to the external device 201.
  • the log processing apparatus 100 sends the first confirmation information to the external device 201 for the log space in the write completion state, it indicates that the log writing in the log space is successful, and the log space is at this time. Write success status.
  • the log processing apparatus 100 transmits the first confirmation information to the external device 201 for each of the log spaces 1, 2, 3, and 5 in the write completion state in the sliding window 200, the log space is 1, 2, 2, 3 and 5 are in the write success state, and the log spaces 8, 10, 11, and 13 outside the sliding window 200 are still in the write completion state.
  • Step S104 The log processing device 100 determines whether the initial log space of the sliding window 200 is in the write success state. If yes, step S105 is performed, and if no, step S106 is performed.
  • the initial log space 1 of the sliding window 200 is in a write success state, and the log processing apparatus 100 executes step S105.
  • Step S105 The log processing apparatus 100 slides the sliding window 200 to the end log space of the log segment 300 until the new starting log space of the sliding window 200 is in another state of the non-writing success state, or up to the end of the sliding window 200.
  • the log space coincides with the end position space of the log segment 300.
  • FIG. 7 is a schematic diagram of a log segment 300 in a fourth state according to an embodiment of the present invention.
  • the sliding window 200 slides to the end log space 16 of the log end until sliding.
  • the new start log space 4 of the window 200 is in another state of the non-write success state, and the sliding window 200 stops sliding, wherein the new start log space 4 of the sliding window 200 is in the unwritten state.
  • non-write success state may also be write completion states.
  • step S103 the log processing apparatus 100 jumps to step S103 to perform similar processing for the log space within the new sliding window 200.
  • the log processing apparatus 100 transmits the first confirmation information to the external device 201 for each of the log spaces 8 and 10 in the write completion state in the new sliding window 200, and is in the write completion state for the outside of the sliding window 200.
  • Each of the log spaces 11 and 13 does not transmit the first confirmation information to the external device 201.
  • FIG. 8 is a schematic diagram of a log segment 300 in a fifth state, as shown in FIG. 8, after the above processing, the log spaces 5, 8 in the new sliding window 200 and 10 are in a write success state.
  • the log processing apparatus 100 may jump to step S104 to determine whether the initial log space 4 of the new sliding window 200 is in a write success state, and as shown in FIG. 8, the log space 4 is in an unwritten state. If the result of the determination is NO, the log processing apparatus 100 jumps to step S106.
  • Step S106 The log processing apparatus 100 writes invalid data on the initial log space of the sliding window 200, transmits the second confirmation information to the external device 201 for the initial log space of the sliding window 200, and waits for the sliding window 200 to include the sliding window. Log writes are completed in other log spaces outside the starting log space of 200. The second confirmation information is used to notify the external device 201 that the log write failed.
  • FIG. 9 is a schematic diagram of a log segment 300 in a sixth state, as shown in FIG. 9, the log processing device 100 may be in a new starting log space 4 of the sliding window 200.
  • the invalid data is written on, so that the log space 4 is in the write failure state, and waits for other log spaces 6, 7, and 9 other than the start log space 4 of the sliding window 200 in the sliding window 200 to complete the log writing.
  • the log processing device 100 may wait for a preset time after writing the log to the log, and if the preset time is exceeded, the invalid data is directly written. .
  • the log processing device 100 counts the log space 4 after writing the log space. If the preset time is exceeded, the invalid data is directly written in the log space 4 in the sliding window 200, so that the log space 4 is written. The failure state is entered, and similar processing can be performed for the log spaces 6, 7, and 9.
  • the log processing apparatus 100 may further write invalid data in the log space after the sliding window 200, so that the log space after the sliding window 200 is in a write failure state.
  • the log processing apparatus 100 completes the log write operation of the current log segment 300, and the log space 1, 2, 3, 5, 8, 10 of the current log segment 300 records a valid log, and other log spaces record invalid. data.
  • the log since the sliding window 200 is used, and the first confirmation information is transmitted to the external device 201 for the log space in the writing completion state in the sliding window 200, the log is in the writing completion state for the sliding window 200.
  • the space does not send the first confirmation information to the external device 201, and the log space before the sliding window 200 is ensured to be in a write success state, so as to avoid the occurrence of a successful write log and a write failure log stored in the log segment 300. It can guarantee the efficiency of log reading.
  • FIG. 10 is another flowchart of a log processing method according to an embodiment of the present invention.
  • Figure 10 shows a specific manner of reading the data segments generated by Figure 2.
  • the log processing method according to the implementation of the present invention further includes:
  • Step S201 The log processing apparatus 100 reads the initial log space of the log segment 300.
  • Step S202 The log processing apparatus 100 determines whether the invalid data is first read in the log segment 300, and if so, executes step S203, and if no, executes step S204.
  • Step S203 The log processing apparatus 100 reads K-1 log spaces located after the log space having invalid data one by one.
  • Step S204 The log processing apparatus 100 reads the next log space of the current log space, and jumps to step S202.
  • the log processing apparatus 100 reads each log space of the log segment 300 one by one from the initial log space of the log segment 300 to the end log space of the log segment 300.
  • the read one by one is located. K-1 log space after the log space of invalid data, thus completing the log end reading.
  • step S201 the log processing apparatus 100 first reads the initial log space 1 of the log end, and determines whether the data read in the initial log space 1 is invalid data.
  • the log is known.
  • the data of the space 1 is a valid log, so the process goes to step S204, the log processing apparatus 100 reads the next log space 2 of the log space 1, and performs a similar loop, thereby respectively reading the log space 1 in which the valid log is stored.
  • step S203 the log processing apparatus 100 reads the log space after the log space having invalid data one by one.
  • the log processing apparatus 100 reads the 6 log spaces 5 to 10 after the log space 4 having invalid data one by one, when in the log space
  • the invalid data read is directly discarded.
  • valid logs are read in log spaces 5, 8, and 10
  • valid logs are recorded.
  • all valid logs are read in log spaces 1, 2, 3, 5, 8, and 10 of log segment 300.
  • the embodiment of the present invention writes the log to the log segment 300 concurrently based on the sliding window 200, since the log space before the sliding window 200 is in the write success state, the success can be successfully read from the log segment 300. All the logs written can effectively ensure the reading efficiency.
  • the sliding window 200 is a fixed-length sliding window, that is, K is a constant, and the value of the K value can be set according to actual needs.
  • the sliding window 200 employed may be a variable length sliding window.
  • K is a variable
  • the concurrent write performance of the log system can be effectively improved, and the efficiency of log reading can be improved.
  • the sliding window 200 since the sliding window 200 is used, and the first confirmation information is transmitted to the external device 201 for the log space in the writing completion state in the sliding window 200, the writing is performed outside the sliding window 200.
  • the log space of the completion state does not transmit the first confirmation information to the external device 201, and since the sliding window covers a larger range with respect to a single log space, the loss of write concurrency can be reduced. Further, since the log space before the sliding window 200 is in the write success state, the efficiency of the log reading can be ensured.
  • FIG. 11 is a schematic structural diagram of a device of a log processing apparatus according to an embodiment of the present invention. As shown in FIG. 11 , the log processing apparatus 100 includes:
  • the log segment application module 1001 is configured to apply for the log segment 300, and the log segment 300 includes M log spaces arranged in order;
  • the log writing module 1002 is configured to concurrently write N logs to the M log spaces, where N ⁇ M, and N logs are generated by the external device 201;
  • the sliding window module 1003 is configured to slide from the initial log space of the log segment 300 to the end log space of the log segment 300 using the sliding window 200, wherein the sliding window 200 covers K log spaces, K ⁇ M;
  • the confirmation information sending module 1004 is configured to separately send the first confirmation information to the external device 201 for each log space in the writing completion state in the sliding window 200, so that each log space in the writing completion state in the sliding window 200 is in the In the write success state, the first confirmation information is not sent to the external device 201 for each log space in the write completion state outside the sliding window 200;
  • the first confirmation information is used to notify the external device 201 that the log writing is successful.
  • the sliding window module 1003 is specifically configured to:
  • the sliding window 200 When the initial log space of the sliding window 200 is in the write success state, the sliding window 200 is slid to the end log space of the log segment 300 until the new starting log space of the sliding window 200 is in a non-writing success state. status.
  • K is a variable
  • the confirmation information sending module 1004 is further configured to:
  • the log processing apparatus 100 further includes a log reading module, and a log reading module, configured to:
  • Each log space of the log segment 300 is read one by one from the initial log space of the log segment 300 to the end log space of the log segment 300;
  • K-1 log spaces located after the log space with invalid data are read one by one.
  • FIG. 12 is a schematic structural diagram of a device according to an embodiment of the present invention.
  • the server 10 includes a processor 1021, a memory 1022, and a bus 1023.
  • the processor 1021 and the memory 1022 are respectively connected to the bus. 1023 is connected, the memory 1022 stores program instructions, and the processor executes the program instructions to cause the server 10 to implement the functions of the log processing apparatus 100 disclosed above.
  • the sliding window 200 since the sliding window 200 is used, and the first confirmation information is transmitted to the external device 201 for the log space in the writing completion state in the sliding window 200, the writing is performed outside the sliding window 200.
  • the log space of the completion state does not transmit the first confirmation information to the external device 201, and since the sliding window covers a larger range with respect to a single log space, the loss of write concurrency can be reduced. Further, since the log space before the sliding window 200 is in the write success state, the efficiency of the log reading can be ensured.
  • the processor in the embodiment of the present application may be a central processing unit (English: central processing unit, abbreviated as CPU), a network processor (English: network processor, abbreviated as NP), or a combination of a CPU and an NP.
  • the processor may further include a hardware chip.
  • the hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (abbreviated as PLD), or a combination thereof.
  • ASIC application-specific integrated circuit
  • PLD programmable logic device
  • the above PLD can be a complex programmable logic device (English: complex programmable logic device, abbreviation: CPLD), field-programmable gate array (English: field-programmable gate array, abbreviation: FPGA), general array logic (English: generic array Logic, abbreviation: GAL) or any combination thereof.
  • CPLD complex programmable logic device
  • FPGA field-programmable gate array
  • GAL general array logic
  • the memory in the embodiment of the present application may include a volatile memory (English: volatile memory), such as random-access memory (abbreviation: RAM); the memory may also include non-volatile memory.
  • Non-volatile memory English: non-volatile memory
  • read-only memory English: read-only memory, abbreviation: ROM
  • flash memory English: flash memory
  • hard disk English: hard disk drive, abbreviation: HDD
  • solid state drive International: solid-state drive, abbreviated: SSD
  • the memory may also include a combination of the above types of memory.
  • the present application provides a computer readable storage medium having instructions stored therein that, when run on a computer, cause the computer to perform any of the possible implementations of the above-described embodiments Said method.
  • the present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method described in any of the possible implementations of the above-described embodiments.
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer usable memory channels (including but not limited to disk storage and optical storage, etc.) in which computer usable program code is embodied.
  • the present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG.
  • the computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine instruction for generating instructions executed by a processor of a computer or other programmable data processing device Means for implementing the functions specified in one or more flows of the flowchart or in a block or blocks of the flowchart.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

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

Abstract

Embodiments of the present invention provide a log processing method and device and a server. The method comprises: applying for a log segment, wherein the log segment comprises M log spaces arranged in an order; concurrently writing N logs to the M log spaces, wherein N ≤ M and the N logs are generated by an external device; sliding a sliding window from a start log space towards an end log space of the log segment, wherein the sliding window covers K log spaces and K < M; and sending to the external device first confirmation information for each log space in a write-completed state in the sliding window, such that each log space in the write-completed state in the sliding window is in the write-completed state, and the first confirmation information is no longer sent to the external device for each log space in the write-completed state in the sliding window. With the above method, the efficiency of log reading can be ensured and loss caused by concurrent writing is reduced.

Description

日志处理方法及装置、服务器Log processing method and device, server 技术领域Technical field

本申请涉及信息技术领域,特别涉及一种日志处理方法及装置、服务器。The present application relates to the field of information technology, and in particular, to a log processing method and apparatus, and a server.

背景技术Background technique

在现有技术的日志系统中,日志系统在磁盘中申请日志段,日志段包括多个顺序排列的日志空间,外部设备向日志系统发送携带有日志的日志写入请求,日志系统将接收到的日志存入日志端的日志空间。In the log system of the prior art, the log system applies for a log segment on the disk, and the log segment includes a plurality of log spaces arranged in sequence. The external device sends a log write request carrying the log to the log system, and the log system receives the log. The log is stored in the log space on the log side.

在现有技术中,外部设备向日志系统发送多个日志写入请求,日志系统将多个日志写入请求分别携带有的日志并发地写入到日志段的日志空间中,针对日志段的任意一个日志空间而言,若该日志空间的日志写入完成之后,日志系统针对位于该日志空间前面的其他日志空间没有发送确认信息(Acknowledgement,ACK)至外部设备,则日志系统针对该日志空间不能发送ACK至外部设备,日志系统必须等到位于该日志空间前面的其他日志空间均发送确认信息ACK至外部设备,才能针对该日志空间均发送确认信息ACK至外部设备。在现有技术中,通过以上设置,可保证在后续对日志段进行读取时,在读取到第一个写入失败的日志就停止读取这个日志段的其他日志空间,从而保证能够高效读取日志段。In the prior art, the external device sends a plurality of log write requests to the log system, and the log system writes the logs carried by the multiple log write requests to the log space of the log segment concurrently, for any of the log segments. In the case of a log space, if the log space is written to the log space, the log system does not send an acknowledgment (ACK) to the external device in the other log space in front of the log space, the log system cannot Sending an ACK to an external device, the log system must wait until the other log space located in front of the log space sends an acknowledgment message ACK to the external device, in order to send an acknowledgment message ACK to the external device for the log space. In the prior art, the above setting ensures that when the log segment is read later, the log of the first write failure is read, and the other log space of the log segment is stopped, thereby ensuring high efficiency. Read the log segment.

但是,在现有技术中,由于日志系统必须等到位于特定日志空间前面的其他日志空间均发送确认信息ACK至外部设备,才能针对该特定日志空间均发送确认信息ACK至外部设备,这就导致了写并发度的损失,影响了写日志的性能,假如把这种ACK之间的依赖关系去掉,那么这个日志段就可能存在写成功的日志和写失败的日志错乱的存放在日志段中,所以在读取日志段的时候,如果要获取有效日志,那就必须要遍历整个日志段,这就导致日志读取低效。However, in the prior art, since the log system must wait until the other log space located in front of the specific log space sends an acknowledgment message ACK to the external device, the ACK message ACK can be sent to the external device for the specific log space, which results in The loss of write concurrency affects the performance of the write log. If the dependency between the ACKs is removed, then the log segment may have a successful write log and a write failed log stored in the log segment, so When reading the log segment, if you want to get a valid log, you must traverse the entire log segment, which makes the log read inefficient.

发明内容Summary of the invention

为解决现有技术的问题,本发明实施例提供一种日志处理方法及装置、服务器,能够保证日志读取的效率,并降低写并发度的损失。To solve the problem of the prior art, the embodiment of the invention provides a log processing method and device, and a server, which can ensure the efficiency of log reading and reduce the loss of write concurrency.

第一方面,本发明实施例提供一种日志处理方法,包括:In a first aspect, an embodiment of the present invention provides a log processing method, including:

申请日志段,日志段包括M个按顺序排列的日志空间;Application log segment, the log segment includes M log spaces arranged in order;

向M个日志空间并发写入N个日志,其中,N≤M,且N个日志由外部设备产生;Write N logs concurrently to M log spaces, where N≤M, and N logs are generated by an external device;

使用滑动窗口从日志段的起始日志空间向日志段的末端日志空间滑动,其中,滑动窗口覆盖K个日志空间,K<M;Use the sliding window to slide from the starting log space of the log segment to the log space at the end of the log segment, wherein the sliding window covers K log spaces, K<M;

针对滑动窗口内处于写入完成状态的每一日志空间分别发送第一确认信息至外部设备,使得滑动窗口内处于写入完成状态的每一日志空间处于写入成功状态,针对滑动窗口 外处于写入完成状态的每一日志空间不发送第一确认信息至外部设备;Sending the first confirmation information to the external device for each log space in the write completion state in the sliding window, so that each log space in the write completion state in the sliding window is in a write success state, and is written outside the sliding window. Each log space in the completion status does not send the first confirmation message to the external device;

其中,第一确认信息用于通知外部设备日志写入成功。The first confirmation information is used to notify the external device that the log writing is successful.

综上,在本发明实施例中,由于使用了滑动窗口,并限定针对滑动窗口内处于写入完成状态的日志空间发送第一确认信息至外部设备,针对滑动窗口外处于写入完成状态的日志空间不发送第一确认信息至外部设备,由于滑动窗口相对于单个日志空间而言所覆盖的范围更大,因此可降低写并发度的损失。进一步地,由于滑动窗口之前的日志空间均处于写入成功状态,因此能够保证日志读取的效率。In summary, in the embodiment of the present invention, since the sliding window is used, and the first confirmation information is sent to the external device for the log space in the writing completion state in the sliding window, the log is in the writing completion state for the sliding window. The space does not send the first confirmation message to the external device, and since the sliding window covers a larger range with respect to a single log space, the loss of write concurrency can be reduced. Further, since the log space before the sliding window is in the write success state, the efficiency of the log reading can be ensured.

在本发明实施例的一种实现方式中,使用滑动窗口从日志段的起始日志空间向末端日志空间滑动,具体包括:In an implementation manner of the embodiment of the present invention, the sliding window is used to slide from the starting log space of the log segment to the end log space, which specifically includes:

在滑动窗口的起始日志空间处于写入成功状态时,将滑动窗口向日志段的末端日志空间进行滑动,直至滑动窗口的新的起始日志空间处于非写入成功状态的其他状态。When the starting log space of the sliding window is in the write success state, the sliding window is swiped to the end log space of the log segment until the new starting log space of the sliding window is in a state other than the non-writing success state.

滑动窗口通过以上方式进行滑动,可保证滑动窗口之前的日志空间均处于写入成功状态。The sliding window is swiped in the above manner to ensure that the log space before the sliding window is in a successful writing state.

在本发明实施例的另一种实现方式中,K为变量,且K=Kn,其中n为滑动窗口的滑动次数,Kn表示滑动窗口进行第n次滑动后覆盖Kn个日志空间,其中,K0=M/10,并且:In another implementation manner of the embodiment of the present invention, K is a variable, and K=Kn, where n is the number of slidings of the sliding window, and Kn is that the sliding window covers the Kn log space after the nth sliding, wherein K0 =M/10, and:

当N>=4时,

Figure PCTCN2018109880-appb-000001
When N>=4,
Figure PCTCN2018109880-appb-000001

当N<4时,

Figure PCTCN2018109880-appb-000002
When N<4,
Figure PCTCN2018109880-appb-000002

通过在不同的负载压力下,动态调整滑动窗口大小,可以有效提高日志系统的并发写性能,同时提升日志读取的效率。By dynamically adjusting the sliding window size under different load pressures, the concurrent write performance of the log system can be effectively improved, and the efficiency of log reading can be improved.

在本发明实施例的另一种实现方式中,该方法还包括:In another implementation manner of the embodiment of the present invention, the method further includes:

在滑动窗口的起始日志空间处于写入失败状态时,在滑动窗口的起始日志空间上写入无效数据,在写入无效数据之后,针对滑动窗口的起始日志空间发送第二确认信息至外部设备,并等待滑动窗口内除滑动窗口的起始日志空间外的其他日志空间完成日志写入,其中,第二确认信息用于通知外部设备日志写入失败。When the initial log space of the sliding window is in the write failure state, invalid data is written on the start log space of the sliding window, and after the invalid data is written, the second confirmation message is sent to the starting log space of the sliding window to The external device waits for the log space in the sliding window except the starting log space of the sliding window to complete the log writing, wherein the second confirmation information is used to notify the external device that the log writing fails.

在本发明实施例的另一种实现方式中,该方法还包括:In another implementation manner of the embodiment of the present invention, the method further includes:

自日志段的起始日志空间向日志段的末端日志空间逐一读取日志段的每一日志空间;Each log space of the log segment is read one by one from the log space of the log segment to the log space at the end of the log segment;

在首次读取到无效数据时,逐一读取位于具有无效数据的日志空间之后的K-1个日志空间。When invalid data is first read, K-1 log spaces located after the log space with invalid data are read one by one.

通过以上读取方式,确保最后一次滑动的滑动窗口内的该K-1个日志空间的日志均可被读取到,从而保证读取到日志的数据完整。Through the above reading mode, it is ensured that the logs of the K-1 log spaces in the sliding window of the last sliding can be read, thereby ensuring that the data read to the log is complete.

第二方面,本发明实施例提供一种日志处理装置,包括:In a second aspect, an embodiment of the present invention provides a log processing apparatus, including:

日志段申请模块,用于申请日志段,日志段包括M个按顺序排列的日志空间;The log segment application module is used to apply for a log segment, and the log segment includes M log spaces arranged in order;

日志写入模块,用于向M个日志空间并发写入N个日志,其中,N≤M,且N个日志由外部设备产生;a log writing module, configured to concurrently write N logs to the M log spaces, where N≤M, and N logs are generated by an external device;

滑动窗口模块,用于使用滑动窗口从日志段的起始日志空间向日志段的末端日志空间滑动,其中,滑动窗口覆盖K个日志空间,K<M;a sliding window module, configured to slide from a starting log space of a log segment to a log space at a end of the log segment by using a sliding window, wherein the sliding window covers K log spaces, K<M;

确认信息发送模块,用于针对滑动窗口内处于写入完成状态的每一日志空间分别发送第一确认信息至外部设备,使得滑动窗口内处于写入完成状态的每一日志空间处于写入成功状态,针对滑动窗口外处于写入完成状态的每一日志空间不发送第一确认信息至外部设 备;The confirmation information sending module is configured to separately send the first confirmation information to the external device for each log space in the write completion state in the sliding window, so that each log space in the write completion state in the sliding window is in a write success state. , the first confirmation information is not sent to the external device for each log space in the write completion state outside the sliding window;

其中,第一确认信息用于通知外部设备日志写入成功。The first confirmation information is used to notify the external device that the log writing is successful.

第二方面或第二方面任意一种实现方式是第一方面或第一方面任意一种实现方式对应的系统实现,第一方面或第一方面任意一种实现方式中的描述适用于第二方面或第二方面任意一种实现方式,在此不再赘述。The implementation of the second aspect or the second aspect is the system implementation corresponding to the first aspect or the implementation manner of any one of the first aspect, and the description in any one of the first aspect or the first aspect is applicable to the second aspect. Or any implementation of the second aspect, and details are not described herein again.

在本发明实施例的一种实现方式中,滑动窗口模块,具体用于:In an implementation manner of the embodiment of the present invention, the sliding window module is specifically configured to:

在滑动窗口的起始日志空间处于写入成功状态时,将滑动窗口向日志段的末端日志空间进行滑动,直至滑动窗口的新的起始日志空间处于非写入成功状态的其他状态。When the starting log space of the sliding window is in the write success state, the sliding window is swiped to the end log space of the log segment until the new starting log space of the sliding window is in a state other than the non-writing success state.

在本发明实施例的另一种实现方式中,K为变量,且K=Kn,其中n为滑动窗口的滑动次数,Kn表示滑动窗口进行第n次滑动后覆盖Kn个日志空间,其中,K0=M/10,并且:In another implementation manner of the embodiment of the present invention, K is a variable, and K=Kn, where n is the number of slidings of the sliding window, and Kn is that the sliding window covers the Kn log space after the nth sliding, wherein K0 =M/10, and:

当N>=4时,

Figure PCTCN2018109880-appb-000003
When N>=4,
Figure PCTCN2018109880-appb-000003

当N<4时,

Figure PCTCN2018109880-appb-000004
When N<4,
Figure PCTCN2018109880-appb-000004

在本发明实施例的另一种实现方式中,确认信息发送模块,还用于:In another implementation manner of the embodiment of the present invention, the confirmation information sending module is further configured to:

在滑动窗口的起始日志空间处于写入失败状态时,在滑动窗口的起始日志空间上写入无效数据,在写入无效数据之后,针对滑动窗口的起始日志空间发送第二确认信息至外部设备,并等待滑动窗口内除滑动窗口的起始日志空间外的其他日志空间完成日志写入,其中,第二确认信息用于通知外部设备日志写入失败。When the initial log space of the sliding window is in the write failure state, invalid data is written on the start log space of the sliding window, and after the invalid data is written, the second confirmation message is sent to the starting log space of the sliding window to The external device waits for the log space in the sliding window except the starting log space of the sliding window to complete the log writing, wherein the second confirmation information is used to notify the external device that the log writing fails.

在本发明实施例的另一种实现方式中,日志处理装置还包括日志读取模块,日志读取模块,用于:In another implementation manner of the embodiment of the present invention, the log processing apparatus further includes a log reading module, and a log reading module, configured to:

自日志段的起始日志空间向日志段的末端日志空间逐一读取日志段的每一日志空间;Each log space of the log segment is read one by one from the log space of the log segment to the log space at the end of the log segment;

在首次读取到无效数据时,逐一读取位于具有无效数据的日志空间之后的K-1个日志空间。When invalid data is first read, K-1 log spaces located after the log space with invalid data are read one by one.

第三方面,本发明实施例提供一种服务器,包括存储器和处理器,存储器存储有程序指令,处理器执行程序指令以使得服务器执行上述日志处理装置的功能。In a third aspect, an embodiment of the present invention provides a server, including a memory and a processor, where the memory stores program instructions, and the processor executes the program instructions to cause the server to perform the functions of the log processing apparatus.

第四方面,本申请提供一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述第一方面或第一方面的任意可能的实现方式中所述的方法。In a fourth aspect, the present application provides a computer readable storage medium having instructions stored therein that, when run on a computer, cause the computer to perform any of the first aspect or the first aspect described above The method described in the implementation.

第五方面,本申请提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述第一方面或第一方面的任意可能的实现方式中所述的方法。In a fifth aspect, the present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method described in the first aspect or any of the possible implementations of the first aspect.

附图说明DRAWINGS

图1是根据本发明实施例的日志处理系统的结构示意图;1 is a schematic structural diagram of a log processing system according to an embodiment of the present invention;

图2是根据本发明实施例的日志处理方法的流程图;2 is a flowchart of a log processing method according to an embodiment of the present invention;

图3是根据本发明实施例的处于第一状态的日志段的示意图;3 is a schematic diagram of a log segment in a first state according to an embodiment of the present invention;

图4是根据本发明实施例的在日志段并发写入日志的示意图;4 is a schematic diagram of concurrently writing a log in a log segment according to an embodiment of the present invention;

图5是根据本发明实施例的处于第二状态的日志段的示意图;FIG. 5 is a schematic diagram of a log segment in a second state according to an embodiment of the present invention; FIG.

图6是根据本发明实施例的处于第三状态的日志段的示意图;6 is a schematic diagram of a log segment in a third state according to an embodiment of the present invention;

图7是根据本发明实施例的处于第四状态的日志段的示意图;7 is a schematic diagram of a log segment in a fourth state according to an embodiment of the present invention;

图8是根据本发明实施例的处于第五状态的日志段的示意图;FIG. 8 is a schematic diagram of a log segment in a fifth state according to an embodiment of the present invention; FIG.

图9是根据本发明实施例的处于第六状态的日志段的示意图;9 is a schematic diagram of a log segment in a sixth state according to an embodiment of the present invention;

图10是根据本发明实施例的日志处理方法的另一流程图;FIG. 10 is another flowchart of a log processing method according to an embodiment of the present invention; FIG.

图11是根据本发明实施例的日志处理装置的装置结构示意图;11 is a schematic structural diagram of an apparatus of a log processing apparatus according to an embodiment of the present invention;

图12是根据本发明实施例的服务器的装置结构示意图。FIG. 12 is a schematic structural diagram of an apparatus of a server according to an embodiment of the present invention.

具体实施方式Detailed ways

首先请参见图1,图1是根据本发明实施例的日志处理系统的结构示意图,如图1所示,日志处理系统包括服务器10、网络20以及外部设备201、202、203,服务器10通过网络20与外部设备201、202、203连接。First, please refer to FIG. 1. FIG. 1 is a schematic structural diagram of a log processing system according to an embodiment of the present invention. As shown in FIG. 1, the log processing system includes a server 10, a network 20, and external devices 201, 202, and 203, and the server 10 passes through a network. 20 is connected to external devices 201, 202, 203.

服务器10具体包括日志处理装置100、操作系统102以及硬件101,硬件101具体包括磁盘1011、网卡1012、CPU1013以及内存1014。其中,日志处理装置100运行在操作系统102上,并通过操作系统102控制网卡1012从网络20接收外部设备201、202、203发送的携带有日志的日志写入请求,并可经由网络20发送确认信息至外部设备201、202、203。The server 10 specifically includes a log processing device 100, an operating system 102, and hardware 101. The hardware 101 specifically includes a magnetic disk 1011, a network card 1012, a CPU 1013, and a memory 1014. The log processing device 100 runs on the operating system 102, and controls the network card 1012 to receive the log-writing request written by the external device 201, 202, 203 from the network 20 through the operating system 102, and can send a confirmation via the network 20. The information is to the external devices 201, 202, 203.

并且,日志处理装置100可通过操作系统102向磁盘1011申请磁盘1011空间以作为日志段,其中,日志段包括多个顺序排列的日志空间,日志空间用于存储日志。Moreover, the log processing apparatus 100 can apply for the disk 1011 space to the disk 1011 as a log segment through the operating system 102, wherein the log segment includes a plurality of sequentially arranged log spaces, and the log space is used to store the log.

可选地,一个日志空间存储一个日志写入请求所携带的日志。Optionally, a log space stores a log carried by a log write request.

以下请参见图2,图2是根据本发明实施例的日志处理方法的流程图,如图2所示,根据本发明实施例的日志处理方法包括以下步骤:Referring to FIG. 2, FIG. 2 is a flowchart of a log processing method according to an embodiment of the present invention. As shown in FIG. 2, a log processing method according to an embodiment of the present invention includes the following steps:

步骤S101:日志处理装置100申请日志段300,并设置滑动窗口200于日志段300的起始位置,其中,日志段300包括M个按顺序排列的日志空间,滑动窗口200覆盖K个日志空间,K<M。Step S101: The log processing device 100 applies for the log segment 300, and sets the sliding window 200 to the starting position of the log segment 300. The log segment 300 includes M log spaces arranged in order, and the sliding window 200 covers K log spaces. K<M.

举例而言,可参见图3,图3是根据本发明实施例的处于第一状态的日志段300的示意图,如图3所示,日志处理装置100申请到日志段300,且M=16,滑动窗口200覆盖7个日志空间,K=7。For example, referring to FIG. 3, FIG. 3 is a schematic diagram of a log segment 300 in a first state according to an embodiment of the present invention. As shown in FIG. 3, the log processing device 100 applies to the log segment 300, and M=16. The sliding window 200 covers 7 log spaces, K=7.

在本发明实施例中,滑动窗口200的起始日志空间与日志段300的起始日志空间重合,从而使得滑动窗口200设置于日志段300的起始位置。In the embodiment of the present invention, the starting log space of the sliding window 200 coincides with the starting log space of the log segment 300, so that the sliding window 200 is set at the starting position of the log segment 300.

在本步骤中,由于日志处理装置100未在日志段300进行日志写入,因此日志段300的每一日志空间均处于未写入状态。In this step, since the log processing apparatus 100 does not perform log writing in the log segment 300, each log space of the log segment 300 is in an unwritten state.

步骤S102:日志处理装置100向M个日志空间并发写入N个日志,其中,N≤M,且N个日志由外部设备201产生。Step S102: The log processing apparatus 100 concurrently writes N logs to the M log spaces, where N≤M, and N logs are generated by the external device 201.

可选地,在本发明实施例中,每一日志空间对应写入一个日志,且N个日志同步写入到M个日志空间的前N个日志空间中。Optionally, in the embodiment of the present invention, each log space is correspondingly written with one log, and N logs are synchronously written into the first N log spaces of the M log spaces.

举例而言,可参见图4,图4是根据本发明实施例在日志段300并发写入日志的示意图,如图4所示,N=13,即日志处理装置100同时在日志空间1至13分别写入日志1至13。For example, referring to FIG. 4, FIG. 4 is a schematic diagram of concurrently writing logs in the log segment 300 according to an embodiment of the present invention. As shown in FIG. 4, N=13, that is, the log processing device 100 is simultaneously in the log space 1 to 13 Write logs 1 to 13 respectively.

步骤S103:日志处理装置100针对滑动窗口200内处于写入完成状态的每一日志空间分别发送第一确认信息至外部设备201,针对滑动窗口200外处于写入完成状态的每一日志空间不发送第一确认信息至外部设备201,其中,第一确认信息用于通知外部设备201 日志写入成功。Step S103: The log processing apparatus 100 separately transmits the first confirmation information to each external space 201 for each log space in the write completion state in the sliding window 200, and does not transmit for each log space in the write completion state outside the sliding window 200. The first confirmation information is sent to the external device 201, wherein the first confirmation information is used to notify the external device 201 that the log writing is successful.

可结合图5和图6进行参考,其中,图5是根据本发明实施例的处于第二状态的日志段300的示意图,图6是根据本发明实施例的处于第三状态的日志段300的示意图。Reference may be made in conjunction with FIGS. 5 and 6, wherein FIG. 5 is a schematic diagram of a log segment 300 in a second state, and FIG. 6 is a log segment 300 in a third state, in accordance with an embodiment of the present invention. schematic diagram.

如图5所示,日志空间1、2、3、5、8、10、11以及13均处于写入完成状态,日志空间4、6、7、9、12、14、15以及16均处于未写入状态。As shown in FIG. 5, the log spaces 1, 2, 3, 5, 8, 10, 11, and 13 are all in the write completion state, and the log spaces 4, 6, 7, 9, 12, 14, 15, and 16 are all in the Write status.

其中,日志空间4、6、7、9、12处于未写入状态的原因在于日志正在写入过程中,或日志写入失败,日志空间14、15以及16处于未写入状态的原因在于并未针对该些日志空间进行日志写入。The reason that the log space 4, 6, 7, 9, 12 is in the unwritten state is that the log is being written, or the log writing fails, and the log spaces 14, 15 and 16 are in the unwritten state because Log writes were not made for these log spaces.

在本步骤中,日志处理装置100针对滑动窗口200内处于写入完成状态的每一日志空间1、2、3以及5分别发送第一确认信息至外部设备201,针对滑动窗口200外处于写入完成状态的每一日志空间8、10、11以及13不发送第一确认信息至外部设备201。In this step, the log processing apparatus 100 transmits the first confirmation information to the external device 201 for each of the log spaces 1, 2, 3, and 5 in the write completion state in the sliding window 200, and is written outside the sliding window 200. Each of the log spaces 8, 10, 11, and 13 of the completion status does not transmit the first confirmation information to the external device 201.

在本发明实施例中,日志处理装置100针对处于写入完成状态的日志空间发送第一确认信息至外部设备201后,表示在该日志空间进行的日志写入成功了,此时该日志空间处于写入成功状态。In the embodiment of the present invention, after the log processing apparatus 100 sends the first confirmation information to the external device 201 for the log space in the write completion state, it indicates that the log writing in the log space is successful, and the log space is at this time. Write success status.

具体可参见图6,日志处理装置100针对滑动窗口200内处于写入完成状态的每一日志空间1、2、3以及5分别发送第一确认信息至外部设备201之后,日志空间1、2、3以及5处于写入成功状态,而滑动窗口200外的日志空间8、10、11以及13则仍处于写入完成状态。For details, referring to FIG. 6, after the log processing apparatus 100 transmits the first confirmation information to the external device 201 for each of the log spaces 1, 2, 3, and 5 in the write completion state in the sliding window 200, the log space is 1, 2, 2, 3 and 5 are in the write success state, and the log spaces 8, 10, 11, and 13 outside the sliding window 200 are still in the write completion state.

步骤S104:日志处理装置100判断滑动窗口200的起始日志空间是否处于写入成功状态,如果是,执行步骤S105,如果否,执行步骤S106。Step S104: The log processing device 100 determines whether the initial log space of the sliding window 200 is in the write success state. If yes, step S105 is performed, and if no, step S106 is performed.

针对图6所示,滑动窗口200的起始日志空间1处于写入成功状态,日志处理装置100执行步骤S105。As shown in FIG. 6, the initial log space 1 of the sliding window 200 is in a write success state, and the log processing apparatus 100 executes step S105.

步骤S105:日志处理装置100将滑动窗口200向日志段300的末端日志空间进行滑动,直至滑动窗口200的新的起始日志空间处于非写入成功状态的其他状态,或直至滑动窗口200的末端日志空间与日志段300的末端位置空间重合。Step S105: The log processing apparatus 100 slides the sliding window 200 to the end log space of the log segment 300 until the new starting log space of the sliding window 200 is in another state of the non-writing success state, or up to the end of the sliding window 200. The log space coincides with the end position space of the log segment 300.

举例而言,可参见图7,图7是根据本发明实施例的处于第四状态的日志段300的示意图,如图7所示,滑动窗口200向日志端的末端日志空间16进行滑动,直至滑动窗口200的新的起始日志空间4处于非写入成功状态的其他状态,滑动窗口200停止滑动,其中,于此滑动窗口200的新的起始日志空间4处于未写入状态。For example, referring to FIG. 7, FIG. 7 is a schematic diagram of a log segment 300 in a fourth state according to an embodiment of the present invention. As shown in FIG. 7, the sliding window 200 slides to the end log space 16 of the log end until sliding. The new start log space 4 of the window 200 is in another state of the non-write success state, and the sliding window 200 stops sliding, wherein the new start log space 4 of the sliding window 200 is in the unwritten state.

在另一些示例中,非写入成功状态的其他状态也可以是写入完成状态。In other examples, other states of the non-write success state may also be write completion states.

在滑动窗口200停止滑动之后,日志处理装置100跳转至步骤S103,针对新的滑动窗口200内的日志空间进行类似处理。After the sliding window 200 stops sliding, the log processing apparatus 100 jumps to step S103 to perform similar processing for the log space within the new sliding window 200.

具体而言,日志处理装置100针对新的滑动窗口200内处于写入完成状态的每一日志空间8以及10分别发送第一确认信息至外部设备201,针对滑动窗口200外处于写入完成状态的每一日志空间11以及13不发送第一确认信息至外部设备201。Specifically, the log processing apparatus 100 transmits the first confirmation information to the external device 201 for each of the log spaces 8 and 10 in the write completion state in the new sliding window 200, and is in the write completion state for the outside of the sliding window 200. Each of the log spaces 11 and 13 does not transmit the first confirmation information to the external device 201.

可结合图8,图8是根据本发明实施例的处于第五状态的日志段300的示意图,如图8所示,在进行上述处理之后,新的滑动窗口200内的日志空间5、8以及10均处于写入成功状态。8 is a schematic diagram of a log segment 300 in a fifth state, as shown in FIG. 8, after the above processing, the log spaces 5, 8 in the new sliding window 200 and 10 are in a write success state.

此时,日志处理装置100可跳转至步骤S104,判断新的滑动窗口200的起始日志空 间4是否处于写入成功状态,而如图8所示,日志空间4处于未写入状态,此时判断结果为否,日志处理装置100跳转至步骤S106。At this time, the log processing apparatus 100 may jump to step S104 to determine whether the initial log space 4 of the new sliding window 200 is in a write success state, and as shown in FIG. 8, the log space 4 is in an unwritten state. If the result of the determination is NO, the log processing apparatus 100 jumps to step S106.

步骤S106:日志处理装置100在滑动窗口200的起始日志空间上写入无效数据,针对滑动窗口200的起始日志空间发送第二确认信息至外部设备201,并等待滑动窗口200内除滑动窗口200的起始日志空间外的其他日志空间完成日志写入。其中,第二确认信息用于通知外部设备201日志写入失败。Step S106: The log processing apparatus 100 writes invalid data on the initial log space of the sliding window 200, transmits the second confirmation information to the external device 201 for the initial log space of the sliding window 200, and waits for the sliding window 200 to include the sliding window. Log writes are completed in other log spaces outside the starting log space of 200. The second confirmation information is used to notify the external device 201 that the log write failed.

可结合图9进行参考,图9是根据本发明实施例的处于第六状态的日志段300的示意图,如图9所示,日志处理装置100可在滑动窗口200的新的起始日志空间4上写入无效数据,使得日志空间4处于写入失败状态,并等待滑动窗口200内除滑动窗口200的起始日志空间4外的其他日志空间6、7以及9完成日志写入。Reference may be made in conjunction with FIG. 9, which is a schematic diagram of a log segment 300 in a sixth state, as shown in FIG. 9, the log processing device 100 may be in a new starting log space 4 of the sliding window 200. The invalid data is written on, so that the log space 4 is in the write failure state, and waits for other log spaces 6, 7, and 9 other than the start log space 4 of the sliding window 200 in the sliding window 200 to complete the log writing.

可选地,针对处于滑动窗口200内处于未写入状态的日志空间,日志处理装置100在对其写入日志后,可等待预设时间,若超出该预设时间,则直接写入无效数据。Optionally, for the log space that is in the unwritten state in the sliding window 200, the log processing device 100 may wait for a preset time after writing the log to the log, and if the preset time is exceeded, the invalid data is directly written. .

例如针对日志空间4,日志处理装置100在对日志空间4进行日志写入后计时,若超出预设时间,则直接在滑动窗口200内的日志空间4写入无效数据,使得日志空间4处于写入失败状态,而针对日志空间6、7、9也可做类似处理。For example, for the log space 4, the log processing device 100 counts the log space 4 after writing the log space. If the preset time is exceeded, the invalid data is directly written in the log space 4 in the sliding window 200, so that the log space 4 is written. The failure state is entered, and similar processing can be performed for the log spaces 6, 7, and 9.

在本发明实施例中,日志处理装置100可进一步在滑动窗口200之后的日志空间均写入无效数据,使得滑动窗口200之后的日志空间均处于写入失败状态。In the embodiment of the present invention, the log processing apparatus 100 may further write invalid data in the log space after the sliding window 200, so that the log space after the sliding window 200 is in a write failure state.

于此,日志处理装置100完成当前日志段300的日志写入操作,当前日志段300的日志空间1、2、3、5、8、10记录了有效的日志,而其他日志空间则记录了无效数据。Here, the log processing apparatus 100 completes the log write operation of the current log segment 300, and the log space 1, 2, 3, 5, 8, 10 of the current log segment 300 records a valid log, and other log spaces record invalid. data.

本发明实施例中,由于使用了滑动窗口200,并限定针对滑动窗口200内处于写入完成状态的日志空间发送第一确认信息至外部设备201,针对滑动窗口200外处于写入完成状态的日志空间不发送第一确认信息至外部设备201,可确保滑动窗口200之前的日志空间均处于写入成功状态,避免发生写成功的日志和写失败的日志错乱的存放在日志段300中的情况,能够保证日志读取的效率。In the embodiment of the present invention, since the sliding window 200 is used, and the first confirmation information is transmitted to the external device 201 for the log space in the writing completion state in the sliding window 200, the log is in the writing completion state for the sliding window 200. The space does not send the first confirmation information to the external device 201, and the log space before the sliding window 200 is ensured to be in a write success state, so as to avoid the occurrence of a successful write log and a write failure log stored in the log segment 300. It can guarantee the efficiency of log reading.

以下请参见图10,图10是根据本发明实施例的日志处理方法的另一流程图。图10示出了读取图2生成的数据段的具体方式。Please refer to FIG. 10, which is another flowchart of a log processing method according to an embodiment of the present invention. Figure 10 shows a specific manner of reading the data segments generated by Figure 2.

如图10所示,根据本发明实施的日志处理方法还包括:As shown in FIG. 10, the log processing method according to the implementation of the present invention further includes:

步骤S201:日志处理装置100读取日志段300的起始日志空间。Step S201: The log processing apparatus 100 reads the initial log space of the log segment 300.

步骤S202:日志处理装置100判断是否是在该日志段300中首次读取到无效数据,如果是,执行步骤S203,如果否,执行步骤S204。Step S202: The log processing apparatus 100 determines whether the invalid data is first read in the log segment 300, and if so, executes step S203, and if no, executes step S204.

步骤S203:日志处理装置100逐一读取位于具有无效数据的日志空间之后的K-1个日志空间。Step S203: The log processing apparatus 100 reads K-1 log spaces located after the log space having invalid data one by one.

步骤S204:日志处理装置100读取当前日志空间的下一日志空间,并跳转至步骤S202。Step S204: The log processing apparatus 100 reads the next log space of the current log space, and jumps to step S202.

综上,日志处理装置100自日志段300的起始日志空间向日志段300的末端日志空间逐一读取日志段300的每一日志空间,在首次读取到无效数据时,逐一读取位于具有无效数据的日志空间之后的K-1个日志空间,从而完成日志端读取。In summary, the log processing apparatus 100 reads each log space of the log segment 300 one by one from the initial log space of the log segment 300 to the end log space of the log segment 300. When the invalid data is read for the first time, the read one by one is located. K-1 log space after the log space of invalid data, thus completing the log end reading.

可结合图9进行理解,在步骤S201,日志处理装置100首先读取日志端的起始日志空间1,并判断在起始日志空间1中读取的数据是否是无效数据,根据图9可知,日志空间1的数据为有效的日志,因此跳转至步骤S204,日志处理装置100读取日志空间1的 下一日志空间2,并进行类似循环,从而分别读取存储了有效的日志的日志空间1至3,直至读取到日志空间4,由于日志空间4中写入的是无效数据,因此日志处理装置100跳转至步骤S203,日志处理装置100逐一读取具有无效数据的日志空间之后的K-1个日志空间,由于图9所示的实施例中,K=7,因此,日志处理装置100逐一读取具有无效数据的日志空间4之后的6个日志空间5至10,当在日志空间4、6、7以及9读取到无效数据时,直接丢弃读取到的无效数据,当在日志空间5、8以及10读取到有效的日志时,对有效的日志进行记录,从而在日志段300的日志空间1、2、3、5、8以及10中读取到所有有效的日志。It can be understood in conjunction with FIG. 9. In step S201, the log processing apparatus 100 first reads the initial log space 1 of the log end, and determines whether the data read in the initial log space 1 is invalid data. According to FIG. 9, the log is known. The data of the space 1 is a valid log, so the process goes to step S204, the log processing apparatus 100 reads the next log space 2 of the log space 1, and performs a similar loop, thereby respectively reading the log space 1 in which the valid log is stored. Up to 3, until the log space 4 is read, since the log space 4 is written as invalid data, the log processing apparatus 100 jumps to step S203, and the log processing apparatus 100 reads the log space after the log space having invalid data one by one. - 1 log space, since K = 7 in the embodiment shown in Fig. 9, the log processing apparatus 100 reads the 6 log spaces 5 to 10 after the log space 4 having invalid data one by one, when in the log space When 4, 6, 7, and 9 read invalid data, the invalid data read is directly discarded. When valid logs are read in log spaces 5, 8, and 10, valid logs are recorded. Thus all valid logs are read in log spaces 1, 2, 3, 5, 8, and 10 of log segment 300.

综上,本发明实施例基于滑动窗口200并发写入日志到日志段300中之后,由于滑动窗口200之前的日志空间均处于写入成功状态,因此可以高效地从日志段300中读取到成功写入的全部日志,能够有效地保证读取效率。In summary, after the embodiment of the present invention writes the log to the log segment 300 concurrently based on the sliding window 200, since the log space before the sliding window 200 is in the write success state, the success can be successfully read from the log segment 300. All the logs written can effectively ensure the reading efficiency.

值得注意的是,在本实施例中,所采用的滑动窗口200为固定长度的滑动窗口,即K为常量,K值的大小可根据实际需要设置。It should be noted that, in this embodiment, the sliding window 200 is a fixed-length sliding window, that is, K is a constant, and the value of the K value can be set according to actual needs.

但是,应理解,在另外一些示例中,所采用的滑动窗口200可以是变长的滑动窗口。However, it should be understood that in other examples, the sliding window 200 employed may be a variable length sliding window.

具体地,K为变量,且K=Kn,其中n为滑动窗口200的滑动次数,Kn表示滑动窗口200进行第n次滑动后覆盖Kn个日志空间,其中,K0=M/10,并且:Specifically, K is a variable, and K=Kn, where n is the number of slides of the sliding window 200, and Kn indicates that the sliding window 200 covers the Kn log spaces after the nth sliding, wherein K0=M/10, and:

当N>=4时,

Figure PCTCN2018109880-appb-000005
When N>=4,
Figure PCTCN2018109880-appb-000005

当N<4时,

Figure PCTCN2018109880-appb-000006
When N<4,
Figure PCTCN2018109880-appb-000006

值得注意的是,在另外一些示例中,也可以对

Figure PCTCN2018109880-appb-000007
Figure PCTCN2018109880-appb-000008
采用向上取整。 It is worth noting that in other examples, it is also possible
Figure PCTCN2018109880-appb-000007
with
Figure PCTCN2018109880-appb-000008
Use rounding up.

通过在不同的负载压力下,动态调整滑动窗口200大小,可以有效提高日志系统的并发写性能,同时提升日志读取的效率。By dynamically adjusting the size of the sliding window 200 under different load pressures, the concurrent write performance of the log system can be effectively improved, and the efficiency of log reading can be improved.

综上,在本发明实施例中,由于使用了滑动窗口200,并限定针对滑动窗口200内处于写入完成状态的日志空间发送第一确认信息至外部设备201,针对滑动窗口200外处于写入完成状态的日志空间不发送第一确认信息至外部设备201,由于滑动窗口相对于单个日志空间而言所覆盖的范围更大,因此可降低写并发度的损失。进一步地,由于滑动窗口200之前的日志空间均处于写入成功状态,因此能够保证日志读取的效率。In summary, in the embodiment of the present invention, since the sliding window 200 is used, and the first confirmation information is transmitted to the external device 201 for the log space in the writing completion state in the sliding window 200, the writing is performed outside the sliding window 200. The log space of the completion state does not transmit the first confirmation information to the external device 201, and since the sliding window covers a larger range with respect to a single log space, the loss of write concurrency can be reduced. Further, since the log space before the sliding window 200 is in the write success state, the efficiency of the log reading can be ensured.

以下请参见图11,图11是根据本发明实施例的日志处理装置的装置结构示意图,如图11所示,日志处理装置100,包括:Referring to FIG. 11 , FIG. 11 is a schematic structural diagram of a device of a log processing apparatus according to an embodiment of the present invention. As shown in FIG. 11 , the log processing apparatus 100 includes:

日志段申请模块1001,用于申请日志段300,日志段300包括M个按顺序排列的日志空间;The log segment application module 1001 is configured to apply for the log segment 300, and the log segment 300 includes M log spaces arranged in order;

日志写入模块1002,用于向M个日志空间并发写入N个日志,其中,N≤M,且N个日志由外部设备201产生;The log writing module 1002 is configured to concurrently write N logs to the M log spaces, where N≤M, and N logs are generated by the external device 201;

滑动窗口模块1003,用于使用滑动窗口200从日志段300的起始日志空间向日志段300的末端日志空间滑动,其中,滑动窗口200覆盖K个日志空间,K<M;The sliding window module 1003 is configured to slide from the initial log space of the log segment 300 to the end log space of the log segment 300 using the sliding window 200, wherein the sliding window 200 covers K log spaces, K<M;

确认信息发送模块1004,用于针对滑动窗口200内处于写入完成状态的每一日志空间分别发送第一确认信息至外部设备201,使得滑动窗口200内处于写入完成状态的每一日志空间处于写入成功状态,针对滑动窗口200外处于写入完成状态的每一日志空间不发送第一确认信息至外部设备201;The confirmation information sending module 1004 is configured to separately send the first confirmation information to the external device 201 for each log space in the writing completion state in the sliding window 200, so that each log space in the writing completion state in the sliding window 200 is in the In the write success state, the first confirmation information is not sent to the external device 201 for each log space in the write completion state outside the sliding window 200;

其中,第一确认信息用于通知外部设备201日志写入成功。The first confirmation information is used to notify the external device 201 that the log writing is successful.

可选地,滑动窗口模块1003,具体用于:Optionally, the sliding window module 1003 is specifically configured to:

在滑动窗口200的起始日志空间处于写入成功状态时,将滑动窗口200向日志段300的末端日志空间进行滑动,直至滑动窗口200的新的起始日志空间处于非写入成功状态的其他状态。When the initial log space of the sliding window 200 is in the write success state, the sliding window 200 is slid to the end log space of the log segment 300 until the new starting log space of the sliding window 200 is in a non-writing success state. status.

可选地,K为变量,且K=Kn,其中n为滑动窗口200的滑动次数,Kn表示滑动窗口200进行第n次滑动后覆盖Kn个日志空间,其中,K0=M/10,并且:Alternatively, K is a variable, and K=Kn, where n is the number of slides of the sliding window 200, and Kn indicates that the sliding window 200 covers the Kn log spaces after the nth sliding, wherein K0=M/10, and:

当N>=4时,

Figure PCTCN2018109880-appb-000009
When N>=4,
Figure PCTCN2018109880-appb-000009

当N<4时,

Figure PCTCN2018109880-appb-000010
When N<4,
Figure PCTCN2018109880-appb-000010

可选地,确认信息发送模块1004,还用于:Optionally, the confirmation information sending module 1004 is further configured to:

在滑动窗口200的起始日志空间处于非写入成功状态的其他状态时,在滑动窗口200的起始日志空间上写入无效数据,在写入无效数据之后,针对滑动窗口200的起始日志空间发送第二确认信息至外部设备201,并等待滑动窗口200内除滑动窗口200的起始日志空间外的其他日志空间完成日志写入,其中,第二确认信息用于通知外部设备201日志写入失败。When the initial log space of the sliding window 200 is in another state of the non-write success state, invalid data is written on the start log space of the sliding window 200, and after the invalid data is written, the start log for the sliding window 200 is written. The space sends the second confirmation information to the external device 201, and waits for other log spaces in the sliding window 200 except the starting log space of the sliding window 200 to complete the log writing, wherein the second confirmation information is used to notify the external device 201 to write the log. Failure failed.

可选地,日志处理装置100还包括日志读取模块,日志读取模块,用于:Optionally, the log processing apparatus 100 further includes a log reading module, and a log reading module, configured to:

自日志段300的起始日志空间向日志段300的末端日志空间逐一读取日志段300的每一日志空间;Each log space of the log segment 300 is read one by one from the initial log space of the log segment 300 to the end log space of the log segment 300;

在首次读取到无效数据时,逐一读取位于具有无效数据的日志空间之后的K-1个日志空间。When invalid data is first read, K-1 log spaces located after the log space with invalid data are read one by one.

以下请参见图12,图12是根据本发明实施例的服务器的装置结构示意图,如图12所示,服务器10,包括处理器1021、存储器1022以及总线1023,处理器1021和存储器1022分别与总线1023连接,存储器1022存储有程序指令,处理器执行程序指令以使得服务器10实现上述所揭示的日志处理装置100的功能。Referring to FIG. 12, FIG. 12 is a schematic structural diagram of a device according to an embodiment of the present invention. As shown in FIG. 12, the server 10 includes a processor 1021, a memory 1022, and a bus 1023. The processor 1021 and the memory 1022 are respectively connected to the bus. 1023 is connected, the memory 1022 stores program instructions, and the processor executes the program instructions to cause the server 10 to implement the functions of the log processing apparatus 100 disclosed above.

综上,在本发明实施例中,由于使用了滑动窗口200,并限定针对滑动窗口200内处于写入完成状态的日志空间发送第一确认信息至外部设备201,针对滑动窗口200外处于写入完成状态的日志空间不发送第一确认信息至外部设备201,由于滑动窗口相对于单个日志空间而言所覆盖的范围更大,因此可降低写并发度的损失。进一步地,由于滑动窗口200之前的日志空间均处于写入成功状态,因此能够保证日志读取的效率。In summary, in the embodiment of the present invention, since the sliding window 200 is used, and the first confirmation information is transmitted to the external device 201 for the log space in the writing completion state in the sliding window 200, the writing is performed outside the sliding window 200. The log space of the completion state does not transmit the first confirmation information to the external device 201, and since the sliding window covers a larger range with respect to a single log space, the loss of write concurrency can be reduced. Further, since the log space before the sliding window 200 is in the write success state, the efficiency of the log reading can be ensured.

需要说明的是,本申请实施例中的处理器可以是中央处理器(英文:central processing unit,缩写:CPU),网络处理器(英文:network processor,缩写:NP)或者CPU和NP的组合。处理器还可以进一步包括硬件芯片。上述硬件芯片可以是专用集成电路(英文:application-specific integrated circuit,缩写:ASIC),可编程逻辑器件(英文:programmable logic device,缩写:PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(英文:complex programmable logic device,缩写:CPLD),现场可编程逻辑门阵列(英文:field-programmable gate array,缩写:FPGA),通用阵列逻辑(英文:generic array logic,缩写:GAL)或其任意组合。It should be noted that the processor in the embodiment of the present application may be a central processing unit (English: central processing unit, abbreviated as CPU), a network processor (English: network processor, abbreviated as NP), or a combination of a CPU and an NP. The processor may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (abbreviated as PLD), or a combination thereof. The above PLD can be a complex programmable logic device (English: complex programmable logic device, abbreviation: CPLD), field-programmable gate array (English: field-programmable gate array, abbreviation: FPGA), general array logic (English: generic array Logic, abbreviation: GAL) or any combination thereof.

需要说明的是,本申请实施例中的存储器可以包括易失性存储器(英文:volatile memory),例如随机存取存储器(英文:random-access memory,缩写:RAM);存储器 也可以包括非易失性存储器(英文:non-volatile memory),例如只读存储器(英文:read-only memory,缩写:ROM),快闪存储器(英文:flash memory),硬盘(英文:hard disk drive,缩写:HDD)或固态硬盘(英文:solid-state drive,缩写:SSD);存储器还可以包括上述种类的存储器的组合。It should be noted that the memory in the embodiment of the present application may include a volatile memory (English: volatile memory), such as random-access memory (abbreviation: RAM); the memory may also include non-volatile memory. Non-volatile memory (English: non-volatile memory), such as read-only memory (English: read-only memory, abbreviation: ROM), flash memory (English: flash memory), hard disk (English: hard disk drive, abbreviation: HDD) Or a solid state drive (English: solid-state drive, abbreviated: SSD); the memory may also include a combination of the above types of memory.

基于相同的发明构思,本申请提供一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述实施例中任意可能的实现方式中所述的方法。Based on the same inventive concept, the present application provides a computer readable storage medium having instructions stored therein that, when run on a computer, cause the computer to perform any of the possible implementations of the above-described embodiments Said method.

基于相同的发明构思,本申请提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例中任意可能的实现方式中所述的方法。Based on the same inventive concept, the present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method described in any of the possible implementations of the above-described embodiments.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储信道(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, system, or computer program product. Thus, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware. Moreover, the application can take the form of a computer program product embodied on one or more computer usable memory channels (including but not limited to disk storage and optical storage, etc.) in which computer usable program code is embodied.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器指令,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. The computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine instruction for generating instructions executed by a processor of a computer or other programmable data processing device Means for implementing the functions specified in one or more flows of the flowchart or in a block or blocks of the flowchart.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。It will be apparent to those skilled in the art that various modifications and changes can be made in the present application without departing from the spirit and scope of the application. Thus, it is intended that the present invention cover the modifications and variations of the present invention.

Claims (11)

一种日志处理方法,其特征在于,包括:A log processing method, comprising: 申请日志段,所述日志段包括M个按顺序排列的日志空间;Applying a log segment, the log segment includes M log spaces arranged in order; 向所述M个日志空间并发写入N个日志,其中,N≤M,且所述N个日志由外部设备产生;Writing N logs concurrently to the M log spaces, where N≤M, and the N logs are generated by an external device; 使用滑动窗口从所述日志段的起始日志空间向所述日志段的末端日志空间滑动,其中,所述滑动窗口覆盖K个日志空间,K<M;Using a sliding window to slide from the starting log space of the log segment to the end log space of the log segment, wherein the sliding window covers K log spaces, K<M; 针对所述滑动窗口内处于写入完成状态的每一日志空间分别发送第一确认信息至所述外部设备,使得所述滑动窗口内处于写入完成状态的每一日志空间处于写入成功状态,针对所述滑动窗口外处于写入完成状态的每一日志空间不发送第一确认信息至所述外部设备;And sending, to the external device, the first confirmation information to each of the log spaces in the write completion state in the sliding window, so that each log space in the write completion state in the sliding window is in a write success state, Not sending the first confirmation information to the external device for each log space in the write completion state outside the sliding window; 其中,所述第一确认信息用于通知所述外部设备日志写入成功。The first confirmation information is used to notify the external device that the log writing is successful. 根据权利要求1所述的方法,其特征在于,所述使用滑动窗口从所述日志段的起始日志空间向末端日志空间滑动,具体包括:The method according to claim 1, wherein the sliding from the starting log space of the log segment to the end log space by using a sliding window comprises: 在所述滑动窗口的起始日志空间处于写入成功状态时,将所述滑动窗口向所述日志段的末端日志空间进行滑动,直至所述滑动窗口的新的起始日志空间处于非写入成功状态的其他状态。When the initial log space of the sliding window is in a write success state, sliding the sliding window to the end log space of the log segment until the new starting log space of the sliding window is not written Other states of the success state. 根据权利要求1或2所述的方法,其特征在于,所述K为变量,且所述K=Kn,其中n为所述滑动窗口的滑动次数,Kn表示所述滑动窗口进行第n次滑动后覆盖Kn个日志空间,其中,K0=M/10,并且:The method according to claim 1 or 2, wherein said K is a variable, and said K = Kn, wherein n is the number of slides of said sliding window, and Kn is said that said sliding window performs an nth sliding After covering Kn log spaces, where K0=M/10, and: 当N>=4时,
Figure PCTCN2018109880-appb-100001
When N>=4,
Figure PCTCN2018109880-appb-100001
当N<4时,
Figure PCTCN2018109880-appb-100002
When N<4,
Figure PCTCN2018109880-appb-100002
根据权利要求1至3任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 3, wherein the method further comprises: 在所述滑动窗口的起始日志空间处于非写入成功状态的其他状态时,在所述滑动窗口的起始日志空间上写入无效数据,在写入所述无效数据之后,针对所述滑动窗口的起始日志空间发送第二确认信息至所述外部设备,并等待所述滑动窗口内除所述滑动窗口的起始日志空间外的其他日志空间完成日志写入,其中,所述第二确认信息用于通知所述外部设备日志写入失败。Writing invalid data on a start log space of the sliding window when the initial log space of the sliding window is in another state of a non-write success state, after the invalid data is written, for the sliding The start log space of the window sends a second confirmation message to the external device, and waits for other log spaces in the sliding window except the start log space of the sliding window to complete log writing, wherein the second The confirmation information is used to notify the external device that the log write failed. 根据权利要求4所述的方法,其特征在于,所述方法还包括:The method of claim 4, wherein the method further comprises: 自所述日志段的起始日志空间向所述日志段的末端日志空间逐一读取所述日志段的每一日志空间;Reading each log space of the log segment one by one from the initial log space of the log segment to the end log space of the log segment; 在首次读取到无效数据时,逐一读取位于具有所述无效数据的日志空间之后的K-1个日志空间。When the invalid data is read for the first time, K-1 log spaces located after the log space having the invalid data are read one by one. 一种日志处理装置,其特征在于,包括:A log processing device, comprising: 日志段申请模块,用于申请日志段,所述日志段包括M个按顺序排列的日志空间;The log segment application module is configured to apply for a log segment, where the log segment includes M log spaces arranged in order; 日志写入模块,用于向所述M个日志空间并发写入N个日志,其中,N≤M,且所述N个日志由外部设备产生;a log writing module, configured to concurrently write N logs to the M log spaces, where N≤M, and the N logs are generated by an external device; 滑动窗口模块,用于使用滑动窗口从所述日志段的起始日志空间向所述日志段的末端日志空间滑动,其中,所述滑动窗口覆盖K个日志空间,K<M;a sliding window module, configured to slide from a starting log space of the log segment to an end log space of the log segment by using a sliding window, wherein the sliding window covers K log spaces, K<M; 确认信息发送模块,用于针对所述滑动窗口内处于写入完成状态的每一日志空间分别发送第一确认信息至所述外部设备,使得所述滑动窗口内处于写入完成状态的每一日志空间处于写入成功状态,针对所述滑动窗口外处于写入完成状态的每一日志空间不发送第一确认信息至所述外部设备;a confirmation information sending module, configured to respectively send first confirmation information to the external device for each log space in the writing completion state in the sliding window, so that each log in the writing completion state is in the sliding window The space is in a write success state, and the first confirmation information is not sent to the external device for each log space in the write completion state outside the sliding window; 其中,所述第一确认信息用于通知所述外部设备日志写入成功。The first confirmation information is used to notify the external device that the log writing is successful. 根据权利要求6所述的装置,其特征在于,所述滑动窗口模块,具体用于:The device according to claim 6, wherein the sliding window module is specifically configured to: 在所述滑动窗口的起始日志空间处于写入成功状态时,将所述滑动窗口向所述日志段的末端日志空间进行滑动,直至所述滑动窗口的新的起始日志空间处于非写入成功状态的其他状态。When the initial log space of the sliding window is in a write success state, sliding the sliding window to the end log space of the log segment until the new starting log space of the sliding window is not written Other states of the success state. 根据权利要求6或7所述的装置,其特征在于,所述K为变量,且所述K=Kn,其中n为所述滑动窗口的滑动次数,Kn表示所述滑动窗口进行第n次滑动后覆盖Kn个日志空间,其中,K0=M/10,并且:The apparatus according to claim 6 or 7, wherein said K is a variable, and said K = Kn, wherein n is the number of times of sliding of said sliding window, and Kn is said that said sliding window performs an nth sliding After covering Kn log spaces, where K0=M/10, and: 当N>=4时,
Figure PCTCN2018109880-appb-100003
When N>=4,
Figure PCTCN2018109880-appb-100003
当N<4时,
Figure PCTCN2018109880-appb-100004
When N<4,
Figure PCTCN2018109880-appb-100004
根据权利要求6至8任一项所述的装置,其特征在于,所述确认信息发送模块,还用于:The device according to any one of claims 6 to 8, wherein the confirmation information sending module is further configured to: 在所述滑动窗口的起始日志空间处于非写入成功状态的其他状态时,在所述滑动窗口的起始日志空间上写入无效数据,在写入所述无效数据之后,针对所述滑动窗口的起始日志空间发送第二确认信息至所述外部设备,并等待所述滑动窗口内除所述滑动窗口的起始日志空间外的其他日志空间完成日志写入,其中,所述第二确认信息用于通知所述外部设备日志写入失败。Writing invalid data on a start log space of the sliding window when the initial log space of the sliding window is in another state of a non-write success state, after the invalid data is written, for the sliding The start log space of the window sends a second confirmation message to the external device, and waits for other log spaces in the sliding window except the start log space of the sliding window to complete log writing, wherein the second The confirmation information is used to notify the external device that the log write failed. 根据权利要求9所述的装置,其特征在于,还包括日志读取模块,所述日志读取模块,用于:The device according to claim 9, further comprising a log reading module, wherein the log reading module is configured to: 自所述日志段的起始日志空间向所述日志段的末端日志空间逐一读取所述日志段的每一日志空间;Reading each log space of the log segment one by one from the initial log space of the log segment to the end log space of the log segment; 在首次读取到无效数据时,逐一读取位于具有所述无效数据的日志空间之后的K-1个日志空间。When the invalid data is read for the first time, K-1 log spaces located after the log space having the invalid data are read one by one. 一种服务器,其特征在于,包括存储器和处理器,所述存储器存储有程序指令,所述处理器执行所述程序指令以使得所述服务器执行权利要求1至5所述的步骤。A server, comprising a memory and a processor, the memory storing program instructions, the processor executing the program instructions to cause the server to perform the steps of claims 1 to 5.
PCT/CN2018/109880 2017-10-12 2018-10-11 Log processing method and device and server Ceased WO2019072212A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710948597.6A CN107844405B (en) 2017-10-12 2017-10-12 Log processing method and device and server
CN201710948597.6 2017-10-12

Publications (1)

Publication Number Publication Date
WO2019072212A1 true WO2019072212A1 (en) 2019-04-18

Family

ID=61661291

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/109880 Ceased WO2019072212A1 (en) 2017-10-12 2018-10-11 Log processing method and device and server

Country Status (2)

Country Link
CN (1) CN107844405B (en)
WO (1) WO2019072212A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107844405B (en) * 2017-10-12 2021-11-19 华为技术有限公司 Log processing method and device and server

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103347086A (en) * 2013-07-11 2013-10-09 南京大学 Synergy kernel construction method based on distributed type negotiation algorithm
US20140081983A1 (en) * 2004-03-09 2014-03-20 Versata Development Group, Inc. Session-Based Processing Method and System
CN104156432A (en) * 2014-08-08 2014-11-19 四川九成信息技术有限公司 File access method
CN107844405A (en) * 2017-10-12 2018-03-27 华为技术有限公司 Log processing method and device, server

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100417251C (en) * 2002-11-08 2008-09-03 中兴通讯股份有限公司 Method for downloading data based on control instructions along with roate
CN101179529A (en) * 2007-12-12 2008-05-14 北京亿企通信息技术有限公司 Method and system for reminding user to inscribe log in enterprise instant communication instrument
US9088808B1 (en) * 2008-02-08 2015-07-21 Google Inc. User interaction based related videos
CN102521405B (en) * 2011-12-26 2014-06-25 中国科学院计算技术研究所 Massive structured data storage and query methods and systems supporting high-speed loading
CN103309767B (en) * 2012-03-08 2016-01-13 阿里巴巴集团控股有限公司 A kind of client log disposal route and device
CN104657366B (en) * 2013-11-18 2019-05-24 深圳市腾讯计算机系统有限公司 The method, apparatus and log disaster tolerance system of massive logs write-in database
CN103645859B (en) * 2013-11-19 2016-04-13 华中科技大学 A kind of magnetic disk array buffer storage method of virtual SSD and SSD isomery mirror image
CN104391679A (en) * 2014-11-18 2015-03-04 浪潮电子信息产业股份有限公司 GPU (graphics processing unit) processing method for high-dimensional data stream in irregular stream
CN104484295B (en) * 2014-12-16 2017-03-22 中国人民解放军国防科学技术大学 Receiver sliding window-based data transmission method in parallel computer system
CN104571956A (en) * 2014-12-29 2015-04-29 成都致云科技有限公司 Data writing method and splitting device
CN106484565B (en) * 2016-09-22 2019-06-28 华为数字技术(成都)有限公司 Method of data synchronization and relevant device between multiple data centers
CN107193898B (en) * 2017-05-09 2019-12-03 中国科学院计算技术研究所 The inquiry sharing method and system of log data stream based on stepped multiplexing

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140081983A1 (en) * 2004-03-09 2014-03-20 Versata Development Group, Inc. Session-Based Processing Method and System
CN103347086A (en) * 2013-07-11 2013-10-09 南京大学 Synergy kernel construction method based on distributed type negotiation algorithm
CN104156432A (en) * 2014-08-08 2014-11-19 四川九成信息技术有限公司 File access method
CN107844405A (en) * 2017-10-12 2018-03-27 华为技术有限公司 Log processing method and device, server

Also Published As

Publication number Publication date
CN107844405A (en) 2018-03-27
CN107844405B (en) 2021-11-19

Similar Documents

Publication Publication Date Title
TWI604308B (en) Data storage device and data maintenance method thereof
CN107025185B (en) Data storage device and method of operation thereof
US10423508B2 (en) Method and system for a high-priority read based on an in-place suspend/resume write
TWI443513B (en) Memory storage device, memory controller thereof, and method for programming data thereof
CN107135662B (en) Differential data backup method, storage system and differential data backup device
TWI668626B (en) Storage apparatus and method for autonomous space compaction
TWI479313B (en) Data writing method, memory controller and memory storage device
US10860447B2 (en) Database cluster architecture based on dual port solid state disk
US20160306588A1 (en) Solid state disk and data moving method
CN106776147B (en) Differential data backup method and differential data backup device
US9547456B2 (en) Method and apparatus for efficient data copying and data migration
CN117251110A (en) Efficient data acquisition for garbage collection
CN104598453A (en) Data migration method based on data buffering
WO2019072212A1 (en) Log processing method and device and server
CN103092955B (en) Checkpointed method, Apparatus and system
JP6215631B2 (en) Computer system and data management method thereof
CN109062511B (en) Data reading method and related device
WO2024179293A1 (en) Data access method, terminal device, and storage medium
CN113093992B (en) A command decompression method, system and solid state hard disk
CN111061683B (en) Method and device for storing and operating data stream at high speed
TWI866812B (en) Method for performing table management of memory device in predetermined communications architecture with aid of flexible table page grouping, memory controller of memory device, memory device, and electronic device
TWI857926B (en) Method for performing table management of memory device in predetermined communications architecture with aid of system-region garbage collection, memory controller of memory device, memory device, and electronic device
TWI867743B (en) Method for performing table management of memory device in predetermined communications architecture with aid of table error correction, memory controller of memory device, memory device, and electronic device
CN107749307A (en) Storage system writes rewrite method, device, equipment and the storage medium during disk failure
WO2016082555A1 (en) Data processing method and apparatus

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18865588

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18865588

Country of ref document: EP

Kind code of ref document: A1