CN106201676A - Task allocation method and device - Google Patents
Task allocation method and device Download PDFInfo
- Publication number
- CN106201676A CN106201676A CN201610489954.2A CN201610489954A CN106201676A CN 106201676 A CN106201676 A CN 106201676A CN 201610489954 A CN201610489954 A CN 201610489954A CN 106201676 A CN106201676 A CN 106201676A
- Authority
- CN
- China
- Prior art keywords
- task
- message queue
- thread
- classification
- priority
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 75
- 238000004519 manufacturing process Methods 0.000 claims description 24
- 238000012544 monitoring process Methods 0.000 claims description 20
- 230000000284 resting effect Effects 0.000 claims description 15
- 230000005059 dormancy Effects 0.000 claims description 9
- 238000010276 construction Methods 0.000 claims description 6
- 238000010586 diagram Methods 0.000 description 6
- 238000009826 distribution Methods 0.000 description 5
- 230000001360 synchronised effect Effects 0.000 description 4
- 238000003860 storage Methods 0.000 description 3
- FFBHFFJDDLITSX-UHFFFAOYSA-N benzyl N-[2-hydroxy-4-(3-oxomorpholin-4-yl)phenyl]carbamate Chemical compound OC1=C(NC(=O)OCC2=CC=CC=C2)C=CC(=C1)N1CCOCC1=O FFBHFFJDDLITSX-UHFFFAOYSA-N 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000010923 batch production Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000002618 waking effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Telephonic Communication Services (AREA)
Abstract
The invention provides a task allocation method and a device, wherein the method comprises the following steps: constructing at least two message queues according to the task classification number; configuring a corresponding relation between task classification and a message queue; determining the priority of a task when a task producer produces the task; when the priority of the task is higher than the set level, distributing the task to a message queue with the least queuing number; when the priority of the task is determined not to be higher than the set level, determining the classification to which the task belongs; distributing the task to a corresponding message queue according to the classification and the corresponding relation of the task; and the scheduling process schedules tasks with corresponding number in each of the at least two message queues respectively and distributes the scheduled tasks to the common queues. According to the scheme, the priority higher than the set level can be guaranteed to be considered to be consumed preferentially.
Description
Technical field
The present invention relates to technical field of data processing, particularly to a kind of method for allocating tasks and device.
Background technology
Along with the development of business event, business system also becomes more and more huger.Business system include multiple
When interacting between subsystem, the dispatching patcher of message queue plays a very important role.
At present, in dispatching patcher, task Producer often produces a task, then this task be assigned in message queue
Rank, consumed by subsystem to wait.But, if Queued tasks is more in message queue, and the task of new production
Priority is higher, is badly in need of being consumed by subsystem, then can cause the high task of this priority wait be lot more time to by
Consumption.
Summary of the invention
Embodiments provide a kind of method for allocating tasks and device, to ensure that the task that priority is high is disappeared in time
Take.
First aspect, embodiments provides a kind of method for allocating tasks, including:
According to classification of task number, build at least two message queue;
Configuration task classification and the corresponding relation of message queue;
Task Producer often produces a task, determines the priority of this task;
When the priority determining this task is higher than and sets level, this task is assigned to the message queue that queuing number is minimum
In;When the priority determining this task is not higher than described setting level, determine the classification belonging to this task;Belonging to this task
Classification and described corresponding relation, this task is assigned in corresponding message queue;
In scheduling process each message queue in described at least two message queue, dispatch corresponding number respectively
Task, and the task of scheduling is assigned in common queue.
Preferably,
Described this task is assigned in the message queue that queuing number is minimum after, farther include: determine described
Whether the minimum message queue of queuing number is null message queue;If not null message queue, then by minimum for described queuing number
The corresponding relation of message queue and classification of task delete, and task corresponding to message queue being minimum with described queuing number
Classification reconfigures the message queue of correspondence.
Preferably,
Described scheduling process includes producing thread and at least two consuming thread;Wherein, described at least two consuming thread
With described at least two message queue one_to_one corresponding;
Farther include: monitor the priority included in each message queue task higher than described setting level
Number, and monitored results is sent to scheduling process;
Farther include: described scheduling process receives monitored results, and is that each consuming thread is joined according to monitored results
Put consumption quantity;
In described scheduling process each message queue in described at least two message queue, corresponding of scheduling respectively
The task of number, takes out from corresponding message queue according to the consumption quantity of configuration including: each consuming thread and consumes number accordingly
The task of amount, and be sent to the task of taking-up produce thread;Produce thread to send out receiving described at least two consuming thread
After sending of task, receiving of task is sent to common queue.
Preferably, farther include: each consuming thread, after being sent to the task of taking-up produce thread, enters
Resting state, when the described whole dormancy of at least two consuming thread, wakes up described production thread up, and described production thread will connect
After receiving of task is sent to common queue, waking up described at least two consuming thread up, described production thread enters dormancy shape
State.
Preferably,
Described according to classification of task number, build at least two message queue, including: the described at least two message of structure
The number more than the number of classification of task 1 of queue;
And/or,
When monitoring described at least two message queue and including null message queue, then by this null message queue of configuration
Delete with the corresponding relation of classification of task.
Second aspect, the embodiment of the present invention additionally provides a kind of task allocation apparatus, including:
Construction unit, for according to classification of task number, builds at least two message queue;
Dispensing unit, for the corresponding relation of configuration task classification with message queue;
Task Producer, for often producing a task, determines the priority of this task;Determining the preferential of this task
This task, higher than when setting level, is assigned in the message queue that queuing number is minimum by level;Determining the priority of this task not
During higher than described setting level, determine the classification belonging to this task;According to the classification belonging to this task and described corresponding relation, should
Task is assigned in corresponding message queue;
Scheduling process, in each message queue in described at least two message queue, scheduling is corresponding respectively
The task of number, and the task of scheduling is assigned in common queue.
Preferably,
Described task Producer, is further used for determining whether the minimum message queue of described queuing number is null message team
Row;If not null message queue, then the corresponding relation of message queue minimum for described queuing number with classification of task is deleted, and
The classification of task triggering message queue that described dispensing unit is minimum with described queuing number corresponding reconfigures corresponding disappearing
Breath queue.
Preferably,
Described scheduling process includes producing thread and at least two consuming thread;Wherein, described at least two consuming thread
With described at least two message queue one_to_one corresponding;
Farther include: the first monitoring unit, for monitoring priority included in each message queue higher than institute
State the task number setting level, and monitored results is sent to scheduling process;
Described scheduling process, is further used for receiving monitored results, and is that each consuming thread is joined according to monitored results
Put consumption quantity;
Each consuming thread, for taking out corresponding consumption quantity according to the consumption quantity of configuration from corresponding message queue
Task, and the task of taking-up is sent to produce thread;
Produce thread, be used for after receiving the task that described at least two consuming thread sends, receiving of task
It is sent to common queue.
Preferably,
Each consuming thread, is further used for, after being sent to the task of taking-up produce thread, entering dormancy shape
State, when the described whole dormancy of at least two consuming thread, wakes up described production thread up;
Described production thread, is further used for after receiving of task is sent to common queue, wake up up described in extremely
Few two consuming thread, described production thread enters resting state.
Preferably,
Described construction unit, specifically for the number of described at least two message queue that builds than the number of classification of task
Many 1;
And/or,
Second monitoring unit, is used for when monitoring described at least two message queue and including null message queue, then will
This null message queue of configuration is deleted with the corresponding relation of classification of task.
Embodiments provide a kind of method for allocating tasks and device, by configuration task classification and message queue
Corresponding relation, is assigned in corresponding message queue with the task by priority not higher than setting level, so each message queue
The number of middle queuing is different, therefore, when the task priority that task Producer produces is higher than setting level, and can be by this priority
It is assigned to the message queue that queuing number is minimum, it is ensured that this priority is higher than the task of setting level higher than the task of setting level
Can be preferably dispatched in common queue, to be consumed in time by subsystem.
Accompanying drawing explanation
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing
In having technology to describe, the required accompanying drawing used is briefly described, it should be apparent that, the accompanying drawing in describing below is the present invention
Some embodiments, for those of ordinary skill in the art, on the premise of not paying creative work, it is also possible to according to
These accompanying drawings obtain other accompanying drawing.
Fig. 1 is a kind of method flow diagram that one embodiment of the invention provides;
Fig. 2 is the another kind of method flow diagram that one embodiment of the invention provides;
Fig. 3 be one embodiment of the invention provide task allocation apparatus corresponding task distribution schematic diagram;
Fig. 4 is the hardware structure figure of the device place equipment that one embodiment of the invention provides;
Fig. 5 is the apparatus structure schematic diagram that one embodiment of the invention provides.
Detailed description of the invention
For making the purpose of the embodiment of the present invention, technical scheme and advantage clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
The a part of embodiment of the present invention rather than whole embodiments, based on the embodiment in the present invention, those of ordinary skill in the art
The every other embodiment obtained on the premise of not making creative work, broadly falls into the scope of protection of the invention.
As it is shown in figure 1, embodiments provide a kind of method for allocating tasks, the method may comprise steps of:
Step 101: according to classification of task number, builds at least two message queue;
Step 102: configuration task classification and the corresponding relation of message queue;
Step 103: task Producer often produces a task, determines the priority of this task;
Step 104: when the priority determining this task is higher than and sets level, this task is assigned to queuing number minimum
In message queue;When the priority determining this task is not higher than described setting level, determine the classification belonging to this task;According to this
Classification belonging to task and described corresponding relation, be assigned to this task in corresponding message queue;
Step 105: in scheduling process each message queue in described at least two message queue, dispatch phase respectively
Answer the task of number, and the task of scheduling is assigned in common queue.
According to the invention described above embodiment, by the corresponding relation of configuration task classification with message queue, with by priority
The task of not higher than setting level is assigned in corresponding message queue, and the number so queued up in each message queue is different, because of
This, in the task priority that task Producer produces higher than when setting level, can divide this priority higher than the task of setting level
It is fitted on the message queue that queuing number is minimum, it is ensured that this priority can be preferably dispatched to general higher than the task of setting level
In logical queue, to be consumed in time by subsystem.
In an embodiment of the invention, when the task priority that task Producer produces is higher than setting level, the most really
Whether this at least two message queue fixed includes null message queue, if including null message queue, by priority higher than setting level
Task be assigned in this null message queue;If not including null message queue, it is determined that described at least two message queue is arranged
The message queue that team's number is minimum, is assigned to, higher than the task of setting level, the message queue that this queuing number is minimum by this priority
In.
Wherein, the queuing situation in each message queue can be monitored by monitoring unit, and by monitor each
The queuing situation of message queue is synchronized in data base, and task Producer can be by each message queue in reading database
Queuing situation determines the message queue that queuing number is minimum.
In an embodiment of the invention, owing to being configured with corresponding relation between message queue and classification of task, task is raw
Product person often produces a task, when this task priority not higher than sets level, can be assigned to this task disappear accordingly
In breath queue, therefore, message queue that this queuing number is minimum is if not null message queue, then this minimum disappearing of queuing number
Breath queue is configured with the classification of task with it with corresponding relation, and higher than the task of setting level, this priority is being assigned to this row
After in team's minimum message queue of number, can be that the classification of task that the minimum message queue of this queuing number is corresponding is joined again
Put the message queue of correspondence, so that the task of this classification that subsequent production goes out be not assigned to the message team that this queuing number is minimum
In row.
In an embodiment of the invention, in order to priority be consumed in time higher than the task of setting level, process is dispatched
May include that production thread and at least two consuming thread;Wherein, described at least two consuming thread disappears with described at least two
Breath queue one_to_one corresponding;
Farther include: monitor the priority included in each message queue task higher than described setting level
Number, and monitored results is sent to scheduling process;
Farther include: described scheduling process receives monitored results, and is that each consuming thread is joined according to monitored results
Put consumption quantity;
In described scheduling process each message queue in described at least two message queue, corresponding of scheduling respectively
The task of number, takes out from corresponding message queue according to the consumption quantity of configuration including: each consuming thread and consumes number accordingly
The task of amount, and be sent to the task of taking-up produce thread;Produce thread to send out receiving described at least two consuming thread
After sending of task, receiving of task is sent to common queue.
Wherein it is possible to the priority included according to each message queue is higher than setting the task number of level, for accordingly
Consuming thread distribution directly proportional consumption quantity, such as, message queue 0 includes that the priority of 10% is higher than setting appointing of level
Business, message queue 1 includes that the priority of 20%, higher than the task of setting level, does not includes in message queue 2-message queue 19
Priority higher than set level task, then can be consuming process 0 configure consumption quantity be 20, join for consuming process 1
The consumption quantity put is 30, and all configuring consumption quantity for consuming process 2-consuming process 19 is 10.
In an embodiment of the invention, in order to prevent consuming thread from taking out task in corresponding message queue always, with
And be sent to produce thread by the task of taking-up, dormancy awakening mechanism can be set: each consuming thread is by appointing of taking out
After business is sent to produce thread, enters resting state, when the described whole dormancy of at least two consuming thread, wake up described life up
Producing thread, described production thread, after receiving of task is sent to common queue, wakes up described at least two consumption line up
Journey, described production thread enters resting state.Such that it is able to the task of realizing one batch of next batch processes, and reach to follow
The purpose that ring performs.
In an embodiment of the invention, in order to ensure can be consumed in time higher than the task of setting level in priority,
The number more than the number of classification of task 1 of the described at least two message queue of structure can be made;So, null message queue is permissible
For special priority of placing higher than the task of setting level.
In an embodiment of the invention, when monitoring described at least two message queue and including null message queue,
The corresponding relation of this null message queue of configuration with classification of task can be deleted, so that this null message queue can be placed excellent
First level is higher than the task of setting level.
According to above-described embodiment, below in conjunction with concrete accompanying drawing, the embodiment of the present invention is described in detail.
As in figure 2 it is shown, embodiments provide a kind of method for allocating tasks, the method may comprise steps of:
Step 201: determine the number of classification of task.
In the present embodiment, as a example by this task distribution system is used for realizing web crawlers, this classification of task is said
Bright.When carrying out web crawlers, need to crawl the data produced on each website, therefore, it can to produce on each website
Task as a classification of task.Such as, website A correspondence classification of task A, website B correspondence classification of task B.
The present embodiment can illustrate as a example by the number of classification of task is 19.
Step 202: build at least two message queue according to the number of classification of task, and configure message queue and divide with task
The corresponding relation of class.
The number of at least two message queue built can determine according to real needs, if the message queue built
Number is more than the number of classification of task, then can be the more multiple message queue of classification configurations of task, less for task
One message queue of classification configurations.If the number of the message queue built is less than the number of classification of task, multiple can be configured
The corresponding message queue of business classification.
In an embodiment of the invention, the number that can build at least two message queue is more than the number of classification of task
1.Such as, 20 message queues are built.
By classification of task and message queue one_to_one corresponding and classification of task one to one is corresponding with message queue configuration
Relation, to be assigned to classify with it in message queue with corresponding relation by the task of production.
Such as, classification of task A is configured to corresponding relation with message queue 0, classification of task B is configured with message queue 1
For corresponding relation ....
Refer to Fig. 3, for combining the task distribution schematic diagram that task allocation apparatus illustrates.In this Fig. 3, message team
The number of row includes 20.
Step 203: this corresponding relation of configuration is stored in data base, and is sent to each task Producer.
Step 204: monitoring unit monitors the queuing situation of each message queue, and queuing situation is synchronized to data base
In, when monitoring includes null message queue, the corresponding relation of this null message queue of configuration with classification of task is deleted, and by sky
The mark of message queue is sent to each task Producer.
Wherein, the queuing situation of message queue can include the task number queued up in message queue.
Step 205: produce a task at task Producer, determine the priority of this task.
In the present embodiment, priority can be set previously according to the urgency level of task, it may for example comprise 1-7 preferential
Level, 1 is lowest priority, and 7 is limit priority.Producing of task all can carry respective priority rank.
Step 206: if the priority of this task is higher than setting level, then this task is assigned to the message that queuing number is minimum
In queue;If the priority of this task not higher than sets level, it is determined that the classification belonging to this task, and this task is assigned to
Its affiliated classification has in the message queue of corresponding relation.
In the present embodiment, one can be arranged and set level, such as, 4 grades, the priority task higher than 4 grades is defined as
It is badly in need of being consumed of task.
Wherein, task Producer first determines whether to include null message queue, if including null message queue, the most directly should
Priority is assigned in this null message queue higher than the task of setting level.And configure the corresponding relation of this null message queue, should
Null message queue is as being specifically designed to the message queue placing priority higher than the task of setting level.
In subsequent process, task Producer produces making new advances of task, when the priority of this task is higher than setting level, and will
This task is assigned directly to this and is specifically designed in the message queue placing high-priority task.If this is used for putting in subsequent process
Set high queuing number in the message queue of priority tasks more, then priority can be placed into higher than the task of setting level
In the message queue that other queuing numbers are minimum.
If not including null message queue, then, the queuing situation of each message queue in task Producer reading database,
Determine the message queue that current queuing number is minimum, this priority is assigned to this queuing number higher than the task of setting level minimum
Message queue in.And after priority is assigned in the message queue that queuing number is minimum higher than the task of setting level,
The corresponding relation of message queue minimum for number of queuing up with classification of task is deleted.
Step 207: the priority that each message queue of storage in data base is included by monitoring unit is higher than setting level
The number of task, be sent to scheduling process.
In the present embodiment, in order to be further ensured that priority be higher than set level task preferentially consumed, monitoring unit
Can monitor which message queue is priority be all assigned to higher than the task of setting level, and monitored results is synchronized to data
In storehouse, and before scheduling process takes task from message queue, this monitored results is sent to scheduling process so that dispatch into
Journey takes task according to the monitored results received from each message queue.
Step 208: scheduling process builds consuming thread, the number of consuming thread and message team according to the number of message queue
The number of row is identical, wherein, and consuming thread and message queue one_to_one corresponding, and close according to consuming thread is corresponding with message queue
System, configures consumption quantity for each consuming thread.
Refer in Fig. 3, the number of this consuming thread is 20, and each consuming thread is relative with corresponding message queue
Should.
Wherein it is possible to the priority included according to each message queue is higher than setting the task number of level, for accordingly
Consuming thread distribution directly proportional consumption quantity, such as, message queue 0 includes that the priority of 10% is higher than setting appointing of level
Business, message queue 1 includes that the priority of 20%, higher than the task of setting level, does not includes in message queue 2-message queue 19
Priority higher than set level task, then can be consuming process 0 configure consumption quantity be 20, join for consuming process 1
The consumption quantity put is 30, and all configuring consumption quantity for consuming process 2-consuming process 19 is 10.
Step 209: each consuming thread takes out the task of corresponding consumption quantity from corresponding message queue, and
The task of taking-up is sent to the production thread of scheduling process, after sending successfully, enters resting state.
In the present embodiment, each consuming thread is after being sent to the task of taking-up produce thread, in order to prevent again
Secondary from message queue, take task, resting state can be entered.
Step 210: when all consuming thread all enter resting state, wake up production thread up.
Step 211: produce thread and all tasks received are sent in common queue, and wake up each consumption line up
Journey, produces thread and enters resting state.
Above, it is ensured that scheduling process, according to the priority case of task, is taken out task from message queue, and will be taken
Going out of task is sent along in common queue, carries out consumption for other subsystems, thus ensure that priority is higher than and set
Thinking of deciding grade and level is preferentially consumed.
As shown in Figure 4, Figure 5, a kind of task allocation apparatus is embodiments provided.Device embodiment can be by soft
Part realizes, it is also possible to realize by the way of hardware or software and hardware combining.For hardware view, as shown in Figure 4, for this
A kind of hardware structure diagram of task allocation apparatus place equipment that bright embodiment provides, except the processor shown in Fig. 4, internal memory,
Outside network interface and nonvolatile memory, in embodiment, the equipment at device place generally can also include other hardware,
Forwarding chip such as responsible process message etc..As a example by implemented in software, as it is shown in figure 5, as the dress on a logical meaning
Put, be that computer program instructions corresponding in nonvolatile memory is read fortune in internal memory by the CPU by its place equipment
Row is formed.The task allocation apparatus that the present embodiment provides, including:
Construction unit 501, for according to classification of task number, builds at least two message queue;
Dispensing unit 502, for the corresponding relation of configuration task classification with message queue;
Task Producer 503, for often producing a task, determines the priority of this task;Determining this task
This task, higher than when setting level, is assigned in the message queue that queuing number is minimum by priority;Determining the preferential of this task
During level not higher than described setting level, determine the classification belonging to this task;According to the classification belonging to this task and described corresponding relation,
This task is assigned in corresponding message queue;
Scheduling process 504, in each message queue in described at least two message queue, dispatches phase respectively
Answer the task of number, and the task of scheduling is assigned in common queue 505.
In an embodiment of the invention, described task Producer, it is further used for determining that described queuing number is minimum
Whether message queue is null message queue;If not null message queue, then by message queue minimum for described queuing number with appoint
The corresponding relation of business classification is deleted, and triggers corresponding the appointing of message queue that described dispensing unit is minimum with described queuing number
Business classification reconfigures the message queue of correspondence.
In an embodiment of the invention, described scheduling process includes producing thread and at least two consuming thread;Wherein,
Described at least two consuming thread and described at least two message queue one_to_one corresponding;
Farther include: the first monitoring unit, for monitoring priority included in each message queue higher than institute
State the task number setting level, and monitored results is sent to scheduling process;
Described scheduling process, is further used for receiving monitored results, and is that each consuming thread is joined according to monitored results
Put consumption quantity;
Each consuming thread, for taking out corresponding consumption quantity according to the consumption quantity of configuration from corresponding message queue
Task, and the task of taking-up is sent to produce thread;
Produce thread, be used for after receiving the task that described at least two consuming thread sends, receiving of task
It is sent to common queue.
In an embodiment of the invention, each consuming thread, it is further used for the task of taking-up is being sent to life
After producing thread, enter resting state, when the described whole dormancy of at least two consuming thread, wake up described production thread up;
Described production thread, is further used for after receiving of task is sent to common queue, wake up up described in extremely
Few two consuming thread, described production thread enters resting state.
In an embodiment of the invention, described construction unit, specifically for the described at least two message queue built
Number more than the number of classification of task 1;
And/or,
Second monitoring unit, is used for when monitoring described at least two message queue and including null message queue, then will
This null message queue of configuration is deleted with the corresponding relation of classification of task.
To sum up, each embodiment of the present invention at least can realize following beneficial effect:
1, in embodiments of the present invention, by the corresponding relation of configuration task classification with message queue, with by priority not
Being assigned in corresponding message queue higher than the task of setting level, the number so queued up in each message queue is different, therefore,
In the task priority that task Producer produces higher than when setting level, this priority can be assigned to higher than the task of setting level
The message queue that queuing number is minimum, it is ensured that this priority can be preferably dispatched to common team higher than the task of setting level
In row, to be consumed in time by subsystem.
2, in embodiments of the present invention, by monitoring the queuing situation of each message queue, and it is synchronized in data base, from
And provide the queuing situation of each message queue can to task Producer, so that task Producer learns that queuing number is minimum
Message queue.
3, in embodiments of the present invention, the priority by being included by each message queue monitored is higher than setting level
The number of task, notify to scheduling process, scheduling process according to this notice to consumption thread configuration consumption quantity, can be according to
Direct proportion mode configures, and thereby may be ensured that priority is higher than thinking of level of setting and is preferentially taken out, and is sent to general
In logical queue, further increase the speed that high-priority task is preferentially consumed.
4, in embodiments of the present invention, at each consuming thread, taking out of task is sent after production thread, logical
Cross entrance resting state and prevent from again taking out from message queue task, thereby may be ensured that production thread is by this batch
After task is sent in common queue, the task of next batch is being processed by each consuming thread, it is achieved thereby that
The purpose that circulation performs.
The contents such as the information between each unit in said apparatus is mutual, execution process, owing to implementing with the inventive method
Example is based on same design, and particular content can be found in the narration in the inventive method embodiment, and here is omitted.
It should be noted that in this article, the relational terms of such as first and second etc is used merely to an entity
Or operation separates with another entity or operating space, and not necessarily require or imply existence between these entities or operation
The relation of any this reality or order.And, term " includes ", " comprising " or its any other variant are intended to non-
Comprising of exclusiveness, so that include that the process of a series of key element, method, article or equipment not only include those key elements,
But also include other key elements being not expressly set out, or also include being consolidated by this process, method, article or equipment
Some key elements.In the case of there is no more restriction, statement the key element " including " and limiting, do not arrange
Except there is also other same factor in including the process of described key element, method, article or equipment.
One of ordinary skill in the art will appreciate that: all or part of step realizing said method embodiment can be passed through
The hardware that programmed instruction is relevant completes, and aforesaid program can be stored in the storage medium of embodied on computer readable, this program
Upon execution, perform to include the step of said method embodiment;And aforesaid storage medium includes: ROM, RAM, magnetic disc or light
In the various medium that can store program code such as dish.
Last it should be understood that the foregoing is only presently preferred embodiments of the present invention, it is merely to illustrate the skill of the present invention
Art scheme, is not intended to limit protection scope of the present invention.All made within the spirit and principles in the present invention any amendment,
Equivalent, improvement etc., be all contained in protection scope of the present invention.
Claims (10)
1. a method for allocating tasks, it is characterised in that including:
According to classification of task number, build at least two message queue;
Configuration task classification and the corresponding relation of message queue;
Task Producer often produces a task, determines the priority of this task;
When the priority determining this task is higher than and sets level, this task is assigned in the message queue that queuing number is minimum;
When the priority determining this task is not higher than described setting level, determine the classification belonging to this task;Belonging to this task
Classification and described corresponding relation, be assigned to this task in corresponding message queue;
In scheduling process each message queue in described at least two message queue, dispatch appointing of corresponding number respectively
Business, and the task of scheduling is assigned in common queue.
Method the most according to claim 1, it is characterised in that
Described this task is assigned in the message queue that queuing number is minimum after, farther include: determine described queuing
Whether the minimum message queue of number is null message queue;If not null message queue, then by described minimum the disappearing of queuing number
The corresponding relation of breath queue and classification of task is deleted, and classification of task corresponding to message queue being minimum with described queuing number
Reconfigure the message queue of correspondence.
Method the most according to claim 1, it is characterised in that
Described scheduling process includes producing thread and at least two consuming thread;Wherein, described at least two consuming thread and institute
State at least two message queue one_to_one corresponding;
Farther include: monitor the priority included in each message queue task number higher than described setting level, and
Monitored results is sent to scheduling process;
Farther include: described scheduling process receives monitored results, and is that the configuration of each consuming thread disappears according to monitored results
Take quantity;
In described scheduling process each message queue in described at least two message queue, dispatch corresponding number respectively
Task, including: each consuming thread takes out corresponding consumption quantity according to the consumption quantity of configuration from corresponding message queue
Task, and be sent to the task of taking-up produce thread;Produce thread and receiving what described at least two consuming thread sent
After task, receiving of task is sent to common queue.
Method the most according to claim 3, it is characterised in that farther include: each consuming thread is by taking-up
After task is sent to produce thread, enter resting state, when the described whole dormancy of at least two consuming thread, wake up up described
Producing thread, described production thread, after receiving of task is sent to common queue, wakes up the consumption of described at least two up
Thread, described production thread enters resting state.
5. according to described method arbitrary in claim 1-4, it is characterised in that
Described according to classification of task number, build at least two message queue, including: the described at least two message queue of structure
Number more than the number of classification of task 1;
And/or,
When monitoring described at least two message queue and including null message queue, then by configuration this null message queue with appoint
The corresponding relation of business classification is deleted.
6. a task allocation apparatus, it is characterised in that including:
Construction unit, for according to classification of task number, builds at least two message queue;
Dispensing unit, for the corresponding relation of configuration task classification with message queue;
Task Producer, for often producing a task, determines the priority of this task;High in the priority determining this task
In time setting level, this task is assigned in the message queue that queuing number is minimum;Determining the priority of this task not higher than
During described setting level, determine the classification belonging to this task;According to the classification belonging to this task and described corresponding relation, by this task
It is assigned in corresponding message queue;
Scheduling process, in each message queue in described at least two message queue, dispatches corresponding number respectively
Task, and the task of scheduling is assigned in common queue.
Task allocation apparatus the most according to claim 6, it is characterised in that
Described task Producer, is further used for determining whether the minimum message queue of described queuing number is null message queue;
If not null message queue, then the corresponding relation of message queue minimum for described queuing number with classification of task is deleted, and touch
The classification of task that message queue that to send out dispensing unit described be minimum with described queuing number is corresponding reconfigures corresponding message
Queue.
Task allocation apparatus the most according to claim 6, it is characterised in that
Described scheduling process includes producing thread and at least two consuming thread;Wherein, described at least two consuming thread and institute
State at least two message queue one_to_one corresponding;
Farther include: the first monitoring unit, for monitor in each message queue included priority be higher than described in set
The task number of deciding grade and level, and monitored results is sent to scheduling process;
Described scheduling process, is further used for receiving monitored results, and is that the configuration of each consuming thread disappears according to monitored results
Take quantity;
Each consuming thread, for taking out appointing of corresponding consumption quantity according to the consumption quantity of configuration from corresponding message queue
Business, and be sent to the task of taking-up produce thread;
Produce thread, for after receiving the task that described at least two consuming thread sends, receiving of task is sent
To common queue.
Task allocation apparatus the most according to claim 8, it is characterised in that
Each consuming thread, is further used for, after being sent to the task of taking-up produce thread, entering resting state,
During the described whole dormancy of at least two consuming thread, wake up described production thread up;
Described production thread, is further used for after receiving of task is sent to common queue, wake up up described at least two
Individual consuming thread, described production thread enters resting state.
10. according to described task allocation apparatus arbitrary in claim 6-9, it is characterised in that
Described construction unit, the number more than the number of classification of task 1 of the described at least two message queue specifically for building;
And/or,
Second monitoring unit, for when monitoring described at least two message queue and including null message queue, then will configure
The corresponding relation of this null message queue and classification of task delete.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610489954.2A CN106201676A (en) | 2016-06-28 | 2016-06-28 | Task allocation method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610489954.2A CN106201676A (en) | 2016-06-28 | 2016-06-28 | Task allocation method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106201676A true CN106201676A (en) | 2016-12-07 |
Family
ID=57462483
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610489954.2A Pending CN106201676A (en) | 2016-06-28 | 2016-06-28 | Task allocation method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106201676A (en) |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106776072A (en) * | 2016-12-16 | 2017-05-31 | 携程旅游信息技术(上海)有限公司 | Information push method and system |
CN107391279A (en) * | 2017-07-31 | 2017-11-24 | 山东浪潮云服务信息科技有限公司 | A kind of message queue container creation method, device and message queue container |
CN108319508A (en) * | 2017-01-18 | 2018-07-24 | 中国移动通信集团公司 | HTTP synchronization requests switch to the method and server of asynchronous process |
CN109358960A (en) * | 2018-11-01 | 2019-02-19 | 郑州云海信息技术有限公司 | A kind of task distribution method, system, equipment and computer readable storage medium |
CN110515749A (en) * | 2019-08-30 | 2019-11-29 | 深圳乐信软件技术有限公司 | Method, apparatus, server and the storage medium for the queue scheduling that information is sent |
CN110890975A (en) * | 2018-09-11 | 2020-03-17 | 北京京东金融科技控股有限公司 | Data task management automation method, system, electronic device and storage medium |
CN109491810B (en) * | 2018-11-20 | 2020-06-23 | 泰华智慧产业集团股份有限公司 | Method and system for extensible multi-time-effect level message forwarding |
CN113360256A (en) * | 2020-03-06 | 2021-09-07 | 烽火通信科技股份有限公司 | Thread scheduling method and system based on control plane massive concurrent messages |
CN113572704A (en) * | 2020-04-29 | 2021-10-29 | 北京沃东天骏信息技术有限公司 | Information processing method, production end, consumption end and server |
CN117093387A (en) * | 2023-10-20 | 2023-11-21 | 腾讯科技(深圳)有限公司 | Message processing method, device, electronic equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102591658A (en) * | 2011-12-28 | 2012-07-18 | 奇智软件(北京)有限公司 | Method and device for processing message |
CN102713852A (en) * | 2012-02-01 | 2012-10-03 | 华为技术有限公司 | Multicore processor system |
CN102915254A (en) * | 2011-08-02 | 2013-02-06 | 中兴通讯股份有限公司 | Task management method and device |
US9250953B2 (en) * | 2013-11-12 | 2016-02-02 | Oxide Interactive Llc | Organizing tasks by a hierarchical task scheduler for execution in a multi-threaded processing system |
-
2016
- 2016-06-28 CN CN201610489954.2A patent/CN106201676A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102915254A (en) * | 2011-08-02 | 2013-02-06 | 中兴通讯股份有限公司 | Task management method and device |
CN102591658A (en) * | 2011-12-28 | 2012-07-18 | 奇智软件(北京)有限公司 | Method and device for processing message |
CN102713852A (en) * | 2012-02-01 | 2012-10-03 | 华为技术有限公司 | Multicore processor system |
US9250953B2 (en) * | 2013-11-12 | 2016-02-02 | Oxide Interactive Llc | Organizing tasks by a hierarchical task scheduler for execution in a multi-threaded processing system |
Cited By (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106776072A (en) * | 2016-12-16 | 2017-05-31 | 携程旅游信息技术(上海)有限公司 | Information push method and system |
CN108319508A (en) * | 2017-01-18 | 2018-07-24 | 中国移动通信集团公司 | HTTP synchronization requests switch to the method and server of asynchronous process |
CN108319508B (en) * | 2017-01-18 | 2020-10-20 | 中国移动通信集团公司 | Method for converting HTTP synchronous request into asynchronous processing and server |
CN107391279B (en) * | 2017-07-31 | 2020-08-25 | 浪潮云信息技术股份公司 | Message queue container creation method and device and message queue container |
CN107391279A (en) * | 2017-07-31 | 2017-11-24 | 山东浪潮云服务信息科技有限公司 | A kind of message queue container creation method, device and message queue container |
CN110890975A (en) * | 2018-09-11 | 2020-03-17 | 北京京东金融科技控股有限公司 | Data task management automation method, system, electronic device and storage medium |
CN109358960A (en) * | 2018-11-01 | 2019-02-19 | 郑州云海信息技术有限公司 | A kind of task distribution method, system, equipment and computer readable storage medium |
CN109491810B (en) * | 2018-11-20 | 2020-06-23 | 泰华智慧产业集团股份有限公司 | Method and system for extensible multi-time-effect level message forwarding |
CN110515749A (en) * | 2019-08-30 | 2019-11-29 | 深圳乐信软件技术有限公司 | Method, apparatus, server and the storage medium for the queue scheduling that information is sent |
CN110515749B (en) * | 2019-08-30 | 2022-06-24 | 深圳乐信软件技术有限公司 | Method, device, server and storage medium for queue scheduling of information transmission |
CN113360256A (en) * | 2020-03-06 | 2021-09-07 | 烽火通信科技股份有限公司 | Thread scheduling method and system based on control plane massive concurrent messages |
CN113572704A (en) * | 2020-04-29 | 2021-10-29 | 北京沃东天骏信息技术有限公司 | Information processing method, production end, consumption end and server |
CN117093387A (en) * | 2023-10-20 | 2023-11-21 | 腾讯科技(深圳)有限公司 | Message processing method, device, electronic equipment and storage medium |
CN117093387B (en) * | 2023-10-20 | 2024-02-13 | 腾讯科技(深圳)有限公司 | Message processing method, device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106201676A (en) | Task allocation method and device | |
US9686141B2 (en) | Systems and methods for resource sharing between two resource allocation systems | |
CN106919445B (en) | Method and device for scheduling containers in cluster in parallel | |
CN101727357B (en) | Method and apparatus for allocating resources in a compute farm | |
CN109656782A (en) | Visual scheduling monitoring method, device and server | |
CN103905533A (en) | Distributed type alarm monitoring method and system based on cloud storage | |
CN110928655A (en) | Task processing method and device | |
CN111464659A (en) | Node scheduling method, node pre-selection processing method, device, equipment and medium | |
CN109815007A (en) | Thread control method, device, electronic equipment and storage medium based on cloud monitoring | |
CN109840142A (en) | Thread control method, device, electronic equipment and storage medium based on cloud monitoring | |
CN105487919A (en) | Multi-core processor systems and methods for assigning tasks | |
CN112130963A (en) | Virtual machine task scheduling method and device, computer equipment and storage medium | |
CN109598441A (en) | Method for allocating tasks and system | |
CN113886034A (en) | Task scheduling method, system, electronic device and storage medium | |
CN111984426A (en) | Task scheduling method and device, electronic equipment and storage medium | |
CN112396371A (en) | Multi-target material allocation method and device based on GIS | |
CN115118723A (en) | Cluster scheduling system | |
CN109840141A (en) | Thread control method, device, electronic equipment and storage medium based on cloud monitoring | |
CN114968565A (en) | Resource management method, device, electronic equipment, storage medium and server | |
CN101937465B (en) | Access method of distributed file system and upper file system thereof | |
CN110287006A (en) | A kind of data dispatching method and system | |
CN110912967A (en) | Service node scheduling method, device, equipment and storage medium | |
CN103430152B (en) | Process the method and system of the data for database update | |
CN105446812A (en) | Multitask scheduling configuration method | |
CN111209333A (en) | Data updating method, device, terminal and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20161207 |
|
RJ01 | Rejection of invention patent application after publication |