CN111367785A - SDN-based fault detection method and device and server - Google Patents

SDN-based fault detection method and device and server Download PDF

Info

Publication number
CN111367785A
CN111367785A CN201811597772.2A CN201811597772A CN111367785A CN 111367785 A CN111367785 A CN 111367785A CN 201811597772 A CN201811597772 A CN 201811597772A CN 111367785 A CN111367785 A CN 111367785A
Authority
CN
China
Prior art keywords
detection
queue
task
target
fault detection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811597772.2A
Other languages
Chinese (zh)
Inventor
张毅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN201811597772.2A priority Critical patent/CN111367785A/en
Publication of CN111367785A publication Critical patent/CN111367785A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention provides a fault detection method, a fault detection device and a fault detection server based on an SDN (software defined network), relates to the field of computers, and aims to solve the problem of low fault detection efficiency caused by mutual resource competition due to mutually independent fault detection processes of various services in the fault detection method of the SDN controller. The method may comprise: generating a target queue, the target queue comprising a plurality of detection tasks for fault detection; and performing fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue. The method and the device can be applied to fault detection of the SDN.

Description

SDN-based fault detection method and device and server
Technical Field
The present invention relates to the field of computers, and in particular, to a method, an apparatus, and a server for detecting a fault in a Software Defined Network (SDN).
Background
SDN is a new network architecture. In SND, an SDN controller, serving as a core, communicates with a network device through a standard protocol to centrally control data exchange of the network device, and opens an interface to an application layer to program a hardware device through an application layer program, thereby developing various service applications.
Since SDN is very complex, various failures often occur in SDN. In order to ensure efficient operation of the SDN, a method for detecting a fault in the SDN is required.
In the related art, the fault detection processes of each service in the SDN are independent from each other, so that the fault detection processes of each service often compete for resources, and thus the fault detection efficiency is low.
Disclosure of Invention
The embodiment of the invention provides a fault detection method, a fault detection device and a fault detection server based on an SDN (software defined network), and aims to solve the problem of low fault detection efficiency caused by resource competition among fault detection processes of various services.
In a first aspect, a fault detection method based on SDN is provided, which is applicable to an SDN controller and may include:
generating a target queue, the target queue comprising a plurality of detection tasks for fault detection;
and performing fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue.
In a second aspect, an apparatus for SDN-based fault detection is provided, including:
a generation module to generate a target queue, the target queue including a plurality of detection tasks for fault detection;
and the processing module is used for uniformly scheduling the plurality of detection tasks in the target queue to realize fault detection of the plurality of detection tasks.
In a third aspect, an embodiment of the present application provides a server, including: a memory on which is stored a computer program that, when executed, performs the steps of the method according to the first aspect as described above.
In a fourth aspect, the present application provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed, the steps in the method according to the first aspect are implemented.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects:
in an embodiment of the present application, a target queue may be generated first, the target queue including a plurality of detection tasks for fault detection; and then, uniformly scheduling the plurality of detection tasks in the target queue to realize fault detection of the plurality of detection tasks. In the process, the plurality of detection tasks are all located in the target queue, and the detection tasks in the target queue are dispatched in a unified manner, so that the orderly management of the detection tasks can be realized, the fault detection of the detection tasks can be realized orderly, the occurrence of the situation that the fault detection processes of various services compete for resources with each other is avoided, and the efficiency of the fault detection can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of a fault detection method based on SDN according to an embodiment of the present invention;
fig. 2 is a flowchart of a fault detection registration method based on SDN according to an embodiment of the present invention;
FIG. 3 is a flowchart of the process of generating a registration queue described in step 210;
FIG. 4 is a flow chart further illustrating the unified scheduling process involved in steps 220-260 in the form of mutually exclusive locks;
FIG. 5 is a flowchart of the process of recording test results described in step 270;
FIG. 6 is a flow chart of a method described in step 280 for returning a test result to an external user;
fig. 7 is a block diagram of a fault detection apparatus based on an SDN according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described in detail and clearly with reference to the accompanying drawings. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The technical solutions provided by the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
The embodiment of the invention provides a fault detection method based on an SDN, which can be executed by an SDN controller. SDNs may be built from multiple physical devices in the same or different local area networks.
The SDN controller in the embodiment of the present invention may be in a software form or a hardware form. When the SDN controller is software, the SDN controller may be installed on a physical device in the SDN, for example, on a server. When the SDN controller is hardware, the SDN controller may be an independent physical device in the SDN, and is used to implement the SDN-based fault detection method provided in the embodiment of the present invention.
In the following description, the SDN controller is taken as an example of a software form and deployed on a server, but this is not intended to be limiting. It should be understood that the SDN controller may also be in a hardware form (e.g., a physical device in the SDN or a component within a physical device), and the SDN controller may also be deployed on other physical devices besides the server.
The technical solutions provided by the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
Fig. 1 is a flowchart of a fault detection method based on SDN according to an embodiment of the present invention, and referring to fig. 1, the fault detection method based on SDN according to an embodiment of the present invention may be executed by an SDN controller, and may include:
step 110, generating a target queue, wherein the target queue comprises a plurality of detection tasks for fault detection.
In the embodiment of the present invention, the target queue may be composed of detection tasks, and the detection tasks may include at least one of a service name, a detection item name, and a detection item detection time interval, and may also include other additional information as needed.
In this embodiment of the present invention, before the target queue is generated in step 110, an instruction of a user to start a server may be received, and the server may be started according to the instruction, and during the starting process of the server, an SDN controller may be initialized.
During the initialization process of the SDN controller, multiple detection tasks may be acquired. The plurality of detection tasks may be preconfigured (e.g., by a user) on the server.
In the embodiment of the present invention, the target queue may be, for example, a detection queue or a registration queue. The registration queue can be a queue formed after the detection task is registered; the detection queue may represent a queue formed by queuing detection tasks for execution by a thread, and the detection tasks in the detection queue may be from a registration queue.
During the initialization process of the SDN controller or after the initialization of the SDN controller is completed, a plurality of detection tasks may be inserted into a registration queue to generate the registration queue.
First, in the process of inserting a plurality of detection tasks into the registration queue, the time for each detection task to start the operation of inserting into the registration queue may be obtained, and the detection start time of the detection task may be determined according to the time for the detection task to be inserted into the registration queue. For example, the time for the detection task to perform detection may be the sum of the time for the detection task to be inserted into the registration queue and the detection interval time of the detection item included in the detection task. Then, the detection start time of the detection task may be sequentially compared with the detection start time of the detection task already existing in the registration queue, and the detection task may be inserted into the registration queue according to the execution time sequence of the detection task. And if the detection starting time of the detection task is the same as the detection starting time of the detection task existing in the registration queue, determining the arrangement position of the detection task in the registration queue according to the sequence of inserting the detection task into the registration queue.
For example, there is a detection task C that the SDN controller is to insert into the registration queue. First, the time when the registration queue is to be operated is acquired from the server system, and assuming that the current server system time is 11 o 'clock, the detection start time of the detection task C is calculated to be 11 o' clock and 20 minutes according to the detection interval time of the detection item included in the detection task C being 20 minutes. Assume that detection task a and detection task B already exist in the current registration queue, and the detection start time is 11: 10 and 11: 25, respectively. Before inserting the detection task C into the registration queue, the SDN controller compares the detection start time of the detection task C with the detection start times of the detection task A and the detection task B in sequence, and inserts the detection task C into the registration queue at the position after the detection task A and before the detection task B according to the sequence of the detection start times. Assuming that the detection start time of the detection task a and the detection start time of the detection task B existing in the current registration queue are 11: 20 and 11: 25 respectively, the execution time of the detection task C is the same as that of the detection task a, and since the detection task C is inserted into the registration queue by the SDN controller after the detection task a, the detection task C is inserted into the registration queue at a position behind the detection task a.
And 120, uniformly scheduling the plurality of detection tasks in the target queue to realize fault detection of the plurality of detection tasks.
The embodiment of the invention can uniformly schedule the detection tasks, and can include at least one of the following items: and uniformly acquiring the detection tasks from the target queue and performing uniform thread distribution on the acquired detection tasks. In the embodiment of the invention, after the corresponding target result is obtained according to the fault detection result query request, a uniform interface can be provided for transmitting the target result. Meanwhile, as mentioned below, after the fault detection is finished, a unified record table can be provided to store the detection result.
In an embodiment of the present application, a target queue may be generated first, which may include a plurality of detection tasks for fault detection; and then, uniformly scheduling the plurality of detection tasks in the target queue to realize fault detection of the plurality of detection tasks. In the process, the plurality of detection tasks are all located in the target queue, and the detection tasks in the target queue are dispatched in a unified manner, so that the orderly management of the detection tasks can be realized, the fault detection of the detection tasks can be realized orderly, the occurrence of the situation that the fault detection processes of various services compete for resources with each other is avoided, and the efficiency of the fault detection can be improved.
Optionally, in an embodiment of the present invention, the performing, in step 120, fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue may include: when at least one detection task in the target queue reaches a time condition for triggering detection, determining whether the number of threads performing fault detection reaches a threshold value, wherein the threshold value is the total number of threads performing fault detection on the detection tasks in parallel; under the condition that the number of threads reaches the threshold value, when a designated thread occurs, utilizing the designated thread to carry out fault detection on a first designated detection task in the at least one detection task; the designated thread is a thread which completes fault detection on a single detection task.
In the embodiment of the present invention, the time condition for triggering detection may be set as needed, or may be determined based on the detection time interval of the detection item of the detection task. The time condition for triggering detection of the detection task may be, for example, the time for performing detection by the detection task determined in the process of generating the target queue (refer to the foregoing description). Embodiments of the invention may use a timer to calculate and/or count time.
In the embodiment of the invention, the SDN controller can adopt one thread pool for parallel execution of a plurality of detection tasks, and the plurality of threads in the thread pool execute the detection tasks in parallel, so that server resources are reasonably distributed, and the detection efficiency is improved. The number of threads in the thread pool can be set as desired, e.g., 5 or 10, etc.
In this embodiment of the present invention, when at least one detection task in the target queue reaches the time condition for triggering detection, it may be determined whether the number of threads performing fault detection in the thread pool reaches a threshold, where the number of threads reaching the threshold indicates that no idle threads exist in the thread pool for performing fault detection on the detection task, and at this time, it is required to wait for a specified thread (for example, a thread that appears after a certain thread in the thread pool finishes executing) to appear in the thread pool. When the designated thread occurs, the designated thread can be used for carrying out fault detection on a first designated detection task in the at least one detection task.
Wherein the first specified detection task may be one of the at least one detection task.
The embodiment of the invention can realize the full utilization of each thread, shorten the time for the detection task to wait for the fault detection and improve the detection efficiency by determining whether the number of the threads which are carrying out the fault detection reaches the threshold value and utilizing the appointed thread to carry out the fault detection on the first appointed detection task in the at least one detection task when the appointed thread appears under the condition that the number of the threads reaches the threshold value.
Optionally, in an embodiment of the present invention, the target queue is a registration queue, and when the target queue is the registration queue, the fault detection method provided in the embodiment of the present invention may further include: placing the at least one detection task in a detection queue if the number of threads reaches the threshold; and under the condition that a designated thread occurs and before the designated thread is utilized to carry out fault detection on a first designated detection task in the at least one detection task, taking out the first designated detection task from the detection queue in sequence. The first designated detection task may be one of the at least one detection task.
In the embodiment of the present invention, if the number of threads in the thread pool for executing the detection task reaches the threshold, that is, all threads are executing fault detection on the detection task, before an idle thread that completes executing a single detection task does not appear, the at least one detection task may be placed in the first detection queue for waiting until an idle designated thread appears in the thread pool, and then the first designated detection task is taken out from the detection queue for detection.
The fault detection method provided by the embodiment of the invention can be applied to the situation of registering the queue, when the target queue is the registered queue, under the condition that the number of the threads reaches the threshold value, the at least one detection task can be put into the detection queue, and the detection task can be acquired from the detection queue for fault detection. Therefore, the fault detection method provided by the embodiment of the invention can be applied to scenes with more detection tasks, and the application range of the fault detection method is expanded.
Optionally, in an embodiment of the present invention, in the step 120, the performing fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue may further include: and when the number of the threads does not reach the threshold value, utilizing an idle thread to carry out fault detection on a second specified detection task in the at least one detection task. Therefore, the idle thread can be fully utilized to carry out fault detection on the detection task in the at least one detection task, the whole detection time is shortened, and the detection efficiency is improved.
In an embodiment of the invention, if the number of threads that are executing the detection task does not reach the threshold, this indicates that there are idle threads in the thread pool that can be dispatched. At this time, an idle thread may be utilized to perform fault detection on a second designated detection task of the at least one detection task, where the second designated detection task may be one of the at least one detection task arranged in a sequential order. For example, when only one of the at least one detection task is available, the idle thread may be directly utilized to perform the detection task. When a plurality of detection tasks exist in the at least one detection task, if only one idle thread appears, one detection task can be taken out from the at least one detection task according to the time sequence of the plurality of detection tasks for the execution of the idle thread; if there are two idle threads, then two of the plurality of inspection tasks may be fetched in chronological order for execution by the two idle threads.
Optionally, in an embodiment of the present invention, in a case that the target queue is a registration queue, the performing fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue in step 120 may further include: determining next detection starting time of a target detection task based on a detection item detection time interval and detection starting time of the target detection task in the at least one detection task, wherein the target detection task is a detection task to be executed; and determining the arrangement position of the target detection task in the target queue based on the next detection starting time and the detection starting time of each detection task in the target queue, and inserting the target detection task into the arrangement position in the target queue after the target detection task is detected.
In the embodiment of the present invention, after the thread performing fault detection starts to execute the detection task, the next detection start time of the detection task may be determined according to the detection time interval and the detection start time of the detection item in the detection task, and then the detection task may be reinserted into the registration queue for the next detection.
In the embodiment of the present invention, after the detection task is started, the next detection time of the detection task may be calculated according to the detection start time of the detection item of the detection task and the detection interval time of the detection item of the detection task. Similar to the method for initially inserting the detection task into the registration queue, the detection task that has been executed once may be inserted into the registration queue again subsequently according to the sequence of the detection time, so as to execute the next detection task. The mode can ensure that each detection task only needs to be initially registered once, and then the detection task can be repeatedly utilized for detection, so that the detection process can be ensured to be more continuous in time, and the detection efficiency is improved.
Optionally, in an embodiment of the present invention, before the inserting the target detection task into the queue position in the target queue, the fault detection method provided in the embodiment of the present invention may further include: acquiring a mutual exclusion lock of the target queue, wherein the mutual exclusion lock is used for ensuring that only one object is allowed to operate a detection task in the target queue at the same time; the inserting the target detection task into the queued position in the target queue comprises: and under the condition of acquiring the mutual exclusion lock, inserting the target detection task into the arrangement position in the target queue.
The embodiment of the invention can ensure the ordered operation of the target queue through the mutual exclusion lock, and avoid the situation that a plurality of objects operate the target queue at the same time.
Optionally, in an embodiment of the present invention, after the step 120 of performing fault detection on the multiple detection tasks by uniformly scheduling the multiple detection tasks in the target queue, the fault detection method provided in the embodiment of the present invention may further include: acquiring a fault detection result; and storing the fault detection result in a record table.
In this embodiment, after the fault detection task is subjected to fault detection, a fault detection result may be generated, and after the fault detection result is obtained, the fault detection result may be stored in a record table, where the record table may be a data storage form commonly used in the computer field, such as a hash table. Therefore, the centralized storage of the fault detection results can be realized, the detection results can be found out quickly, and the follow-up access to the detection results is facilitated.
Optionally, in an embodiment of the present invention, before the storing the fault detection result in the record table, the fault detection method provided in the embodiment of the present invention may further include: acquiring a write lock for the record table, wherein the write lock represents that only write operation on the record table is allowed. Accordingly, the storing the fault detection result in a log table may include: and storing the fault detection result in a record table under the condition of acquiring the write lock of the record table. Meanwhile, after the failure detection result is stored in a record table, the write lock of the record table can be released.
In the embodiment of the present invention, a hash table may be used as a record table for recording the detection result. In this embodiment, a write lock may be added to the record table, so that it is prevented that multiple objects write to the hash table at the same time, which may cause data confusion.
Optionally, in an embodiment of the present invention, after the storing the fault detection result in the record table, the fault detection method provided in the embodiment of the present invention may further include: receiving a detection result query request transmitted through a uniform interface; acquiring a read lock aiming at the record table, wherein the read lock represents that only the read operation on the record table is allowed; reading a target result corresponding to the fault detection result query request from the record table; and returning the target result through the unified interface.
In the embodiment of the present invention, a unified interface can be provided for data interaction to an external user, wherein the interface can be a general network interface, such as a REST interface. When a user calls the interface to send a request query result instruction to the SDN controller, the SDN controller can obtain a target result corresponding to the instruction from the record table.
In the embodiment of the present invention, a hash table may be used as a record table for recording the detection result. The embodiment of the invention sets the read lock for the record table, when the detection result needs to be inquired from the record table, the read lock needs to be acquired firstly, the record table can be inquired after the read lock is acquired, and the read lock is released after the hash table is inquired. Therefore, the method can prevent new detection results from being written into the hash table while reading the hash table, which causes asynchronous reading data,
in the embodiment of the present invention, format conversion may also be performed on the detection result of the query, for example, the detection result may be converted into a lightweight data exchange format such as JSON. And after the detection result is subjected to format conversion, the detection result after the format conversion can be returned to the user. Therefore, the transmission quantity of the data can be reduced, and the data transmission is more convenient.
Fig. 2 is a flowchart of a fault detection method based on SDN according to an embodiment of the present invention. Referring to fig. 2, a fault detection method based on SDN provided by an embodiment of the present invention may include:
step 210, obtaining a plurality of detection tasks, and generating a registration queue according to the obtained plurality of detection tasks.
In the embodiment of the invention, after the SDN controller is initialized, the detection task is inserted into the registration queue for storage, and the registration queue is generated.
Step 220, determining whether at least one detection task meeting the time condition of triggering detection exists in the registration queue.
When there is at least one detection task that meets the time condition to trigger detection, step 230 may be performed; when there is no at least one detection task that meets the time condition for triggering detection, a detection task that meets the time condition for triggering detection may be waited for to appear in the registration queue.
In step 230, when there is at least one detection task that meets the time condition for triggering detection, it is determined whether the number of threads that are executing the detection task reaches a threshold.
In step 240, if the number of threads executing the detection task reaches a threshold, the detection task that has reached the detection time in the registration queue is taken out from the registration queue and placed in the detection queue.
In the embodiment of the present invention, if the number of threads executing detection tasks reaches a threshold, no thread is available for the SDN controller to assign to execute the detection tasks, the SDN controller may take out the detection tasks that reach the time condition for triggering detection in the registration queue from the registration queue and store the detection tasks in the detection queue, and after the threads are idle, an idle thread is selected to execute the detection tasks in the detection queue.
And 250, when a designated thread appears, sequentially taking out a first designated detection task from the detection queue, and detecting the first designated detection task by using the designated thread.
The designated thread is a thread which completes fault detection on a single detection task.
In step 260, if the number of threads executing the detection task does not reach the threshold, the detection task is executed by using an idle thread.
In the embodiment of the present invention, if the number of threads executing the detection task does not reach the threshold, it indicates that there is a thread idle, and the thread idle may be used to execute the detection task.
In the embodiment of the present invention, if a thread which is idle after executing one detection task occurs, the SDN controller will first assign the thread to the detection task at the head of the detection queue to execute the detection of the detection task. Because the detection tasks in the detection queue are sorted according to the sequence of inserting the queue and the detection start time, under the condition that the number of threads executing the detection tasks reaches a threshold value, each time a thread which is idle after executing a single detection task appears, the SDN controller can preferentially allocate the idle thread to the detection task which is positioned at the head of the queue in the detection queue.
And 270, acquiring a detection result, and writing the result into a record table.
In the embodiment of the present invention, after the detection of each detection task is completed, the SDN controller acquires a detection result. In the embodiment of the present invention, a hash table may be used as a storage form for recording the detection result, but is not limited to this form, and in the following description, a description will be given of a record table using a hash table as a record detection result, in which keys of the hash table are "service name + detection item name" of service registration, and values are detection results including the service name, the detection name, health, failure cause, detection start time, and detection end time. .
Step 280, receiving a query request of the detection result, obtaining the queried detection result from the record table and returning the detection result.
In the embodiment of the present invention, the SDN controller provides a uniform interface for querying the detection result to the user, and the interface type may be a REST type, but is not limited to this type. When the SDN controller receives a request for querying a detection result sent by a user, the SDN controller may query all results in the hash table before the time when the user request is received, and may perform format conversion on the queried detection result, where the converted format may be a JSON format, and the JSON format has strong data readability and is easy to transmit. And after the format conversion of the detection result is completed, the SDN controller returns the detection result with the converted format to the user through the unified interface.
Fig. 3 is a flow chart of the process of generating a registration queue described in step 210. As shown in fig. 3, the detailed steps of generating the registration queue include:
in step 310, a mutual exclusion lock of the registration queue is obtained.
In the embodiment of the invention, the mutual exclusion lock is added to the registration queue to ensure that only a single thread is allowed to operate on the queue at any time.
In the embodiment of the present invention, the SDN controller may generate the registration queue after acquiring the detection task. The queue lock of the registration queue may be acquired first before the detection task is inserted into the registration queue.
In step 320, the detection start time of the detection task is calculated.
In the embodiment of the present invention, the detection start time of the detection task may be calculated according to the sum of the detection interval time of the detection item included in the detection task and the time for performing the operation of inserting the registration queue.
Step 330, inserting the detection tasks into the registration queue according to the detection start time sequence.
In the embodiment of the invention, the detection start time of the detection task can be compared with the detection start time of all the detection tasks existing in the registration queue, then the position of the detection task in the registration queue is determined according to the time sequence, and the detection task can be inserted into the position. If the detection start time of the detection task is the same as that of the detection task existing in the registration queue, the position of the detection task in the registration queue can be determined based on the sequence of inserting the detection task into the registration queue.
Step 340, determining whether the position of the detection task inserted into the registration queue is the first position of the queue.
Step 350, if the position of the detection task inserted into the target queue is the first position of the queue, notifying the timer to reset the timing time, and changing the timing time into the detection start time of the detection task.
In the embodiment of the invention, when the timing time for the detection task arrives, the time condition that the detection task triggers the detection can be considered to be reached. If the position of the detection task inserted into the target queue is the first position of the queue, it is indicated that the detection time of the detection task is the nearest, detection should be preferentially performed, the timing time of the timer is changed into the detection start time of the detection task, and the SDN controller preferentially allocates threads to the detection task to perform detection after the timer expires.
And step 360, if the position of the detection task inserted into the target queue is not the first position of the queue, placing the detection task in a queue waiting state.
In the embodiment of the invention, the detection tasks are queued in the registration queue according to the detection start time sequence, and the timer can notify the SDN controller to allocate threads after the detection start time is reached so as to perform detection on the detection tasks.
At step 370, the mutual exclusion lock of the registration queue is released.
In the embodiment of the invention, when the operation of detecting the insertion of the task into the registration queue is completed, the mutual exclusion lock of the registration queue can be released.
FIG. 4 is a flow chart further illustrating the unified scheduling process involved in steps 220-260 in the form of mutually exclusive locks. As shown in FIG. 4, a unified scheduling process involving mutually exclusive locks may include:
step 410, when at least one detection task in the registration queue reaches the time condition of triggering detection, acquiring the mutual exclusion lock of the registration queue.
When at least one detection task in the registration queue reaches a time condition for triggering detection, for example, the detection starting time is reached, a queue lock of the registration queue can be acquired first. After the queue lock is acquired, the at least one detection task may be taken out of the registration queue.
Step 420, obtaining the at least one detection task from the registration queue, and deleting the at least one detection task from the registration queue.
At step 430, it is determined whether the number of threads executing the detection task reaches a threshold.
In step 440, if the number of threads executing the detection task reaches the threshold, the detection task that has reached the detection time in the registration queue is taken out from the registration queue and stored in the detection queue.
And step 450, when the specified thread appears, the specified thread is distributed to the first specified detection task in the detection queue to perform detection. The designated thread is a thread which completes fault detection on a single detection task, and the first designated detection task may be a first detection task in the detection queue.
In step 460, if the number of threads executing the detection task does not reach the threshold, the detection task is executed by using the idle line.
In the embodiment of the invention, if the number of available idle threads is less than the number of the at least one detection task, the threads are distributed according to the sequence of the detection tasks in the detection queue.
Step 470, waiting for the detection of the detection task to be completed, and outputting the detection result.
Step 480, calculating the next detection start time of the detection task, and reinserting the detection task into the registration queue.
In an embodiment of the present invention, step 480 and step 470 may be performed in parallel. After the detection of the detection task is completed, the detection task can be put into the registration queue again. And detecting according to the detection starting time of the detection task at this time and the detection time to obtain the next detection starting time.
Then, the position in the registration queue can be determined based on the obtained detection start time, and the position is placed in the registration queue again to wait for the next detection, and the specific implementation manner refers to steps 330 to 360.
Step 490, release the registration queue lock.
Fig. 5 is a flowchart of the process of recording the test results described in step 270. As shown in fig. 5, the process of aggregating the fault detection results may include:
and 510, acquiring the detection result and a write lock of the hash table, and writing the acquired detection result into the hash table for recording the detection result.
In the embodiment of the invention, a write lock is added to the hash table for recording the detection result, so as to prevent the hash table from being read simultaneously to cause data confusion when a plurality of threads finish the detection of a single detection task simultaneously. Meanwhile, a write lock is added to the hash table for recording the detection result, so that the read operation of the hash table by a thread can be prevented while the write operation of the hash table is performed, and the obtained read result is not synchronous with the content in the actual table. Therefore, the write lock may be acquired before the detection result is written into the hash table.
Step 520, writing the detection result into the hash table.
At step 530, the hash table write lock is released.
Fig. 6 is a flowchart of the method for returning the test result to the external user described in step 280. As shown in fig. 6, the process of returning the detection result may include:
step 610, when an instruction for inquiring the detection result sent by an external user is received, a hash table reading lock for recording the detection result is obtained.
In the embodiment of the present invention, a read lock is further defined for the hash table for recording the detection result, and the read lock allows multiple threads to simultaneously read the hash table, but does not allow a thread to write the hash table when reading.
Step 620, obtaining the detection result from the hash table.
In the embodiment of the present invention, the SDN controller may query all detection results in the hash table before the time when the user sends the request instruction, so as to return the detection results to the user.
At step 630, the hash table read lock is released.
And step 640, converting the detection result into a JSON format after the detection result is obtained from the hash table.
In the embodiment of the present invention, the SDN controller may convert the queried detection result into a lightweight data format for transmission. In the present embodiment, the detection result may be converted into JSON format, but is not limited to such data format.
Step 650, return the JSON string representing the query result to the user.
Fig. 7 is a block diagram of a fault detection apparatus based on an SDN according to an embodiment of the present invention. Referring to fig. 7, an SDN-based fault detection apparatus provided in an embodiment of the present invention may include:
a generating module 710 for generating a target queue, the target queue comprising a plurality of detection tasks for fault detection;
the processing module 720 is configured to implement fault detection on the multiple detection tasks by uniformly scheduling the multiple detection tasks in the target queue.
In an embodiment of the present application, a target queue may be generated first, the target queue including a plurality of detection tasks for fault detection; and then, uniformly scheduling the plurality of detection tasks in the target queue to realize fault detection of the plurality of detection tasks. In the process, the plurality of detection tasks are all located in the target queue, and the detection tasks in the target queue are dispatched in a unified manner, so that the orderly management of the detection tasks can be realized, the fault detection of the detection tasks can be realized orderly, the occurrence of the situation that the fault detection processes of various services compete for resources with each other is avoided, and the efficiency of the fault detection can be improved.
Optionally, in an embodiment of the present invention, the target queue is a detection queue or a registration queue, and the detection task includes a service name, a detection item name, and a detection item detection time interval.
Optionally, in an embodiment of the present invention, the processing module 720 is specifically configured to:
when at least one detection task in the target queue reaches a time condition for triggering detection, determining whether the number of threads performing fault detection reaches a threshold value, wherein the threshold value is the total number of threads performing fault detection on the detection tasks in parallel;
under the condition that the number of threads reaches the threshold value, when a designated thread occurs, utilizing the designated thread to carry out fault detection on a first designated detection task in the at least one detection task; the designated thread is a thread which completes fault detection on a single detection task.
Optionally, in an embodiment of the present invention, the target queue is a registration queue, and when the target queue is a registration queue, the processing module 720 is further configured to: placing the at least one detection task in a detection queue if the number of threads reaches the threshold; and when a specified thread occurs, sequentially taking out the first specified detection task from the detection queue.
Optionally, in an embodiment of the present invention, the processing module 720 is further configured to: and when the number of the threads does not reach the threshold value, utilizing an idle thread to carry out fault detection on a second specified detection task in the at least one detection task.
Optionally, in an embodiment of the present invention, the processing module 720 is further configured to;
determining next detection starting time of a target detection task based on a detection item detection time interval and detection starting time of the target detection task in the at least one detection task, wherein the target detection task is a detection task to be executed;
and determining the arrangement position of the target detection task in the target queue based on the next detection starting time and the detection starting time of each detection task in the target queue, and inserting the target detection task into the arrangement position in the target queue after the target detection task is detected.
Optionally, in an embodiment of the present invention, the processing module 720 is further configured to:
before the target detection task is inserted into the arrangement position in the target queue, acquiring a mutual exclusion lock of the target queue, wherein the mutual exclusion lock is used for ensuring that only one object is allowed to operate the detection task in the target queue at the same time;
and under the condition of acquiring the mutual exclusion lock, inserting the target detection task into the arrangement position in the target queue.
Optionally, in an embodiment of the present invention, the apparatus 700 further includes: an obtaining module 730, configured to obtain a fault detection result; and a storage module 740, configured to store the fault detection result obtained by the obtaining module 730 in a record table.
Optionally, in an embodiment of the present invention, the obtaining module 730 is further configured to:
acquiring a write lock aiming at the record table, wherein the write lock represents that only write operation is allowed to the record table;
the storage module 740 is specifically configured to: under the condition of acquiring the write lock of the record table, storing the fault detection result in the record table;
after the storing the fault detection result in a log table, the method further comprises: releasing the write lock of the record table.
Optionally, in an embodiment of the present invention, the apparatus 700 further includes: a receive module 750, a read module 760, and a return module 770; wherein:
the receiving module 750 is configured to receive a detection result query request after the storage module stores the fault detection result in a record table;
the obtaining module 730 is further configured to: acquiring a read lock aiming at the record table, wherein the read lock represents that only the read operation on the record table is allowed;
the reading module 760 is configured to read a target result corresponding to the fault detection result query request from the record table;
the returning module 770 is configured to return the target result read by the reading module. Furthermore, an embodiment of the present invention further provides a server, which may include a memory and a processor, where the memory may store a computer program, and when the computer program is executed by the processor, the server may implement the steps in any SDN-based fault detection method described above. For example, steps in the SDN based fault detection method shown in fig. 1 or steps in the SDN based fault detection method shown in fig. 2.
Furthermore, embodiments of the present invention may also provide a non-transitory computer-readable storage medium, on which a computer program is stored, which when executed, implements the steps in any of the SDN-based fault detection methods described above. For example, steps in the SDN based fault detection method shown in fig. 1 or steps in the SDN based fault detection method shown in fig. 2.
The server and the storage medium provided by the embodiment of the application can generate a target queue firstly, wherein the target queue comprises a plurality of detection tasks for fault detection; and then, uniformly scheduling the plurality of detection tasks in the target queue to realize fault detection of the plurality of detection tasks. In the process, the plurality of detection tasks are all located in the target queue, and the detection tasks in the target queue are dispatched in a unified manner, so that the orderly management of the detection tasks can be realized, the fault detection of the detection tasks can be realized orderly, the occurrence of the situation that the fault detection processes of various services compete for resources with each other is avoided, and the efficiency of the fault detection can be improved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention 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.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. 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.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include transitory computer readable media (transmyedia) such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, 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, 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.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results.

