CN109104326B - Timeout processing method and device and electronic equipment - Google Patents

Timeout processing method and device and electronic equipment Download PDF

Info

Publication number
CN109104326B
CN109104326B CN201810569910.XA CN201810569910A CN109104326B CN 109104326 B CN109104326 B CN 109104326B CN 201810569910 A CN201810569910 A CN 201810569910A CN 109104326 B CN109104326 B CN 109104326B
Authority
CN
China
Prior art keywords
time slice
machine
server
slice element
timeout
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
CN201810569910.XA
Other languages
Chinese (zh)
Other versions
CN109104326A (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.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Advanced New 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 Advanced New Technologies Co Ltd filed Critical Advanced New Technologies Co Ltd
Priority to CN201810569910.XA priority Critical patent/CN109104326B/en
Publication of CN109104326A publication Critical patent/CN109104326A/en
Application granted granted Critical
Publication of CN109104326B publication Critical patent/CN109104326B/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
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0817Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking functioning
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0852Delays

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Debugging And Monitoring (AREA)

Abstract

An embodiment of the present specification provides a timeout processing method and apparatus, and an electronic device, where the method includes: when the timer reaches unit time each time, controlling the pointer of the timer to move a time slice element in the circular queue according to a set sequence; the circular queue is a circular queue formed by a plurality of time slice elements, each time slice element records a machine IP set, and the mapping relation between the time slice elements and the recorded machine IP is recorded in a mapping table; according to a preset timeout type, performing corresponding timeout processing on machine IPs in a machine IP set recorded by a target time slice element pointed by the timer pointer; after the machine IP overtime processing is finished, deleting the mapping relation between the target time slice element and the machine IP in the mapping table; and after the timeout processing of all the machine IPs is finished, emptying the machine IPs recorded by the target time slice elements.

Description

Timeout processing method and device and electronic equipment
Technical Field
The embodiment of the specification relates to the technical field of internet, in particular to a timeout processing method and device and electronic equipment.
Background
Many services have a requirement for timeout processing, for example, a heartbeat detection task in a distributed system center, a registration center needs to perform timeout detection on a server, and when a heartbeat message sent by the server is not received for a preset time, it indicates that the server fails, and the server needs to be offline. For example, in an instant messaging system, timeout processing needs to be performed on the online state of a client.
In the related art, the timeout process may generally adopt a multi-timer approach. A timer is started for each task, and when the timer reaches the timeout duration, the timeout processing for the task can be triggered.
Disclosure of Invention
An embodiment of the specification provides a timeout processing method and device and an electronic device:
according to a first aspect of embodiments herein, there is provided a timeout processing method, the method including:
when the timer reaches unit time each time, controlling the pointer of the timer to move a time slice element in the circular queue according to a set sequence; the circular queue is a circular queue formed by a plurality of time slice elements, each time slice element records a machine IP set, and the mapping relation between the time slice elements and the recorded machine IP is recorded in a mapping table;
according to a preset timeout type, performing corresponding timeout processing on machine IPs in a machine IP set recorded by a target time slice element pointed by the timer pointer;
after the machine IP overtime processing is finished, deleting the mapping relation between the target time slice element and the machine IP in the mapping table;
and after the timeout processing of all the machine IPs is finished, emptying the machine IPs recorded by the target time slice elements.
According to a second aspect of embodiments herein, there is provided a timeout processing apparatus, the apparatus including:
the control unit is used for controlling the pointer of the timer to move a time slice element in the circular queue according to a set sequence when the timer counts time to reach unit time each time; the circular queue is a circular queue formed by a plurality of time slice elements, each time slice element records a machine IP set, and the mapping relation between the time slice elements and the recorded machine IP is recorded in a mapping table;
the processing unit is used for carrying out corresponding overtime processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer according to a preset overtime type;
a deleting unit, configured to delete the mapping relationship between the target time slice element and the machine IP in the mapping table after the machine IP timeout processing is completed;
and the clearing unit is used for clearing the machine IP recorded by the target time slice element after the timeout processing of all the machine IPs is completed.
According to a third aspect of embodiments herein, there is provided an electronic apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to any of the timeout processing methods described above.
The embodiment of the present specification provides an timeout processing scheme, where timeout processing is performed based on a circular queue, only one timer is needed, and when the timer reaches a unit time each time, one timeout processing may be triggered, and compared with an existing multi-timer, the number of timers may be reduced from N to 1, so that resource consumption of the timers is reduced.
Drawings
FIG. 1 is a schematic diagram of a conventional distributed system provided herein;
FIG. 2 is a schematic diagram of a distributed system provided by an embodiment of the present description;
FIG. 3 is a diagram illustrating a circular queue, a timer pointer, and a mapping table according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a circular queue provided by an embodiment of the present description;
5a-5c are schematic diagrams of machine IP additions and updates in a circular queue provided by an embodiment of the present description;
FIG. 6 is a flowchart of a timeout processing method provided by an embodiment of the present specification;
FIG. 7 is a diagram illustrating timeout processing based on a circular queue according to an embodiment of the present disclosure;
fig. 8 is a hardware configuration diagram of a timeout processing apparatus provided in an embodiment of the present specification;
fig. 9 is a block diagram of a timeout processing apparatus according to an embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present specification. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the specification, as detailed in the appended claims.
The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of the present specification. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
In a distributed system as shown in fig. 1, it will typically include a server 11, a client 12, and a registry 13. The server 11 may refer to a service cluster constructed by a plurality of servers; the client 12 may typically be a cluster of clients.
In one aspect, a registration request may be sent to registry 13 during server startup to notify registry 13 that the server is online and available to provide services. Generally, after receiving a registration request sent by a server, the registry 13 may add the machine IP of the server to the machine IP list. The registry 13 may issue the latest machine IP list to the client 12, so that the client 12 may route the machine IP recorded in the latest machine IP list to the corresponding server, and further send a service request to the routed server to obtain the corresponding service.
On the other hand, the registry 13 may be based on a heartbeat detection mechanism to ensure that the server can be deleted from the server 11 in case of a failure of the server, so as to ensure that the servers 11 are all normal servers. Specifically, the registry 13 may periodically and fully send a heartbeat request to a server corresponding to the machine IP recorded in the machine IP list; if the server is normal, a response can be returned after the heartbeat request is received; if the server is abnormal, for example, the network is abnormal, the server fails, and the heartbeat request cannot be received, so that the response cannot be returned. For the registry 13, if no server return response is received within a preset time period after the heartbeat request is sent, it indicates that the server is faulty, and the machine IP of the server needs to be deleted from the machine IP list, and this process may be referred to as a timeout process. Of course, this is only one case of the timeout processing, and in practical applications, different types of timeout processing may exist in different services in different fields and different scenes, and this is not limited in this specification. For example, in an instant messaging scenario, if the client does not operate for a long time, timeout processing may be performed on the client, which may specifically include marking an online status of the client as offline.
As described above, in the related art, the timeout process may generally adopt a multi-timer approach. A timer is started for each task, and when the timer reaches the timeout duration, the timeout processing for the task can be triggered.
In addition, the timeout process may adopt a polling scanning mode. In this way, there may be one task list to record all tasks to be executed; and the timing task list is scanned in a timed polling mode, namely whether the tasks on the task list are completely scanned or not is judged, if yes, the tasks are deleted, and if not, overtime processing is carried out. The method is relatively inefficient, and when the number of tasks is large and the requirements of the task time are different, the execution efficiency of the overtime processing cannot be guaranteed.
In order to solve the above problem, the present description as shown in fig. 2 proposes a system configuration diagram to which a timeout processing scheme is applied. Similar to the aforementioned fig. 1, may include a server 21, a client 22, and a registry 23. The server 21 and the client 22 are similar to the above.
The registry 23 may include a timer 231, a timer pointer 232, a circular queue 233, and a mapping table 234.
Such as the circular queue, the timer pointer, and the mapping table shown in fig. 3. The circular queue may be a circular queue composed of several time slice elements, each time slice element is recorded with a machine IP set (only the machine IP set recorded by time slice element 0 is shown in the figure), and the mapping relationship of the time slice element and the recorded machine IP is recorded in a mapping table. Typically, each server corresponds to a unique machine IP, and the routing to the corresponding server is performed according to the machine IP.
The timer can be used for timing and is preset with unit time. The timer and timer pointer are typically used in conjunction. When the timer reaches the unit time, the timer pointer can be controlled to move a time slice element in the circular queue according to the set sequence and count again.
The timer pointer is used to identify a time slice element corresponding to the current time, that is, a target time slice element pointed to by the timer pointer in the circular queue.
How the circular queue is built is described first below:
in one embodiment, the circular queue is established by:
acquiring the timeout duration of a preset timeout type;
and calculating the number N of the overtime duration corresponding to the unit time, and creating a circular queue of N elements.
For example, assuming that the unit time is 10 seconds, and the obtained preset timeout type timeout duration is 70 seconds, it may be calculated that the number N of the timeout duration corresponding to the unit time is 70/10-7; thus, a circular queue having 7 elements as shown in FIG. 4 can be created.
In the following, by taking a heartbeat detection scenario as an example, how the registration center adds and updates the machine IP in the circular queue is described, which may specifically include the following steps:
a1: receiving a registration request sent by a server; wherein, the registration request carries a server IP;
a2: acquiring a target time slice element pointed by the timer pointer in the circular queue at the current moment;
a3: adding the server IP in the server IP set recorded by the target time slice element;
a4: and adding the mapping relation between the target time slice element and the server IP in the mapping table.
Taking the newly created circular queue shown in fig. 4 as an example, the set of machine IPs recorded by each time slice element in the circular queue is empty, and the mapping table is also empty. Supposing that the registration requests of the machine A and the machine B are received in the first unit time of the newly-built circular queue; then, as shown in FIG. 5a, the timer pointer at the current time should point to time slice element 0 (i.e., the time slice element with index "0"); further, the machine IP A and the machine IP B can be added to the machine set recorded by the time slice element 0; and adding the mapping relation between the time slice element 0 and the IP of the A machine and the mapping relation between the time slice element 0 and the IP of the B machine in the mapping table.
Through the embodiment, the machine IP can be added in the circular queue.
In one embodiment, in actual practice, the currently received machine IP may have been previously registered; for example, after a machine is on-line and registration is completed, a fault is off-line, and since the registration center cannot know the off-line condition in real time, a mapping relationship added during registration at that time is still recorded, and when the machine is on-line again, multiple registrations occur, and for this situation, the present specification provides the following scheme:
before the step a3, the method may further include:
acquiring a time slice element corresponding to the server IP from the mapping table; setting a target time slice element pointed by the timer pointer in a circular queue at the current moment as a first time slice element, and acquiring a time slice element corresponding to the server IP in a mapping table as a second time slice element;
the step a3 specifically includes:
when the second time slice element is empty, adding the server IP in a server IP set recorded by the first time slice element;
the step a4 specifically includes:
and when the second time slice element is empty, adding the mapping relation between the first time slice element and the server IP in the mapping table.
On the basis of the aforementioned fig. 5a, it is assumed that registration requests of the C machine and the D machine are received within the second unit time; as shown in fig. 5b, the timer pointer should now point to time slice element 1; querying a second timeslice element corresponding to the C machine IP in the mapping table (at this time, the mapping table is the mapping table shown in fig. 5 a), and as the query result is null, as shown in fig. 5b, adding the C machine IP to the machine set recorded by the timeslice element 1; and adding the mapping relation between the time slice element 1 and the C machine IP in the mapping table. Similarly, a second time slice element corresponding to the D machine IP in the mapping table is queried, and since the query result is null, as shown in fig. 5b, the D machine IP may be added to the machine set recorded in the time slice element 1; and adding the mapping relation between the time slice element 1 and the D machine IP in the mapping table.
In an embodiment, when the second time slice element is not empty, deleting the server IP from the set of server IPs recorded by the second time slice element;
and deleting the mapping relation between the second time slice element and the server IP from the mapping table.
On the basis of the aforementioned fig. 5b, it is assumed that the registration request of the a machine is received within the third unit time; as shown in fig. 5c, the timer pointer now points to time slice element 2; querying a second time slice element corresponding to the machine IP of a in the mapping table (at this time, the mapping table is the mapping table shown in fig. 5 b), because the time slice element 0 can be queried; it indicates that the a machine has been previously registered and therefore the mapping table needs to be updated. Specifically, as shown in FIG. 5c, the A machine IP is deleted from the set of machine IPs recorded for time slice element 0; and deleting the mapping relation between the time slice element 0 and the A machine IP from the mapping table. In addition, as described above, it is also necessary to add a machine IP to the set of machine IPs recorded in the time slice element 2, and add the mapping relationship between the time slice element 2 and the a machine IP to the mapping table.
Through the embodiment, the machine IP can be updated in the circular queue.
An embodiment of a timeout processing method according to the present disclosure, which may be applied in a registry, may be described below with reference to an example shown in fig. 6, and the method may include the following steps:
step 210: when the timer reaches unit time each time, controlling the pointer of the timer to move a time slice element in the circular queue according to a set sequence; the circular queue is a circular queue formed by a plurality of time slice elements, each time slice element records a machine IP set, and the mapping relation between the time slice elements and the recorded machine IP is recorded in a mapping table.
In one embodiment, the circular queue is established by:
acquiring the timeout duration of a preset timeout type;
and calculating the number N of the overtime duration corresponding to the unit time, and creating a circular queue of N elements.
Step 220: and performing corresponding timeout processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer according to a preset timeout type.
In an embodiment, the preset timeout type is timeout processing of an online state of a client in an instant messaging scene, and the machine IP is a client IP;
the performing, according to a preset timeout type, corresponding timeout processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer specifically includes:
and according to the online state timeout processing, marking the online state of the client IP in the client IP set recorded by the target time slice element pointed by the timer pointer as offline.
In an instant messaging scenario, the online status of a client often needs to be monitored, each operation of the client can be regarded as a registration request, and if the client does not operate for a long time, the online status of the client can be marked as offline. In this specification, the timeout duration may represent a duration in which the client does not operate, that is, when the client does not operate within the timeout duration, the online status of the client needs to be marked as offline. If the last operation of the client is recorded on a time slice element X of the circular queue, when the timer pointer makes a round trip on the circular queue (reaches the timeout duration) and points to the time slice element X again, if the client IP is still recorded on the time slice element X, it indicates that the client does not operate within the timeout duration, and the client needs to be subjected to timeout processing, so that the online state of the client can be marked as offline.
In an embodiment, the preset timeout type is a heartbeat detection timeout process of a server, and the machine IP is a server IP;
the performing, according to a preset timeout type, corresponding timeout processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer specifically includes:
according to the heartbeat detection timeout processing, the server IP heartbeat detection result in the server IP set recorded by the target time slice element pointed by the timer pointer is marked as abnormal;
and sending the abnormal server IP to the client so that the client deletes the abnormal server IP from the cached server IP list.
In a heartbeat detection scene of a server, a registration center generally needs to send a heartbeat request to the server in order to determine whether the server is normal, and if the server does not return a response for a long time, a heartbeat detection result of the server can be marked as abnormal; if the server returns a response, it may be considered a registration request, and the machine registration process in the previous embodiment is performed, as in the a machine in fig. 5c, updating from time slice element 0 to time slice element 2. In this specification, the timeout duration may refer to a duration in which the server does not return a response, that is, when the server does not return a response within the timeout duration, the heartbeat detection result of the server needs to be marked as abnormal. If the server is recorded on the time slice element X of the circular queue during registration, and when the timer pointer makes a round trip on the circular queue (reaches the timeout duration) and points to the time slice element X again, if the server IP is still recorded on the time slice element X, it indicates that the server does not respond to the heartbeat request within the timeout duration, the client needs to be subjected to timeout processing, and the heartbeat detection result of the server can be marked as abnormal.
Step 230: and after the machine IP overtime processing is finished, deleting the mapping relation between the target time slice element and the machine IP in the mapping table.
Step 240: and after the timeout processing of all the machine IPs is finished, emptying the machine IPs recorded by the target time slice elements.
The timeout process is described below with reference to the circular queue shown in FIG. 7, assuming that when the timer pointer points to time slice element 0, time slice element 0 does not record the machine IP; if a registration request sent by the machine A exists in unit time, the IP of the machine A is newly recorded in the time slice element 0;
when the timer counts time to reach unit time, the timer pointer points to a time slice element 1 from a time slice element 0, and if the time slice element 1 does not record the machine IP and a registration request sent by a B machine exists in the unit time, the time slice element 1 newly records the machine IP of the B machine;
when the timer counts time to reach unit time, the timer pointer points to a time slice element 2 from a time slice element 1, and if the time slice element 2 does not record the machine IP and a registration request sent by a C machine exists in the unit time, the time slice element 2 newly records the C machine IP;
no registration request sent by the machine exists in other time; the time slice elements pointed to by the timer pointers are constantly changing, from 3 to 4, from 4 to 5, …, from N-2 to N-1;
when the timer reaches the unit time, the timer pointer points to the time slice element 0 from the time slice element N-1; since the time slice element 0 records the a machine IP, the a machine needs to be subjected to timeout processing, and after the timeout processing is completed, the a machine IP is deleted from the machine set recorded by the time slice element 0, and the mapping relationship between the time slice element 0 and the a machine IP is deleted from the mapping table.
In summary, the timeout processing scheme provided in this embodiment of the present disclosure performs timeout processing based on a circular queue, and only needs one timer, and when the timer reaches a unit time each time, the timeout processing may be triggered, so that compared with the existing multiple timers, the number of the timers may be reduced from N to 1, thereby reducing resource consumption of the timers. On the other hand, during timeout processing, only the corresponding timeout processing needs to be performed on the machine IPs in the set of machine IPs recorded by the current time slice element, and compared with the existing polling scanning method that all the machine IPs need to be scanned in full, the processing performance is improved from the efficiency of O (n) times of full scanning to the efficiency of O (1) times, thereby improving the processing effect of timeout processing.
Corresponding to the foregoing embodiments of the timeout processing method, the present specification also provides embodiments of a timeout processing apparatus. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. The software implementation is taken as an example, and as a logical device, the device is formed by reading corresponding computer business program instructions in the nonvolatile memory into the memory for operation through the processor of the device in which the device is located. From a hardware aspect, as shown in fig. 8, the hardware structure diagram of the device where the timeout processing apparatus is located in this specification is shown, except for the processor, the network interface, the memory, and the nonvolatile memory shown in fig. 8, the device where the apparatus is located in the embodiment may generally process an actual function according to the timeout, and may further include other hardware, which is not described again.
Referring to fig. 9, a block diagram of a timeout processing apparatus according to an embodiment of the present disclosure is provided, where the timeout processing apparatus corresponds to the embodiment shown in fig. 6, and the timeout processing apparatus includes:
the control unit 310 is used for controlling the pointer of the timer to move one time slice element in the circular queue according to the set sequence when the timer counts time to reach unit time each time; the circular queue is a circular queue formed by a plurality of time slice elements, each time slice element records a machine IP set, and the mapping relation between the time slice elements and the recorded machine IP is recorded in a mapping table;
the processing unit 320 is configured to perform corresponding timeout processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer according to a preset timeout type;
a deleting unit 330, configured to delete the mapping relationship between the target time slice element and the machine IP in the mapping table after the machine IP timeout processing is completed;
and the clearing unit 340 is used for clearing the machine IP recorded by the target time slice element after the timeout processing of all the machine IPs is completed.
In an alternative embodiment, the circular queue is built by the following subunits:
the acquisition subunit acquires the timeout time of a preset timeout type;
and the calculating subunit calculates the number N of the overtime time corresponding to the unit time and creates a circular queue of N elements.
In an optional embodiment, the preset timeout type is timeout processing of an online state of a client in an instant messaging scene, and the machine IP is a client IP;
the processing unit 320 specifically includes:
and according to the online state timeout processing, marking the online state of the client IP in the client IP set recorded by the target time slice element pointed by the timer pointer as offline.
In an optional embodiment, the preset timeout type is a heartbeat detection timeout process of a server, and the machine IP is a server IP;
the processing unit 320 specifically includes:
the marking subunit marks the server IP heartbeat detection result in the server IP set recorded by the target time slice element pointed by the timer pointer as abnormal according to the heartbeat detection timeout processing;
and the deleting subunit is used for sending the abnormal server IP to the client so that the client deletes the abnormal server IP from the cached server IP list.
In an optional embodiment, the apparatus further comprises:
a receiving unit which receives a registration request sent by a server; wherein, the registration request carries a server IP;
the acquisition unit is used for acquiring a target time slice element pointed by the timer pointer at the current moment in the circular queue;
a first adding unit, which adds the server IP in the server IP set recorded by the target time slice element;
and the second adding unit is used for adding the mapping relation between the target time slice element and the server IP in the mapping table.
In an optional embodiment, the apparatus further comprises:
the obtaining subunit obtains a time slice element corresponding to the server IP from the mapping table; setting a target time slice element pointed by the timer pointer in a circular queue at the current moment as a first time slice element, and acquiring a time slice element corresponding to the server IP in a mapping table as a second time slice element;
the first adding unit specifically includes:
when the second time slice element is empty, adding the server IP in a server IP set recorded by the first time slice element;
the second adding unit specifically comprises:
and when the second time slice element is empty, adding the mapping relation between the first time slice element and the server IP in the mapping table.
In an optional embodiment, the apparatus further comprises:
a first deletion subunit configured to, when the second time slice element is not empty, delete the server IP from the set of server IPs recorded by the second time slice element;
and the second deleting subunit deletes the mapping relation between the second time slice element and the server IP in the mapping table.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in the specification. One of ordinary skill in the art can understand and implement it without inventive effort.
Fig. 9 above describes the internal functional modules and the structural schematic of the timeout processing apparatus, and the substantial execution subject of the timeout processing apparatus may be an electronic device, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
when the timer reaches unit time each time, controlling the pointer of the timer to move a time slice element in the circular queue according to a set sequence; the circular queue is a circular queue formed by a plurality of time slice elements, each time slice element records a machine IP set, and the mapping relation between the time slice elements and the recorded machine IP is recorded in a mapping table;
according to a preset timeout type, performing corresponding timeout processing on machine IPs in a machine IP set recorded by a target time slice element pointed by the timer pointer;
after the machine IP overtime processing is finished, deleting the mapping relation between the target time slice element and the machine IP in the mapping table;
and after the timeout processing of all the machine IPs is finished, emptying the machine IPs recorded by the target time slice elements.
In an alternative embodiment, the circular queue is established by:
acquiring the timeout time of a preset timeout type;
and calculating the number N of the overtime time corresponding to the unit time, and creating a circular queue of N elements.
In an optional embodiment, the preset timeout type is timeout processing of an online state of a client in an instant messaging scene, and the machine IP is a client IP;
the performing, according to a preset timeout type, corresponding timeout processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer specifically includes:
and according to the online state timeout processing, marking the online state of the client IP in the client IP set recorded by the target time slice element pointed by the timer pointer as offline.
In an optional embodiment, the preset timeout type is a heartbeat detection timeout process of a server, and the machine IP is a server IP;
the performing, according to a preset timeout type, corresponding timeout processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer specifically includes:
according to the heartbeat detection timeout processing, the server IP heartbeat detection result in the server IP set recorded by the target time slice element pointed by the timer pointer is marked as abnormal;
and sending the abnormal server IP to the client so that the client deletes the abnormal server IP from the cached server IP list.
In an optional embodiment, further comprising:
receiving a registration request sent by a server; wherein, the registration request carries a server IP;
acquiring a target time slice element pointed by the timer pointer in the circular queue at the current moment;
adding the server IP in the server IP set recorded by the target time slice element;
and adding the mapping relation between the target time slice element and the server IP in the mapping table.
In an optional embodiment, further comprising:
acquiring a time slice element corresponding to the server IP from the mapping table; setting a target time slice element pointed by the timer pointer in a circular queue at the current moment as a first time slice element, and acquiring a time slice element corresponding to the server IP in a mapping table as a second time slice element;
adding the server IP in the server IP set recorded by the target time slice element specifically comprises:
when the second time slice element is empty, adding the server IP in a server IP set recorded by the first time slice element;
adding the mapping relationship between the target time slice element and the server IP in the mapping table specifically includes:
and when the second time slice element is empty, adding the mapping relation between the first time slice element and the server IP in the mapping table.
In an optional embodiment, further comprising:
deleting the server IP from the server IP set recorded by the second time slice element when the second time slice element is not empty;
and deleting the mapping relation between the second time slice element and the server IP from the mapping table.
In the above embodiments of the electronic device, it should be understood that the Processor may be a Central Processing Unit (CPU), other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor, and the aforementioned memory may be a read-only memory (ROM), a Random Access Memory (RAM), a flash memory, a hard disk, or a solid state disk. The steps of a method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiment of the electronic device, since it is substantially similar to the embodiment of the method, the description is simple, and for the relevant points, reference may be made to part of the description of the embodiment of the method.
Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following, in general, the principles of the specification and including such departures from the present disclosure as come within known or customary practice within the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.
It will be understood that the present description is not limited to the precise arrangements described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

Claims (15)

1. A timeout handling method, the method comprising:
when the timer reaches unit time each time, controlling the pointer of the timer to move a time slice element in the circular queue according to a set sequence; the circular queue is a circular queue formed by a plurality of time slice elements, each time slice element records a machine IP set, and the mapping relation between the time slice element and the recorded machine IP is recorded in a mapping table;
according to a preset timeout type, performing corresponding timeout processing on machine IPs in a machine IP set recorded by a target time slice element pointed by the timer pointer;
after the machine IP overtime processing is finished, deleting the mapping relation between the target time slice element and the machine IP in the mapping table;
after the timeout processing of all the machine IPs is finished, emptying the machine IPs recorded by the target time slice elements;
wherein the machine IP in the mapping table is recorded by:
receiving a registration request carrying a machine IP;
acquiring a target time slice element pointed by the timer pointer in the circular queue at the current moment;
adding the machine IP in the set of machine IPs of the target time slice element record;
and adding the mapping relation between the target time slice element and the machine IP in the mapping table.
2. The method of claim 1, the circular queue being established by:
acquiring the timeout duration of a preset timeout type;
and calculating the number N of the overtime duration corresponding to the unit time, and creating a circular queue of N elements.
3. The method of claim 1, wherein the preset timeout type is timeout processing of an online state of a client in an instant messaging scenario, and the machine IP is a client IP;
the performing, according to a preset timeout type, corresponding timeout processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer specifically includes:
and according to the online state timeout processing, marking the online state of the client IP in the client IP set recorded by the target time slice element pointed by the timer pointer as offline.
4. The method of claim 1, wherein the preset timeout type is a heartbeat detection timeout process of a server, and the machine IP is a server IP;
the performing, according to a preset timeout type, corresponding timeout processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer specifically includes:
according to the heartbeat detection timeout processing, the server IP heartbeat detection result in the server IP set recorded by the target time slice element pointed by the timer pointer is marked as abnormal;
and sending the abnormal server IP to the client so that the client deletes the abnormal server IP from the cached server IP list.
5. The method of claim 1, the machine IP being a server IP, respectively:
the receiving of the registration request carrying the machine IP includes:
receiving a registration request sent by a server; wherein, the registration request carries a server IP;
the adding the machine IP in the set of machine IPs of the target time slice element record comprises:
adding the server IP in the server IP set recorded by the target time slice element;
adding the mapping relationship between the target time slice element and the machine IP in the mapping table comprises:
and adding the mapping relation between the target time slice element and the server IP in the mapping table.
6. The method of claim 5, further comprising:
acquiring a time slice element corresponding to the server IP from the mapping table; setting a target time slice element pointed by the timer pointer in a circular queue at the current moment as a first time slice element, and acquiring a time slice element corresponding to the server IP in a mapping table as a second time slice element;
adding the server IP in the server IP set recorded by the target time slice element specifically comprises:
when the second time slice element is empty, adding the server IP in a server IP set recorded by the first time slice element;
adding the mapping relationship between the target time slice element and the server IP in the mapping table specifically includes:
and when the second time slice element is empty, adding the mapping relation between the first time slice element and the server IP in the mapping table.
7. The method of claim 6, further comprising:
deleting the server IP from the server IP set recorded by the second time slice element when the second time slice element is not empty;
and deleting the mapping relation between the second time slice element and the server IP from the mapping table.
8. A timeout handling apparatus, the apparatus comprising:
the control unit is used for controlling the pointer of the timer to move a time slice element in the circular queue according to a set sequence when the timer counts time to reach unit time each time; the circular queue is a circular queue formed by a plurality of time slice elements, each time slice element records a machine IP set, and the mapping relation between the time slice element and the recorded machine IP is recorded in a mapping table;
the processing unit is used for carrying out corresponding overtime processing on the machine IP in the machine IP set recorded by the target time slice element pointed by the timer pointer according to a preset overtime type;
a deleting unit, configured to delete the mapping relationship between the target time slice element and the machine IP in the mapping table after the machine IP timeout processing is completed;
the clearing unit is used for clearing the machine IP recorded by the target time slice element after the overtime processing of all the machine IPs is finished;
wherein, the machine IP in the mapping table is recorded by the following units:
the receiving unit is used for receiving a registration request carrying a machine IP;
the acquisition unit is used for acquiring a target time slice element pointed by the timer pointer at the current moment in the circular queue;
a first adding unit that adds the machine IP in a set of machine IPs recorded by the target time slice element;
and the second adding unit is used for adding the mapping relation between the target time slice element and the machine IP in the mapping table.
9. The apparatus of claim 8, the circular queue is established by the following sub-units:
the acquisition subunit acquires the timeout duration of a preset timeout type;
and the calculating subunit calculates the number N of the overtime duration corresponding to the unit time, and creates a circular queue of N elements.
10. The apparatus of claim 8, wherein the preset timeout type is timeout processing of an online status of a client in an instant messaging scenario, and the machine IP is a client IP;
the processing unit specifically includes:
and according to the online state timeout processing, marking the online state of the client IP in the client IP set recorded by the target time slice element pointed by the timer pointer as offline.
11. The apparatus according to claim 8, wherein the preset timeout type is a heartbeat detection timeout process of a server, and the machine IP is a server IP;
the processing unit specifically includes:
the marking subunit marks the server IP heartbeat detection result in the server IP set recorded by the target time slice element pointed by the timer pointer as abnormal according to the heartbeat detection timeout processing;
and the deleting subunit is used for sending the abnormal server IP to the client so that the client deletes the abnormal server IP from the cached server IP list.
12. The apparatus of claim 8, the machine IP is a server IP, respectively:
the receiving unit includes:
receiving a registration request sent by a server; wherein, the registration request carries a server IP;
the first adding unit includes:
adding the server IP in the server IP set recorded by the target time slice element;
the second adding unit includes:
and adding the mapping relation between the target time slice element and the server IP in the mapping table.
13. The apparatus of claim 12, the apparatus further comprising:
the obtaining subunit obtains a time slice element corresponding to the server IP from the mapping table; setting a target time slice element pointed by the timer pointer in a circular queue at the current moment as a first time slice element, and acquiring a time slice element corresponding to the server IP in a mapping table as a second time slice element;
the first adding unit specifically includes:
when the second time slice element is empty, adding the server IP in a server IP set recorded by the first time slice element;
the second adding unit specifically comprises:
and when the second time slice element is empty, adding the mapping relation between the first time slice element and the server IP in the mapping table.
14. The apparatus of claim 13, the apparatus further comprising:
a first deletion subunit configured to, when the second time slice element is not empty, delete the server IP from the set of server IPs recorded by the second time slice element;
and the second deleting subunit deletes the mapping relation between the second time slice element and the server IP from the mapping table.
15. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of any of the preceding claims 1-7 by executing the executable instructions.
CN201810569910.XA 2018-06-05 2018-06-05 Timeout processing method and device and electronic equipment Active CN109104326B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810569910.XA CN109104326B (en) 2018-06-05 2018-06-05 Timeout processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810569910.XA CN109104326B (en) 2018-06-05 2018-06-05 Timeout processing method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN109104326A CN109104326A (en) 2018-12-28
CN109104326B true CN109104326B (en) 2021-08-20

Family

ID=64796589

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810569910.XA Active CN109104326B (en) 2018-06-05 2018-06-05 Timeout processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN109104326B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008068B (en) * 2019-02-28 2023-09-22 创新先进技术有限公司 Distributed task disaster recovery method and device thereof
CN112751895B (en) * 2019-10-30 2022-02-25 千寻位置网络有限公司 Communication connection keep-alive method and system thereof
CN111245935B (en) * 2020-01-10 2022-10-21 深圳前海环融联易信息科技服务有限公司 Timeout request processing method and device, computer equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103067258A (en) * 2012-12-14 2013-04-24 北京思特奇信息技术股份有限公司 Message overtime detection processing method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7848227B2 (en) * 2005-01-26 2010-12-07 Cisco Technology, Inc. Retransmit timeout suppression in large scale networks
CN100570568C (en) * 2007-01-12 2009-12-16 中兴通讯股份有限公司 The timing method and the system that are used for real time operating system
CN101645024B (en) * 2009-08-21 2012-09-19 无锡威泰迅电力科技有限公司 Dispatching method of annular propulsion timer

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103067258A (en) * 2012-12-14 2013-04-24 北京思特奇信息技术股份有限公司 Message overtime detection processing method

Also Published As

Publication number Publication date
CN109104326A (en) 2018-12-28

Similar Documents

Publication Publication Date Title
CN109104326B (en) Timeout processing method and device and electronic equipment
US11057461B2 (en) Scalable peer matching
CN110677492B (en) Access request processing method and device, electronic equipment and storage medium
CN111614748B (en) Apparatus and method for scalable peer-to-peer matching
US10028019B2 (en) Method for controlling network media information publication, apparatus, and server
CN110636115A (en) Cross-cloud service calling processing method, gateway server and requester server
CN107092628B (en) Time series data processing method and device
CN107040576B (en) Information pushing method and device and communication system
CN111327647A (en) Method and device for providing service to outside by container and electronic equipment
CN111163072A (en) Method and device for determining characteristic value in machine learning model and electronic equipment
CN110784549A (en) Network node selection method and device, first network node and storage medium
CN110781149A (en) Method, device, equipment and storage medium for managing live broadcast room information
CN111556135A (en) Request scheduling method, system and device and electronic equipment
JP6793498B2 (en) Data store device and data management method
CN113660168B (en) Multi-center research data processing method and device and server
CN111355765B (en) Network request processing and sending method and device
CN110213213B (en) Timing task processing method and system for application
CN111064802A (en) Network request processing method and device, electronic equipment and storage medium
CN111061588A (en) Method and device for locating database abnormal source
CN112417404B (en) User identity recognition method, computing device and computer storage medium
CN110119314A (en) A kind of server calls method, apparatus, server and storage medium
CN110233843B (en) User request processing method and device
CN114328156B (en) Health detection method, device and equipment of protocol port and readable storage medium
CN115658745A (en) Data processing method, data processing device, computer equipment and computer readable storage medium
CN115017538A (en) Data processing method and device, electronic equipment and storage medium

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
TA01 Transfer of patent application right

Effective date of registration: 20200924

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200924

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant