WO2013097248A1 - Distributed task processing method, device and system based on message queue - Google Patents

Distributed task processing method, device and system based on message queue Download PDF

Info

Publication number
WO2013097248A1
WO2013097248A1 PCT/CN2011/085203 CN2011085203W WO2013097248A1 WO 2013097248 A1 WO2013097248 A1 WO 2013097248A1 CN 2011085203 W CN2011085203 W CN 2011085203W WO 2013097248 A1 WO2013097248 A1 WO 2013097248A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
processing
message queue
processing task
priority level
Prior art date
Application number
PCT/CN2011/085203
Other languages
French (fr)
Chinese (zh)
Inventor
武嘉
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2011/085203 priority Critical patent/WO2013097248A1/en
Priority to CN201180003148.5A priority patent/CN103502943B/en
Publication of WO2013097248A1 publication Critical patent/WO2013097248A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system

Definitions

  • the present invention relates to the field of information technology (Information Technology, referred to as IT), and in particular, to a message queue-based distributed task processing method, device and system.
  • IT Information Technology
  • Distributed computing is a computer science that studies how to divide a problem that requires a very large computational power into many small parts, then distributes these parts to many computers for processing, and finally combines these calculations to get the final result. the result of.
  • These computing resources can be run on the same computer or on multiple computers connected via a network.
  • Distributed computing has several advantages over other algorithms: Rare resources can be shared; distributed computing can balance computing load across multiple computers; programs can be placed on the computer that is best suited to run it.
  • a message queue (Message Queue, MQ for short), a central node, and several task processing nodes are usually maintained.
  • the message queue is used to save the task to be executed, and the central node is used to sort the tasks in the message queue according to the priority of the task, and implement the hierarchical management function to ensure that the high priority task is located in the queue of the message queue.
  • the processing node is used to cyclically scan the message queue, obtain the task at the head of the queue from the message queue, and execute the task.
  • the prior art needs to sort the tasks in the message queue according to the task priority. When the number of tasks to be processed is large and the number of tasks is large, Increase the overhead of system sequencing and reduce the efficiency of the system.
  • a message queue-based distributed task processing method is provided in the embodiment of the present invention.
  • Each message queue in the task message queue group stores a processing task carried by the task processing node, and the method includes:
  • the task processing node determines, according to the priority level of the processing task carried by the task, the priority level of the message queue storing the processing task;
  • the task processing node sequentially scans the message queues in the task message queue group from the message queue with the highest priority level according to the priority level from high to low. If the message queue containing the processing task is scanned, Perform step C, otherwise, repeat step B;
  • the task processing node acquires the current processing task, and executes the current processing task. After the execution, the process returns to step B, where the current processing task is stored in the message queue including the processing task.
  • a message queue-based distributed task scheduling method provided by an embodiment of the present invention includes: acquiring a processed task after segmentation;
  • the processing task is sent to a message queue associated with the type of the processing task in the task message queue group, waiting for the task processing node to execute.
  • a message queue priority level determining unit configured to determine a priority level of a message queue storing the processing task according to a priority level of a processing task carried by the self-host;
  • a scanning unit configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
  • a task execution unit configured to: when the scanning unit scans a message queue that includes a processing task, Acquiring a current processing task, and executing the current processing task, where the current processing task is stored in the message queue that includes the processing task.
  • An obtaining unit configured to obtain a processed task after the segmentation
  • a sending unit configured to send, according to the type of the processing task acquired by the acquiring unit, the processing task to a message queue associated with the type of the processing task in the task message queue group, and wait for the task processing node to execute.
  • a distributed task processing system includes at least one task processing node, where the task processing node is configured to determine, according to a priority level of a processing task carried by the task, a message storing the processing task.
  • the priority level of the queue, and the message queues in the task message queue group are cyclically scanned from the message queue with the highest priority level in order of priority level, and the scanned processing tasks are executed, where Each message queue in the task message queue group stores a processing task carried by the task processing node;
  • the task processing node includes:
  • a message queue priority level determining unit configured to determine a priority level of a message queue storing the processing task according to a priority level of a processing task carried by the self-host;
  • a scanning unit configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
  • a task execution unit configured to: when the scan unit scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the message that includes the processing task In the queue.
  • the method, the device and the system for the distributed task processing based on the message queue are provided in the embodiment of the present invention. Different types of tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to be Processing tasks in the message queue are sorted in order of priority, eliminating the need for sorting The resulting system overhead increases the efficiency of the system work.
  • FIG. 1 is a schematic structural diagram of a distributed task processing system according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a method for distributed task processing based on message queues according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a distributed task scheduling method based on message queue according to an embodiment of the present invention
  • a flow chart of a method for implementing distributed message processing based on message queues is provided in the example;
  • FIG. 5 is a flowchart of another method for implementing distributed message processing based on message queue according to an embodiment of the present invention.
  • FIG. 6 is a task processing node according to an embodiment of the present invention.
  • FIG. 7 is a scheduler according to an embodiment of the present invention.
  • FIG. 8 is a schematic task processing system according to an embodiment of the present invention. detailed description
  • FIG. 1 is a structural diagram of a distributed task processing system according to an embodiment of the present invention.
  • the task segmentation node segments the original task to obtain at least one processing task, and performs corresponding segmentation on the data file associated with the original task to obtain at least one fragment, so that each processing is performed.
  • the tasks correspond to a slice that matches the processing task.
  • the split processing task is sent to the scheduler, and the scheduler sends the processing task to the task message queue group according to the type of the processing task.
  • the message queue associated with the type of processing task is waiting for the task processing node to execute.
  • the dividing the data file refers to dividing the data file into at least one slice without processing the data file.
  • the task splitting node provided by the embodiment of the present invention may be a dedicated hardware device, a task processing node in the distributed task processing system, or a scheduler.
  • a task message queue group is taken as an example to describe the technical solution.
  • the embodiment of the present invention may have one or more task message queue groups.
  • the number of task message queue groups does not constitute a limitation on the embodiments of the present invention, and the following embodiments are also the same.
  • the task processing node may be various types of servers or personal computers; the scheduler may be various types of servers or personal computers.
  • the task message queue group may be stored in a dedicated hardware device or may be stored in any storage node in the distributed task storage system.
  • an embodiment of the present invention provides a method for distributed task processing based on a message queue. As shown in Figure 2, the method includes:
  • the task processing node determines, according to a priority level of the processing task carried by the task, a priority level of the message queue storing the processing task.
  • Each of the task message queue groups stores a processing task carried by the task processing node, for example, if the processing tasks carried by the task processing node include a video transcoding task, a video rendering task, and a person For the face recognition task, the task message queue group will include three message queues corresponding to the video transcoding task, the video rendering task, and the face recognition task;
  • the task message queue group may be pre-configured, and the body of the task message queue group may be configured as a dedicated hardware device or any task processing node in the distributed task processing system; It should be noted that a global message queue group can also be pre-configured.
  • Each of the message queues in the office message queue stores a processing task carried by the system, and the task processing node selects from the global message queue and the task processing node itself according to the type of the processing task carried by the task processing node.
  • the task processing node determines a priority level of the processing task carried by the task processing node according to the service requirement; for example, the processing task carried by the task processing node includes a video transcoding task, a video rendering task, and a face recognition.
  • the task but the main processing task carried by the task processing node is a video transcoding task, followed by a video rendering task, and again a face recognition task, then the task processing node determines that the message queue with the highest priority level is a stored video transcoding task.
  • Message queue, the second highest priority message queue is a message queue for storing video rendering tasks, and the low priority level message queue is a message queue for storing face recognition tasks;
  • Manner 2 The priority level of the processing task is set in advance, wherein, the entity that presets the priority level of the processing task may be a dedicated hardware device or the task processing. Node
  • Step S202 The task processing node sequentially scans the message queues in the task message queue group from the message queue with the highest priority level according to the priority level of the priority level. If the message queue containing the processing task is scanned, Step S203 is performed, otherwise, step S202 is repeated;
  • this step S202 can be further subdivided into four steps S202a, S202b, S202c, and S202d, as follows:
  • S202a The task processing node scans a message queue with the highest priority level in the task message queue group;
  • the task processing node first scans the message queue of the stored video transcoding task; S202b: The task processing node determines whether the scanned message queue contains a processing task, and if so, step S203 is performed, otherwise, step S202c is performed;
  • step S202c The task processing node determines whether the priority level of the scanned message queue is the lowest, and if yes, returns to step S202a, otherwise, step S202d is performed;
  • the task processing node rescans the message queue from the message queue with the highest priority level
  • the task processing node scans the next message queue in the task message queue group according to the order of priority from high to low, and returns to step S202b;
  • the task processing node scans the message queue of the secondary priority level according to the order of priority level from high to low;
  • step S203 when the task processing node first scans the message queue including the processing task, step S203 is performed;
  • step S203 The task processing node acquires the current processing task, and executes the current processing task. After the execution, the process returns to step S202, where the current processing task is stored in the message queue that includes the processing task.
  • the method may include any one of the following methods:
  • Manner 1 The task processing node acquires any processing task that is not executed in the message queue that includes the processing task, and executes any processing task that is not executed; for example, if the message queue includes the processing task Include five processing tasks, randomly acquiring one processing task from the five processing tasks as a current processing task, and executing the randomly acquired current processing task;
  • Manner 2 the task processing node acquires a team head processing task that is not executed in the message queue that includes the processing task, and executes the unexecuted team head processing task; for example, if the processing is included The message queue of the task includes five processing tasks, and then the processing task located at the head of the message queue is selected as the current processing task, so that the same type of processing task is executed in the order of first in first out;
  • the message queue including the current processing task deletes the current processing task.
  • a method for processing a distributed task based on a message queue is provided in the embodiment of the present invention.
  • Different types of tasks are allocated in different message queues.
  • the embodiment of the present invention does not need to be in the message queue.
  • the processing tasks are sorted in order of priority, which eliminates the system overhead caused by sorting and improves the efficiency of the system work.
  • a message queue only saves one type of processing task, and only needs to increase Message Queuing can handle other types of processing tasks, and business scalability is strong.
  • a message queue-based distributed task scheduling method includes:
  • the main body executed by this embodiment is a scheduler
  • the task splitting node splits the original task to obtain at least one processing task, and performs corresponding segmentation on the data file associated with the original task to obtain at least one fragment.
  • Each processing task corresponds to a fragment matching the processing task, and after the task dividing node divides the original task, the processing task obtained after the segmentation is sent to the scheduler;
  • the task splitting node may be the scheduler, and after the splitter splits the original task, directly acquiring the processed task after the splitting;
  • S302 Send, according to the type of the processing task, the processing task to a message queue associated with the type of the processing task in the task message queue group, and wait for the task processing node to execute;
  • Each of the task message queue groups stores a processing task carried by the task processing node, for example, if the processing task carried by the task processing node includes video transcoding.
  • the task, the video rendering task, and the face recognition task, the task message queue group will include three message queues, corresponding to the video transcoding task, the video rendering task, and the face recognition task;
  • the task message queue group may be configured in advance, and the body of the task message queue group may be configured as a dedicated hardware device or any task processing node in the distributed task processing system;
  • a global message queue group may also be pre-configured, and each message queue in the global message queue group stores a processing task carried by the system, and the task processing node according to the type of processing task carried by the task processing node And selecting, from the global message queue, a message queue associated with the type of the processing task carried by the task processing node itself, to form the task message queue group.
  • a message queue-based distributed task scheduling method is provided in the embodiment of the present invention. Different types of tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to process the message queue. Tasks are sorted in order of priority, eliminating system overhead caused by sorting and improving the efficiency of system work. Secondly, compared with the prior art, a message queue only stores one type of processing task, and only needs to add messages. The queue can handle other types of processing tasks, and the business is highly scalable. As shown in FIG. 4, a flow chart of a method for implementing distributed task processing based on message queues according to an embodiment of the present invention includes:
  • the task splitting node receives the original task
  • the task segmentation node divides the original task to obtain at least one processing task, and performs corresponding segmentation on the data file associated with the original task to obtain at least one fragment, so that each processing task corresponds to one and the processing a shard that matches the task;
  • the task segmentation node divides the original task into three processing tasks, and the task segmentation node divides the data file corresponding to the original task into segments corresponding to the three processing tasks.
  • Each slice corresponds to a processing task;
  • each processed task after segmentation carries a complete task schedule.
  • the information and the execution information can be executed smoothly after the task processing node obtains the processing task.
  • the embodiment of the present invention does not limit the specific expression of the processing task saved in the message queue, as an example.
  • a video transcoding task can be expressed in the following form:
  • the task splitting node provided by the embodiment of the present invention may be a dedicated hardware device, a task processing node in a distributed task processing system, or a scheduler.
  • the embodiment of the present invention does not limit the method for dividing the original task.
  • the original task may be divided into processing tasks according to a specific format of the data file associated with the original task, and Perform corresponding segmentation on the data file;
  • the scheduler After receiving the processing task, the scheduler pushes the processing task to a message queue associated with the type of the processing task in the task message queue group according to the type of the processing task, and waits for the task processing node to process;
  • Each of the task message queue groups stores a processing task carried by the task processing node, for example, if the processing tasks carried by the task processing node include a video transcoding task, a video rendering task, and a person For the face recognition task, the task message queue group will include three message queues corresponding to the video transcoding task, the video rendering task, and the face recognition task;
  • the task message queue group may be configured in advance, and the body of the task message queue group may be configured as a dedicated hardware device or any task processing node in the distributed task processing system;
  • a global message queue group may also be pre-configured, and each message queue in the global message queue group stores a processing task carried by the system, and the task processing node is configured according to A message queue associated with the type of the processing task carried by the task processing node itself is selected from the global message queue to form the task message queue group;
  • the task processing node determines, according to a priority level of the processing task carried by the task, a priority level of the message queue storing the processing task.
  • the method may include any one of the following methods:
  • the task processing node determines a priority level of the processing task carried by the task processing node according to the service requirement; for example, the processing task carried by the task processing node includes a video transcoding task, a video rendering task, and a face recognition.
  • the task but the main processing task carried by the task processing node is a video transcoding task, followed by a video rendering task, and again a face recognition task, then the task processing node determines that the message queue with the highest priority level is a stored video transcoding task.
  • Message queue, the second highest priority message queue is a message queue for storing video rendering tasks, and the low priority level message queue is a message queue for storing face recognition tasks;
  • Manner 2 The priority level of the processing task is set in advance, wherein, the entity that presets the priority level of the processing task may be a dedicated hardware device or the task processing. Node
  • step S405 can be performed before, after or simultaneously with any of the steps S401 to S404, and there is no sequence;
  • Step S406 The task processing node sequentially scans the message queues in the task message queue group from the message queue with the highest priority level according to the priority level of the priority level. If the message queue containing the processing task is scanned, Step S407 is performed, otherwise, step S406 is repeated;
  • this step S406 can be further subdivided into four steps S406a, S406b, S406c, and S406d, as follows:
  • the task processing node scans a message queue with the highest priority level in the task message queue group; For example, if the message queue with the highest priority level is the message queue storing the video transcoding task, the task processing node first scans the message queue of the stored video transcoding task;
  • step S406b The task processing node determines whether the scanned message queue contains a processing task, and if so, step S407 is performed, otherwise, step S406c is performed;
  • step S406c The task processing node determines whether the priority level of the scanned message queue is the lowest, and if yes, returns to step S406a, otherwise, step S406d;
  • the task processing node rescans the message queue from the message queue with the highest priority level
  • the task processing node scans the next message queue in the task message queue group according to the order of priority from high to low, and returns to step S406b;
  • the task processing node scans the message queue of the secondary priority level according to the order of priority level from high to low;
  • step S407 when the task processing node first scans the message queue including the processing task, step S407 is performed;
  • step S407 The task processing node acquires the current processing task, and executes the current processing task. After the execution, the process returns to step S406, where the current processing task is stored in the message queue that includes the processing task.
  • the method may include any one of the following methods:
  • Manner 1 The task processing node acquires any processing task that is not executed in the message queue that includes the processing task, and executes any processing task that is not executed; for example, if the message queue includes the processing task Include five processing tasks, randomly acquiring one processing task from the five processing tasks as a current processing task, and executing the randomly acquired current processing task;
  • Manner 2 the task processing node acquires an unexecuted team head processing task in the message queue that includes the processing task, and executes the unexecuted team head processing task; for example, if the message queue including the processing task is included Including five processing tasks, the processing task located at the head of the message queue is selected as the current processing task, so that the same type of processing tasks are executed in the first-in first-out order;
  • the message queue including the current processing task deletes the current processing task.
  • a method for processing a distributed task based on a message queue is provided in the embodiment of the present invention.
  • Different types of processing tasks are allocated in different message queues.
  • the embodiment of the present invention does not need to be in a message queue.
  • the processing tasks are sorted in order of priority, which eliminates the system overhead caused by sorting and improves the efficiency of the system work.
  • a message queue only stores one type of processing tasks, only Adding a message queue can handle other types of processing tasks, and the service scalability is strong.
  • the priority of the processing task can be dynamically determined by the task processing node according to the business needs, ensuring that the emergency service can be obtained higher during the entire task processing process.
  • the priority of the task processing node is more flexible, and again, the original task is segmented to obtain at least one processing task, so that the current processing task does not occupy the resources of the task processing node for a long time, and the resources of the task processing node are not guaranteed. Blocking, able to execute high-quality in time The first level of processing tasks.
  • FIG. 5 it is a flow chart of a method for implementing distributed message processing based on a message queue according to an embodiment of the present disclosure. The embodiment is applied to a distributed video task processing system, and specifically includes:
  • the task splitting node receives the original task.
  • the original task is an original video task.
  • the task splitting node splits the original video task to obtain at least one processing task, and performs corresponding segmentation on the data file associated with the original video task to obtain at least one fragment, so that each processing task corresponds to one The processing task is matched with the fragmentation.
  • the processing task is a video processing task.
  • the task splitting node divides the original video task into three video processing tasks.
  • Each of the three video processing tasks corresponds to a video processing task; wherein, each of the video processing tasks after the segmentation carries complete task scheduling information and execution information, So that the task processing node can smoothly execute after acquiring the video processing task;
  • a video transcoding task may be in the following form:
  • the manner in which the task splitting node splits the original task specifically includes: the task splitting node splits the original video task according to a preset splitting strategy to obtain at least one video processing task, and is in an I frame. Separating the video data file associated with the original video task to obtain at least one fragment, wherein the segmentation strategy needs to ensure that the video data file is segmented at the position of the I frame;
  • the I frame is the first frame in the Group Of Pictures (GOP), and can be used as a reference point for random access;
  • GOP Group Of Pictures
  • the task splitting node provided by the embodiment of the present invention may be a dedicated hardware device, a task processing node in a distributed task processing system, or a scheduler.
  • S503 The task segmentation node sends the segmented video processing task to the scheduler.
  • the scheduler After receiving the video processing task, the scheduler pushes the video processing task to a message queue associated with the type of the video processing task in the task message queue group according to the type of the video processing task, and waits for task processing. Node processing
  • Each of the task message queues stores a video processing task carried by the task processing node, for example, if the video processing task carried by the task processing node includes The frequency transcoding task, the video rendering task, and the face recognition task, the task message queue group will include three message queues corresponding to the video transcoding task, the video rendering task, and the face recognition task;
  • the task message queue group may be configured in advance, and the body of the task message queue group may be configured as a dedicated hardware device or any task processing node in the distributed task processing system;
  • a global message queue group may also be pre-configured, and each message queue in the global message queue group stores a video processing task carried by the system, and the task processing node processes the video according to its own bearer.
  • a task type selecting, from the global message queue, a message queue associated with a type of a video processing task carried by the task processing node itself, to form the task message queue group;
  • the task processing node determines, according to a priority level of the video processing task carried by the task processing node, a priority level of the message queue for storing the video processing task.
  • the task processing node determines a priority level of the video processing task carried by the task processing node according to the service requirement; for example, the video processing task carried by the task processing node includes a video transcoding task, a video rendering task, and a person The face recognition task, but the main video processing task carried by the task processing node is a video transcoding task, followed by a video rendering task, and again a face recognition task, then the task processing node determines that the message queue with the highest priority level is a stored video.
  • the message queue of the transcoding task, the message queue of the second highest priority level is a message queue for storing the video rendering task, and the message queue of the low priority level is a message queue for storing the face recognition task;
  • the priority level of the video processing task is set in advance, wherein, the entity that presets the priority level of the video processing task may be a dedicated hardware device, or may be Task processing node;
  • this step S505 can be any of steps S501 to S504. Before, after or at the same time, there is no order;
  • step S506 The task processing node sequentially scans the message queue in the task message queue group from the message queue with the highest priority level according to the priority level from high to low, and scans the message queue that includes the video processing task. , step S507 is performed, otherwise, step S506 is repeated;
  • this step S506 can be further subdivided into S506a,
  • S506a The task processing node scans a message queue with the highest priority level in the task message queue group;
  • the task processing node first scans the message queue of the stored video transcoding task
  • step S506b The task processing node determines whether the scanned message queue contains a video processing task, and if so, step S507 is performed, otherwise, step S506c is performed;
  • step S506c The task processing node determines whether the priority level of the scanned message queue is the lowest, and if yes, returns to step S506a, otherwise, step S506d;
  • the task processing node rescans the message queue from the message queue with the highest priority level
  • the task processing node scans the next message queue in the task message queue group according to the order of priority from high to low, and returns to step S506b;
  • the task processing node scans the message queue of the secondary priority level according to the order of priority level from high to low;
  • step S507 when the task processing node first scans the message queue including the video processing task, step S507 is performed;
  • the task processing node acquires a current processing task, and executes the current processing task. After the execution, the process returns to step S506.
  • the current processing task is a current video processing task
  • the current video task is stored in the message queue including the video processing task.
  • the manner in which the task processing node obtains the current video processing task and performs the current video processing task may include any one of the following methods:
  • the task processing node acquires any video processing task that is not executed in the message queue that includes the video processing task, and executes any video processing task that is not executed; for example, if the processing task is included
  • the message queue includes five video processing tasks, and randomly acquires one video processing task from the five video processing tasks as a current video processing task, and executes the randomly acquired current video processing task;
  • Manner 2 The task processing node acquires a team head video processing task that is not executed in the message queue that includes the video processing task, and executes the unexecuted team head video processing task; for example, if the video processing is included
  • the message queue of the task includes five video processing tasks, and then the video processing task located at the head of the message queue is selected as the current video processing task, so that the same type of video processing task is executed in the first-in first-out order;
  • the message queue including the current video processing task deletes the current video processing task.
  • a method for processing a distributed task based on a message queue is provided in the embodiment of the present invention.
  • Different types of video processing tasks are allocated in different message queues.
  • the embodiment of the present invention does not need to use a message queue.
  • the video processing tasks are sorted in priority order, which eliminates the system overhead caused by sorting and improves the efficiency of the system work.
  • a message queue only stores one type of video processing task. Only need to increase the message queue to handle other types of video processing tasks, and the service scalability is strong.
  • the priority of the video processing task can be dynamically determined by the task processing node according to the business needs, ensuring emergency in the whole task processing process.
  • a task processing node includes: a message queue priority level determining unit 601, configured to determine, according to a priority level of a processing task carried by itself, to store the processing task. The priority level of the message queue;
  • the scanning unit 602 is configured to scan according to the priority level of the message queue determined by the message queue priority level determining unit 601, in order of priority level from highest to lowest, starting from the message queue with the highest priority level. a message queue in the task message queue group;
  • the task execution unit 603 is configured to: when the scanning unit 602 scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the included processing task In the message queue.
  • the task processing node provided by the embodiment of the present invention further includes: a processing task priority level determining unit, configured to determine, according to the service requirement, a priority level of the processing task carried by the task processing node, or pre-set The priority level of the processing task is described, so that the message queue priority level determining unit 601 determines the priority level of the message queue in the task message queue group.
  • a processing task priority level determining unit configured to determine, according to the service requirement, a priority level of the processing task carried by the task processing node, or pre-set The priority level of the processing task is described, so that the message queue priority level determining unit 601 determines the priority level of the message queue in the task message queue group.
  • a segmentation unit configured to segment the original task to obtain at least one processing task, and perform corresponding segmentation on the data file corresponding to the original task to obtain at least one fragment, so that each processing task corresponds to the processing task a matching fragment, so that the scheduler sends the processing task to a message queue associated with the type of the processing task in the task message queue group according to the type of the processing task, so that the scanning unit 602 scans the segmentation Processing tasks.
  • the original task is an original video task
  • the processing task is a video processing task
  • the task segmentation unit is specifically configured to: use a preset segmentation policy to the original video task. Performing segmentation to obtain at least one video processing task, and segmenting the video data file associated with the original video task at the position of the I frame to obtain at least one slice, such that each video processing task corresponds to one of the video processing tasks. Matching fragments;
  • the segmentation policy ensures that the video data file is segmented at the location of the I frame.
  • the task execution unit is specifically configured to acquire any processing task that is not executed in the message queue that includes the processing task, and execute Any of the processing tasks not performed; or,
  • the team leader processing task that is not executed in the message queue that includes the processing task is acquired, and the unexecuted team head processing task is executed.
  • the message queue priority level determining unit determines the priority of the message queue for storing the processing task, and does not need to sort the processing tasks according to the priority, and eliminates The system overhead caused by the sorting improves the efficiency of the system work.
  • the priority of the processing task can be dynamically determined by the processing task priority level determining unit according to the business needs, ensuring that the urgent business can be performed during the entire task processing process. Obtaining a higher priority makes the task processing node more flexible in processing the video task.
  • a scheduler includes:
  • the obtaining unit 701 is configured to obtain the processed task after the segmentation
  • the sending unit 702 is configured to send, according to the type of the processing task acquired by the acquiring unit 701, the processing task to a message queue associated with the type of the processing task in the task message queue group, and wait for the task processing node to execute.
  • a dividing unit configured to split the original task to obtain at least one processing task, and to the original
  • the data file corresponding to the initial task is segmented to obtain at least one fragment, so that each processing task corresponds to a fragment matching the processing task, so that the obtaining unit 701 acquires the processing after the segmentation unit is divided. task.
  • the original task is an original video task
  • the processing task is a video processing task
  • the dividing unit is specifically configured to segment the original video task according to a preset segmentation strategy to obtain at least one video processing task, and Segmenting the video data file associated with the original video task at a position of the I frame to obtain at least one slice, such that each video processing task corresponds to a slice matching the video processing task;
  • the segmentation policy ensures that the video data file is segmented at the location of the I frame.
  • the sending unit sends the processing task to the message queue associated with the type of the processing task in the task message queue group.
  • the video in the message queue is not needed.
  • the processing tasks are sorted in order of priority, which eliminates the system overhead caused by sorting and improves the efficiency of the system work.
  • a message queue only stores one type of video processing task, only Adding a message queue can handle other types of video processing tasks, and the service is highly scalable.
  • the splitting unit splits the original task to obtain at least one video processing task, so that the current processing task does not occupy the resources of the task processing node for a long time, ensuring The resources of the task processing node are not blocked, and high-priority processing tasks can be executed in time.
  • the embodiment of the present invention further provides a distributed task processing system, including at least one task processing node, where the task processing node is configured to determine, according to a priority level of a processing task carried by the task, a message queue for storing the processing task. Priority level, and in order from highest to lowest priority level, the message queue in the task message queue group is cyclically scanned from the message queue with the highest priority level, and the scanned processing task is executed, where the task is performed. Each message queue in the message queue group stores a processing task carried by the task processing node;
  • the task processing node includes:
  • a message queue priority level determining unit for prioritizing processing tasks according to its own No, determining a priority level of a message queue storing the processing task
  • a scanning unit configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
  • a task execution unit configured to: when the scan unit scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the message that includes the processing task In the queue.
  • a distributed task processing system is provided in the embodiment of the present invention. Different types of tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to prioritize processing tasks in the message queue. Sorting in order eliminates the overhead caused by sorting and improves the efficiency of the system. Secondly, compared with the prior art, a message queue only stores one type of processing task, and only needs to increase the message queue to process Other types of processing tasks, business scalability.
  • the embodiment of the present invention further provides a distributed task processing system, where the system includes a scheduler 801, a task message queue group storage node 802, and a task processing node 803, as shown in FIG. Obtaining the processed processing task, and sending the processing task to the message queue associated with the type of the processing task in the task message queue group stored by the task message queue group storage node 802 according to the type of the processing task Waiting for the task processing node to execute;
  • the task message queue group storage node 802 is configured to store the task message queue group; the task processing node 803 is configured to determine, according to a priority level of a processing task carried by the host, a message queue for storing the processing task. a priority level, and sequentially scanning the message queues in the task message queue group stored by the task message queue group storage node 802 in order from the highest priority message queue in the order of priority level, and executing The scanned processing task, wherein each message queue in the task message queue group stores a processing task carried by the task processing node 803.
  • the task processing node 803 includes: a message queue priority level determining unit, configured to determine a priority level of a message queue storing the processing task according to a priority level of a processing task carried by the self-host;
  • a scanning unit configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
  • a task execution unit configured to: when the scan unit scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the message that includes the processing task In the queue.
  • the scheduler 801 includes:
  • An obtaining unit configured to obtain a processed task after the segmentation
  • a sending unit configured to send, according to the type of the processing task acquired by the acquiring unit, the processing task to a message associated with the type of the processing task in the task message queue group stored by the task message queue group storage node 802 Queue, waiting for the task processing node to execute.
  • task message queue group storage node 802 and the task processing node 803 may be the same node.
  • the number of task processing nodes is not limited, and there may be multiple task processing nodes.
  • a method, a device, and a system for processing a distributed task based on a message queue are provided in the embodiments of the present invention.
  • Different types of video processing tasks are allocated in different message queues.
  • the video processing tasks in the message queue need to be sorted in order of priority, which eliminates the system overhead caused by the sorting and improves the efficiency of the system work.
  • one message queue only stores one type.
  • the video processing task can process other types of video processing tasks by adding a message queue, and the service scalability is strong.
  • the priority of the video processing task can be dynamically determined by the task processing node according to the business needs, ensuring the processing of the entire task.
  • the urgent video service in the process can obtain higher priority, making the task processing node more flexible in processing video tasks. Then, the original video task is segmented to obtain at least one video processing task, so that the current video processing task does not occupy the resources of the task processing node for a long time, and the resources of the task processing node are not blocked, and the high priority video can be executed in time. Handling tasks.