Claims (12)

1. A fault detection method based on a Software Defined Network (SDN) is applied to an SDN controller and comprises the following steps:
generating a target queue, the target queue comprising a plurality of detection tasks for fault detection;
and performing fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue.
2. The fault detection method according to claim 1, wherein the target queue is a detection queue or a registration queue, and the detection task includes a service name, a detection item name, and a detection item detection time interval.
3. The method according to claim 1 or 2, wherein the performing fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue comprises:
when at least one detection task in the target queue reaches a time condition for triggering detection, determining whether the number of threads performing fault detection reaches a threshold value, wherein the threshold value is the total number of threads performing fault detection on the detection tasks in parallel;
under the condition that the number of threads reaches the threshold value, when a designated thread occurs, utilizing the designated thread to carry out fault detection on a first designated detection task in the at least one detection task; the designated thread is a thread which completes fault detection on a single detection task.
4. The method according to claim 3, wherein the target queue is a registration queue, and the performing fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue further comprises:
placing the at least one detection task in a detection queue if the number of threads reaches the threshold;
and under the condition that a designated thread occurs and before the designated thread is utilized to carry out fault detection on a first designated detection task in the at least one detection task, taking out the first designated detection task from the detection queue in sequence.
5. The method according to claim 3, wherein the performing fault detection on the plurality of detection tasks by uniformly scheduling the plurality of detection tasks in the target queue further comprises:
and when the number of the threads does not reach the threshold value, utilizing an idle thread to carry out fault detection on a second specified detection task in the at least one detection task.
6. The method according to claim 4, wherein said performing fault detection on said plurality of detection tasks by uniformly scheduling said plurality of detection tasks in said target queue further comprises;
determining next detection starting time of a target detection task based on a detection item detection time interval and detection starting time of the target detection task in the at least one detection task, wherein the target detection task is a detection task to be executed;
and determining the arrangement position of the target detection task in the target queue based on the next detection starting time and the detection starting time of each detection task in the target queue, and inserting the target detection task into the arrangement position in the target queue after the target detection task is detected.
7. The fault detection method of claim 6, wherein prior to said inserting said object detection task into said queued position in said object queue, said method further comprises:
acquiring a mutual exclusion lock of the target queue, wherein the mutual exclusion lock is used for ensuring that only one object is allowed to operate a detection task in the target queue at the same time;
the inserting the target detection task into the queued position in the target queue comprises: and under the condition of acquiring the mutual exclusion lock, inserting the target detection task into the arrangement position in the target queue.
8. The method according to claim 1, wherein after the performing fault detection on the plurality of detection tasks is performed by uniformly scheduling the plurality of detection tasks in the target queue, the method further comprises:
acquiring a fault detection result;
and storing the fault detection result in a record table.
9. The fault detection method of claim 8, wherein prior to said storing said fault detection result in a log table, said method further comprises:
acquiring a write lock aiming at the record table, wherein the write lock represents that only write operation is allowed to the record table;
the storing the fault detection result in a record table includes: under the condition of acquiring the write lock of the record table, storing the fault detection result in the record table;
after the storing the fault detection result in a log table, the method further comprises: releasing the write lock of the record table.
10. The fault detection method of claim 8, wherein after said storing the fault detection result in a log table, the method further comprises:
receiving a detection result query request transmitted through a uniform interface;
acquiring a read lock aiming at the record table, wherein the read lock represents that only the read operation on the record table is allowed;
reading a target result corresponding to the fault detection result query request from the record table;
and returning the target result through the unified interface.
11. A fault detection device based on a Software Defined Network (SDN), comprising:
a generation module to generate a target queue, the target queue including a plurality of detection tasks for fault detection;
and the processing module is used for uniformly scheduling the plurality of detection tasks in the target queue to realize fault detection of the plurality of detection tasks.
12. A server, characterized by comprising a memory and a processor, the memory having stored thereon a computer program which, when executed, carries out the steps in the method according to any one of claims 1 to 10.
CN201811597772.2A 2018-12-26 2018-12-26 SDN-based fault detection method and device and server Pending CN111367785A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811597772.2A CN111367785A (en) 2018-12-26 2018-12-26 SDN-based fault detection method and device and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811597772.2A CN111367785A (en) 2018-12-26 2018-12-26 SDN-based fault detection method and device and server

