CN109379246B - Memory detection method and device - Google Patents

Memory detection method and device Download PDF

Info

Publication number
CN109379246B
CN109379246B CN201811108892.1A CN201811108892A CN109379246B CN 109379246 B CN109379246 B CN 109379246B CN 201811108892 A CN201811108892 A CN 201811108892A CN 109379246 B CN109379246 B CN 109379246B
Authority
CN
China
Prior art keywords
memory area
memory
current
space
message
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.)
Active
Application number
CN201811108892.1A
Other languages
Chinese (zh)
Other versions
CN109379246A (en
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.)
Ruijie Networks Co Ltd
Original Assignee
Ruijie Networks 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 Ruijie Networks Co Ltd filed Critical Ruijie Networks Co Ltd
Priority to CN201811108892.1A priority Critical patent/CN109379246B/en
Publication of CN109379246A publication Critical patent/CN109379246A/en
Application granted granted Critical
Publication of CN109379246B publication Critical patent/CN109379246B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0631Management of faults, events, alarms or notifications using root cause analysis; using analysis of correlation between notifications, alarms or events based on decision criteria, e.g. hierarchy, tree or time analysis
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0668Management of faults, events, alarms or notifications using network fault recovery by dynamic selection of recovery network elements, e.g. replacement by the most appropriate element after failure
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/16Threshold monitoring
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • H04L67/5682Policies or rules for updating, deleting or replacing the stored data

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Hardware Redundancy (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The application discloses a memory detection method and device. The method executes step a: if judging that the second memory area does not have idle resources, sending a heartbeat message to the second equipment through the memory space of the first memory area; and B: comparing the current memory space of the second memory area with a preset back-up threshold; when the current memory space of the second memory area is not smaller than the preset back-up threshold, determining that the second memory area is in transient abnormity before the current moment; and B, when the current memory space of the second memory area is smaller than the preset back-up threshold value, returning to execute the step A. The method reduces the equipment switching frequency caused by the fact that the whole memory cannot send the heartbeat message after being occupied by the service to be processed in the prior art, namely reduces the switching times among the equipment, reduces the packet loss rate and improves the accuracy of heartbeat detection.

Description

Memory detection method and device
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and an apparatus for detecting a memory.
Background
The distributed system is a multi-device architecture interconnected by communication networks, and tasks are executed by coordinating and interacting among devices. In a distributed communication system, a heartbeat mechanism can be utilized to perform reliability detection between devices. The heartbeat mechanism is a mechanism for regularly sending a self-defined structural body, such as a heartbeat message, between the devices to inform the other party of the current working state of the other party so as to ensure the effective connection between the devices. When the abnormality of the opposite device is detected, the abnormal device is repaired, such as device switching operation.
The sending and receiving of the heartbeat message by the device depends on the operation of an operating system in the device, such as the operation of a Central Processing Unit (CPU) and/or a memory resource. In the distributed system, the CPU of the first device processes the X service, other services, such as the A service and the B service, are cached in the memory, and the CPU can process the A service and the B service in sequence only after the X service is processed and the CPU is released. In order to avoid losing the data packets, the service a and the service B need to cache the data packets to be processed in their own cache queues, and the cached data packets need to apply for occupying the memory.
If the CPU has a long time to process the X service and the memory is occupied by the cache messages of the a service and the B service, the heartbeat message between the devices cannot be normally sent because there is no free memory, and after a period of time, the second device (or called opposite-end device) confirms that the first device is abnormal, thereby causing device switching.
However, the time period for the CPU to process the X service is a situation of transient memory exhaustion, and when the CPU finishes processing the X service, the transient memory exhaustion will disappear, and the memory of the first device can be recovered to normal.
Disclosure of Invention
The embodiment of the application provides a method and a device for detecting a memory, which provide a memory space for sending a heartbeat message by reducing cached to-be-processed service volume, so as to reduce the equipment switching frequency caused by the fact that the memory is occupied by the to-be-processed service in the prior art, and reduce the packet loss rate.
In a first aspect, a method for detecting a memory is provided, and is applied to a first device, where the first device includes a first memory area and a second memory area, and the method may include:
step A: if the second memory area is judged and known to have no free resources, a heartbeat message is sent to the second equipment through the memory space of the first memory area, and the first memory area comprises the message occupation space of a preset number of heartbeat messages;
and B: comparing the current memory space of the second memory area with a preset back-up threshold, wherein the current memory space which is compared for the first time is the initial memory space of the second memory area;
when the current memory space of the second memory area is not smaller than the preset back-up threshold, determining that the second memory area is in transient abnormity before the current moment;
when the current memory space of the second memory area is smaller than the preset back-up threshold value, returning to execute the step A;
the second memory area is used for caching the current operation service and the service to be processed, and caching the heartbeat message to be sent when idle resources exist.
In an optional implementation, after sending a heartbeat message to the second device through the message occupied space of the first memory area, the method further includes:
and releasing the message occupation space of the center hop message in the first memory area.
When the current memory space of the second memory area is not less than the preset back-up threshold, the method further comprises:
and on the basis of the current memory space of the second memory area, compensating the occupied space of the message released in the first memory area, and updating the current memory space of the second memory area.
In an optional implementation, when the current memory space of the second memory area is smaller than the preset back-up threshold, after the step a is executed again, the method further includes: and if the times of returning to execute the step A are equal to the preset number of the center jump messages of the first memory area, determining that the second memory area is in permanent abnormity.
In an optional implementation, after determining that the second memory area is in a long exception, the method further includes:
and generating alarm information, wherein the alarm information is used for indicating that the second memory area is in permanent abnormity.
In an optional implementation, after determining that the second memory area is in a long exception, the method further includes:
and receiving a switching instruction sent by the second equipment after the first preset time period, wherein the switching instruction is used for indicating to switch to the second equipment to process the current service corresponding to the current service volume.
In an optional implementation, after determining that the second memory area is in a long exception, the method further includes:
and switching to a second device to process the current service corresponding to the current service volume.
In an optional implementation, the preset number of heartbeat messages in the memory space of the first memory region is determined by the memory space of the first memory region and the size of each heartbeat message, the sending interval between adjacent heartbeat messages is a second preset time period, and the second preset time period is smaller than the first preset time period.
In an alternative implementation, the predetermined backoff threshold is determined according to a memory occupation ratio of the currently running service.
In an optional implementation, the method further comprises:
and if the second memory area is judged to have the idle resources, sending a heartbeat message to the second equipment through the second memory area.
In a second aspect, a detection apparatus is provided, which is applied in a first device, where the first device includes a first memory area and a second memory area, and the apparatus may include: a transmitting unit, a comparing unit and a determining unit;
the sending unit is used for sending a heartbeat message to the second equipment through the memory space of the first memory area if judging that the second memory area does not have the idle resources, wherein the first memory area comprises the message occupation space of a preset number of heartbeat messages;
the comparison unit is used for comparing the current memory space of the second memory area with a preset back-up threshold, wherein the current memory space which is compared for the first time is the initial memory space of the second memory area;
the determining unit is used for determining that the second memory area is in transient abnormity before the current moment when the current memory space of the second memory area is not smaller than the preset back-up threshold;
when the current memory space of the second memory area is smaller than a preset back-up threshold value, triggering a sending unit;
the second memory area is used for caching the current operation service and the service to be processed, and caching the heartbeat message to be sent when idle resources exist.
In an optional implementation, the apparatus further comprises a release unit and a complementary unit;
and the releasing unit is used for releasing the message occupation space of the center hop message in the first memory area after the sending unit sends a heartbeat message to the second equipment through the message occupation space in the first memory area.
And the back-up unit is used for performing back-up on the occupied space of the released message in the first memory area based on the current memory space of the second memory area and updating the current memory space of the second memory area when the current memory space of the second memory area is not smaller than the preset back-up threshold value.
In an optional implementation, the determining unit is further configured to, when the current memory space of the second memory area is smaller than the preset back-up threshold, return to execute step a, and if the number of times of triggering the sending unit is equal to the preset number of the heartbeat messages in the first memory area, determine that the second memory area is in a permanent exception state.
In an alternative implementation, the apparatus further comprises a generating unit;
and the generating unit is used for generating alarm information after the second memory area is determined to be in the permanent abnormity, and the alarm information is used for indicating that the second memory area is in the permanent abnormity.
In an alternative implementation, the apparatus further comprises a receiving unit;
and the receiving unit is used for receiving a switching instruction sent by the second equipment after the second memory area is determined to be in permanent abnormality, wherein the switching instruction is used for indicating to switch to the second equipment to process the current service corresponding to the current service volume.
In an alternative implementation, the apparatus further comprises a switching unit;
and the switching unit is used for switching to the second equipment to process the current service corresponding to the current service volume after determining that the second memory area is in permanent abnormity.
In an optional implementation, the preset number of heartbeat messages in the memory space of the first memory region is determined by the memory space of the first memory region and the size of each heartbeat message, the sending interval between adjacent heartbeat messages is a second preset time period, and the second preset time period is smaller than the first preset time period.
In an alternative implementation, the predetermined backoff threshold is determined according to a memory occupation ratio of the currently running service.
In an optional implementation, the sending unit is further configured to send the heartbeat message to the second device through the second memory area if it is determined that the second memory area has the idle resource.
In a third aspect, an electronic device is provided, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor adapted to perform the method steps of any of the above first aspects when executing a program stored in the memory.
In a fourth aspect, a computer-readable storage medium is provided, having stored therein a computer program which, when executed by a processor, performs the method steps of any of the above first aspects.
And B, executing the step A: if the second memory area is judged and known to have no free resources, a heartbeat message is sent to the second equipment through the memory space of the first memory area, and the first memory area comprises the message occupation space of a preset number of heartbeat messages; and B: comparing the current memory space of the second memory area with a preset back-up threshold, wherein the current memory space which is compared for the first time is the initial memory space of the second memory area; when the current memory space of the second memory area is not smaller than the preset back-up threshold, determining that the second memory area is in transient abnormity before the current moment; and B, when the current memory space of the second memory area is smaller than the preset back-up threshold value, returning to execute the step A. According to the method, the whole memory is divided into the second memory area and the first memory area which sends the heartbeat message when no idle resource exists in the second memory area, so that the equipment switching frequency caused by the fact that the whole memory cannot send the heartbeat message after being occupied by the service to be processed in the prior art is reduced, namely the switching frequency among equipment is reduced, the packet loss rate is reduced, and the accuracy of heartbeat detection is improved.
Drawings
Fig. 1 is a framework diagram of a distributed system to which the memory detection method according to the embodiment of the present invention is applied;
FIG. 2 is a schematic diagram of a heartbeat detection scheme;
fig. 3 is a schematic flowchart of a method for detecting a memory according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a detection apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without any creative effort belong to the protection scope of the present application.
The method for detecting a memory provided in the embodiment of the present invention is applied to the distributed system shown in fig. 1, where the distributed system includes a plurality of first devices and a second device (or "standby device") corresponding to each of the first devices. The first device and the second device may be servers or terminals, and in order to ensure the accuracy of detection, the servers may be application servers or cloud servers with strong computing power; a terminal may be a User Equipment (UE) with high computing power, a handheld device with wireless communication capabilities, a vehicle mounted device, a wearable device, a computing device or other processing device connected to a wireless modem, a Mobile Station (MS), etc.
The first device is used for processing the current service and caching the service to be processed.
First, the first device and the second device need to establish a communication connection, and after the communication connection is established, the first device may send service information to the second device, where the service information may include a memory space size of a current service.
The first device and the second device monitor the running state of the other device through heartbeat detection. Fig. 2 shows a schematic diagram of a heartbeat detection principle, and as shown in fig. 2, a first device starts a self-configured Timer (Timer), and sends a heartbeat message to a second device when a timing period of the Timer arrives. After receiving the heartbeat message from the first device, the second device updates a heartbeat count (counter) of the first device, and if the second device does not receive the heartbeat message of the first device within a first preset time period, the second device determines that the first device is abnormal, and executes corresponding fault processing, namely, switches to the second device to process the current service.
Correspondingly, the second device may also start a self-configured Timer (Timer), and send the heartbeat packet to the first device when a timing period of the Timer comes. After receiving the heartbeat message from the second device, the first device updates a heartbeat count (counter) of the second device, and if the first device does not receive the heartbeat message of the second device within a first preset time period, the first device determines that the second device is abnormal, and executes corresponding fault processing, such as generating alarm information and/or restarting the second device.
In the prior art, when there is no idle resource in the memory of the first device, the second device does not receive the heartbeat packet of the first device in the first preset time period, and the second device directly considers that the first device is abnormal, and performs the device switching operation, thereby causing packet loss in the switching process.
The system of the embodiment of the invention executes the step A: if the second memory area is judged and known to have no free resources, a heartbeat message is sent to the second equipment through the memory space of the first memory area, and the first memory area comprises the message occupation space of a preset number of heartbeat messages; and B: comparing the current memory space of the second memory area with a preset back-up threshold, wherein the current memory space which is compared for the first time is the initial memory space of the second memory area; when the current memory space of the second memory area is not smaller than the preset back-up threshold, determining that the second memory area is in transient abnormity before the current moment; and B, when the current memory space of the second memory area is smaller than the preset back-up threshold value, returning to execute the step A. The method reduces the equipment switching frequency caused by the fact that the heartbeat message cannot be sent after the whole memory is filled with the service to be processed in the prior art, namely reduces the switching times among the equipment, reduces the packet loss rate and improves the accuracy of heartbeat detection.
It should be noted that the second device in the system may also perform the above operations, and the embodiment of the present invention is not described herein again.
The preferred embodiments of the present application will be described below with reference to the accompanying drawings of the specification, it being understood that the preferred embodiments described herein are merely for illustrating and explaining the present invention and are not intended to limit the present invention, and that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
Fig. 3 is a flowchart illustrating a method for detecting a memory according to an embodiment of the present invention. As shown in fig. 3, in a first device including a first memory area and a second memory area, the method may include:
step 310, based on the memory occupation ratio of the current traffic, a first memory area and a second memory area are created.
Before executing the step, the first device establishes a communication connection, such as a TCP communication connection, with the second device, and sends service information to the second device, where the service information may include information such as a current traffic volume, a first device identifier, and an MAC address, and the current traffic volume includes a traffic volume of a currently running service and a traffic volume of a service to be processed.
The first device creates a first memory area and a second memory area based on the memory occupation ratio of the current traffic.
The second memory area is used for caching the current operation service and the service to be processed, and caching the heartbeat message to be sent when the idle resource exists. The first memory area is used for caching heartbeat messages to be sent when no idle resources exist in the second memory area, the first memory area comprises a preset number of message occupation spaces of the heartbeat messages, and the message occupation spaces are memory spaces occupied by the heartbeat messages.
In an optional implementation manner, a cache queue of heartbeat messages is created in the first memory area, the number of the heartbeat messages in the cache queue is determined by the memory space of the first memory area and the size of each heartbeat message, and the sending interval between adjacent heartbeat messages is a second preset time period, that is, the buffering time of the cache queue is a product of the second preset time period and the number of the heartbeat messages, it can be understood that the buffering time is a preset time period for prolonging an abnormal phenomenon, and the abnormal phenomenon is a condition that no idle resource exists in the second memory area.
For example, the memory space is 20M, the size of each heartbeat packet is 1M (the size of the heartbeat packet is only stated as an example), the number of the heartbeat packets in the buffer queue is 20, and if the transmission interval between adjacent heartbeat packets in the buffer queue is 6s, the buffer time available in the buffer queue is 2 min.
Optionally, the second memory area may include a memory space occupied by the service memory and a message memory space occupied by the heartbeat message, and if the memory space occupied by the service memory is 100M and the message memory space occupied by the heartbeat message is 30M, the second memory area is 130M in total.
Step 320, if it is determined that there is no idle resource in the second memory area, sending a heartbeat message to the second device through the first memory area.
And under the condition that the second memory area has idle resources, the first equipment sends a heartbeat message to the second equipment through the second memory area. Under the condition that no idle resource exists in the second memory area, the first device sends a heartbeat message to the second device through the first memory area and releases the message occupation space of the heartbeat message, and the first device receives the heartbeat message sent by the second device through the second memory area, so that the message occupation space of the received heartbeat message is not increased in the first memory area, that is to say, under the condition, the message occupation space of the first memory area is released along with the sending of each heartbeat message.
If the first device receives the heartbeat message sent by the second device in the first preset time period through the second memory area, the memory space of the second memory area increases the message occupation space of the heartbeat message, and the memory space of the first memory area does not increase the message occupation space of the heartbeat message.
If the first device does not receive the heartbeat message sent by the second device in the first preset time period through the second memory area, the memory space of the second memory area and the memory space of the first memory area do not increase the message occupation space of the heartbeat message.
In one example, in the case that there are free resources in the second memory area, the initial memory space of the first memory area is 20M, the current memory space is 20M, the initial memory space of the second memory area is 30M, and the current memory space is 28M. The first device sends 1M heartbeat messages to the second device through the first memory area, and the memory space of the first memory area becomes 19M. If a heartbeat message of 1M sent by the second device is received in the first preset time period, the memory space of the first memory area is kept at 19M, and the memory space of the second memory area is changed into 29M. If the heartbeat message of 1M sent by the second device is not received within the first preset time period, the memory space of the first memory area is kept 19M, and the memory space of the second memory area is still kept 28M.
Step 330, comparing the current memory space of the second memory area with a preset back-up threshold value, and determining whether the second memory area is in transient abnormality before the current time.
The first device may compare the current memory space of the second memory area with a preset back-up threshold in real time, where the preset back-up threshold is a minimum memory value for the second memory area to back-up the occupied space of the message released by the first memory area. The current memory space to be compared for the first time is the initial memory space of the second memory area, and the preset back-up threshold value can be determined according to the memory occupation proportion of the current running service, and can also be a fixed value set according to a service processed by the first device for a long time.
In an embodiment, when the first device detects that the current memory space of the second memory area is not less than the preset back-up threshold, it is determined that the second memory area is in a transient abnormality before the current time, where the current time is the time when the current memory space of the second memory area is not less than the preset back-up threshold.
Further, if it is determined that the current memory space of the first memory area is smaller than the initial memory space, that is, the first memory area releases the message occupation space, when the current memory space of the second memory area is not smaller than the preset back-up threshold, the message occupation space released in the first memory area may be back-up based on the current memory space of the second memory area, and the current memory space of the second memory area is updated, that is, the memory space of the second memory area after performing back-up is the new current memory space.
And if the second memory area after the back compensation is executed has idle resources, sending a heartbeat message to the second equipment through the new current memory space in the second memory area. If there is no free resource in the second memory area after performing the compensation, the process returns to step 320.
It can be understood that, if it is determined that the current memory space of the first memory area is equal to the initial memory space, that is, the message occupied space is not released by the first memory area, the back compensation of the message occupied space is not performed.
For example, the initial memory space of the second memory area is 30M, the predetermined complementary threshold of the second memory area is 25M, and the initial memory space of the first memory area is 20M.
After a time period T, the second memory area caches a large amount of services to be processed, at this time, the first device detects that the current memory space of the second memory area is 0M, that is, no free resources exist in the second memory area, then the first memory area is used to send heartbeat messages to the second device, after two heartbeat messages are released in the first memory area, for example, 2M message occupation space is released, at this time, the first device detects that the current memory space of the second memory area is 28M (that is, the current memory space of the second memory area is changed from 0M to 28M), since 28 is greater than 25, it is determined that the second memory area is in transient anomaly before the current time, and in the case that the current memory space of the second memory area is greater than 25M, the current 28M memory space of the second memory area is used to complement the 2M message occupation space released in the first memory area, and after the complementation, the new current memory space of the first memory area is 20M, the new current memory space of the second memory area is 26M, and then because the second memory area has idle resources, the heartbeat message is sent to the second device through the new current memory space of the second memory area.
In an embodiment, when the current memory space of the second memory area is smaller than the predetermined complementary threshold and there is no free resource, the step 320 is executed again.
And B, when the number of times of executing the step A is smaller than the preset number of the center jump messages in the first memory area, detecting that the current memory space of the second memory area is not smaller than a preset back-up threshold value, and determining that the second memory area is in transient abnormity before being compared with the preset back-up threshold value.
If the number of times of returning to execute step 320 is equal to the preset number of the heartbeat messages in the first memory area, it is determined that the second memory area is in permanent abnormality.
For example, the memory space of the first memory area includes a message occupation space of 20 heartbeat messages, that is, the first memory area may send out 20 heartbeat messages. When no free resource exists in the second memory area, after the first memory area continuously sends 10 heartbeat messages, the service volume cached in the second memory area is reduced, so that the second memory area has the free resource, at the moment, the current memory space of the second memory area is larger than the preset back-up threshold value, the memory space of the first memory area can be back-up, and at the moment, the second memory area is determined to be in transient abnormity before the moment when the current memory space of the second memory area is compared to be larger than the preset back-up threshold value.
However, when the second memory area does not have the free resources, and after the first memory area has continuously sent 20 heartbeat messages, the traffic cached in the second memory area is not changed, that is, the second memory area still does not have the free resources, at this time, the current memory space of the second memory area is smaller than the preset back-supplementing threshold value, the memory space of the first memory area cannot be back-supplemented, and at this time, it is determined that the second memory area is in a permanent abnormality.
Optionally, after determining that the second memory area is in the permanent exception, the first device may generate alarm information, where the alarm information is used to indicate that the second memory area of the first device is in the permanent exception, and the alarm information may be recorded in log information.
Optionally, after it is determined that the second memory area is in a permanent abnormality, because the first device cannot send the heartbeat message to the second device, after a first preset time period, the first device receives a switching instruction sent by the second device, where the switching instruction is used to instruct to switch to the second device to process the current service and the service to be processed.
Or after determining that the second memory area is in permanent exception, the first device may start a device switching operation, and switch to the second device to process the current service and the service to be processed.
The method executes step a: if the second memory area is judged and known to have no free resources, a heartbeat message is sent to the second equipment through the memory space of the first memory area, and the first memory area comprises the message occupation space of a preset number of heartbeat messages; and B: comparing the current memory space of the second memory area with a preset back-up threshold, wherein the current memory space which is compared for the first time is the initial memory space of the second memory area; when the current memory space of the second memory area is not smaller than the preset back-up threshold, determining that the second memory area is in transient abnormity before the current moment; and B, when the current memory space of the second memory area is smaller than the preset back-up threshold value, returning to execute the step A. According to the method, the whole memory is divided into the second memory area and the first memory area which sends the heartbeat message when no idle resource exists in the second memory area, so that the equipment switching frequency caused by the fact that the whole memory cannot send the heartbeat message after being occupied by the service to be processed in the prior art is reduced, namely the switching frequency among equipment is reduced, the packet loss rate is reduced, and the accuracy of heartbeat detection is improved.
Corresponding to the above method, an embodiment of the present invention further provides a detection apparatus, as shown in fig. 4, where the detection apparatus includes: a transmitting unit 410, a comparing unit 420 and a determining unit 430;
a sending unit 410, configured to send a heartbeat message to the second device through a memory space of the first memory area if it is determined that there is no idle resource in the second memory area, where the first memory area includes a message occupation space of a preset number of heartbeat messages;
a comparing unit 420, configured to compare a current memory space of the second memory area with a preset back-up threshold, where the current memory space to be compared for the first time is an initial memory space of the second memory area;
a determining unit 430, configured to determine that the second memory area is in a transient exception before the current time when the current memory space of the second memory area is not smaller than the preset back-up threshold;
when the current memory space of the second memory area is smaller than the preset back-up threshold, triggering the sending unit 420;
the second memory area is used for caching the current operation service and the service to be processed, and caching the heartbeat message to be sent when idle resources exist.
In an alternative implementation, the apparatus further comprises a release unit 440 and a back-up unit 450;
a releasing unit 440, configured to release a message occupied space of a heartbeat message in the first memory area after the sending unit 410 sends the heartbeat message to the second device through the first memory area.
A back-up unit 450, configured to back-up the occupied space of the released message in the first memory area based on the current memory space of the second memory area and update the current memory space of the second memory area when the current memory space of the second memory area is not smaller than the preset back-up threshold.
In an optional implementation, the determining unit 430 is further configured to, when the current memory space of the second memory area is smaller than the preset back-up threshold, after the step a is executed again, determine that the second memory area is in a permanent exception if the number of times of executing the step a again is equal to the preset number of the heartbeat messages in the first memory area.
In an alternative implementation, the apparatus further comprises a generating unit 460;
the generating unit 460 is configured to generate warning information after determining that the second memory area is in the permanent exception, where the warning information is used to indicate that the second memory area is in the permanent exception.
In an optional implementation, the apparatus further comprises a receiving unit 470;
a receiving unit 470, configured to receive a switching instruction sent by the second device after the second memory area is determined to be in a permanent exception, where the switching instruction is used to instruct to switch to the second device to process the current service corresponding to the current traffic.
In an optional implementation, the apparatus further comprises a switching unit 480;
the switching unit 480 is configured to switch to the second device to process the current service corresponding to the current service volume after determining that the second memory area is in a permanent exception.
In an optional implementation, the preset number of heartbeat messages in the memory space of the first memory region is determined by the memory space of the first memory region and the size of each heartbeat message, the sending interval between adjacent heartbeat messages is a second preset time period, and the second preset time period is smaller than the first preset time period.
In an alternative implementation, the predetermined backoff threshold is determined according to a memory occupation ratio of the currently running service.
In an optional implementation, the sending unit 410 is further configured to send the heartbeat message to the second device through the second memory area if it is determined that the second memory area has idle resources.
The functions of the functional units of the detection apparatus provided in the above embodiment of the present invention may be implemented by the above method steps, and therefore, detailed working processes and beneficial effects of the units in the detection apparatus provided in the embodiment of the present invention are not described herein again.
An embodiment of the present invention further provides an electronic device, as shown in fig. 5, including a processor 510, a communication interface 520, a memory 530 and a communication bus 540, where the processor 510, the communication interface 520, and the memory 530 complete mutual communication through the communication bus 540.
A memory 530 for storing a computer program;
the processor 510, when executing the program stored in the memory 530, implements the following steps:
and B, executing the step A: if the second memory area is judged and known to have no free resources, a heartbeat message is sent to the second equipment through the memory space of the first memory area, and the first memory area comprises the message occupation space of a preset number of heartbeat messages;
and B: comparing the current memory space of the second memory area with a preset back-up threshold, wherein the current memory space which is compared for the first time is the initial memory space of the second memory area;
when the current memory space of the second memory area is not smaller than the preset back-up threshold, determining that the second memory area is in transient abnormity before the current moment;
when the current memory space of the second memory area is smaller than the preset back-up threshold value, returning to execute the step A;
the second memory area is used for caching the current operation service and the service to be processed, and caching the heartbeat message to be sent when idle resources exist.
In an optional implementation, after sending a heartbeat message to the second device through the message occupied space of the first memory area, the message occupied space of the heartbeat message in the first memory area is released.
And when the current memory space of the second memory area is not smaller than the preset back-filling threshold value, back-filling the occupied space of the message released in the first memory area based on the current memory space of the second memory area, and updating the current memory space of the second memory area.
In an optional implementation, when the current memory space of the second memory area is smaller than the preset back-up threshold, after the step a is executed again, if the number of times of executing the step a again is equal to the preset number of the heartbeat messages in the first memory area, it is determined that the second memory area is in a permanent exception.
In an optional implementation, after determining that the second memory area is in the permanent exception, generating alarm information, where the alarm information is used to indicate that the second memory area is in the permanent exception.
In an optional implementation, after determining that the second memory area is in a permanent exception, receiving a switching instruction sent by the second device after a first preset time period, where the switching instruction is used to instruct to switch to the second device to process a current service corresponding to a current traffic volume.
In an optional implementation, after determining that the second memory area is in a permanent exception, switching to the second device to process the current service corresponding to the current traffic.
In an optional implementation, the preset number of heartbeat messages in the memory space of the first memory region is determined by the memory space of the first memory region and the size of each heartbeat message, the sending interval between adjacent heartbeat messages is a second preset time period, and the second preset time period is smaller than the first preset time period.
In an alternative implementation, the predetermined backoff threshold is determined according to a memory occupation ratio of the currently running service.
In an optional implementation, if it is determined that the second memory area has idle resources, the heartbeat message is sent to the second device through the second memory area.
The aforementioned communication bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
Since the implementation and the beneficial effects of the problem solving of each device of the electronic device in the above embodiment can be realized by referring to each step in the embodiment shown in fig. 3, detailed working processes and beneficial effects of the electronic device provided by the embodiment of the present invention are not described herein again.
In yet another embodiment of the present invention, a computer-readable storage medium is further provided, which has instructions stored therein, and when the instructions are executed on a computer, the instructions cause the computer to execute the detection method described in any of the above embodiments.
In a further embodiment provided by the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the detection method described in any of the above embodiments.
As will be appreciated by one of skill in the art, the embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all changes and modifications that fall within the true scope of the embodiments of the present application.
It is apparent that those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if such modifications and variations of the embodiments of the present application fall within the scope of the claims of the embodiments of the present application and their equivalents, the embodiments of the present application are also intended to include such modifications and variations.

Claims (20)

1. A memory detection method is applied to a first device, wherein the first device comprises a first memory area and a second memory area, and the method comprises the following steps:
step A: if judging that the second memory area does not have idle resources, sending a heartbeat message to the second equipment through the first memory area, wherein the first memory area comprises a message occupation space with a preset number of heartbeat messages; if the second memory area is judged and known to have the idle resources, sending a heartbeat message to the second equipment through the second memory area;
and B: comparing the current memory space of the second memory area with a preset back-up threshold, wherein the current memory space which is compared for the first time is the initial memory space of the second memory area;
when the current memory space of the second memory area is not smaller than the preset back-up threshold, determining that the second memory area is in transient abnormity before the current moment;
when the current memory space of the second memory area is smaller than the preset back-up threshold, returning to execute the step A;
the second memory area is used for caching the current operation service and the service to be processed, and caching the heartbeat message to be sent when idle resources exist; the preset back-filling threshold value is the minimum memory value of the second memory area for back-filling the message occupation space released by the first memory area.
2. The method of claim 1, wherein after sending a heartbeat message to the second device via the first memory region, the method further comprises:
releasing the message occupation space of the heartbeat message in the first memory area;
when the current memory space of the second memory area is not less than the preset back-up threshold, the method further includes:
and on the basis of the current memory space of the second memory area, compensating the occupied space of the message released in the first memory area, and updating the current memory space of the second memory area.
3. The method according to claim 1, wherein when the current memory space of the second memory area is smaller than the preset back-up threshold, the method further comprises, after the step a is executed again:
and if the number of times of executing the step A is equal to the preset number of the center jump messages in the first memory area, determining that the second memory area is in permanent abnormity.
4. The method of claim 3, wherein after determining that the second memory region is in a permanent exception, the method further comprises:
and generating alarm information, wherein the alarm information is used for indicating that the second memory area is in permanent abnormity.
5. The method of claim 3, wherein after determining that the second memory region is in a permanent exception, the method further comprises:
and receiving a switching instruction sent by the second equipment after a first preset time period, wherein the switching instruction is used for instructing to switch to the second equipment to process the current service and the service to be processed.
6. The method of claim 3, wherein after determining that the second memory region is in a permanent exception, the method further comprises:
and switching to the second equipment to process the current service and the service to be processed.
7. The method according to claim 5, wherein the predetermined number of heartbeat messages in the memory space of the first memory region is determined by the memory space of the first memory region and the size of each heartbeat message, and the transmission interval between adjacent heartbeat messages is a second predetermined time period, and the second predetermined time period is smaller than the first predetermined time period.
8. The method according to any of claims 1-7, wherein the predetermined backoff threshold is determined according to a memory usage ratio of the currently running service.
9. The method of any one of claims 1-7, wherein the method further comprises:
and if the second memory area is judged to have the idle resources, sending a heartbeat message to the second equipment through the second memory area.
10. A memory detection device is applied to a first device, wherein the first device comprises a first memory area and a second memory area, and the memory detection device comprises:
the sending unit is used for sending a heartbeat message to the second equipment through the first memory area if judging that the second memory area does not have the idle resources, wherein the first memory area comprises a message occupation space with a preset number of heartbeat messages; if the second memory area is judged and known to have the idle resources, sending a heartbeat message to the second equipment through the second memory area;
a comparing unit, configured to compare a current memory space of the second memory area with a preset back-up threshold, where the current memory space to be compared for the first time is an initial memory space of the second memory area;
a determining unit, configured to determine that the second memory area is in a transient exception before a current time when a current memory space of the second memory area is not smaller than the preset back-up threshold;
when the current memory space of the second memory area is smaller than the preset back-up threshold, triggering the sending unit;
the second memory area is used for caching the current operation service and the service to be processed, and caching the heartbeat message to be sent when idle resources exist; the preset back-filling threshold value is the minimum memory value of the second memory area for back-filling the message occupation space released by the first memory area.
11. The apparatus of claim 10, further comprising a release unit and a anaplerotic unit;
the release unit is configured to release a message occupation space of the heartbeat message in the first memory area after the sending unit sends the heartbeat message to the second device through the first memory area;
and the back-up unit is configured to back up the occupied space of the message released in the first memory area based on the current memory space of the second memory area and update the current memory space of the second memory area when the current memory space of the second memory area is not smaller than the preset back-up threshold.
12. The apparatus according to claim 10, wherein the determining unit is further configured to, when the current memory space of the second memory area is smaller than the preset complementary threshold, after the step a is executed again, determine that the second memory area is in the permanent exception if the number of times of executing the step a again is equal to the preset number of the heartbeat messages in the first memory area.
13. The apparatus of claim 12, wherein the apparatus further comprises a generating unit;
the generating unit is configured to generate warning information after determining that the second memory area is in a permanent exception, where the warning information is used to indicate that the second memory area is in a permanent exception.
14. The apparatus of claim 12, wherein the apparatus further comprises a receiving unit;
the receiving unit is configured to receive a switching instruction sent by the second device after a first preset time period after determining that the second memory area is in a permanent exception, where the switching instruction is used to instruct to switch to the second device to process the current service and the service to be processed.
15. The apparatus of claim 12, wherein the apparatus further comprises a switching unit;
and the switching unit is used for switching to the second device to process the current service and the service to be processed after the second memory area is determined to be in permanent exception.
16. The apparatus according to claim 14, wherein the predetermined number of heartbeat messages in the memory space of the first memory area is determined by the memory space of the first memory area and a size of each heartbeat message, and a transmission interval between adjacent heartbeat messages is a second predetermined time period, and the second predetermined time period is smaller than the first predetermined time period.
17. The apparatus according to any of claims 10-16, wherein the predetermined backoff threshold is determined according to a memory usage ratio of the currently running service.
18. The apparatus according to any one of claims 10 to 16, wherein the sending unit is further configured to send a heartbeat packet to the second device through the second memory area if it is determined that there is an idle resource in the second memory area.
19. An electronic device, characterized in that the electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1-9 when executing a program stored on a memory.
20. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-9.
CN201811108892.1A 2018-09-21 2018-09-21 Memory detection method and device Active CN109379246B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811108892.1A CN109379246B (en) 2018-09-21 2018-09-21 Memory detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811108892.1A CN109379246B (en) 2018-09-21 2018-09-21 Memory detection method and device

Publications (2)

Publication Number Publication Date
CN109379246A CN109379246A (en) 2019-02-22
CN109379246B true CN109379246B (en) 2021-03-05

Family

ID=65401759

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811108892.1A Active CN109379246B (en) 2018-09-21 2018-09-21 Memory detection method and device

Country Status (1)

Country Link
CN (1) CN109379246B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111162965A (en) * 2019-12-17 2020-05-15 杭州迪普科技股份有限公司 Method and device for monitoring Buffer
CN111131458A (en) * 2019-12-25 2020-05-08 深圳市网心科技有限公司 Heartbeat keep-alive method, electronic device, system and medium
CN114253457B (en) * 2020-09-21 2024-06-25 华为技术有限公司 Memory control method and device
CN114791832B (en) * 2022-04-24 2024-02-27 深圳软牛科技集团股份有限公司 IOS system repairing method and device when equipment space is insufficient and related components

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102984029A (en) * 2012-11-30 2013-03-20 福建星网锐捷网络有限公司 Heartbeat detection device and method applied to distributed system and network equipment
CN103186469A (en) * 2011-12-27 2013-07-03 上海博泰悦臻电子设备制造有限公司 Memory allocation method and device, and memory recovery method
CN104991850A (en) * 2015-06-27 2015-10-21 广州华多网络科技有限公司 Heartbeat package control method and apparatus for application program

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102968380B (en) * 2012-11-02 2016-12-07 深圳市同洲电子股份有限公司 The management method of memory partitioning and device in memory file system
CN103365784B (en) * 2013-06-27 2016-03-30 华为技术有限公司 The method of Memory recycle and distribution and device
CN108111630B (en) * 2018-01-22 2021-11-02 北京奇艺世纪科技有限公司 Zookeeper cluster system and connection method and system thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103186469A (en) * 2011-12-27 2013-07-03 上海博泰悦臻电子设备制造有限公司 Memory allocation method and device, and memory recovery method
CN102984029A (en) * 2012-11-30 2013-03-20 福建星网锐捷网络有限公司 Heartbeat detection device and method applied to distributed system and network equipment
CN104991850A (en) * 2015-06-27 2015-10-21 广州华多网络科技有限公司 Heartbeat package control method and apparatus for application program

Also Published As

Publication number Publication date
CN109379246A (en) 2019-02-22

Similar Documents

Publication Publication Date Title
CN109379246B (en) Memory detection method and device
CN107040674B (en) Charging method, device and system
WO2016169103A1 (en) Network switching method and device, and mobile terminal
US20230283492A1 (en) Traffic charging method, network device and storage medium
CN110417761B (en) Communication method and device based on dual-computer redundancy
US10740161B2 (en) Broadcast message sending method and apparatus, and mobile terminal
CN108141901B (en) Method and terminal for controlling service connection
CN107409427B (en) Data transmission method and device of data service
WO2014101508A1 (en) Transmission processing method and receiving method for warning message, and related devices
CN112867149B (en) RAN notification area updating method and device
US10972442B1 (en) Distributed predictive packet quantity threshold reporting
CN108259082B (en) Protection switching method and control service board
EP4304150A1 (en) Frame preemption method and apparatus, and device and storage medium
CN111953561B (en) Method and device for inhibiting VRRP oscillation
CN113965523A (en) Loop-based PFC deadlock processing method and device
EP3299960A1 (en) Virtual machine deployment method, device and network function virtualization orchestrator (nfvo)
CN108616461B (en) Policy switching method and device
CA3066827C (en) Paging failure processing method, access network device, and core network device
CN104540161A (en) Node state detection method and device
CN113676894A (en) Service processing method and device
EP2887727A1 (en) Method and device for congestion control
CN110740483B (en) Information processing method and device in LTE switching process
CN112188545B (en) Access control method, device, storage medium and base station
CN115002020B (en) OSPF-based data processing method and device
CN111182642B (en) Method, device and equipment for scheduling non-periodic discontinuous service

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20190222

Assignee: BEIJING STAR-NET RUIJIE NETWORKS Co.,Ltd.

Assignor: RUIJIE NETWORKS Co.,Ltd.

Contract record no.: X2022350000023

Denomination of invention: A memory detection method and device

Granted publication date: 20210305

License type: Common License

Record date: 20220808