Abstract

The present invention relates to the field of information technology, and in particular, to a distributed task processing method, device and system based on a message queue. In the distributed task processing method based on a message queue provided in the embodiments of the present invention, each message queue in a task message queue group stores one kind of processing task borne by a task processing node, the task processing node determines the priority level of a message queue which stores a processing task according to the priority level of a processing task borne thereby and starts to circularly scan the message queues in the task message queue group successively from the message queue with the highest priority level in an order from high priority level to low priority level and executes the scanned processing task. By way of the method provided in the embodiments of the present invention, different kinds of tasks are distributed in different message queues without ranking the processing tasks in the message queue, which cancels the system overhead due to ranking and improves the working efficiency of the system.

Description

一种基于消息队列的分布式任务处理的方法、 装置及系统 技术领域  Method, device and system for distributed task processing based on message queue
本发明涉及信息技术(Information Technology, 简称: IT )领域, 尤其涉 及一种基于消息队列的分布式任务处理的方法、 装置及系统。  The present invention relates to the field of information technology (Information Technology, referred to as IT), and in particular, to a message queue-based distributed task processing method, device and system.
背景技术 Background technique
分布式计算是一门计算机科学, 它研究如何把一个需要非常巨大的计 算能力才能解决的问题分成许多小的部分, 然后把这些部分分配给许多计 算机进行处理, 最后把这些计算结果综合起来得到最终的结果。 这些运算 资源既可以在同一台计算机上运行, 也可以在通过网络连接起来的多台计 算机上运行。  Distributed computing is a computer science that studies how to divide a problem that requires a very large computational power into many small parts, then distributes these parts to many computers for processing, and finally combines these calculations to get the final result. the result of. These computing resources can be run on the same computer or on multiple computers connected via a network.
分布式计算比起其它算法具有以下几个优点: 稀有资源可以共享; 通 过分布式计算可以在多台计算机上平衡计算负载; 可以把程序放在最适合 运行它的计算机上。  Distributed computing has several advantages over other algorithms: Rare resources can be shared; distributed computing can balance computing load across multiple computers; programs can be placed on the computer that is best suited to run it.
现有的分布式计算系统, 为实现任务的分级管理, 通常维护一个消息队列 ( Message Queue, 简称: MQ ) , —个中心节点以及若干任务处理节点。 其中, 消息队列用于保存所要执行的任务, 中心节点用于根据任务的优先级对消息队 列中的任务进行排序, 实现分级管理功能, 以保证高优先级的任务位于消息队 列的队首, 任务处理节点用于循环扫描消息队列, 从所述消息队列获取位于队 首的任务并执行该任务。  In the existing distributed computing system, in order to implement hierarchical management of tasks, a message queue (Message Queue, MQ for short), a central node, and several task processing nodes are usually maintained. The message queue is used to save the task to be executed, and the central node is used to sort the tasks in the message queue according to the priority of the task, and implement the hierarchical management function to ensure that the high priority task is located in the queue of the message queue. The processing node is used to cyclically scan the message queue, obtain the task at the head of the queue from the message queue, and execute the task.
通过对现有技术的分析, 发明人认为现有技术至少存在以下问题: 现有技术需要对消息队列中的任务按任务优先级进行排序, 当要求处理的 任务种类多且任务数量大时, 将增加系统排序的开销, 降低系统的工作效率。  Through the analysis of the prior art, the inventor believes that the prior art has at least the following problems: The prior art needs to sort the tasks in the message queue according to the task priority. When the number of tasks to be processed is large and the number of tasks is large, Increase the overhead of system sequencing and reduce the efficiency of the system.
发明内容 本发明实施例的目的在于提供一种基于消息队列的分布式任务处理的方 法、 装置及系统, 使得分布式任务处理系统不需对消息队列中的处理任务进行 排序。 Summary of the invention It is an object of embodiments of the present invention to provide a method, apparatus, and system for distributed task processing based on message queues, so that the distributed task processing system does not need to sort processing tasks in the message queue.
本发明实施例提供的一种基于消息队列的分布式任务处理方法, 任务消息 队列组中的每个消息队列存储任务处理节点承载的一种处理任务, 该方法包 括:  A message queue-based distributed task processing method is provided in the embodiment of the present invention. Each message queue in the task message queue group stores a processing task carried by the task processing node, and the method includes:
A, 所述任务处理节点按照自身承载的处理任务的优先级级别, 确定存储 所述处理任务的消息队列的优先级级别;  A, the task processing node determines, according to the priority level of the processing task carried by the task, the priority level of the message queue storing the processing task;
B, 所述任务处理节点按照优先级级别由高到低的顺序, 从优先级级别最 高的消息队列开始依次扫描所述任务消息队列组中的消息队列, 若扫描到包含 处理任务的消息队列, 执行步骤 C, 否则, 重复步骤 B;  B. The task processing node sequentially scans the message queues in the task message queue group from the message queue with the highest priority level according to the priority level from high to low. If the message queue containing the processing task is scanned, Perform step C, otherwise, repeat step B;
C, 所述任务处理节点获取当前处理任务, 并执行所述当前处理任务, 执 行完之后返回步骤 B, 其中, 所述当前处理任务存储在所述包含处理任务的消 息队列中。  C. The task processing node acquires the current processing task, and executes the current processing task. After the execution, the process returns to step B, where the current processing task is stored in the message queue including the processing task.
本发明实施例提供的一种基于消息队列的分布式任务调度方法, 包括: 获取分割后的处理任务;  A message queue-based distributed task scheduling method provided by an embodiment of the present invention includes: acquiring a processed task after segmentation;
根据所述处理任务的类型, 将所述处理任务发送至任务消息队列组中与所 述处理任务的类型关联的消息队列, 等待任务处理节点执行。  And according to the type of the processing task, the processing task is sent to a message queue associated with the type of the processing task in the task message queue group, waiting for the task processing node to execute.
本发明实施例提供的一种任务处理节点, 包括:  A task processing node provided by an embodiment of the present invention includes:
消息队列优先级级别确定单元, 用于按照自身承载的处理任务的优先级级 别, 确定存储所述处理任务的消息队列的优先级级别;  a message queue priority level determining unit, configured to determine a priority level of a message queue storing the processing task according to a priority level of a processing task carried by the self-host;
扫描单元, 用于根据所述消息队列优先级级别确定单元确定的所述消息队 列的优先级级别, 按照优先级级别由高到低的顺序, 从优先级级别最高的消息 队列开始依次扫描任务消息队列组中的消息队列;  a scanning unit, configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
任务执行单元, 用于在所述扫描单元扫描到包含处理任务的消息队列时, 获取当前处理任务, 并执行所述当前处理任务, 其中, 所述当前处理任务存储 在所述包含处理任务的消息队列中。 a task execution unit, configured to: when the scanning unit scans a message queue that includes a processing task, Acquiring a current processing task, and executing the current processing task, where the current processing task is stored in the message queue that includes the processing task.
本发明实施例提供的一种调度器, 包括:  A scheduler provided by an embodiment of the present invention includes:
获取单元, 用于获取分割后的处理任务;  An obtaining unit, configured to obtain a processed task after the segmentation;
发送单元, 用于根据所述获取单元获取的处理任务的类型, 将所述处理任 务发送至任务消息队列组中与所述处理任务的类型关联的消息队列, 等待任务 处理节点执行。  And a sending unit, configured to send, according to the type of the processing task acquired by the acquiring unit, the processing task to a message queue associated with the type of the processing task in the task message queue group, and wait for the task processing node to execute.
本发明实施例提供的一种分布式任务处理系统, 所述系统包括至少一个任 务处理节点, 所述任务处理节点用于按照自身承载的处理任务的优先级级别, 确定存储所述处理任务的消息队列的优先级级别, 并按照优先级级别由高到低 的顺序, 从优先级级别最高的消息队列开始依次循环扫描任务消息队列组中的 消息队列, 并执行扫描到的处理任务, 其中, 所述任务消息队列组中的每个消 息队列存储所述任务处理节点承载的一种处理任务;  A distributed task processing system according to an embodiment of the present invention, the system includes at least one task processing node, where the task processing node is configured to determine, according to a priority level of a processing task carried by the task, a message storing the processing task. The priority level of the queue, and the message queues in the task message queue group are cyclically scanned from the message queue with the highest priority level in order of priority level, and the scanned processing tasks are executed, where Each message queue in the task message queue group stores a processing task carried by the task processing node;
其中, 所述任务处理节点包括:  The task processing node includes:
消息队列优先级级别确定单元, 用于按照自身承载的处理任务的优先级级 别, 确定存储所述处理任务的消息队列的优先级级别;  a message queue priority level determining unit, configured to determine a priority level of a message queue storing the processing task according to a priority level of a processing task carried by the self-host;
扫描单元, 用于根据所述消息队列优先级级别确定单元确定的所述消息队 列的优先级级别, 按照优先级级别由高到低的顺序, 从优先级级别最高的消息 队列开始依次扫描任务消息队列组中的消息队列;  a scanning unit, configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
任务执行单元, 用于在所述扫描单元扫描到包含处理任务的消息队列时, 获取当前处理任务, 并执行所述当前处理任务, 其中, 所述当前处理任务存储 在所述包含处理任务的消息队列中。  a task execution unit, configured to: when the scan unit scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the message that includes the processing task In the queue.
本发明实施例提供的一种基于消息队列的分布式任务处理的方法、 装置及 系统, 不同类型的任务被分配在不同的消息队列中, 与现有技术相比, 本发明 实施例不需对消息队列中的处理任务按优先级顺序进行排序, 消除了因排序而 造成的系统开销, 提高了系统工作的效率。 The method, the device and the system for the distributed task processing based on the message queue are provided in the embodiment of the present invention. Different types of tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to be Processing tasks in the message queue are sorted in order of priority, eliminating the need for sorting The resulting system overhead increases the efficiency of the system work.
附图说明 DRAWINGS
图 1为本发明实施例提供的一种分布式任务处理系统架构图;  FIG. 1 is a schematic structural diagram of a distributed task processing system according to an embodiment of the present invention;
图 2为本发明实施例提供的一种基于消息队列的分布式任务处理的方法; 图 3为本发明实施例提供的另一种基于消息队列的分布式任务调度方法; 图 4为本发明实施例提供的一种基于消息队列的分布式任务处理的方法实 现流程图;  FIG. 2 is a schematic diagram of a method for distributed task processing based on message queues according to an embodiment of the present invention; FIG. 3 is a schematic diagram of a distributed task scheduling method based on message queue according to an embodiment of the present invention; A flow chart of a method for implementing distributed message processing based on message queues is provided in the example;
图 5为本发明实施例提供的另一种基于消息队列的分布式任务处理的方法 实现流程图;  FIG. 5 is a flowchart of another method for implementing distributed message processing based on message queue according to an embodiment of the present invention; FIG.
图 6为本发明实施例提供的一种任务处理节点;  FIG. 6 is a task processing node according to an embodiment of the present invention;
图 7为本发明实施例提供的一种调度器;  FIG. 7 is a scheduler according to an embodiment of the present invention;
图 8为本发明实施例提供的一种分布式任务处理系统。 具体实施方式  FIG. 8 is a schematic task processing system according to an embodiment of the present invention. detailed description
下面将结合本发明实施例中的附图, 对本发明实施例中的技术方案进行清 楚、 完整地描述。  The technical solutions in the embodiments of the present invention will be clearly and completely described in the following with reference to the accompanying drawings in the embodiments.
如图 1所示, 为本发明实施例提供的一种分布式任务处理系统架构图。 其 中, 任务分割节点在接收到原始任务后, 对所述原始任务进行分割得到至少一 个处理任务, 并对与所述原始任务关联的数据文件进行相应的分割得到至少一 个分片, 使得每个处理任务都对应一个与该处理任务相匹配的分片。 所述任务 分割节点对所述原始任务进行分割后, 向调度器发送分割后的处理任务, 所述 调度器根据所述处理任务的类型将所述处理任务分别发送至任务消息队列组 中与所述处理任务的种类关联的消息队列, 等待任务处理节点执行。  FIG. 1 is a structural diagram of a distributed task processing system according to an embodiment of the present invention. After receiving the original task, the task segmentation node segments the original task to obtain at least one processing task, and performs corresponding segmentation on the data file associated with the original task to obtain at least one fragment, so that each processing is performed. The tasks correspond to a slice that matches the processing task. After the task splitting node splits the original task, the split processing task is sent to the scheduler, and the scheduler sends the processing task to the task message queue group according to the type of the processing task. The message queue associated with the type of processing task is waiting for the task processing node to execute.
其中, 所述对数据文件进行分割是指在不对数据文件进行处理的情况下, 将所述数据文件分割成至少一个分片。 需要说明的是, 本发明实施例提供的任务分割节点既可以是专用的硬件设 备,也可以是分布式任务处理系统中的任一个任务处理节点,还可以是调度器。 The dividing the data file refers to dividing the data file into at least one slice without processing the data file. It should be noted that the task splitting node provided by the embodiment of the present invention may be a dedicated hardware device, a task processing node in the distributed task processing system, or a scheduler.
在此, 需要指出的是, 本发明实施例以一个任务消息队列组为例对技术方 案进行阐述, 本领域技术人员可以理解, 本发明实施例可以有一个或多个任务 消息队列组, 所述任务消息队列组的数目并不构成对本发明实施例的限定, 以 下实施例也一样。  It should be noted that, in the embodiment of the present invention, a task message queue group is taken as an example to describe the technical solution. Those skilled in the art may understand that the embodiment of the present invention may have one or more task message queue groups. The number of task message queue groups does not constitute a limitation on the embodiments of the present invention, and the following embodiments are also the same.
在此, 需要进一步指出的是, 为表述清楚, 该系统中只提供了一个任务处 理节点,本领域技术人员可以理解,本发明实施例可以包含多个任务处理节点, 所述任务处理节点的数目并不构成对本发明实施例的限定, 以下实施例也一 样。  It should be further noted that, for the sake of clarity, only one task processing node is provided in the system, and those skilled in the art can understand that the embodiment of the present invention may include multiple task processing nodes, and the number of the task processing nodes. The present invention is not limited to the embodiments of the present invention, and the following embodiments are also the same.
需要说明的是, 任务处理节点可以是各种类型的服务器或个人计算机; 调 度器可以是各种类型的服务器或个人计算机。  It should be noted that the task processing node may be various types of servers or personal computers; the scheduler may be various types of servers or personal computers.
需要说明的是, 所述任务消息队列组可以保存在一个专用的硬件设备中, 也可以保存在分布式任务存储系统中的任一存储节点中。  It should be noted that the task message queue group may be stored in a dedicated hardware device or may be stored in any storage node in the distributed task storage system.
基于图 1所示的分布式任务处理系统架构, 本发明实施例提供一种基于消 息队列的分布式任务处理的方法。 如图 2所示, 该方法包括:  Based on the distributed task processing system architecture shown in FIG. 1, an embodiment of the present invention provides a method for distributed task processing based on a message queue. As shown in Figure 2, the method includes:
S201 : 任务处理节点根据自身承载的处理任务的优先级级别, 确定存储所 述处理任务的消息队列的优先级级别;  S201: The task processing node determines, according to a priority level of the processing task carried by the task, a priority level of the message queue storing the processing task.
其中, 所述任务消息队列组中的每个消息队列存储所述任务处理节点承载 的一种处理任务, 例如, 若所述任务处理节点承载的处理任务包括视频转码任 务、 视频渲染任务以及人脸识别任务, 则该任务消息队列组将包含三个消息队 列, 分别对应视频转码任务、 视频渲染任务以及人脸识别任务;  Each of the task message queue groups stores a processing task carried by the task processing node, for example, if the processing tasks carried by the task processing node include a video transcoding task, a video rendering task, and a person For the face recognition task, the task message queue group will include three message queues corresponding to the video transcoding task, the video rendering task, and the face recognition task;
需要说明的是, 可以预先配置所述任务消息队列组, 配置所述任务消息队 列组的主体既可以是专用的硬件设备, 也可以是该分布式任务处理系统中的任 一任务处理节点; 还需说明的是, 还可以预先配置一个全局消息队列组, 该全 局消息队列组中的每个消息队列存储所述系统承载的一种处理任务, 所述任务 处理节点根据自身承载的处理任务类型, 从所述全局消息队列中选择与所述任 务处理节点自身承载的处理任务的类型关联的消息队列, 组成所述任务消息队 列组; It should be noted that, the task message queue group may be pre-configured, and the body of the task message queue group may be configured as a dedicated hardware device or any task processing node in the distributed task processing system; It should be noted that a global message queue group can also be pre-configured. Each of the message queues in the office message queue stores a processing task carried by the system, and the task processing node selects from the global message queue and the task processing node itself according to the type of the processing task carried by the task processing node. The message queue associated with the type of processing task, which constitutes the task message queue group;
在此, 需要进一步说明的是, 本发明实施例提供的所述任务处理节点确定 自身承载的处理任务的优先级的方式, 可以包括以下任一方式:  The method for determining the priority of the processing task carried by the task processing node provided by the embodiment of the present invention may include any one of the following methods:
方式一: 所述任务处理节点根据业务需求确定所述任务处理节点承载的处 理任务的优先级级别; 例如, 所述任务处理节点承载的处理任务包括视频转码 任务、 视频渲染任务以及人脸识别任务, 但该任务处理节点承载的主要处理任 务为视频转码任务, 其次为视频渲染任务, 再次为人脸识别任务, 则, 该任务 处理节点确定优先级级别最高的消息队列为存储视频转码任务的消息队列, 次 高优先级级别的消息队列为存储视频渲染任务的消息队列, 低优先级级别的消 息队列为存储人脸识别任务的消息队列;  Manner 1: The task processing node determines a priority level of the processing task carried by the task processing node according to the service requirement; for example, the processing task carried by the task processing node includes a video transcoding task, a video rendering task, and a face recognition. The task, but the main processing task carried by the task processing node is a video transcoding task, followed by a video rendering task, and again a face recognition task, then the task processing node determines that the message queue with the highest priority level is a stored video transcoding task. Message queue, the second highest priority message queue is a message queue for storing video rendering tasks, and the low priority level message queue is a message queue for storing face recognition tasks;
方式二: 预先设置所述处理任务的优先级级别, 其中, 需要说明的是, 所 述预先设置所述处理任务的优先级级别的主体既可以是专用的硬件设备, 也可 以是所述任务处理节点;  Manner 2: The priority level of the processing task is set in advance, wherein, the entity that presets the priority level of the processing task may be a dedicated hardware device or the task processing. Node
S202: 所述任务处理节点按照优先级级别由高到低的顺序, 从优先级级别 最高的消息队列开始依次扫描所述任务消息队列组中的消息队列, 若扫描到包 含处理任务的消息队列, 执行步骤 S203 , 否则, 重复本步骤 S202;  S202: The task processing node sequentially scans the message queues in the task message queue group from the message queue with the highest priority level according to the priority level of the priority level. If the message queue containing the processing task is scanned, Step S203 is performed, otherwise, step S202 is repeated;
其中, 需要说明的是, 如图 2所示, 本步骤 S202可进一步细分为 S202a, S202b, S202c, S202d四个步骤, 如下所示:  It should be noted that, as shown in FIG. 2, this step S202 can be further subdivided into four steps S202a, S202b, S202c, and S202d, as follows:
S202a: 所述任务处理节点扫描所述所述任务消息队列组中优先级级别最 高的消息队列;  S202a: The task processing node scans a message queue with the highest priority level in the task message queue group;
例如, 若优先级级别最高的消息队列为存储视频转码任务的消息队列, 则 所述任务处理节点首先扫描该存储视频转码任务的消息队列; S202b: 所述任务处理节点判断所扫描的消息队列是否包含处理任务, 若 是, 则执行步骤 S203 , 否则, 执行步骤 S202c; For example, if the message queue with the highest priority level is the message queue storing the video transcoding task, the task processing node first scans the message queue of the stored video transcoding task; S202b: The task processing node determines whether the scanned message queue contains a processing task, and if so, step S203 is performed, otherwise, step S202c is performed;
S202c: 所述任务处理节点判断所扫描的消息队列的优先级级别是否最低, 若是, 则返回步骤 S202a, 否则, 执行步骤 S202d;  S202c: The task processing node determines whether the priority level of the scanned message queue is the lowest, and if yes, returns to step S202a, otherwise, step S202d is performed;
其中, 需要说明的是, 若所述任务处理节点当前扫描的消息队列为优先级 级别最低的消息队列, 则所述任务处理节点从优先级级别最高的消息队列开始 重新扫描消息队列;  It should be noted that, if the message queue currently scanned by the task processing node is the message queue with the lowest priority level, the task processing node rescans the message queue from the message queue with the highest priority level;
S202d: 所述任务处理节点按照优先级由高到低的顺序, 扫描所述任务消 息队列组中下一个消息队列, 并返回步骤 S202b;  S202d: The task processing node scans the next message queue in the task message queue group according to the order of priority from high to low, and returns to step S202b;
其中, 需要说明的是, 若优先级级别最高的消息队列没有存储处理任务, 所述任务处理节点按照优先级级别由高到低的顺序, 扫描次优先级级别的消息 队列;  It should be noted that, if the message queue with the highest priority level does not store the processing task, the task processing node scans the message queue of the secondary priority level according to the order of priority level from high to low;
需要进一步说明的是, 所述任务处理节点在首次扫描到包含处理任务的消 息队列时, 即执行步骤 S203;  It should be further noted that, when the task processing node first scans the message queue including the processing task, step S203 is performed;
S203: 所述任务处理节点获取当前处理任务, 并执行所述当前处理任务, 执行完之后返回步骤 S202, 其中, 所述当前处理任务存储在所述包含处理任务 的消息队列中;  S203: The task processing node acquires the current processing task, and executes the current processing task. After the execution, the process returns to step S202, where the current processing task is stored in the message queue that includes the processing task.
其中, 需要说明的是, 本发明实施例提供的所述任务处理节点获取所述当 前处理任务, 并执行所述当前处理任务的方式, 可以包括以下任一方式:  It should be noted that, in the manner that the task processing node obtains the current processing task and performs the current processing task, the method may include any one of the following methods:
方式一: 所述任务处理节点获取所述包含处理任务的消息队列中未被执行 的任一处理任务, 并执行所述未被执行的任一处理任务; 例如, 若该包含处理 任务的消息队列包含 5个处理任务, 则从所述 5个处理任务中随机获取一个处 理任务作为当前处理任务, 并执行该随机获取的当前处理任务;  Manner 1: The task processing node acquires any processing task that is not executed in the message queue that includes the processing task, and executes any processing task that is not executed; for example, if the message queue includes the processing task Include five processing tasks, randomly acquiring one processing task from the five processing tasks as a current processing task, and executing the randomly acquired current processing task;
方式二: 所述任务处理节点获取所述包含处理任务的消息队列中未被执行 的队首处理任务, 并执行所述未被执行的队首处理任务; 例如, 若该包含处理 任务的消息队列包含 5个处理任务, 则选择位于消息队列队首的处理任务为当 前处理任务, 使得按照先进先出的顺序执行同一类型的处理任务; Manner 2: the task processing node acquires a team head processing task that is not executed in the message queue that includes the processing task, and executes the unexecuted team head processing task; for example, if the processing is included The message queue of the task includes five processing tasks, and then the processing task located at the head of the message queue is selected as the current processing task, so that the same type of processing task is executed in the order of first in first out;
需要进一步说明的是, 在所述任务处理节点获取所述当前处理任务之后, 所述包含该当前处理任务的消息队列将所述当前处理任务删除。  It should be further noted that, after the task processing node acquires the current processing task, the message queue including the current processing task deletes the current processing task.
本发明实施例提供的一种基于消息队列的分布式任务处理的方法, 不同类 型的任务被分配在不同的消息队列中, 与现有技术相比, 本发明实施例不需对 消息队列中的处理任务按优先级顺序进行排序, 消除了因排序而造成的系统开 销, 提高了系统工作的效率, 其次, 与现有技术相比, 一个消息队列只保存一 种类型的处理任务, 只需增加消息队列即可处理其他类型的处理任务, 业务扩 展性强。 如图 3所示, 为本发明实施例提供的一种基于消息队列的分布式任务调度 方法, 具体包括:  A method for processing a distributed task based on a message queue is provided in the embodiment of the present invention. Different types of tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to be in the message queue. The processing tasks are sorted in order of priority, which eliminates the system overhead caused by sorting and improves the efficiency of the system work. Secondly, compared with the prior art, a message queue only saves one type of processing task, and only needs to increase Message Queuing can handle other types of processing tasks, and business scalability is strong. As shown in FIG. 3, a message queue-based distributed task scheduling method according to an embodiment of the present invention includes:
S301 : 获取分割后的处理任务;  S301: Obtain a processed task after the segmentation;
其中, 需要说明的是, 本实施例执行的主体为调度器;  It should be noted that the main body executed by this embodiment is a scheduler;
需要进一步说明的是, 任务分割节点在接收到原始任务后, 对所述原始任 务进行分割得到至少一个处理任务, 并对与所述原始任务关联的数据文件进行 相应的分割得到至少一个分片, 使得每个处理任务都对应一个与该处理任务相 匹配的分片, 任务分割节点对原始任务进行分割后, 将分割后得到的处理任务 发送给调度器;  It should be further noted that, after receiving the original task, the task splitting node splits the original task to obtain at least one processing task, and performs corresponding segmentation on the data file associated with the original task to obtain at least one fragment. Each processing task corresponds to a fragment matching the processing task, and after the task dividing node divides the original task, the processing task obtained after the segmentation is sent to the scheduler;
需要再进一步说明的是, 所述任务分割节点可以是所述调度器, 则所述调 度器对原始任务进行分割后, 直接获取分割后的处理任务;  It should be further noted that the task splitting node may be the scheduler, and after the splitter splits the original task, directly acquiring the processed task after the splitting;
S302: 根据所述处理任务的类型, 将所述处理任务发送至任务消息队列组 中与所述处理任务的类型关联的消息队列, 等待任务处理节点执行;  S302: Send, according to the type of the processing task, the processing task to a message queue associated with the type of the processing task in the task message queue group, and wait for the task processing node to execute;
其中, 所述任务消息队列组中的每个消息队列存储所述任务处理节点承载 的一种处理任务, 例如, 若所述任务处理节点承载的处理任务包括视频转码任 务、 视频渲染任务以及人脸识别任务, 则该任务消息队列组将包含三个消息队 列, 分别对应视频转码任务、 视频渲染任务以及人脸识别任务; Each of the task message queue groups stores a processing task carried by the task processing node, for example, if the processing task carried by the task processing node includes video transcoding. The task, the video rendering task, and the face recognition task, the task message queue group will include three message queues, corresponding to the video transcoding task, the video rendering task, and the face recognition task;
需要说明的是, 可以预先配置所述任务消息队列组, 配置所述任务消息队 列组的主体既可以是专用的硬件设备, 也可以是该分布式任务处理系统中的任 一任务处理节点;  It should be noted that the task message queue group may be configured in advance, and the body of the task message queue group may be configured as a dedicated hardware device or any task processing node in the distributed task processing system;
还需说明的是, 还可以预先配置一个全局消息队列组, 该全局消息队列组 中的每个消息队列存储所述系统承载的一种处理任务, 所述任务处理节点根据 自身承载的处理任务类型, 从所述全局消息队列中选择与所述任务处理节点自 身承载的处理任务的类型关联的消息队列, 组成所述任务消息队列组。  It should be noted that a global message queue group may also be pre-configured, and each message queue in the global message queue group stores a processing task carried by the system, and the task processing node according to the type of processing task carried by the task processing node And selecting, from the global message queue, a message queue associated with the type of the processing task carried by the task processing node itself, to form the task message queue group.
本发明实施例提供的一种基于消息队列的分布式任务调度方法, 不同类型 的任务被分配在不同的消息队列中, 与现有技术相比, 本发明实施例不需对消 息队列中的处理任务按优先级顺序进行排序, 消除了因排序而造成的系统开 销, 提高了系统工作的效率, 其次, 与现有技术相比, 一个消息队列只保存一 种类型的处理任务, 只需增加消息队列即可处理其他类型的处理任务, 业务扩 展性强。 如图 4所示, 为本发明实施例提供的一种基于消息队列的分布式任务处理 的方法实现流程图, 具体包括:  A message queue-based distributed task scheduling method is provided in the embodiment of the present invention. Different types of tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to process the message queue. Tasks are sorted in order of priority, eliminating system overhead caused by sorting and improving the efficiency of system work. Secondly, compared with the prior art, a message queue only stores one type of processing task, and only needs to add messages. The queue can handle other types of processing tasks, and the business is highly scalable. As shown in FIG. 4, a flow chart of a method for implementing distributed task processing based on message queues according to an embodiment of the present invention includes:
S401 : 任务分割节点接收原始任务;  S401: The task splitting node receives the original task;
S402: 任务分割节点对所述原始任务进行分割得到至少一个处理任务, 并 对与所述原始任务关联的数据文件进行相应的分割得到至少一个分片, 使得每 个处理任务都对应一个与该处理任务相匹配的分片;  S402: The task segmentation node divides the original task to obtain at least one processing task, and performs corresponding segmentation on the data file associated with the original task to obtain at least one fragment, so that each processing task corresponds to one and the processing a shard that matches the task;
例如, 所述任务分割节点把所述原始任务分割为三个处理任务, 则所述任 务分割节点将把与所述原始任务对应的数据文件分割为与所述三个处理任务 对应的分片, 每个分片对应于一个处理任务;  For example, the task segmentation node divides the original task into three processing tasks, and the task segmentation node divides the data file corresponding to the original task into segments corresponding to the three processing tasks. Each slice corresponds to a processing task;
其中, 需要说明的是, 分割后的每一个处理任务均携带了完整的任务调度 信息以及执行信息, 以便于任务处理节点获取处理任务后即可顺利执行; 在此, 需要说明的是, 本发明实施例并不限定保存在消息队列中的处理任 务的具体表现形式, 作为示例而不是限定, 一种视频转码任务的表现形式可以 是如下的形式: Among them, it should be noted that each processed task after segmentation carries a complete task schedule. The information and the execution information can be executed smoothly after the task processing node obtains the processing task. Here, it should be noted that the embodiment of the present invention does not limit the specific expression of the processing task saved in the message queue, as an example. Not limited, a video transcoding task can be expressed in the following form:
{  {
"userid": "UserlD",  "userid": "UserlD",
"userkey": "UserKey",  "userkey": "UserKey",
"action": "Action",  "action": "Action",
"jobid": "JobID",  "jobid": "JobID",
"subjobid": "SubJobID",  "subjobid": "SubJobID",
"jobdescribe": "describe",  "jobdescribe": "describe",
"SLAtime": "SLA time",  "SLAtime": "SLA time",
"source": ["SourceFile", "SourceFile2", ... , "SourceFileN"], "source": ["SourceFile", "SourceFile2", ... , "SourceFileN"],
"sourcerun": ["SourceRunl", "SourceRun2", ... , "SourceRunN"], "streamtype":["typel", "type2",. . . "typeN"], "sourcerun": ["SourceRunl", "SourceRun2", ... , "SourceRunN"], "streamtype":["typel", "type2",. . . "typeN"],
"notify": "NotifyURL",  "notify": "NotifyURL",
"splitduration": "Split duration",  "splitduration": "Split duration",
"splitsize": "Split size",  "splitsize": "Split size",
"splitaudio": "yes|no",  "splitaudio": "yes|no",
"sourceduration": "sourceduration",  "sourceduration": "sourceduration",
"iserror": "errorcode",  "iserror": "errorcode",
"format":  "format":
[  [
{  {
"output": "Output format",  "output": "Output format",
"destination": "DestFile",  "destination": "DestFile",
"video— codec": "Video Codec",  "video_codec": "Video Codec",
"audio codec": "Audio Codec", "bitrate": "Video bitrate", "audio codec": "Audio Codec", "bitrate": "Video bitrate",
"framerate": "Frame rate",  "framerate": "Frame rate",
"audio— bitrate": "Audio bitrate",  "audio-bitrate": "Audio bitrate",
"audio— sample— rate": "Audio quality", "audio_sample- rate": "Audio quality",
"audio— volume": "Volume", "audio_ volume": "Volume",
"size": "Size",  "size": "Size",
"crop— left": "Crop Left",  "crop- left": "Crop Left",
"crop— top": "Crop Top",  "crop- top": "Crop Top",
"crop— right": "Crop Right",  "crop-right": "Crop Right",
"crop— bottom": "Crop Bottom",  "crop_ bottom": "Crop Bottom",
"keep— aspect— ratio": "yes/no",  "keep- aspect- ratio": "yes/no",
"set— aspect— ratio": "ASPECT— RATIO", "set- aspect- ratio": "ASPECT- RATIO",
"add_meta": "yes/no", "add_meta": "yes/no",
"hint": "yes/no",  "hint": "yes/no",
"rc—init— occupancy": "RC Occupancy", "minrate": "Min Rate",  "rc_init_occupation": "RC Occupancy", "minrate": "Min Rate",
"maxrate": "Max Rate", "maxrate": "Max Rate",
"bufsize": "RC Buffer Size", "bufsize": "RC Buffer Size",
"keyframe": "Keyframe Period (GOP)", "start": "Start From", "keyframe": "Keyframe Period (GOP)", "start": "Start From",
"duration": "Result Duration", "duration": "Result Duration",
"fragment— duration": "Fragment Duration' "quality_speed_balance": "balance", "metadata": "fragment_ duration": "Fragment Duration' "quality_speed_balance": "balance", "metadata":
{  {
"title": "Title",  "title": "Title",
"copyright": "Copyright",  "copyright": "Copyright",
"author": "Author",  "author": "Author",
"description": "Description", "album": "Album" "description": "Description", "album": "Album"
},  },
"profile": "high/main/baseline",  "profile": "high/main/baseline",
"turbo": "yes/no",  "turbo": "yes/no",
}  }
]  ]
}  }
还需要说明的是, 本发明实施例提供的任务分割节点既可以是专用的硬件 设备, 也可以是分布式任务处理系统中的任一个任务处理节点, 还可以是调度 器;  It should be noted that the task splitting node provided by the embodiment of the present invention may be a dedicated hardware device, a task processing node in a distributed task processing system, or a scheduler.
需要进一步说明的是, 本发明实施例并不限定对原始任务进行分割的方 法, 作为示例而非限定, 可以根据原始任务关联的数据文件的具体格式, 将所 述原始任务分割为处理任务, 并对数据文件进行相应的分割;  It should be further noted that the embodiment of the present invention does not limit the method for dividing the original task. As an example and not by way of limitation, the original task may be divided into processing tasks according to a specific format of the data file associated with the original task, and Perform corresponding segmentation on the data file;
S403: 所述任务分割节点向调度器发送分割后的处理任务;  S403: The task splitting node sends the split processing task to the scheduler.
S404: 所述调度器接收到处理任务后, 根据所述处理任务的类型将所述处 理任务推送至任务消息队列组中与所述处理任务的类型关联的消息队列, 等待 任务处理节点处理;  S404: After receiving the processing task, the scheduler pushes the processing task to a message queue associated with the type of the processing task in the task message queue group according to the type of the processing task, and waits for the task processing node to process;
其中, 所述任务消息队列组中的每个消息队列存储所述任务处理节点承载 的一种处理任务, 例如, 若所述任务处理节点承载的处理任务包括视频转码任 务、 视频渲染任务以及人脸识别任务, 则该任务消息队列组将包含三个消息队 列, 分别对应视频转码任务、 视频渲染任务以及人脸识别任务;  Each of the task message queue groups stores a processing task carried by the task processing node, for example, if the processing tasks carried by the task processing node include a video transcoding task, a video rendering task, and a person For the face recognition task, the task message queue group will include three message queues corresponding to the video transcoding task, the video rendering task, and the face recognition task;
需要说明的是, 可以预先配置所述任务消息队列组, 配置所述任务消息队 列组的主体既可以是专用的硬件设备, 也可以是该分布式任务处理系统中的任 一任务处理节点;  It should be noted that the task message queue group may be configured in advance, and the body of the task message queue group may be configured as a dedicated hardware device or any task processing node in the distributed task processing system;
还需说明的是, 还可以预先配置一个全局消息队列组, 该全局消息队列组 中的每个消息队列存储所述系统承载的一种处理任务, 所述任务处理节点根据 自身承载的处理任务类型, 从所述全局消息队列中选择与所述任务处理节点自 身承载的处理任务的类型关联的消息队列, 组成所述任务消息队列组; It should be noted that a global message queue group may also be pre-configured, and each message queue in the global message queue group stores a processing task carried by the system, and the task processing node is configured according to A message queue associated with the type of the processing task carried by the task processing node itself is selected from the global message queue to form the task message queue group;
S405 : 任务处理节点根据自身承载的处理任务的优先级级别, 确定存储所 述处理任务的消息队列的优先级级别;  S405: The task processing node determines, according to a priority level of the processing task carried by the task, a priority level of the message queue storing the processing task.
其中, 需要说明的是, 本发明实施例提供的所述任务处理节点确定自身承 载的处理任务的优先级的方式, 可以包括以下任一方式:  It should be noted that, in the manner that the task processing node according to the embodiment of the present invention determines the priority of the processing task carried by the task processing node, the method may include any one of the following methods:
方式一: 所述任务处理节点根据业务需求确定所述任务处理节点承载的处 理任务的优先级级别; 例如, 所述任务处理节点承载的处理任务包括视频转码 任务、 视频渲染任务以及人脸识别任务, 但该任务处理节点承载的主要处理任 务为视频转码任务, 其次为视频渲染任务, 再次为人脸识别任务, 则, 该任务 处理节点确定优先级级别最高的消息队列为存储视频转码任务的消息队列, 次 高优先级级别的消息队列为存储视频渲染任务的消息队列, 低优先级级别的消 息队列为存储人脸识别任务的消息队列;  Manner 1: The task processing node determines a priority level of the processing task carried by the task processing node according to the service requirement; for example, the processing task carried by the task processing node includes a video transcoding task, a video rendering task, and a face recognition. The task, but the main processing task carried by the task processing node is a video transcoding task, followed by a video rendering task, and again a face recognition task, then the task processing node determines that the message queue with the highest priority level is a stored video transcoding task. Message queue, the second highest priority message queue is a message queue for storing video rendering tasks, and the low priority level message queue is a message queue for storing face recognition tasks;
方式二: 预先设置所述处理任务的优先级级别, 其中, 需要说明的是, 所 述预先设置所述处理任务的优先级级别的主体既可以是专用的硬件设备, 也可 以是所述任务处理节点;  Manner 2: The priority level of the processing task is set in advance, wherein, the entity that presets the priority level of the processing task may be a dedicated hardware device or the task processing. Node
需要进一步说明的是, 本步骤 S405可以在步骤 S401至步骤 S404中任一 步骤之前、 之后或同时执行, 并没有先后顺序;  It should be further noted that the step S405 can be performed before, after or simultaneously with any of the steps S401 to S404, and there is no sequence;
S406: 所述任务处理节点按照优先级级别由高到低的顺序, 从优先级级别 最高的消息队列开始依次扫描所述任务消息队列组中的消息队列, 若扫描到包 含处理任务的消息队列, 执行步骤 S407 , 否则, 重复本步骤 S406;  S406: The task processing node sequentially scans the message queues in the task message queue group from the message queue with the highest priority level according to the priority level of the priority level. If the message queue containing the processing task is scanned, Step S407 is performed, otherwise, step S406 is repeated;
其中, 需要说明的是, 如图 4所示, 本步骤 S406可进一步细分为 S406a, S406b, S406c, S406d四个步骤, 如下所示:  It should be noted that, as shown in FIG. 4, this step S406 can be further subdivided into four steps S406a, S406b, S406c, and S406d, as follows:
S406a: 所述任务处理节点扫描所述所述任务消息队列组中优先级级别最 高的消息队列; 例如, 若优先级级别最高的消息队列为存储视频转码任务的消息队列, 则 所述任务处理节点首先扫描该存储视频转码任务的消息队列; S406a: The task processing node scans a message queue with the highest priority level in the task message queue group; For example, if the message queue with the highest priority level is the message queue storing the video transcoding task, the task processing node first scans the message queue of the stored video transcoding task;
S406b: 所述任务处理节点判断所扫描的消息队列是否包含处理任务, 若 是, 则执行步骤 S407 , 否则, 执行步骤 S406c;  S406b: The task processing node determines whether the scanned message queue contains a processing task, and if so, step S407 is performed, otherwise, step S406c is performed;
S406c: 所述任务处理节点判断所扫描的消息队列的优先级级别是否最低, 若是, 则返回步骤 S406a, 否则, 执行步骤 S406d;  S406c: The task processing node determines whether the priority level of the scanned message queue is the lowest, and if yes, returns to step S406a, otherwise, step S406d;
其中, 需要说明的是, 若所述任务处理节点当前扫描的消息队列为优先级 级别最低的消息队列, 则所述任务处理节点从优先级级别最高的消息队列开始 重新扫描消息队列;  It should be noted that, if the message queue currently scanned by the task processing node is the message queue with the lowest priority level, the task processing node rescans the message queue from the message queue with the highest priority level;
S406d: 所述任务处理节点按照优先级由高到低的顺序, 扫描所述任务消 息队列组中下一个消息队列, 并返回步骤 S406b;  S406d: The task processing node scans the next message queue in the task message queue group according to the order of priority from high to low, and returns to step S406b;
其中, 需要说明的是, 若优先级级别最高的消息队列没有存储处理任务, 所述任务处理节点按照优先级级别由高到低的顺序, 扫描次优先级级别的消息 队列;  It should be noted that, if the message queue with the highest priority level does not store the processing task, the task processing node scans the message queue of the secondary priority level according to the order of priority level from high to low;
需要进一步说明的是, 所述任务处理节点在首次扫描到包含处理任务的消 息队列时, 即执行步骤 S407;  It should be further noted that, when the task processing node first scans the message queue including the processing task, step S407 is performed;
S407: 所述任务处理节点获取当前处理任务, 并执行所述当前处理任务, 执行完之后返回步骤 S406, 其中, 所述当前处理任务存储在所述包含处理任务 的消息队列中;  S407: The task processing node acquires the current processing task, and executes the current processing task. After the execution, the process returns to step S406, where the current processing task is stored in the message queue that includes the processing task.
其中, 需要说明的是, 本发明实施例提供的所述任务处理节点获取所述当 前处理任务, 并执行所述当前处理任务的方式, 可以包括以下任一方式:  It should be noted that, in the manner that the task processing node obtains the current processing task and performs the current processing task, the method may include any one of the following methods:
方式一: 所述任务处理节点获取所述包含处理任务的消息队列中未被执行 的任一处理任务, 并执行所述未被执行的任一处理任务; 例如, 若该包含处理 任务的消息队列包含 5个处理任务, 则从所述 5个处理任务中随机获取一个处 理任务作为当前处理任务, 并执行该随机获取的当前处理任务; 方式二: 所述任务处理节点获取所述包含处理任务的消息队列中未被执行 的队首处理任务, 并执行所述未被执行的队首处理任务; 例如, 若该包含处理 任务的消息队列包含 5个处理任务, 则选择位于消息队列队首的处理任务为当 前处理任务, 使得按照先进先出的顺序执行同一类型的处理任务; Manner 1: The task processing node acquires any processing task that is not executed in the message queue that includes the processing task, and executes any processing task that is not executed; for example, if the message queue includes the processing task Include five processing tasks, randomly acquiring one processing task from the five processing tasks as a current processing task, and executing the randomly acquired current processing task; Manner 2: the task processing node acquires an unexecuted team head processing task in the message queue that includes the processing task, and executes the unexecuted team head processing task; for example, if the message queue including the processing task is included Including five processing tasks, the processing task located at the head of the message queue is selected as the current processing task, so that the same type of processing tasks are executed in the first-in first-out order;
需要进一步说明的是, 在所述任务处理节点获取所述当前处理任务之后, 所述包含该当前处理任务的消息队列将所述当前处理任务删除。  It should be further noted that, after the task processing node acquires the current processing task, the message queue including the current processing task deletes the current processing task.
本发明实施例提供的一种基于消息队列的分布式任务处理的方法, 不同类 型的处理任务被分配在不同的消息队列中, 与现有技术相比, 本发明实施例不 需对消息队列中的处理任务按优先级顺序进行排序, 消除了因排序而造成的系 统开销, 提高了系统工作的效率, 其次, 与现有技术相比, 一个消息队列只保 存一种类型的处理任务, 只需增加消息队列即可处理其他类型的处理任务, 业 务扩展性强, 另外, 处理任务的优先级可由任务处理节点根据业务需要动态确 定, 保证了在整个任务处理的过程中紧急的业务可以获得较高的优先级, 使得 任务处理节点处理任务更加灵活, 再次, 对原始任务进行分割得到至少一个处 理任务, 使得当前处理任务不会长时间占用任务处理节点的资源, 保证了任务 处理节点的资源不被阻塞, 能够及时执行高优先级的处理任务。 如图 5所示, 为本发明实施例提供的一种基于消息队列的分布式任务处理 的方法实现流程图, 该实施例应用于分布式视频任务处理系统, 具体包括: A method for processing a distributed task based on a message queue is provided in the embodiment of the present invention. Different types of processing tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to be in a message queue. The processing tasks are sorted in order of priority, which eliminates the system overhead caused by sorting and improves the efficiency of the system work. Secondly, compared with the prior art, a message queue only stores one type of processing tasks, only Adding a message queue can handle other types of processing tasks, and the service scalability is strong. In addition, the priority of the processing task can be dynamically determined by the task processing node according to the business needs, ensuring that the emergency service can be obtained higher during the entire task processing process. The priority of the task processing node is more flexible, and again, the original task is segmented to obtain at least one processing task, so that the current processing task does not occupy the resources of the task processing node for a long time, and the resources of the task processing node are not guaranteed. Blocking, able to execute high-quality in time The first level of processing tasks. As shown in FIG. 5, it is a flow chart of a method for implementing distributed message processing based on a message queue according to an embodiment of the present disclosure. The embodiment is applied to a distributed video task processing system, and specifically includes:
S501 : 任务分割节点接收原始任务, 在本实施例中, 所述原始任务为原始 视频任务; S501: The task splitting node receives the original task. In this embodiment, the original task is an original video task.
S502: 任务分割节点对所述原始视频任务进行分割得到至少一个处理任 务, 并对与所述原始视频任务关联的数据文件进行相应的分割得到至少一个分 片,使得每个处理任务都对应一个与该处理任务相匹配的分片,在本实施例中, 所述处理任务为视频处理任务;  S502: The task splitting node splits the original video task to obtain at least one processing task, and performs corresponding segmentation on the data file associated with the original video task to obtain at least one fragment, so that each processing task corresponds to one The processing task is matched with the fragmentation. In this embodiment, the processing task is a video processing task.
例如, 所述任务分割节点把所述原始视频任务分割为三个视频处理任务, 所述三个视频处理任务对应的分片, 每个分片对应于一个视频处理任务; 其中, 需要说明的是, 分割后的每一个视频处理任务均携带了完整的任务 调度信息以及执行信息, 以便于任务处理节点获取视频处理任务后即可顺利执 行; For example, the task splitting node divides the original video task into three video processing tasks. Each of the three video processing tasks corresponds to a video processing task; wherein, each of the video processing tasks after the segmentation carries complete task scheduling information and execution information, So that the task processing node can smoothly execute after acquiring the video processing task;
在此, 需要说明的是, 本发明实施例并不限定保存在消息队列中的视频处 理任务的具体表现形式, 作为示例而不是限定, 一种视频转码任务的表现形式 可以是如下的形式:  It should be noted that the embodiment of the present invention does not limit the specific expression of the video processing task stored in the message queue. As an example and not by way of limitation, a video transcoding task may be in the following form:
{  {
"userid": "UserlD",  "userid": "UserlD",
"userkey": "UserKey",  "userkey": "UserKey",
"action": "Action",  "action": "Action",
"jobid": "JobID",  "jobid": "JobID",
"subjobid": "SubJobID",  "subjobid": "SubJobID",
"jobdescribe": "describe",  "jobdescribe": "describe",
"SLAtime": "SLA time",  "SLAtime": "SLA time",
"source": ["SourceFile", "SourceFile2", ... , "SourceFileN"], "source": ["SourceFile", "SourceFile2", ... , "SourceFileN"],
"sourcerun": ["SourceRunl", "SourceRun2", ... , "SourceRunN"],"sourcerun": ["SourceRunl", "SourceRun2", ... , "SourceRunN"],
"streamtype":["typel", "type2",. . . "typeN"], "streamtype":["typel", "type2",. . . "typeN"],
"notify": "NotifyURL",  "notify": "NotifyURL",
"splitduration": "Split duration",  "splitduration": "Split duration",
"splitsize": "Split size",  "splitsize": "Split size",
"splitaudio": "yes|no",  "splitaudio": "yes|no",
"sourceduration": "sourceduration",  "sourceduration": "sourceduration",
"iserror": "errorcode",  "iserror": "errorcode",
"format":  "format":
[  [
{ "output": "Output format", { "output": "Output format",
"destination": "DestFile",  "destination": "DestFile",
"video— codec": "Video Codec",  "video_codec": "Video Codec",
"audio— codec": "Audio Codec",  "audio_codec": "Audio Codec",
"bitrate": "Video bitrate",  "bitrate": "Video bitrate",
"framerate": "Frame rate",  "framerate": "Frame rate",
"audio— bitrate": "Audio bitrate",  "audio-bitrate": "Audio bitrate",
"audio— sample— rate": "Audio quality", "audio_sample- rate": "Audio quality",
"audio— volume": "Volume", "audio_ volume": "Volume",
"size": "Size",  "size": "Size",
"crop— left": "Crop Left",  "crop- left": "Crop Left",
"crop— top": "Crop Top",  "crop- top": "Crop Top",
"crop— right": "Crop Right",  "crop-right": "Crop Right",
"crop— bottom": "Crop Bottom",  "crop_ bottom": "Crop Bottom",
"keep— aspect— ratio": "yes/no",  "keep- aspect- ratio": "yes/no",
"set— aspect— ratio": "ASPECT— RATIO", "set- aspect- ratio": "ASPECT- RATIO",
"add_meta": "yes/no", "add_meta": "yes/no",
"hint": "yes/no",  "hint": "yes/no",
"rc—init— occupancy": "RC Occupancy", "minrate": "Min Rate",  "rc_init_occupation": "RC Occupancy", "minrate": "Min Rate",
"maxrate": "Max Rate", "maxrate": "Max Rate",
"bufsize": "RC Buffer Size", "bufsize": "RC Buffer Size",
"keyframe": "Keyframe Period (GOP)", "start": "Start From", "keyframe": "Keyframe Period (GOP)", "start": "Start From",
"duration": "Result Duration", "duration": "Result Duration",
"fragment— duration": "Fragment Duration' "quality_speed_balance": "balance", "metadata": "fragment_ duration": "Fragment Duration' "quality_speed_balance": "balance", "metadata":
{ "title": "Title", { "title": "Title",
"copyright": "Copyright",  "copyright": "Copyright",
"author": "Author",  "author": "Author",
"description": "Description",  "description": "Description",
"album": "Album"  "album": "Album"
},  },
"profile": "high/main/baseline",  "profile": "high/main/baseline",
"turbo": "yes/no",  "turbo": "yes/no",
}  }
]  ]
}  }
需要说明的是,所述任务分割节点对原始任务进行分割的方式,具体包括: 所述任务分割节点根据预先设置的分割策略对原始视频任务进行分割得 到至少一个视频处理任务, 并在 I帧的位置对与所述原始视频任务关联的视频 数据文件进行分割得到至少一个分片, 其中, 所述分割策略需保证在 I帧的位 置对视频数据文件进行分割;  It should be noted that, the manner in which the task splitting node splits the original task specifically includes: the task splitting node splits the original video task according to a preset splitting strategy to obtain at least one video processing task, and is in an I frame. Separating the video data file associated with the original video task to obtain at least one fragment, wherein the segmentation strategy needs to ensure that the video data file is segmented at the position of the I frame;
其中, 需要指出的是, 所述 I帧为画面组(Group Of Pictures, 简称: GOP ) 中的第一个帧, 可作为随机访问的参考点;  It should be noted that the I frame is the first frame in the Group Of Pictures (GOP), and can be used as a reference point for random access;
需要进一步说明的是, 本发明实施例提供的任务分割节点既可以是专用的 硬件设备, 也可以是分布式任务处理系统中的任一个任务处理节点, 还可以是 调度器;  It should be further noted that the task splitting node provided by the embodiment of the present invention may be a dedicated hardware device, a task processing node in a distributed task processing system, or a scheduler.
S503: 所述任务分割节点向调度器发送分割后的视频处理任务;  S503: The task segmentation node sends the segmented video processing task to the scheduler.
S504: 所述调度器接收到视频处理任务后, 根据所述视频处理任务的类型 将所述视频处理任务推送至任务消息队列组中与所述视频处理任务的类型关 联的消息队列, 等待任务处理节点处理;  S504: After receiving the video processing task, the scheduler pushes the video processing task to a message queue associated with the type of the video processing task in the task message queue group according to the type of the video processing task, and waits for task processing. Node processing
其中, 所述任务消息队列组中的每个消息队列存储所述任务处理节点承载 的一种视频处理任务, 例如, 若所述任务处理节点承载的视频处理任务包括视 频转码任务、 视频渲染任务以及人脸识别任务, 则该任务消息队列组将包含三 个消息队列, 分别对应视频转码任务、 视频渲染任务以及人脸识别任务; Each of the task message queues stores a video processing task carried by the task processing node, for example, if the video processing task carried by the task processing node includes The frequency transcoding task, the video rendering task, and the face recognition task, the task message queue group will include three message queues corresponding to the video transcoding task, the video rendering task, and the face recognition task;
需要说明的是, 可以预先配置所述任务消息队列组, 配置所述任务消息队 列组的主体既可以是专用的硬件设备, 也可以是该分布式任务处理系统中的任 一任务处理节点;  It should be noted that the task message queue group may be configured in advance, and the body of the task message queue group may be configured as a dedicated hardware device or any task processing node in the distributed task processing system;
还需说明的是, 还可以预先配置一个全局消息队列组, 该全局消息队列组 中的每个消息队列存储所述系统承载的一种视频处理任务, 所述任务处理节点 根据自身承载的视频处理任务类型, 从所述全局消息队列中选择与所述任务处 理节点自身承载的视频处理任务的类型关联的消息队列, 组成所述任务消息队 列组;  It should be noted that a global message queue group may also be pre-configured, and each message queue in the global message queue group stores a video processing task carried by the system, and the task processing node processes the video according to its own bearer. a task type, selecting, from the global message queue, a message queue associated with a type of a video processing task carried by the task processing node itself, to form the task message queue group;
S505 : 任务处理节点根据自身承载的视频处理任务的优先级级别, 确定存 储视频处理任务的消息队列的优先级级别;  S505: The task processing node determines, according to a priority level of the video processing task carried by the task processing node, a priority level of the message queue for storing the video processing task.
其中, 需要说明的是, 本发明实施例提供的所述任务处理节点确定自身承 载的视频处理任务的优先级的方式, 可以包括以下任一方式:  It should be noted that the manner in which the task processing node determines the priority of the video processing task carried by the task processing node provided by the embodiment of the present invention may include any one of the following methods:
方式一: 所述任务处理节点根据业务需求确定所述任务处理节点承载的视 频处理任务的优先级级别; 例如, 所述任务处理节点承载的视频处理任务包括 视频转码任务、 视频渲染任务以及人脸识别任务, 但该任务处理节点承载的主 要视频处理任务为视频转码任务,其次为视频渲染任务,再次为人脸识别任务, 则, 该任务处理节点确定优先级级别最高的消息队列为存储视频转码任务的消 息队列, 次高优先级级别的消息队列为存储视频渲染任务的消息队列, 低优先 级级别的消息队列为存储人脸识别任务的消息队列;  Manner 1: The task processing node determines a priority level of the video processing task carried by the task processing node according to the service requirement; for example, the video processing task carried by the task processing node includes a video transcoding task, a video rendering task, and a person The face recognition task, but the main video processing task carried by the task processing node is a video transcoding task, followed by a video rendering task, and again a face recognition task, then the task processing node determines that the message queue with the highest priority level is a stored video. The message queue of the transcoding task, the message queue of the second highest priority level is a message queue for storing the video rendering task, and the message queue of the low priority level is a message queue for storing the face recognition task;
方式二: 预先设置所述视频处理任务的优先级级别, 其中, 需要说明的是, 所述预先设置所述视频处理任务的优先级级别的主体既可以是专用的硬件设 备, 也可以是所述任务处理节点;  Manner 2: The priority level of the video processing task is set in advance, wherein, the entity that presets the priority level of the video processing task may be a dedicated hardware device, or may be Task processing node;
需要进一步说明的是, 本步骤 S505可以在步骤 S501至步骤 S504中任一 步骤之前、 之后或同时执行, 并没有先后顺序; It should be further noted that this step S505 can be any of steps S501 to S504. Before, after or at the same time, there is no order;
S506: 所述任务处理节点按照优先级级别由高到低的顺序, 从优先级级别 最高的消息队列开始依次扫描所述任务消息队列组中的消息队列, 若扫描到包 含视频处理任务的消息队列, 执行步骤 S507 , 否则, 重复本步骤 S506;  S506: The task processing node sequentially scans the message queue in the task message queue group from the message queue with the highest priority level according to the priority level from high to low, and scans the message queue that includes the video processing task. , step S507 is performed, otherwise, step S506 is repeated;
其中, 需要说明的是, 如图 5所示, 本步骤 S506可进一步细分为 S506a, It should be noted that, as shown in FIG. 5, this step S506 can be further subdivided into S506a,
S506b, S506c, S506d四个步骤, 如下所示: S506b, S506c, S506d four steps, as follows:
S506a: 所述任务处理节点扫描所述所述任务消息队列组中优先级级别最 高的消息队列;  S506a: The task processing node scans a message queue with the highest priority level in the task message queue group;
例如, 若优先级级别最高的消息队列为存储视频转码任务的消息队列, 则 所述任务处理节点首先扫描该存储视频转码任务的消息队列;  For example, if the message queue with the highest priority level is the message queue storing the video transcoding task, the task processing node first scans the message queue of the stored video transcoding task;
S506b: 所述任务处理节点判断所扫描的消息队列是否包含视频处理任务, 若是, 则执行步骤 S507 , 否则, 执行步骤 S506c;  S506b: The task processing node determines whether the scanned message queue contains a video processing task, and if so, step S507 is performed, otherwise, step S506c is performed;
S506c: 所述任务处理节点判断所扫描的消息队列的优先级级别是否最低, 若是, 则返回步骤 S506a, 否则, 执行步骤 S506d;  S506c: The task processing node determines whether the priority level of the scanned message queue is the lowest, and if yes, returns to step S506a, otherwise, step S506d;
其中, 需要说明的是, 若所述任务处理节点当前扫描的消息队列为优先级 级别最低的消息队列, 则所述任务处理节点从优先级级别最高的消息队列开始 重新扫描消息队列;  It should be noted that, if the message queue currently scanned by the task processing node is the message queue with the lowest priority level, the task processing node rescans the message queue from the message queue with the highest priority level;
S506d: 所述任务处理节点按照优先级由高到低的顺序, 扫描所述任务消 息队列组中下一个消息队列, 并返回步骤 S506b;  S506d: The task processing node scans the next message queue in the task message queue group according to the order of priority from high to low, and returns to step S506b;
其中, 需要说明的是, 若优先级级别最高的消息队列没有存储视频处理任 务, 所述任务处理节点按照优先级级别由高到低的顺序, 扫描次优先级级别的 消息队列;  It should be noted that, if the message queue with the highest priority level does not store the video processing task, the task processing node scans the message queue of the secondary priority level according to the order of priority level from high to low;
需要进一步说明的是, 所述任务处理节点在首次扫描到包含视频处理任务 的消息队列时, 即执行步骤 S507;  It should be further noted that, when the task processing node first scans the message queue including the video processing task, step S507 is performed;
S507: 所述任务处理节点获取当前处理任务, 并执行所述当前处理任务, 执行完之后返回步骤 S506, 本发明实施例中, 所述当前处理任务为当前视频处 理任务, 所述当前视频任务存储在所述包含视频处理任务的消息队列中; 其中, 需要说明的是, 本发明实施例提供的所述任务处理节点获取所述当 前视频处理任务, 并执行所述当前视频处理任务的方式, 可以包括以下任一方 式: S507: The task processing node acquires a current processing task, and executes the current processing task. After the execution, the process returns to step S506. In the embodiment of the present invention, the current processing task is a current video processing task, and the current video task is stored in the message queue including the video processing task. The manner in which the task processing node obtains the current video processing task and performs the current video processing task may include any one of the following methods:
方式一: 所述任务处理节点获取所述包含视频处理任务的消息队列中未被 执行的任一视频处理任务, 并执行所述未被执行的任一视频处理任务; 例如, 若该包含处理任务的消息队列包含 5个视频处理任务, 则从所述 5个视频处理 任务中随机获取一个视频处理任务作为当前视频处理任务, 并执行该随机获取 的当前视频处理任务;  Manner 1: The task processing node acquires any video processing task that is not executed in the message queue that includes the video processing task, and executes any video processing task that is not executed; for example, if the processing task is included The message queue includes five video processing tasks, and randomly acquires one video processing task from the five video processing tasks as a current video processing task, and executes the randomly acquired current video processing task;
方式二: 所述任务处理节点获取所述包含视频处理任务的消息队列中未被 执行的队首视频处理任务, 并执行所述未被执行的队首视频处理任务; 例如, 若该包含视频处理任务的消息队列包含 5个视频处理任务, 则选择位于消息队 列队首的视频处理任务为当前视频处理任务, 使得按照先进先出的顺序执行同 一类型的视频处理任务;  Manner 2: The task processing node acquires a team head video processing task that is not executed in the message queue that includes the video processing task, and executes the unexecuted team head video processing task; for example, if the video processing is included The message queue of the task includes five video processing tasks, and then the video processing task located at the head of the message queue is selected as the current video processing task, so that the same type of video processing task is executed in the first-in first-out order;
需要进一步说明的是, 在所述任务处理节点获取所述当前视频处理任务之 后, 所述包含该当前视频处理任务的消息队列将所述当前视频处理任务删除。  It should be further noted that, after the task processing node acquires the current video processing task, the message queue including the current video processing task deletes the current video processing task.
本发明实施例提供的一种基于消息队列的分布式任务处理的方法, 不同类 型的视频处理任务被分配在不同的消息队列中, 与现有技术相比, 本发明实施 例不需对消息队列中的视频处理任务按优先级顺序进行排序, 消除了因排序而 造成的系统开销, 提高了系统工作的效率, 其次, 与现有技术相比, 一个消息 队列只保存一种类型的视频处理任务, 只需增加消息队列即可处理其他类型的 视频处理任务, 业务扩展性强, 另外, 视频处理任务的优先级可由任务处理节 点根据业务需要动态确定, 保证了在整个任务处理的过程中紧急的视频业务可 以获得较高的优先级, 使得任务处理节点处理视频任务更加灵活, 再次, 对原 始视频任务进行分割得到至少一个视频处理任务, 使得当前视频处理任务不会 长时间占用任务处理节点的资源, 保证了任务处理节点的资源不被阻塞, 能够 及时执行高优先级的视频处理任务。 如图 6所示, 为本发明实施例提供的一种任务处理节点, 包括: 消息队列优先级级别确定单元 601 , 用于按照自身承载的处理任务的优先 级级别, 确定存储所述处理任务的消息队列的优先级级别; A method for processing a distributed task based on a message queue is provided in the embodiment of the present invention. Different types of video processing tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to use a message queue. The video processing tasks are sorted in priority order, which eliminates the system overhead caused by sorting and improves the efficiency of the system work. Secondly, compared with the prior art, a message queue only stores one type of video processing task. Only need to increase the message queue to handle other types of video processing tasks, and the service scalability is strong. In addition, the priority of the video processing task can be dynamically determined by the task processing node according to the business needs, ensuring emergency in the whole task processing process. Video services can get higher priority, making the task processing node more flexible in processing video tasks. The initial video task is segmented to obtain at least one video processing task, so that the current video processing task does not occupy the resources of the task processing node for a long time, ensures that the resources of the task processing node are not blocked, and can perform high-priority video processing tasks in time. As shown in FIG. 6, a task processing node according to an embodiment of the present invention includes: a message queue priority level determining unit 601, configured to determine, according to a priority level of a processing task carried by itself, to store the processing task. The priority level of the message queue;
扫描单元 602, 用于根据所述消息队列优先级级别确定单元 601确定的所 述消息队列的优先级级别, 按照优先级级别由高到低的顺序, 从优先级级别最 高的消息队列开始依次扫描任务消息队列组中的消息队列;  The scanning unit 602 is configured to scan according to the priority level of the message queue determined by the message queue priority level determining unit 601, in order of priority level from highest to lowest, starting from the message queue with the highest priority level. a message queue in the task message queue group;
任务执行单元 603 , 用于在所述扫描单元 602扫描到包含处理任务的消息 队列时, 获取当前处理任务, 并执行所述当前处理任务, 其中, 所述当前处理 任务存储在所述包含处理任务的消息队列中。  The task execution unit 603 is configured to: when the scanning unit 602 scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the included processing task In the message queue.
其中, 需要说明的是, 本发明实施例提供的任务处理节点还包括: 处理任务优先级级别确定单元, 用于根据业务需求确定任务处理节点承载 的处理任务的优先级级别, 或者, 预先设置所述处理任务的优先级级别, 以便 所述消息队列优先级级别确定单元 601确定所述任务消息队列组中消息队列的 优先级级别。  It should be noted that, the task processing node provided by the embodiment of the present invention further includes: a processing task priority level determining unit, configured to determine, according to the service requirement, a priority level of the processing task carried by the task processing node, or pre-set The priority level of the processing task is described, so that the message queue priority level determining unit 601 determines the priority level of the message queue in the task message queue group.
需要说明的是, 本发明实施例提供的任务处理节点还包括:  It should be noted that the task processing node provided by the embodiment of the present invention further includes:
分割单元, 用于对原始任务进行分割得到至少一个处理任务, 并对所述原 始任务对应的数据文件进行相应的分割得到至少一个分片, 使得每个处理任务 都对应一个与所述处理任务相匹配的分片, 以便调度器根据所述处理任务的类 型将所述处理任务发送至所述任务消息队列组中与所述处理任务的类型关联 的消息队列, 使得所述扫描单元 602扫描分割后的处理任务。  a segmentation unit, configured to segment the original task to obtain at least one processing task, and perform corresponding segmentation on the data file corresponding to the original task to obtain at least one fragment, so that each processing task corresponds to the processing task a matching fragment, so that the scheduler sends the processing task to a message queue associated with the type of the processing task in the task message queue group according to the type of the processing task, so that the scanning unit 602 scans the segmentation Processing tasks.
还需要说明的是, 所述原始任务为原始视频任务, 所述处理任务为视频处 理任务, 所述任务分割单元具体用于根据预先设置的分割策略对原始视频任务 进行分割得到至少一个视频处理任务, 并在 I帧的位置对与所述原始视频任务 关联的视频数据文件进行分割得到至少一个分片, 使得每个视频处理任务都对 应一个与所述视频处理任务相匹配的分片; It should be noted that the original task is an original video task, the processing task is a video processing task, and the task segmentation unit is specifically configured to: use a preset segmentation policy to the original video task. Performing segmentation to obtain at least one video processing task, and segmenting the video data file associated with the original video task at the position of the I frame to obtain at least one slice, such that each video processing task corresponds to one of the video processing tasks. Matching fragments;
其中, 所述分割策略保证在 I帧的位置对视频数据文件进行分割。  The segmentation policy ensures that the video data file is segmented at the location of the I frame.
需要进一步说明的是, 在所述扫描单元扫描到包含处理任务的消息队列 时, 所述任务执行单元具体用于获取所述包含处理任务的消息队列中未被执行 的任一处理任务, 并执行所述未被执行的任一处理任务; 或者,  It should be further noted that, when the scanning unit scans the message queue that includes the processing task, the task execution unit is specifically configured to acquire any processing task that is not executed in the message queue that includes the processing task, and execute Any of the processing tasks not performed; or,
具体用于获取所述包含处理任务的消息队列中未被执行的队首处理任务, 并执行所述未被执行的队首处理任务。  Specifically, the team leader processing task that is not executed in the message queue that includes the processing task is acquired, and the unexecuted team head processing task is executed.
本发明实施例提供的一种任务处理节点, 消息队列优先级级别确定单元确 定存储处理任务的消息队列的优先级, 与现有技术性比, 不需对处理任务按优 先级进行排序进行排序, 消除了因排序而造成的系统开销, 提高了系统工作的 效率, 其次, 处理任务的优先级可由处理任务优先级级别确定单元根据业务需 要动态确定, 保证了在整个任务处理的过程中紧急的业务可以获得较高的优先 级, 使得任务处理节点处理视频任务更加灵活, 另外, 分割单元对原始任务进 行分割得到至少一个视频处理任务, 使得当前处理任务不会长时间占用任务处 理节点的资源, 保证了任务处理节点的资源不被阻塞, 能够及时执行高优先级 的处理任务。 如图 7所示, 为本发明实施例提供的一种调度器, 包括:  In the task processing node provided by the embodiment of the present invention, the message queue priority level determining unit determines the priority of the message queue for storing the processing task, and does not need to sort the processing tasks according to the priority, and eliminates The system overhead caused by the sorting improves the efficiency of the system work. Secondly, the priority of the processing task can be dynamically determined by the processing task priority level determining unit according to the business needs, ensuring that the urgent business can be performed during the entire task processing process. Obtaining a higher priority makes the task processing node more flexible in processing the video task. In addition, the segmentation unit splits the original task to obtain at least one video processing task, so that the current processing task does not occupy the resources of the task processing node for a long time, thereby ensuring The resources of the task processing node are not blocked, and high-priority processing tasks can be executed in time. As shown in FIG. 7, a scheduler according to an embodiment of the present invention includes:
获取单元 701 , 用于获取分割后的处理任务;  The obtaining unit 701 is configured to obtain the processed task after the segmentation;
发送单元 702, 用于根据所述获取单元 701获取的处理任务的类型, 将所 述处理任务发送至任务消息队列组中与所述处理任务的类型关联的消息队列, 等待任务处理节点执行。  The sending unit 702 is configured to send, according to the type of the processing task acquired by the acquiring unit 701, the processing task to a message queue associated with the type of the processing task in the task message queue group, and wait for the task processing node to execute.
其中, 本发明实施例提供的所述调度器还包括:  The scheduler provided by the embodiment of the present invention further includes:
分割单元, 用于对原始任务进行分割得到至少一个处理任务, 并对所述原 始任务对应的数据文件进行相应的分割得到至少一个分片, 使得每个处理任务 都对应一个与所述处理任务相匹配的分片, 以便所述获取单元 701获取所述分 割单元分割后的处理任务。 a dividing unit, configured to split the original task to obtain at least one processing task, and to the original The data file corresponding to the initial task is segmented to obtain at least one fragment, so that each processing task corresponds to a fragment matching the processing task, so that the obtaining unit 701 acquires the processing after the segmentation unit is divided. task.
需要说明的是, 所述原始任务为原始视频任务, 所述处理任务为视频处理 任务, 所述分割单元具体用于根据预先设置的分割策略对原始视频任务进行分 割得到至少一个视频处理任务, 并在 I帧的位置对与所述原始视频任务关联的 视频数据文件进行分割得到至少一个分片, 使得每个视频处理任务都对应一个 与所述视频处理任务相匹配的分片;  It should be noted that, the original task is an original video task, and the processing task is a video processing task, and the dividing unit is specifically configured to segment the original video task according to a preset segmentation strategy to obtain at least one video processing task, and Segmenting the video data file associated with the original video task at a position of the I frame to obtain at least one slice, such that each video processing task corresponds to a slice matching the video processing task;
其中, 所述分割策略保证在 I帧的位置对视频数据文件进行分割。  The segmentation policy ensures that the video data file is segmented at the location of the I frame.
本发明实施例提供的一种调度器, 发送单元将处理任务发送至任务消息队 列组中与所述处理任务的类型关联的消息队列, 与现有技术相比, 不需对消息 队列中的视频处理任务按优先级顺序进行排序, 消除了因排序而造成的系统开 销, 提高了系统工作的效率, 其次, 与现有技术相比, 一个消息队列只保存一 种类型的视频处理任务, 只需增加消息队列即可处理其他类型的视频处理任 务, 业务扩展性强, 另外, 分割单元对原始任务进行分割得到至少一个视频处 理任务, 使得当前处理任务不会长时间占用任务处理节点的资源, 保证了任务 处理节点的资源不被阻塞, 能够及时执行高优先级的处理任务。 为本发明实施例还提供一种分布式任务处理系统, 包括至少一个任务处理 节点, 所述任务处理节点用于按照自身承载的处理任务的优先级级别, 确定存 储所述处理任务的消息队列的优先级级别, 并按照优先级级别由高到低的顺 序, 从优先级级别最高的消息队列开始依次循环扫描任务消息队列组中的消息 队列, 并执行扫描到的处理任务, 其中, 所述任务消息队列组中的每个消息队 列存储所述任务处理节点承载的一种处理任务;  According to the embodiment of the present invention, the sending unit sends the processing task to the message queue associated with the type of the processing task in the task message queue group. Compared with the prior art, the video in the message queue is not needed. The processing tasks are sorted in order of priority, which eliminates the system overhead caused by sorting and improves the efficiency of the system work. Secondly, compared with the prior art, a message queue only stores one type of video processing task, only Adding a message queue can handle other types of video processing tasks, and the service is highly scalable. In addition, the splitting unit splits the original task to obtain at least one video processing task, so that the current processing task does not occupy the resources of the task processing node for a long time, ensuring The resources of the task processing node are not blocked, and high-priority processing tasks can be executed in time. The embodiment of the present invention further provides a distributed task processing system, including at least one task processing node, where the task processing node is configured to determine, according to a priority level of a processing task carried by the task, a message queue for storing the processing task. Priority level, and in order from highest to lowest priority level, the message queue in the task message queue group is cyclically scanned from the message queue with the highest priority level, and the scanned processing task is executed, where the task is performed. Each message queue in the message queue group stores a processing task carried by the task processing node;
其中, 所述任务处理节点包括:  The task processing node includes:
消息队列优先级级别确定单元, 用于按照自身承载的处理任务的优先级级 别, 确定存储所述处理任务的消息队列的优先级级别; a message queue priority level determining unit for prioritizing processing tasks according to its own No, determining a priority level of a message queue storing the processing task;
扫描单元, 用于根据所述消息队列优先级级别确定单元确定的所述消息队 列的优先级级别, 按照优先级级别由高到低的顺序, 从优先级级别最高的消息 队列开始依次扫描任务消息队列组中的消息队列;  a scanning unit, configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
任务执行单元, 用于在所述扫描单元扫描到包含处理任务的消息队列时, 获取当前处理任务, 并执行所述当前处理任务, 其中, 所述当前处理任务存储 在所述包含处理任务的消息队列中。  a task execution unit, configured to: when the scan unit scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the message that includes the processing task In the queue.
本发明实施例提供的一种分布式任务处理系统, 不同类型的任务被分配在 不同的消息队列中, 与现有技术相比, 本发明实施例不需对消息队列中的处理 任务按优先级顺序进行排序, 消除了因排序而造成的系统开销, 提高了系统工 作的效率, 其次, 与现有技术相比,一个消息队列只保存一种类型的处理任务, 只需增加消息队列即可处理其他类型的处理任务, 业务扩展性强。 本发明实施例还提供一种分布式任务处理系统, 该系统包括调度器 801 , 任务消息队列组存储节点 802以及任务处理节点 803 , 如图 8所示, 其中, 所 述调度器 801 , 用于获取分割后的处理任务, 并根据所述处理任务的类型, 将 所述处理任务发送至所述任务消息队列组存储节点 802存储的任务消息队列组 中与所述处理任务的类型关联的消息队列, 等待所述任务处理节点执行;  A distributed task processing system is provided in the embodiment of the present invention. Different types of tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not need to prioritize processing tasks in the message queue. Sorting in order eliminates the overhead caused by sorting and improves the efficiency of the system. Secondly, compared with the prior art, a message queue only stores one type of processing task, and only needs to increase the message queue to process Other types of processing tasks, business scalability. The embodiment of the present invention further provides a distributed task processing system, where the system includes a scheduler 801, a task message queue group storage node 802, and a task processing node 803, as shown in FIG. Obtaining the processed processing task, and sending the processing task to the message queue associated with the type of the processing task in the task message queue group stored by the task message queue group storage node 802 according to the type of the processing task Waiting for the task processing node to execute;
所述任务消息队列组存储节点 802, 用于存储所述任务消息队列组; 所述任务处理节点 803 , 用于按照自身承载的处理任务的优先级级别, 确 定存储所述处理任务的消息队列的优先级级别, 并按照优先级级别由高到低的 顺序, 从优先级级别最高的消息队列开始依次循环扫描所述任务消息队列组存 储节点 802存储的任务消息队列组中的消息队列, 并执行扫描到的处理任务, 其中, 所述任务消息队列组中的每个消息队列存储所述任务处理节点 803承载 的一种处理任务。  The task message queue group storage node 802 is configured to store the task message queue group; the task processing node 803 is configured to determine, according to a priority level of a processing task carried by the host, a message queue for storing the processing task. a priority level, and sequentially scanning the message queues in the task message queue group stored by the task message queue group storage node 802 in order from the highest priority message queue in the order of priority level, and executing The scanned processing task, wherein each message queue in the task message queue group stores a processing task carried by the task processing node 803.
其中, 需要说明的是, 所述任务处理节点 803包括: 消息队列优先级级别确定单元, 用于按照自身承载的处理任务的优先级级 别, 确定存储所述处理任务的消息队列的优先级级别; It should be noted that the task processing node 803 includes: a message queue priority level determining unit, configured to determine a priority level of a message queue storing the processing task according to a priority level of a processing task carried by the self-host;
扫描单元, 用于根据所述消息队列优先级级别确定单元确定的所述消息队 列的优先级级别, 按照优先级级别由高到低的顺序, 从优先级级别最高的消息 队列开始依次扫描任务消息队列组中的消息队列;  a scanning unit, configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
任务执行单元, 用于在所述扫描单元扫描到包含处理任务的消息队列时, 获取当前处理任务, 并执行所述当前处理任务, 其中, 所述当前处理任务存储 在所述包含处理任务的消息队列中。  a task execution unit, configured to: when the scan unit scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the message that includes the processing task In the queue.
所述调度器 801包括:  The scheduler 801 includes:
获取单元, 用于获取分割后的处理任务;  An obtaining unit, configured to obtain a processed task after the segmentation;
发送单元, 用于根据所述获取单元获取的处理任务的类型, 将所述处理任 务发送至所述任务消息队列组存储节点 802存储的任务消息队列组中与所述处 理任务的类型关联的消息队列, 等待任务处理节点执行。  a sending unit, configured to send, according to the type of the processing task acquired by the acquiring unit, the processing task to a message associated with the type of the processing task in the task message queue group stored by the task message queue group storage node 802 Queue, waiting for the task processing node to execute.
需要说明的是,所述任务消息队列组存储节点 802与所述任务处理节点 803 可以是同一个节点。  It should be noted that the task message queue group storage node 802 and the task processing node 803 may be the same node.
其中, 需要说明的是, 本发明实施例并不限定任务处理节点的数目, 可以 有多个所述任务处理节点。  It should be noted that, in the embodiment of the present invention, the number of task processing nodes is not limited, and there may be multiple task processing nodes.
本发明实施例提供的一种基于消息队列的分布式任务处理的方法、 装置及 系统,不同类型的视频处理任务被分配在不同的消息队列中,与现有技术相比, 本发明实施例不需对消息队列中的视频处理任务按优先级顺序进行排序, 消除 了因排序而造成的系统开销,提高了系统工作的效率, 其次, 与现有技术相比, 一个消息队列只保存一种类型的视频处理任务, 只需增加消息队列即可处理其 他类型的视频处理任务, 业务扩展性强, 另外, 视频处理任务的优先级可由任 务处理节点根据业务需要动态确定, 保证了在整个任务处理的过程中紧急的视 频业务可以获得较高的优先级, 使得任务处理节点处理视频任务更加灵活, 再 次, 对原始视频任务进行分割得到至少一个视频处理任务, 使得当前视频处理 任务不会长时间占用任务处理节点的资源, 保证了任务处理节点的资源不被阻 塞, 能够及时执行高优先级的视频处理任务。 A method, a device, and a system for processing a distributed task based on a message queue are provided in the embodiments of the present invention. Different types of video processing tasks are allocated in different message queues. Compared with the prior art, the embodiment of the present invention does not. The video processing tasks in the message queue need to be sorted in order of priority, which eliminates the system overhead caused by the sorting and improves the efficiency of the system work. Secondly, compared with the prior art, one message queue only stores one type. The video processing task can process other types of video processing tasks by adding a message queue, and the service scalability is strong. In addition, the priority of the video processing task can be dynamically determined by the task processing node according to the business needs, ensuring the processing of the entire task. The urgent video service in the process can obtain higher priority, making the task processing node more flexible in processing video tasks. Then, the original video task is segmented to obtain at least one video processing task, so that the current video processing task does not occupy the resources of the task processing node for a long time, and the resources of the task processing node are not blocked, and the high priority video can be executed in time. Handling tasks.
总之, 以上所述仅为本发明技术方案的较佳实施例而已, 并非用于限定本 发明的保护范围。凡在本发明的精神和原则之内, 所作的任何修改、等同替换、 改进等, 均应包含在本发明的保护范围之内。  In summary, the above description is only a preferred embodiment of the technical solution of the present invention, and is not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and scope of the present invention are intended to be included within the scope of the present invention.