Publications (1)

Publication Number Publication Date
CN111367785A true CN111367785A (en) 2020-07-03

Family

ID=71206116

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811597772.2A Pending CN111367785A (en) 2018-12-26 2018-12-26 SDN-based fault detection method and device and server

Country Status (1)

Country Link
CN (1) CN111367785A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114489867A (en) * 2022-04-19 2022-05-13 浙江大华技术股份有限公司 Algorithm module scheduling method, algorithm module scheduling device and readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114489867A (en) * 2022-04-19 2022-05-13 浙江大华技术股份有限公司 Algorithm module scheduling method, algorithm module scheduling device and readable storage medium

Similar Documents

Publication Publication Date Title
CN107291558B (en) Application program interface deadlock monitoring method and device
CN106293893B (en) Job scheduling method and device and distributed system
CN105045632A (en) Method and device for implementing lock free queue in multi-core environment
CN106933672B (en) Distributed environment coordinated consumption queue method and device
US9092272B2 (en) Preparing parallel tasks to use a synchronization register
CN106569892B (en) Resource scheduling method and equipment
CN109165158B (en) Method and device for scheduling test cases, computing equipment and computer storage medium
CN107515784A (en) A kind of method and apparatus of computing resource in a distributed system
CN111258742B (en) Data synchronization method, system, computing device and storage medium
CN109376020B (en) Data processing method, device and storage medium under multi-block chain interaction concurrence
CN114168302A (en) Task scheduling method, device, equipment and storage medium
CN111177160B (en) Service updating method, device, server and medium
CN113282402A (en) Test task scheduling method oriented to complex resource constraint
CN111367785A (en) SDN-based fault detection method and device and server
CN114416311A (en) Method and device for managing message queue based on Go language
US20200301732A1 (en) Information processing system and non-transitory computer readable medium storing program
CN109558249B (en) Control method and device for concurrent operation
CN107168790B (en) Job scheduling method and device
CN105760215A (en) Map-reduce model based job running method for distributed file system
CN111984510B (en) Performance test method and device for dispatching system
CN110011832B (en) Configuration issuing method and device for planned tasks
CN112541038A (en) Time series data management method, system, computing device and storage medium
CN115357342B (en) Cold start resource processing method and device
CN112732664B (en) Evidence extraction method, device, electronic equipment and storage medium
CN117742979B (en) Distributed lock method oriented to space-time data processing and electronic equipment

Legal Events

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