Claims

权 利 要 求 书 Claim
1、 一种基于消息队列的分布式任务处理方法, 其特征在于, 任务消息队 列组中的每个消息队列存储任务处理节点承载的一种处理任务, 该方法包括: A message queue-based distributed task processing method, characterized in that each message queue in the task message queue group stores a processing task carried by the task processing node, and the method includes:
A, 所述任务处理节点按照自身承载的处理任务的优先级级别, 确定存储 所述处理任务的消息队列的优先级级别; A, the task processing node determines, according to the priority level of the processing task carried by the task, the priority level of the message queue storing the processing task;
B , 所述任务处理节点按照优先级级别由高到低的顺序, 从优先级级别最 高的消息队列开始依次扫描所述任务消息队列组中的消息队列, 若扫描到包含 处理任务的消息队列, 执行步骤 C, 否则, 重复步骤 B;  B. The task processing node sequentially scans the message queue in the task message queue group from the message queue with the highest priority level according to the priority level from high to low. If the message queue containing the processing task is scanned, Perform step C, otherwise, repeat step B;
C, 所述任务处理节点获取当前处理任务, 并执行所述当前处理任务, 执 行完之后返回步骤 B, 其中, 所述当前处理任务存储在所述包含处理任务的消 息队列中。  C. The task processing node acquires the current processing task, and executes the current processing task. After the execution, the process returns to step B, where the current processing task is stored in the message queue including the processing task.
2、 根据权利要求 1所述的方法, 其特征在于, 还包括:  2. The method according to claim 1, further comprising:
所述任务处理节点根据业务需求确定自身承载的处理任务的优先级级别, 或者, 预先设置所述处理任务的优先级级别。  The task processing node determines a priority level of the processing task carried by the task according to the service requirement, or sets a priority level of the processing task in advance.
3、 根据权利要求 1或 2所述的方法, 其特征在于, 还包括:  The method according to claim 1 or 2, further comprising:
调度器接收到所述处理任务后, 根据所述处理任务的类型将所述处理任务 发送至所述任务消息队列组中与所述处理任务的类型关联的消息队列。  After receiving the processing task, the scheduler sends the processing task to a message queue associated with the type of the processing task according to the type of the processing task.
4、 根据权利要求 3 所述的方法, 其特征在于, 所述调度器接收到所述处 理任务之前, 还包括:  The method according to claim 3, wherein, before receiving the processing task, the scheduler further includes:
对原始任务进行分割得到至少一个处理任务, 并对与所述原始任务关联的 数据文件进行相应的分割得到至少一个分片, 使得每个处理任务都对应一个与 所述处理任务相匹配的分片。  Dividing the original task to obtain at least one processing task, and performing corresponding segmentation on the data file associated with the original task to obtain at least one fragment, so that each processing task corresponds to a fragment matching the processing task. .
5、 根据权利要求 4所述的方法, 其特征在于, 所述原始任务为原始视频 任务, 所述处理任务为视频处理任务;  The method according to claim 4, wherein the original task is an original video task, and the processing task is a video processing task;
贝' J , 所述对原始任务进行分割得到至少一个处理任务, 并对与所述原始任 务关联的数据文件进行相应的分割得到至少一个分片, 使得每个处理任务都对 应一个与所述处理任务相匹配的分片, 包括: Bay' J, the segmentation of the original task to obtain at least one processing task, and with the original The associated data file is segmented to obtain at least one fragment, so that each processing task corresponds to a fragment matching the processing task, including:
根据预先设置的分割策略对所述原始视频任务进行分割得到至少一个视 频处理任务, 并在 I帧的位置对与所述原始视频任务关联的视频数据文件进行 分割得到至少一个分片, 使得每个视频处理任务都对应一个与所述视频处理任 务相匹配的分片;  And dividing the original video task according to a preset segmentation strategy to obtain at least one video processing task, and segmenting the video data file associated with the original video task at the position of the I frame to obtain at least one slice, so that each The video processing tasks all correspond to a slice that matches the video processing task;
其中, 所述分割策略保证在 I帧的位置对视频数据文件进行分割。  The segmentation policy ensures that the video data file is segmented at the location of the I frame.
6、根据权利要求 1-5中任一项所述的方法, 其特征在于, 所述任务处理节 点获取所述当前处理任务, 并执行所述当前任务, 包括:  The method according to any one of claims 1 to 5, wherein the task processing node acquires the current processing task and executes the current task, including:
所述任务处理节点获取所述包含处理任务的消息队列中未被执行的任一 处理任务, 并执行所述未被执行的任一处理任务; 或者,  The task processing node acquires any processing task that is not executed in the message queue that includes the processing task, and executes any processing task that is not executed; or
所述任务处理节点获取所述包含处理任务的消息队列中未被执行的队首 处理任务, 并执行所述未被执行的队首处理任务。  The task processing node acquires a team head processing task that is not executed in the message queue that includes the processing task, and executes the unexecuted team head processing task.
7、 一种基于消息队列的分布式任务调度方法, 其特征在于, 该方法包括: 获取分割后的处理任务;  A message queue-based distributed task scheduling method, the method comprising: obtaining a divided processing task;
根据所述处理任务的类型, 将所述处理任务发送至任务消息队列组中与所 述处理任务的类型关联的消息队列, 等待任务处理节点执行。  And according to the type of the processing task, the processing task is sent to a message queue associated with the type of the processing task in the task message queue group, waiting for the task processing node to execute.
8、 根据权利要求 7所述的方法, 其特征在于, 所述获取分割后的处理任 务之前, 还包括:  The method according to claim 7, wherein before the obtaining the processed task after the segmentation, the method further includes:
对原始任务进行分割得到至少一个处理任务, 并对与所述原始任务关联的 数据文件进行相应的分割得到至少一个分片, 使得每个处理任务都对应一个与 所述处理任务相匹配的分片。  Dividing the original task to obtain at least one processing task, and performing corresponding segmentation on the data file associated with the original task to obtain at least one fragment, so that each processing task corresponds to a fragment matching the processing task. .
9、 根据权利要求 8 所述的方法, 其特征在于, 所述原始任务为原始视频 任务, 所述处理任务为视频处理任务;  The method according to claim 8, wherein the original task is an original video task, and the processing task is a video processing task;
贝' J , 所述对原始任务进行分割得到至少一个处理任务, 并对与所述原始任 务关联的数据文件进行相应的分割得到至少一个分片, 使得每个处理任务都对 应一个与所述处理任务相匹配的分片, 包括: Bay' J, the segmentation of the original task to obtain at least one processing task, and with the original The associated data file is segmented to obtain at least one fragment, so that each processing task corresponds to a fragment matching the processing task, including:
根据预先设置的分割策略对所述原始视频任务进行分割得到至少一个视 频处理任务, 并在 I帧的位置对与所述原始视频任务关联的视频数据文件进行 分割得到至少一个分片, 使得每个视频处理任务都对应一个与所述视频处理任 务相匹配的分片;  And dividing the original video task according to a preset segmentation strategy to obtain at least one video processing task, and segmenting the video data file associated with the original video task at the position of the I frame to obtain at least one slice, so that each The video processing tasks all correspond to a slice that matches the video processing task;
其中, 所述分割策略保证在 I帧的位置对视频数据文件进行分割。  The segmentation policy ensures that the video data file is segmented at the location of the I frame.
10、 一种任务处理节点, 其特征在于, 包括:  10. A task processing node, comprising:
消息队列优先级级别确定单元, 用于按照自身承载的处理任务的优先级级 别, 确定存储所述处理任务的消息队列的优先级级别;  a message queue priority level determining unit, configured to determine a priority level of a message queue storing the processing task according to a priority level of a processing task carried by the self-host;
扫描单元, 用于根据所述消息队列优先级级别确定单元确定的所述消息队 列的优先级级别, 按照优先级级别由高到低的顺序, 从优先级级别最高的消息 队列开始依次扫描任务消息队列组中的消息队列;  a scanning unit, configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
任务执行单元, 用于在所述扫描单元扫描到包含处理任务的消息队列时, 获取当前处理任务, 并执行所述当前处理任务, 其中, 所述当前处理任务存储 在所述包含处理任务的消息队列中。  a task execution unit, configured to: when the scan unit scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the message that includes the processing task In the queue.
11、 根据权利要求 10所述的任务处理节点, 其特征在于, 还包括: 处理任务优先级级别确定单元, 用于根据业务需求确定任务处理节点承载 的处理任务的优先级级别, 或者, 预先设置所述处理任务的优先级级别, 以便 所述消息队列优先级级别确定单元确定所述任务消息队列组中消息队列的优 先级级别。  The task processing node according to claim 10, further comprising: a processing task priority level determining unit, configured to determine a priority level of the processing task carried by the task processing node according to the service requirement, or preset And processing the priority level of the task, so that the message queue priority level determining unit determines a priority level of the message queue in the task message queue group.
12、 根据权利要求 10或 11所述的任务处理节点, 其特征在于, 还包括: 分割单元, 用于对原始任务进行分割得到至少一个处理任务, 并对所述原 始任务对应的数据文件进行相应的分割得到至少一个分片, 使得每个处理任务 都对应一个与所述处理任务相匹配的分片, 以便调度器根据所述处理任务的类 型将所述处理任务发送至所述任务消息队列组中与所述处理任务的类型关联 的消息队列, 使得所述扫描单元扫描分割后的处理任务。 The task processing node according to claim 10 or 11, further comprising: a segmentation unit, configured to segment the original task to obtain at least one processing task, and corresponding to the data file corresponding to the original task Segmentation results in at least one slice such that each processing task corresponds to a slice that matches the processing task, so that the scheduler is based on the class of the processing task The type sends the processing task to a message queue associated with the type of the processing task in the task message queue group, such that the scanning unit scans the divided processing tasks.
13、 根据权利要求 12所述的任务处理节点, 其特征在于, 所述任务分割 单元具体用于根据预先设置的分割策略对原始视频任务进行分割得到至少一 个视频处理任务, 并在 I帧的位置对与所述原始视频任务关联的视频数据文件 进行分割得到至少一个分片, 使得每个视频处理任务都对应一个与所述视频处 理任务相匹配的分片;  The task processing node according to claim 12, wherein the task segmentation unit is specifically configured to segment the original video task according to a preset segmentation strategy to obtain at least one video processing task, and at the position of the I frame. Segmenting the video data file associated with the original video task to obtain at least one slice, such that each video processing task corresponds to a slice matching the video processing task;
其中, 所述分割策略保证在 I帧的位置对视频数据文件进行分割。  The segmentation policy ensures that the video data file is segmented at the location of the I frame.
14、 根据权利要求 10-13任一项所述的任务处理节点, 其特征在于, 在所 述扫描单元扫描到包含处理任务的消息队列时, 所述任务执行单元具体用于获 取所述包含处理任务的消息队列中未被执行的任一处理任务, 并执行所述未被 执行的任一处理任务; 或者,  The task processing node according to any one of claims 10 to 13, wherein when the scanning unit scans a message queue including a processing task, the task execution unit is specifically configured to acquire the inclusion processing. Any processing task that is not executed in the message queue of the task, and executes any of the processing tasks that are not performed; or
具体用于获取所述包含处理任务的消息队列中未被执行的队首处理任务, 并执行所述未被执行的队首处理任务。  Specifically, the team leader processing task that is not executed in the message queue that includes the processing task is acquired, and the unexecuted team head processing task is executed.
15、 一种调度器, 其特征在于, 包括:  15. A scheduler, comprising:
获取单元, 用于获取分割后的处理任务;  An obtaining unit, configured to obtain a processed task after the segmentation;
发送单元, 用于根据所述获取单元获取的处理任务的类型, 将所述处理任 务发送至任务消息队列组中与所述处理任务的类型关联的消息队列, 等待任务 处理节点执行。  And a sending unit, configured to send, according to the type of the processing task acquired by the acquiring unit, the processing task to a message queue associated with the type of the processing task in the task message queue group, and wait for the task processing node to execute.
16、 根据权利要求 15所述的调度器, 其特征在于, 还包括:  The scheduler according to claim 15, further comprising:
分割单元, 用于对原始任务进行分割得到至少一个处理任务, 并对所述原 始任务对应的数据文件进行相应的分割得到至少一个分片, 使得每个处理任务 都对应一个与所述处理任务相匹配的分片, 以便所述获取单元获取所述分割单 元分割后的处理任务。  a segmentation unit, configured to segment the original task to obtain at least one processing task, and perform corresponding segmentation on the data file corresponding to the original task to obtain at least one fragment, so that each processing task corresponds to the processing task Matching the fragment, so that the acquiring unit acquires the processing task after the dividing unit is divided.
17、 根据权利要求 16所述的调度器, 其特征在于, 所述分割单元具体用 于根据预先设置的分割策略对原始视频任务进行分割得到至少一个视频处理 任务, 并在 I帧的位置对与所述原始视频任务关联的视频数据文件进行分割得 到至少一个分片, 使得每个视频处理任务都对应一个与所述视频处理任务相匹 配的分片; The scheduler according to claim 16, wherein the dividing unit is specifically used And dividing the original video task according to the preset segmentation strategy to obtain at least one video processing task, and segmenting the video data file associated with the original video task at the position of the I frame to obtain at least one fragment, so that each video The processing tasks all correspond to a slice matching the video processing task;
其中, 所述分割策略保证在 I帧的位置对视频数据文件进行分割。  The segmentation policy ensures that the video data file is segmented at the location of the I frame.
18、 一种分布式任务处理系统, 其特征在于, 所述系统包括至少一个任务 处理节点, 所述任务处理节点用于按照自身承载的处理任务的优先级级别, 确 定存储所述处理任务的消息队列的优先级级别, 并按照优先级级别由高到低的 顺序, 从优先级级别最高的消息队列开始依次循环扫描任务消息队列组中的消 息队列, 并执行扫描到的处理任务, 其中, 所述任务消息队列组中的每个消息 队列存储所述任务处理节点承载的一种处理任务;  A distributed task processing system, wherein the system includes at least one task processing node, and the task processing node is configured to determine, according to a priority level of a processing task carried by the task, a message storing the processing task. The priority level of the queue, and the message queues in the task message queue group are cyclically scanned from the message queue with the highest priority level in order of priority level, and the scanned processing tasks are executed, where Each message queue in the task message queue group stores a processing task carried by the task processing node;
其中, 所述任务处理节点包括:  The task processing node includes:
消息队列优先级级别确定单元, 用于按照自身承载的处理任务的优先级级 别, 确定存储所述处理任务的消息队列的优先级级别;  a message queue priority level determining unit, configured to determine a priority level of a message queue storing the processing task according to a priority level of a processing task carried by the self-host;
扫描单元, 用于根据所述消息队列优先级级别确定单元确定的所述消息队 列的优先级级别, 按照优先级级别由高到低的顺序, 从优先级级别最高的消息 队列开始依次扫描任务消息队列组中的消息队列;  a scanning unit, configured to scan, according to the priority level of the message queue determined by the message queue priority level determining unit, the task message is sequentially scanned from the message queue with the highest priority level according to the order of priority level from highest to lowest a message queue in a queue group;
任务执行单元, 用于在所述扫描单元扫描到包含处理任务的消息队列时, 获取当前处理任务, 并执行所述当前处理任务, 其中, 所述当前处理任务存储 在所述包含处理任务的消息队列中。  a task execution unit, configured to: when the scan unit scans a message queue that includes a processing task, acquire a current processing task, and execute the current processing task, where the current processing task is stored in the message that includes the processing task In the queue.
19、 根据权利要求 18所述的系统, 其特征在于, 还包括:  19. The system of claim 18, further comprising:
任务消息队列组存储节点, 用于存储所述任务消息队列组;  a task message queue group storage node, configured to store the task message queue group;
调度器, 用于获取分割后的处理任务, 并根据所述处理任务的类型, 将所 述处理任务发送至所述任务消息队列组存储节点存储的任务消息队列组中与 所述处理任务的类型关联的消息队列, 等待所述任务处理节点执行; 其中, 所述调度器包括: a scheduler, configured to acquire the processed processing task, and send the processing task to a task message queue group stored in the task message queue group storage node and a type of the processing task according to the type of the processing task An associated message queue, waiting for the task processing node to execute; The scheduler includes:
获取单元, 用于获取分割后的处理任务;  An obtaining unit, configured to obtain a processed task after the segmentation;
发送单元, 用于根据所述获取单元获取的处理任务的类型, 将所述处理任 务发送至所述任务消息队列组存储节点存储的任务消息队列组中与所述处理 任务的类型关联的消息队列, 等待任务处理节点执行。  a sending unit, configured to send, according to the type of the processing task acquired by the acquiring unit, the processing task to a message queue associated with the type of the processing task in the task message queue group stored by the task message queue group storage node Wait for the task processing node to execute.
PCT/CN2011/085203 2011-12-31 2011-12-31 Distributed task processing method, device and system based on message queue WO2013097248A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2011/085203 WO2013097248A1 (en) 2011-12-31 2011-12-31 Distributed task processing method, device and system based on message queue
CN201180003148.5A CN103502943B (en) 2011-12-31 2011-12-31 A kind of method, the apparatus and system of the distributed task scheduling treatment based on message queue

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/085203 WO2013097248A1 (en) 2011-12-31 2011-12-31 Distributed task processing method, device and system based on message queue

Publications (1)

Publication Number Publication Date
WO2013097248A1 true WO2013097248A1 (en) 2013-07-04

Family

ID=48696298

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/085203 WO2013097248A1 (en) 2011-12-31 2011-12-31 Distributed task processing method, device and system based on message queue

Country Status (2)

Country Link
CN (1) CN103502943B (en)
WO (1) WO2013097248A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107153527A (en) * 2017-05-17 2017-09-12 北京环境特性研究所 A kind of parallel radar data processing method based on message queue
CN107391283A (en) * 2017-08-16 2017-11-24 郑州云海信息技术有限公司 A kind of message treatment method and device
CN109086132A (en) * 2018-06-26 2018-12-25 深圳市买买提信息科技有限公司 A kind of recognition of face task balance call method, device and terminal device
CN109214741A (en) * 2017-07-07 2019-01-15 北京京东尚科信息技术有限公司 A kind of method for early warning and early warning system of monitor control index
WO2019223596A1 (en) * 2018-05-25 2019-11-28 杭州海康威视数字技术股份有限公司 Method, device, and apparatus for event processing, and storage medium
WO2022105616A1 (en) * 2020-11-19 2022-05-27 International Business Machines Corporation Parallel file system scans with multiple shared queues

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104834558B (en) * 2015-05-19 2018-06-01 北京京东尚科信息技术有限公司 A kind of method and system of data processing
CN109814988A (en) * 2017-11-22 2019-05-28 深圳竹云科技有限公司 Task processing method and system
CN110046041B (en) * 2019-04-15 2021-04-09 北京中安智达科技有限公司 Data acquisition method based on battery scheduling framework
CN110262905A (en) * 2019-05-31 2019-09-20 四川长虹电器股份有限公司 The method for pushing of the message-oriented middleware of priority query based on building high performance and scalability
CN111061548B (en) * 2019-11-29 2024-04-05 西安四叶草信息技术有限公司 Safe scanning task scheduling method and scheduler
CN111245745B (en) * 2020-01-07 2022-05-24 腾讯科技(深圳)有限公司 Message sending method, device, node equipment and storage medium
CN111340681B (en) * 2020-02-10 2024-02-20 青岛海信宽带多媒体技术有限公司 Image processing method and device
CN115412510B (en) * 2022-10-31 2023-01-17 成都中科合迅科技有限公司 Flexible configuration method based on distributed framework service

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1349362A (en) * 2000-10-17 2002-05-15 华为技术有限公司 Multiple carrier task processing method in GSM wideband base station
CN101039309A (en) * 2006-03-16 2007-09-19 联想(北京)有限公司 Link sharing service apparatus and communication method thereof
CN101261592A (en) * 2007-03-07 2008-09-10 国际商业机器公司 Method and apparatus for scheduling task request
CN101359295A (en) * 2007-08-01 2009-02-04 阿里巴巴集团控股有限公司 Batch task scheduling and allocating method and system
EP2065803A1 (en) * 2007-11-30 2009-06-03 Neutrino Concepts Ltd. Parallel pipelining and width processing

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1349362A (en) * 2000-10-17 2002-05-15 华为技术有限公司 Multiple carrier task processing method in GSM wideband base station
CN101039309A (en) * 2006-03-16 2007-09-19 联想(北京)有限公司 Link sharing service apparatus and communication method thereof
CN101261592A (en) * 2007-03-07 2008-09-10 国际商业机器公司 Method and apparatus for scheduling task request
CN101359295A (en) * 2007-08-01 2009-02-04 阿里巴巴集团控股有限公司 Batch task scheduling and allocating method and system
EP2065803A1 (en) * 2007-11-30 2009-06-03 Neutrino Concepts Ltd. Parallel pipelining and width processing

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107153527A (en) * 2017-05-17 2017-09-12 北京环境特性研究所 A kind of parallel radar data processing method based on message queue
CN109214741A (en) * 2017-07-07 2019-01-15 北京京东尚科信息技术有限公司 A kind of method for early warning and early warning system of monitor control index
CN109214741B (en) * 2017-07-07 2021-11-12 北京京东尚科信息技术有限公司 Early warning method and early warning system for monitoring indexes
CN107391283A (en) * 2017-08-16 2017-11-24 郑州云海信息技术有限公司 A kind of message treatment method and device
WO2019223596A1 (en) * 2018-05-25 2019-11-28 杭州海康威视数字技术股份有限公司 Method, device, and apparatus for event processing, and storage medium
CN109086132A (en) * 2018-06-26 2018-12-25 深圳市买买提信息科技有限公司 A kind of recognition of face task balance call method, device and terminal device
WO2022105616A1 (en) * 2020-11-19 2022-05-27 International Business Machines Corporation Parallel file system scans with multiple shared queues

Also Published As

Publication number Publication date
CN103502943B (en) 2017-06-16
CN103502943A (en) 2014-01-08

Similar Documents

Publication Publication Date Title
WO2013097248A1 (en) Distributed task processing method, device and system based on message queue
JP4597608B2 (en) A storage scheduler conscious of continuous media priority.
CN110769278B (en) Distributed video transcoding method and system
Ali et al. RES: Real-time video stream analytics using edge enhanced clouds
US7219121B2 (en) Symmetrical multiprocessing in multiprocessor systems
CN1237767C (en) A resource access shared scheduling and controlling method and apparatus
US7765405B2 (en) Receive side scaling with cryptographically secure hashing
WO2017133351A1 (en) Resource allocation method and resource manager
WO2017166777A1 (en) Task scheduling method and device
US8661209B2 (en) Data processing apparatus, data processing method, and computer-readable recording medium for writing and reading data to and from a storage
WO2012155628A1 (en) Method and apparatus for task management
US20050220112A1 (en) Distributed packet processing with ordered locks to maintain requisite packet orderings
WO2016145904A1 (en) Resource management method, device and system
US9031077B2 (en) Systems, methods, and computer program products providing a data unit sequencing queue
WO2013091219A1 (en) Method and apparatus for processing concurrent tasks
CN111343288B (en) Job scheduling method and system and computing device
JP5825261B2 (en) Information processing apparatus, method and program thereof
JP2001203842A (en) Method and device for optimizing resource transition from low priority job to high priority job
TW201709047A (en) Routine task allocating method and multicore computer using the same
WO2021212965A1 (en) Resource scheduling method and related device
WO2013097234A1 (en) Service processing method and system
US20110194137A1 (en) Page parallel rip with interleaved chunks
CN109491775B (en) Task processing and scheduling method used in edge computing environment
CN112714319A (en) Computer readable storage medium, video encoding and decoding method and apparatus using multiple execution units
WO2023124135A1 (en) Feature retrieval method and apparatus, electronic device, computer storage medium and program

Legal Events

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

Ref document number: 11878879

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11878879

Country of ref document: EP

Kind code of ref document: A1