CN105100280B - Method for allocating tasks and device - Google Patents

Method for allocating tasks and device Download PDF

Info

Publication number
CN105100280B
CN105100280B CN201510553050.7A CN201510553050A CN105100280B CN 105100280 B CN105100280 B CN 105100280B CN 201510553050 A CN201510553050 A CN 201510553050A CN 105100280 B CN105100280 B CN 105100280B
Authority
CN
China
Prior art keywords
task
time point
start time
server
authority
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510553050.7A
Other languages
Chinese (zh)
Other versions
CN105100280A (en
Inventor
韦传毅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Kugou Computer Technology Co Ltd
Original Assignee
Guangzhou Kugou Computer Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Kugou Computer Technology Co Ltd filed Critical Guangzhou Kugou Computer Technology Co Ltd
Priority to CN201510553050.7A priority Critical patent/CN105100280B/en
Publication of CN105100280A publication Critical patent/CN105100280A/en
Application granted granted Critical
Publication of CN105100280B publication Critical patent/CN105100280B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/10Network architectures or network communication protocols for network security for controlling access to devices or network resources

Abstract

The invention discloses a kind of method for allocating tasks and devices, belong to network technique field.The described method includes: the authority request sent by receiving at least one execute server, determine the server identification for including in first authority request received, based on the server identification, distribution instruction is sent to corresponding first execute server, so that executing the task when first execute server receives distribution instruction.By sending distribution instruction to execute server corresponding to first authority request received, giving the authority distribution for the task that executes to the execute server in every sub-distribution task.The process of the distribution permission carries out without the mode of distribution distributed lock, and the distribution permission process of different task is independent of each other, and avoids due to the problem of distributed lock can not discharge and cause next task that cannot normally execute when executing previous task.

Description

Method for allocating tasks and device
Technical field
The present invention relates to network technique field, in particular to a kind of method for allocating tasks and device.
Background technique
With the continuous expansion of internet scale, the task in network system is more and more, if serviced only with one Device execute task, will lead to the server burden it is excessive, influence the execution efficiency of task.For this purpose, distributed system can be used To execute task.
Distributed system includes authority distribution server and multiple for executing the execute server of task, multiple to execute clothes Business device can request the permission of execution task to authority distribution server, only get the execute server for executing task right Corresponding task could be executed.Specifically, when the start time point of the task of arrival, each execute server takes to authority distribution Business device sending permission acquisition request, authority distribution server can receive the authority acquiring request that multiple execute servers are sent, And distributed lock is distributed to specified execute server corresponding to first authority acquiring request received.The specified execution After server gets the distributed lock, task can be executed based on the distributed lock, and by the initial time of next task Permission end time point of the point as the distributed lock.When the subsequent permission end time point for reaching the distributed lock, this refers to The distributed lock can be discharged by determining execute server, then the authority distribution server recycles the distributed lock, so that other execute clothes Device be engaged in based on distributed lock execution next task.
In the implementation of the present invention, the inventor finds that the existing technology has at least the following problems:
When caused due to system crash etc. specified execute server can not release profile formula is locked on time when, the permission Distribution server cannot recycle the distributed lock, then other execute servers can not execute next based on the distributed lock Business, has influenced the normal execution of next task.
Summary of the invention
In order to solve problems in the prior art, the embodiment of the invention provides a kind of method for allocating tasks and devices.It is described Technical solution is as follows:
In a first aspect, providing a kind of method for allocating tasks, which comprises
The authority request of at least one execute server transmission is received, the authority request is existed by corresponding execute server Current point in time is sent when reaching the start time point of task;
Determine the server identification for including in first authority request received;
Based on the server identification, distribution instruction is sent to corresponding first execute server, so that described first holds Row server is instructed according to the distribution, executes the task.
Optionally, the method also includes:
It, will when receiving first authority request under the premise of the state of the task is to be not carried out state The state of the task is set as having executed state;
When receiving the authority request of the second execute server transmission again, the transmission of the second execute server of Xiang Suoshu is asked Seek failed message.
Optionally, before the authority request for receiving the transmission of at least one execute server, the method also includes:
Establish the corresponding relationship between task identification and start time point.
Optionally, described to establish after the corresponding relationship between task identification and start time point, the method also includes:
The start time point acquisition instruction that any execute server is sent is received, the start time point acquisition instruction includes Task identification;
According to the corresponding relationship, the corresponding start time point of the task identification is obtained;
The start time point is sent to the corresponding execute server of the start time point acquisition instruction.
Optionally, before the authority request for receiving the transmission of at least one execute server, the method also includes:
According to the sequencing of the start time point of each task, task list is generated, includes more in the task list A entry, each entry include the state of task identification, start time point and task, and the state of the task is to have executed state Or it is not carried out state.
Optionally, the sequencing of the start time point according to each task, after generating task list, the side Method further include:
Receive the start time point acquisition instruction that any execute server is sent;
From the task list, the start time point of first task in the state that is not carried out is obtained;
The start time point is sent to the corresponding execute server of the start time point acquisition instruction.
Second aspect provides a kind of method for allocating tasks, which comprises
Determine the start time point of pending task;
When detecting that current point in time reaches the start time point, send to authority distribution server to the task Authority request;
When receiving the distribution instruction that the authority distribution server is sent, the task is executed.
Optionally, it is described to authority distribution server send to the authority request of the task after, the method is also wrapped It includes:
When receiving the request failure message that the authority distribution server is sent, the task is cancelled.
Optionally, the start time point of the pending task of the determination, comprising:
Start time point acquisition instruction is sent to the authority distribution server, the start time point acquisition instruction includes Task identification, so that the authority distribution server is according to the corresponding relationship between the task identification and start time point of foundation, Obtain the corresponding start time point of the task identification;
Receive the start time point that the authority distribution server returns.
Optionally, the start time point of the pending task of the determination, comprising:
To the authority distribution server send start time point acquisition instruction so that the authority distribution server from appoint It is engaged in list, obtains the corresponding start time point of first task in the state that is not carried out;
Receive the start time point that the authority distribution server returns.
The third aspect, provides a kind of task allocation apparatus, and described device includes:
Receiving module, for receiving the authority request of at least one execute server transmission, the authority request is by corresponding to Execute server current point in time reach task start time point when send;
Determining module is identified, for determining the server identification for including in first authority request received;
Sending module sends distribution instruction to corresponding first execute server, makes for being based on the server identification It obtains first execute server to be instructed according to the distribution, executes the task.
Optionally, described device further include:
State setting module, under the premise of the state of the task is to be not carried out state, when receiving described the When one authority request, it is set as the state of the task to have executed state;
The sending module is also used to when receiving the authority request of the second execute server transmission again, Xiang Suoshu Second execute server sends request failure message.
Optionally, described device further include:
Corresponding relation building module, for establishing the corresponding relationship between task identification and start time point.
Optionally, described device further include:
The receiving module, is also used to receive the start time point acquisition instruction that any execute server is sent, and described The time point acquisition instruction that begins includes task identification;
Start time point obtains module, when for according to the corresponding relationship, obtaining the corresponding starting of the task identification Between point;
The sending module is also used to send described rise to the corresponding execute server of the start time point acquisition instruction Begin time point.
Optionally, described device further include:
Task list generation module generates task list for the sequencing according to the start time point of each task, It include multiple entries in the task list, each entry includes the state of task identification, start time point and task, and described The state of business is to have executed state or be not carried out state.
Optionally, described device further include:
The receiving module is also used to receive the start time point acquisition instruction that any execute server is sent;
Start time point obtains module, for from the task list, obtaining first in the state that is not carried out The start time point of business;
The sending module is also used to send described rise to the corresponding execute server of the start time point acquisition instruction Begin time point.
Fourth aspect provides a kind of task allocation apparatus, the system comprises:
Start time point determining module, for determining the start time point of pending task;
Sending module, for when detect current point in time reach the start time point when, to authority distribution server Send the authority request to the task;
Task processing module, for when receiving the distribution instruction that the authority distribution server is sent, described in execution Task.
Optionally, the task processing module is also used to when the request failure for receiving the authority distribution server transmission When message, the task is cancelled.
Optionally, the start time point determining module is also used to send start time point to the authority distribution server Acquisition instruction, the start time point acquisition instruction includes task identification, so that the authority distribution server is according to foundation Corresponding relationship between task identification and start time point obtains the corresponding start time point of the task identification;Described in reception The start time point that authority distribution server returns.
Optionally, the start time point determining module is also used to send start time point to the authority distribution server Acquisition instruction, so that the authority distribution server from task list, obtains first task pair in the state that is not carried out The start time point answered;Receive the start time point that the authority distribution server returns.
Technical solution provided in an embodiment of the present invention has the benefit that
Method and apparatus provided in an embodiment of the present invention, the permission by receiving the transmission of at least one execute server are asked It asks, determines the server identification for including in first authority request received, the server identification is based on, to corresponding first Execute server sends distribution instruction, so that executing the task when first execute server receives distribution instruction.It is logical It crosses in every sub-distribution task, sends distribution instruction to execute server corresponding to first authority request received, it will The authority distribution of execution task gives the execute server.The process of the distribution permission without distribution distributed lock mode into Row, the distribution permission process of different task is independent of each other, avoid due to when executing previous task distributed lock can not discharge and The problem of causing next task that cannot normally execute.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodiment Attached drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other Attached drawing.
Fig. 1 is a kind of structural schematic diagram of network system provided in an embodiment of the present invention;
Fig. 2 is a kind of flow chart of method for allocating tasks provided in an embodiment of the present invention;
Fig. 3 is a kind of flow chart of method for allocating tasks provided in an embodiment of the present invention;
Fig. 4 is a kind of flow chart of method for allocating tasks provided in an embodiment of the present invention;
Fig. 5 is a kind of structural schematic diagram of task allocation apparatus provided in an embodiment of the present invention;
Fig. 6 is a kind of structural schematic diagram of task allocation apparatus provided in an embodiment of the present invention;
Fig. 7 is a kind of structural schematic diagram of server provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation description, it is clear that described embodiments are some of the embodiments of the present invention, instead of all the embodiments.Based on this hair Embodiment in bright, every other implementation obtained by those of ordinary skill in the art without making creative efforts Example, shall fall within the protection scope of the present invention.
Fig. 1 is a kind of structural schematic diagram of network system provided in an embodiment of the present invention, as shown in Figure 1, the network system It include: authority distribution server 101 and multiple execute servers 102, the authority distribution server 101 and multiple execute servers Pass through network connection between 102 respectively.
Each execute server 102 is used to determine the start time point of pending task, when detecting that current point in time arrives When up to the start time point, the authority request to the task is sent to authority distribution server 101.
The authority distribution server 101 is used to receive the authority request of at least one execute server 102 transmission, and determination connects The server identification for including in first authority request received is based on the server identification, executes service to corresponding first Device 102 sends distribution instruction, when receiving the authority request of the second execute server transmission again, second executes service to this Device 102 sends request failure message.
First execute server 102 is used to execute when receiving the distribution instruction of authority distribution server transmission The task.
Second execute server 102 is used for when receiving the request failure message of authority distribution server transmission, Cancel the task.
Fig. 2 is a kind of flow chart of method for allocating tasks provided in an embodiment of the present invention.The execution master of the inventive embodiments Body is authority distribution server, referring to fig. 2, this method comprises:
201, the authority request of at least one execute server transmission is received, the authority request is by corresponding execute server It is sent when current point in time reaches the start time point of task.
202, the server identification for including in first authority request received is determined.
203, it is based on the server identification, distribution instruction is sent to corresponding first execute server, so that this first is held Row server is instructed according to the distribution, executes the task.
Method provided in this embodiment is determined and is received by receiving the authority request of at least one execute server transmission To first authority request in include server identification, be based on the server identification, to corresponding first execute server Distribution instruction is sent, so that executing the task when first execute server receives distribution instruction.By dividing every time When with task, distribution instruction is sent to execute server corresponding to first authority request received, task will be executed Authority distribution gives the execute server.The process of the distribution permission carries out without the mode of distribution distributed lock, and difference is appointed The distribution permission process of business is independent of each other, and distributed lock can not discharge and lead to next when avoiding due to execution previous task The problem of business cannot be executed normally.
Optionally, this method further include:
Under the premise of the state of the task is to be not carried out state, when receiving first authority request, by this The state of business is set as having executed state;
When receiving the authority request of the second execute server transmission again, sends and request to second execute server Failed message.
Optionally, before the authority request that at least one execute server of the reception is sent, this method further include:
Establish the corresponding relationship between task identification and start time point.
Optionally, this is established after the corresponding relationship between task identification and start time point, this method further include:
The start time point acquisition instruction that any execute server is sent is received, which includes appointing Business mark;
According to the corresponding relationship, the corresponding start time point of the task identification is obtained;
The start time point is sent to the corresponding execute server of start time point acquisition instruction.
Optionally, before the authority request that at least one execute server of the reception is sent, this method further include:
According to the sequencing of the start time point of each task, task list is generated, includes multiple in the task list Entry, each entry include the state of task identification, start time point and task, and the state of the task is the state that executed or not Execution state.
Optionally, the sequencing of the start time point according to each task, after generating task list, this method is also Include:
Receive the start time point acquisition instruction that any execute server is sent;
From the task list, the start time point of first task in the state that is not carried out is obtained;
The start time point is sent to the corresponding execute server of start time point acquisition instruction.
All the above alternatives can form alternative embodiment of the invention using any combination, herein no longer It repeats one by one.
Fig. 3 is a kind of flow chart of method for allocating tasks provided in an embodiment of the present invention.The execution master of the inventive embodiments Body is execute server, referring to Fig. 3, this method comprises:
301, the start time point of pending task is determined.
302, it when detecting that current point in time reaches the start time point, sends to authority distribution server to the task Authority request.
303, when receiving the distribution instruction of authority distribution server transmission, the task is executed.
Method provided in this embodiment, by the start time point of the pending task of determination, when detecting current point in time When reaching the start time point, the authority request to the task is sent to authority distribution server, so that the authority distribution service Device receives the authority request of at least one execute server transmission, determines first authority request received, and send distribution Instruction executes the task when execute server receives distribution instruction.By in every sub-distribution task, to what is received Execute server corresponding to first authority request sends distribution instruction, gives the authority distribution for the task that executes to the execution service Device.The process of the distribution permission carries out without the mode of distribution distributed lock, and the distribution permission process of different task is mutually not It influences, avoids since distributed lock can not discharge and cause what next task cannot execute normally to ask when executing previous task Topic.
Optionally, after this sends to authority distribution server to the authority request of the task, this method further include:
When receiving the request failure message of authority distribution server transmission, the task is cancelled.
Optionally, the start time point of the pending task of the determination, comprising:
Start time point acquisition instruction is sent to the authority distribution server, which includes task Mark, so that the authority distribution server, according to the corresponding relationship between the task identification and start time point of foundation, obtaining should The corresponding start time point of task identification;
Receive the start time point of authority distribution server return.
Optionally, the start time point of the pending task of the determination, comprising:
Start time point acquisition instruction is sent to the authority distribution server, so that the authority distribution server is arranged from task In table, the corresponding start time point of first task in the state that is not carried out is obtained;
Receive the start time point of authority distribution server return.
All the above alternatives can form alternative embodiment of the invention using any combination, herein no longer It repeats one by one.
Fig. 4 is a kind of flow chart of method for allocating tasks provided in an embodiment of the present invention.The interaction master of the inventive embodiments Body is authority distribution server, the first execute server, the second execute server and third execute server, referring to fig. 4, the party Method includes:
401, authority distribution server determines the start time point of each pending task.
The embodiment of the present invention can be applied in distributed system, which includes authority distribution server and more A execute server.Wherein, which is used to configure multiple pending tasks, and is multiple execute servers The execution permission of distribution task, and each execute server be used for get execution task permission when, execute corresponding task. For each task, the execute server for only getting the execution permission of the task could execute the task, other are not The execute server for getting execution permission cannot then execute the task.
Wherein, the task which is configured may include wheat on setting user, wheat notice etc. in transmission Task, specifically can the function according to provided by the distributed system determine, it is not limited in the embodiment of the present invention.
The authority distribution server can determine the start time point of each task, which, which refers to, starts to execute The start time point at the time point of the task, different task may be the same or different, and the embodiment of the present invention does not do this It limits.
It wherein, can be true according to the setting of maintenance personnel when which determines the start time point of task It is fixed, alternatively, can also be ranked up to multiple tasks, needed for according to the start time point of previous task and executing previous task Duration determines the start time point of next task.Alternatively, when another task needs execution while appointed task starts to execute When, can determine the start time point of another task according to the start time point of appointed task, the embodiment of the present invention to this not It limits.
For example, the start time point of the upper wheat task of setting user is 8:00, and a length of 10 minutes when the upper wheat of each user, Then the authority distribution server can determine that the start time point that wheat task under the user is arranged is 8:10.And the use is being set Under family while wheat, need to send lower wheat notice to the user, then the start time point for sending lower wheat notice task is also 8:10.
In practical application, for the ease of distinguishing to multiple tasks, which can be each task Corresponding task identification is distributed, which, for uniquely determining corresponding task, can be task names, mission number Deng it is not limited in the embodiment of the present invention.
Correspondingly, the authority distribution server can establish task mark after the start time point for determining each task Know the corresponding relationship between start time point.For example, the corresponding relationship of the upper wheat task of setting user can be as shown in table 1 below.
Table 1
Task identification Start time point
The upper wheat of user is set 8:00
Alternatively, after the start time point for determining each task, the authority distribution server can establish task identification, Corresponding relationship between start time point and task status.Wherein, the state of each task can be to have executed state or do not held Row state, when task is also not carried out, it is to be not carried out state which, which can be set task status,.For example, setting The corresponding relationship for setting the upper wheat task of user can be as shown in table 2 below.
Table 2
Task identification Start time point Task status
The upper wheat of user is set 8:00 It is not carried out state
It further, can also be according to each after which determines the start time point of each task The sequencing of the start time point of task generates task list, includes multiple entries in the task list, each entry includes Task identification and start time point, alternatively, each entry includes task identification, start time point and task status.
For example, three tasks are arranged in the authority distribution server: wheat task under the upper wheat task of setting user, setting user, The task that lower wheat notifies is sent to user.The task list then established can be as shown in table 3 below.
Table 3
Task identification Start time point State
The upper wheat of user is set 8:00 It is not carried out state
Wheat under user is set 8:10 It is not carried out state
Lower wheat notice is sent to user 8:10 It is not carried out state
In addition, after establishing corresponding relationship or generating task list, the authority distribution server can by corresponding relationship and Task list is stored into database, which may include MySQL database, oracle database etc., and the present invention is implemented Example does not limit this.For example, task list can be stored the tables of data to MySQL database by the authority distribution server In TableA.
402, first execute server obtains the start time point of first task, is somebody's turn to do when detecting that current point in time reaches When start time point, the first authority request is sent to authority distribution server, first authority request is for requesting this first The execution permission of business executes step 404.
In a distributed manner for the first execute server in system, in order to execute first task, this first executes clothes Business device can obtain the start time point of the first task first from the authority distribution server, so as to subsequent when the arrival starting The execution permission of the first task is requested when time point.
Specifically, the available first task mark of first execute server, sends to the authority distribution server Begin time point acquisition instruction, which includes first task mark, when the authority distribution server receives When to the start time point acquisition instruction, identified according to the first task, obtain the start time point of the first task, to this One execute server sends the start time point, which can get the start time point, and storing should Start time point.Wherein, when which stores the start time point, task identification and initial time be can establish Corresponding relationship or generation task list between point, detailed process is similar with step 401, and details are not described herein.
Wherein, first task mark can be by the maintenance personnel of first execute server in the first execute server Setting, or first execute server is handed down to by the authority distribution server in advance, the embodiment of the present invention does not limit this It is fixed.
In addition, when the authority distribution server receives the start time point acquisition instruction, it can be according to the task of foundation Identify the corresponding relationship between start time point, obtain the first task and identify corresponding start time point, alternatively, can also be with According to the task list of generation, obtains the first task and identify corresponding start time point, the embodiment of the present invention does not limit this It is fixed.
It should be noted that the embodiment of the present invention is only directed to the first task specified with first execute server, to The server is illustrated for sending start time point acquisition instruction, and in practical applications, first execute server is also It can not appointed task.
It that is to say, which sends start time point acquisition instruction to the authority distribution server, this The time point acquisition instruction that begins does not include any task identification, then the authority distribution server receives start time point acquisition and refers to It when enabling, from task list, obtains in being not carried out the corresponding start time point of first task of state, and to first clothes Business device sends the start time point, then first execute server is available to the start time point, subsequent to request to locate In the execution permission of first task of the state that is not carried out.And the authority distribution server can also will be in and be not carried out state The task identification of first task be sent to first execute server, know so as to first execute server and need to request Which task execute permission is.
Wherein, which can send initial time to the authority distribution server every preset duration Point acquisition instruction.For example, first execute server can scan the tables of data of store tasks list every preset duration TableA, to obtain the start time point of pending task, which can be 1s, 1 minute etc..Alternatively, this first is held Row server can also send start time point acquisition instruction to the authority distribution server only when being in idle condition, this Inventive embodiments do not limit this.
After first execute server determines the start time point of the first task, judge whether current point in time arrives Up to the start time point, when detecting that current point in time reaches the start time point, to authority distribution server send this One authority request.
Wherein, which includes first server mark, which identifies for uniquely determining this First execute server can be address, title or the equipment Serial Number etc. of first execute server, the embodiment of the present invention pair This is without limitation.In addition, first authority request can also include that the first task identifies, so that the authority distribution server obtains Know first authority request it is requested be which task execution permission.Certainly, which can not also wrap First task mark is included, then it is to be currently to be not carried out that the authority distribution Server Default first authority request is requested The execution permission of first task of state.
Further, when detecting that current point in time reaches the start time point, which can be with Judgement currently whether be in idle condition, if being currently at idle state, to the authority distribution server send this first Authority request, and when being not presently within idle state, no longer first authority request is sent to the authority distribution server.
It, can be according to getting in addition, after first execute server gets the start time point of multiple tasks Start time point, multiple task is screened, determines the preset task in multiple task, is only arrived in current point in time Up to preset task start time point when, just send corresponding authority request to authority distribution server.Wherein, the preset task Can being selected from multiple task for maintenance personnel for task, can also to belong to the task of specified type in multiple task, It is not limited in the embodiment of the present invention.
403, second execute server obtains the start time point of the first task, when detect current point in time reach When the start time point, to authority distribution server send the second authority request, second authority request for request this first The execution permission of task executes step 406.
The detailed process of step 403 and the detailed process of step 402 are similar, and details are not described herein.
The embodiment of the present invention is only sent with the first execute server and the second execute server to authority distribution server It is illustrated for the time point acquisition instruction that begins, and in practical applications, any execute server can take to the authority distribution Business device sends start time point acquisition instruction, to obtain the start time point of any task.
The embodiment of the present invention is only with the first execute server and the second execute server to authority distribution server transmission route It is illustrated for limit request, and in practical applications, any execute server can be to the authority distribution server transmission route Limit request, to request the execution permission of the first task.
404, when the authority distribution server receives first authority request, the is sent to first execute server One distribution instruction.
The embodiment of the present invention in the case where first execute server and the second execute server initiate authority request, The authority distribution server first receives for first authority request.I.e. when the authority distribution server receives first power When limit request, the first task other execute servers are not distributed into also, then based on include in first authority request the One server identification sends the first distribution instruction to first execute server, first execute server can according to this One distribution instruction, executes first task, that is to say, which instructs the distribution issued as a kind of " lock ", By way of sending distribution instruction, the execution permission of the first task is distributed into first execute server, so that other Execute server cannot get the execution permission of the first task.
Wherein, which may include the detail information of the first task, so as to first execute server First task is executed according to the detail information.The detail information includes task data needed for executing the first task, executes and be somebody's turn to do The device address etc. for needing to interact when first task, it is not limited in the embodiment of the present invention.
It should be noted that when the authority distribution server receives the first authority request, can directly first be held to this Row server sends the first distribution instruction, can also be when ensuring currently to arrived the start time point of the first task, Send the first distribution instruction.It that is to say, when which receives first authority request, judge current time Whether point arrived the start time point of the first task, if current point in time arrived the start time point, to this First execute server send this first distribution instruction, if current point in time does not reach the start time point also, not to First execute server sends the first distribution instruction.
When certain execute servers initiate authority request before the start time point of task, the authority distribution server By judging current point in time, it can ensure that and hold to avoid the execution permission for distributing the task for the execute server Row server is only capable of that after start time point, the task could be executed, convenient for the management to task.
In addition, after the authority distribution server sends the first distribution instruction to first execute server, in order to anti- Only by other execute servers of the right of execution freight weight limit subdivision dispensing of the first task, the authority distribution server it is available this The corresponding relationship of one task, and delete the corresponding relationship of the first task.Alternatively, by the shape of the first task in the task list State is set as having executed state.So, in the follow-up process, when the authority distribution server has received other execute servers Authority request when, the execution permission of the first task will not be distributed into other execute servers again.
It should be noted that being only that the authority distribution server connects with first authority request in embodiments of the present invention It is illustrated for first authority request received, and in practical applications, which receives at least one The authority request that execute server is sent determines the server identification for including in first authority request received, and being based on should Server identification sends distribution instruction to corresponding execute server, so that the execution permission of task is distributed to first hair The execute server for sending authority request, by the execute server according to the corresponding task of distribution instruction execution.
405, when first execute server receives the first distribution instruction, the first task is executed.
When first execute server receives the first distribution instruction, it can be instructed, be executed according to first distribution The first task.Specifically, the detail information of the available first task of the first execute server, according to the detail information Execute the first task.
Wherein, which it is first can to obtain this when obtaining the start time point of the first task The detail information of business, or from the first distribution instruction, obtain the detail information of the first task, or receive this After one distribution instruction, detail information acquisition request is sent to the authority distribution server, to obtain the detail information, the present invention is real Example is applied not limit this.
406, it when the authority distribution server receives the second authority request, sends and requests to second execute server Failed message.
In the embodiment of the present invention, before receiving second authority request, which has received this First authority request, and the execution permission of the first task is distributed into first execute server.So, when the authority distribution When server receives second authority request, to second execute server send request failure message, with indicate this second Execute server request executes permission failure.
It, can when the authority distribution server receives an authority request to the first task in practical application To judge whether to have stored the corresponding relationship of the first task, when determination has stored the corresponding relationship of the first task, indicate The first task is also not carried out, then distribution instruction is sent to the execute server for sending the authority request, for the execution service Device distributes the execution permission, and deletes the corresponding relationship of the first task.And when the corresponding pass for determining the not stored first task It when being, indicates that the first task has executed, then sends request failure message to the execute server for sending the authority request, to refer to Show that execute server request executes permission failure.
Alternatively, when the authority distribution server receives an authority request to the first task, it can basis The task list obtains the state of the current first task.If it is determined that the state of the first task is to be not carried out state, indicate The execution permission of the also unallocated first task, then to send the authority request execute server send distribution instruction, with for The execute server distributes the execution permission, and is set as the state of first task to have executed state.And if it is determined that this The state of one task is the state that executed, and indicates the execution permission of the allocated first task, then to the transmission authority request Execute server send request failure message, with indicate the execute server request execute permission failure.
It should be noted that the embodiment of the present invention only with when first execute server execute step 405 after, the permission Distribution server is illustrated for receiving second authority request, and in practical applications, which can With any moment after receiving first authority request, second authority request is received, the embodiment of the present invention is to this Without limitation.
407, when second execute server receives the request failure message, the first task is cancelled.
When second execute server receives the request failure message, determine that the execution permission of the first task has been divided Other execute servers of dispensing, then second execute server no longer executes the first task.
Specifically, it if second execute server is when obtaining the start time point of the first task, obtains in advance To the detail information of the first task, and prepare to execute the first task according to the detail information, but receives request mistake When losing message, the detail information can be deleted.And second execute server can also continue to send out to the authority distribution server Start time point acquisition instruction is sent, to obtain the start time point of other tasks.
408, when third execute server detects that current point in time reaches the start time point of the second task, to the power It limits distribution server and sends third authority request, which is used to request the execution permission of the second task.
409, when the authority distribution server receives the third authority request, the is sent to the third execute server Two distribution instructions, execute second task by the third execute server.
Above-mentioned steps 408-409 is similar with step 402-405, and details are not described herein.
In the authority distribution server by way of issuing distribution instruction, the execution permission of first task is distributed to this After first execute server, whether no matter first execute server executes the process of the first task is completed, when current It, still can be by way of issuing distribution instruction, by the second task when time point reaches the start time point of second task It executes permission and distributes to third execute server.
It that is to say, during distributing the execution permission of each task, the authority distribution server is by issuing distribution The execution permission of corresponding task is handed down to execution service corresponding to first authority request received by the mode of instruction Device.And the process for distributing the execution permission of different task is independent of each other, it, will not when the implementation procedure of a certain task breaks down Influence the normal allocation of next task execution permission.
It should be noted that the embodiment of the present invention can be applied in live broadcast system, live broadcast system includes authority distribution clothes Business device and multiple execute servers.By taking a direct broadcast band as an example, when multiple users are broadcast live in turn in direct broadcast band, need Being executed for task includes: task of the upper wheat of user is arranged, the task of the upper wheat notice of transmissions, the task of wheat under user is arranged, sends out Send the task dispatching of lower wheat notice.The authority distribution server can pre-set the start time point of each task, when each When reaching the start time point of a certain task, multiple execute servers initiate authority requests, and the authority distribution server is to transmission The execute server of first authority request sends distribution instruction, so that the execution permission of the task is distributed to transmission first The execute server of authority request, and other execute servers requested to sending permission send request failure message.
Method provided in this embodiment is determined and is received by receiving the authority request of at least one execute server transmission To first authority request in include server identification, be based on the server identification, to corresponding first execute server Distribution instruction is sent, so that executing the task when first execute server receives distribution instruction.By dividing every time When with task, distribution instruction is sent to execute server corresponding to first authority request received, task will be executed Authority distribution gives the execute server.The process of the distribution permission carries out without the mode of distribution distributed lock, and difference is appointed The distribution permission process of business is independent of each other, and distributed lock can not discharge and lead to next when avoiding due to execution previous task The problem of business cannot be executed normally.Further, the start time point of each task is stored in database profession, using database Strong affairs, carry out start time point inquiry and execute permission distribution, easy to operate, securely and reliably, at low cost, the bit error rate It is low.
Fig. 5 is a kind of structural schematic diagram of task allocation apparatus provided in an embodiment of the present invention, referring to Fig. 5, the device packet It includes:
Receiving module 501, for receiving the authority request of at least one execute server transmission, the authority request is by corresponding to Execute server current point in time reach task start time point when send;
Determining module 502 is identified, for determining the server identification for including in first authority request received;
Sending module 503 sends distribution instruction to corresponding first execute server for being based on the server identification, So that first execute server is instructed according to the distribution, the task is executed.
Device provided in an embodiment of the present invention is determined by receiving the authority request of at least one execute server transmission The server identification for including in first authority request received is based on the server identification, executes clothes to corresponding first Business device sends distribution instruction, so that executing the task when first execute server receives distribution instruction.By every When sub-distribution task, distribution instruction is sent to execute server corresponding to first authority request received, is appointed executing The authority distribution of business gives the execute server.The process of the distribution permission carries out without the mode of distribution distributed lock, no Distribution permission process with task is independent of each other, avoid due to when executing previous task distributed lock can not discharge and under causing The problem of one task cannot be executed normally.
Optionally, the device further include:
State setting module, under the premise of the state of the task is to be not carried out state, when receiving this first When authority request, it is set as the state of the task to have executed state;
The sending module 503 is also used to when receiving the authority request of the second execute server transmission again, to this Two execute servers send request failure message.
Optionally, the device further include:
Corresponding relation building module, for establishing the corresponding relationship between task identification and start time point.
Optionally, the device further include:
The receiving module 501 is also used to receive the start time point acquisition instruction that any execute server is sent, the starting Time point acquisition instruction includes task identification;
Start time point obtains module, for obtaining the corresponding start time point of the task identification according to the corresponding relationship;
The sending module 503 is also used to send the starting to the corresponding execute server of start time point acquisition instruction Time point.
Optionally, the device further include:
Task list generation module generates task list for the sequencing according to the start time point of each task, It include multiple entries in the task list, each entry includes the state of task identification, start time point and task, the task State is to have executed state or be not carried out state.
Optionally, the device further include:
The receiving module 501 is also used to receive the start time point acquisition instruction that any execute server is sent;
Start time point obtains module, for obtaining first task in the state that is not carried out from the task list Start time point;
The sending module 503 is also used to send the starting to the corresponding execute server of start time point acquisition instruction Time point.
All the above alternatives can form alternative embodiment of the invention using any combination, herein no longer It repeats one by one.
Fig. 6 is a kind of structural schematic diagram of task allocation apparatus provided in an embodiment of the present invention, referring to Fig. 6, the device packet It includes:
Start time point determining module 601, for determining the start time point of pending task;
Sending module 602, for when detecting that current point in time reaches the start time point, to authority distribution server Send the authority request to the task;
Task processing module 603, for executing this when receiving the distribution instruction of authority distribution server transmission Business.
Device provided in an embodiment of the present invention, through the start time point of the pending task of determination, when detecting current Between point when reaching the start time point, send to authority distribution server to the authority request of the task, so that the authority distribution Server receives the authority request of at least one execute server transmission, determines first authority request received, and send Distribution instruction executes the task when the device receives distribution instruction.By in every sub-distribution task, to what is received Device corresponding to first authority request sends distribution instruction, gives the authority distribution for the task that executes to the device.Distribution power The process of limit carries out without the mode of distribution distributed lock, and the distribution permission process of different task is independent of each other, and avoids Due to the problem of distributed lock can not discharge and cause next task that cannot normally execute when executing previous task.
Optionally, which is also used to when the request failure for receiving authority distribution server transmission When message, the task is cancelled.
Optionally, which is also used to send start time point to the authority distribution server Acquisition instruction, which includes task identification, so that task of the authority distribution server according to foundation Corresponding relationship between mark and start time point, obtains the corresponding start time point of the task identification;Receive the authority distribution The start time point that server returns.
Optionally, which is also used to send start time point to the authority distribution server Acquisition instruction, so that from task list, it is corresponding to obtain first task in the state that is not carried out for the authority distribution server Start time point;Receive the start time point of authority distribution server return.
All the above alternatives can form alternative embodiment of the invention using any combination, herein no longer It repeats one by one.
It should be understood that task allocation apparatus provided by the above embodiment is in the task of distribution, only with above-mentioned each function The division progress of module can according to need and for example, in practical application by above-mentioned function distribution by different function moulds Block is completed, i.e., the internal structure of equipment is divided into different functional modules, to complete all or part of function described above Energy.In addition, task allocation apparatus provided by the above embodiment and method for allocating tasks embodiment belong to same design, it is specific real Existing process is detailed in embodiment of the method, and which is not described herein again.
Fig. 7 is a kind of structural schematic diagram of server provided in an embodiment of the present invention, which can be because of configuration or property Energy is different and generates bigger difference, may include one or more central processing units (central processing Units, CPU) 722 (for example, one or more processors) and memory 732, one or more storages apply journey The storage medium 730 (such as one or more mass memory units) of sequence 742 or data 744.Wherein, 732 He of memory Storage medium 730 can be of short duration storage or persistent storage.The program for being stored in storage medium 730 may include one or one With upper module (diagram does not mark), each module may include to the series of instructions operation in server.Further, in Central processor 722 can be set to communicate with storage medium 730, execute on server 700 a series of in storage medium 730 Instruction operation.
Server 700 can also include one or more power supplys 726, one or more wired or wireless networks Interface 750, one or more input/output interfaces 758, one or more keyboards 756, and/or, one or one The above operating system 741, such as Windows ServerTM, Mac OS XTM, UnixTM,LinuxTM, FreeBSDTMEtc..
Those of ordinary skill in the art will appreciate that realizing that all or part of the steps of above-described embodiment can pass through hardware It completes, relevant hardware can also be instructed to complete by program, the program can store in a kind of computer-readable In storage medium, storage medium mentioned above can be read-only memory, disk or CD etc..
The foregoing is merely presently preferred embodiments of the present invention, is not intended to limit the invention, it is all in spirit of the invention and Within principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.

Claims (8)

1. a kind of method for allocating tasks, which is characterized in that applied in the authority distribution server in live broadcast system, the method Include:
According to the sequencing of the start time point of each task, task list is generated, includes multiple in the task list Mesh, each entry include the state of task identification, start time point and task, and the state of the task is the state that executed or not Execution state;
Receive the start time point acquisition instruction that any execute server being in idle condition is sent;
From the task list, the start time point of first task in the state that is not carried out is obtained;
The start time point and first described is sent to the corresponding execute server of the start time point acquisition instruction The task identification of task;
The authority request that the execute server that at least one is in idle condition is sent is received, the authority request is held by corresponding Row server is sent when current point in time reaches the start time point of preset task, and the preset task is maintenance personnel's selection Task or belong to the task of specified type;
Determine the server identification for including in first authority request received;
Judge whether the current point in time arrived the start time point of the preset task, if the current point in time is When reaching the start time point, then it is based on the server identification, sends distribution instruction to corresponding first execute server, So that first execute server instructs the detail information execution for the preset task for including described pre- according to the distribution If task.
2. the method according to claim 1, wherein the method also includes:
It, will when receiving first authority request under the premise of the state of the preset task is to be not carried out state The state of the preset task is set as having executed state;
When receiving the authority request of the second execute server transmission again, the second execute server of Xiang Suoshu sends request and loses Lose message.
3. a kind of method for allocating tasks, which is characterized in that applied in the execute server in live broadcast system, the method packet It includes:
Determine the start time point of pending preset task, the preset task is the task of maintenance personnel's selection or belongs to The task of specified type;
When detecting that current point in time reaches the start time point, and when the execute server is in idle condition, Xiang Quan Distribution server transmission is limited to the authority request of the preset task;
When receiving the distribution instruction that the authority distribution server is sent, according to the distribution instruction include it is described default The detail information of task executes the preset task, when the distribution instruction is that the authority distribution server judges described current Between the start time point that whether arrived the preset task put, and arrived the start time point in the current point in time When send;
The start time point of the pending preset task of the determination, comprising:
If the execute server is in idle condition, Xiang Suoshu authority distribution server sends start time point acquisition instruction, So that the authority distribution server is from task list, when obtaining the corresponding starting of first task in the state that is not carried out Between point;
Receive the task identification of the start time point that the authority distribution server returns and first task.
4. according to the method described in claim 3, it is characterized in that, described send to authority distribution server to described default After the authority request of business, the method also includes:
When receiving the request failure message that the authority distribution server is sent, the preset task is cancelled, and delete Except the detail information of the preset task.
5. a kind of task allocation apparatus, which is characterized in that applied in the authority distribution server in live broadcast system, described device Include:
Task list generation module generates task list for the sequencing according to the start time point of each task, described It include multiple entries in task list, each entry includes the state of task identification, start time point and task, the task State is to have executed state or be not carried out state;
Receiving module, the start time point acquisition instruction sent for receiving any execute server being in idle condition;
Start time point obtains module, for obtaining first task in the state that is not carried out from the task list Start time point;
Sending module, for the corresponding execute server of the start time point acquisition instruction send the start time point with And the task identification of first task;
The receiving module is also used to receive the authority request that the execute server that at least one is in idle condition is sent, institute State authority request by corresponding execute server current point in time reach preset task start time point when transmission, it is described pre- If task is the task of maintenance personnel's selection or the belonging to specified type of the task;
Determining module is identified, for determining the server identification for including in first authority request received;
The sending module, is also used to judge whether the current point in time arrived the start time point of the preset task, If the current point in time arrived the start time point, it is based on the server identification, is held to corresponding first Row server sends distribution instruction, so that the preset task that first execute server includes according to the distribution instruction Detail information execute the preset task.
6. device according to claim 5, which is characterized in that described device further include:
State setting module, under the premise of the state of the preset task is to be not carried out state, when receiving described the When one authority request, it is set as the state of the preset task to have executed state;
The sending module is also used to when receiving the authority request of the second execute server transmission again, Xiang Suoshu second Execute server sends request failure message.
7. a kind of task allocation apparatus, which is characterized in that applied in the execute server in live broadcast system, described device packet It includes:
Start time point determining module, for determining the start time point of pending preset task, the preset task is dimension It protects the task of personnel selection or belongs to the task of specified type;
Sending module detects that current point in time reaches the start time point for working as, and the execute server is in sky When not busy state, the authority request to the preset task is sent to authority distribution server;
Task processing module, for when receiving the distribution instruction that the authority distribution server is sent, according to the distribution The detail information for the preset task that instruction includes executes the preset task, and the distribution instruction is the authority distribution clothes Business device judges whether the current point in time arrived the start time point of the preset task, and the current point in time It is sent when reaching the start time point;
It is in idle condition if the start time point determining module is also used to the execute server, Xiang Suoshu authority distribution clothes Business device sends start time point acquisition instruction, is not carried out so that the authority distribution server from task list, obtains to be in The corresponding start time point of first task of state;Receive the start time point that the authority distribution server returns with And the task identification of first task.
8. device according to claim 7, which is characterized in that the task processing module, which is also used to work as, receives the power When limiting the request failure message that distribution server is sent, the preset task is cancelled, and delete the detailed of the preset task Feelings information.
CN201510553050.7A 2015-08-31 2015-08-31 Method for allocating tasks and device Active CN105100280B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510553050.7A CN105100280B (en) 2015-08-31 2015-08-31 Method for allocating tasks and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510553050.7A CN105100280B (en) 2015-08-31 2015-08-31 Method for allocating tasks and device

Publications (2)

Publication Number Publication Date
CN105100280A CN105100280A (en) 2015-11-25
CN105100280B true CN105100280B (en) 2019-09-13

Family

ID=54579795

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510553050.7A Active CN105100280B (en) 2015-08-31 2015-08-31 Method for allocating tasks and device

Country Status (1)

Country Link
CN (1) CN105100280B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107479963A (en) * 2016-06-08 2017-12-15 国家计算机网络与信息安全管理中心 A kind of method for allocating tasks and system
CN106407002B (en) * 2016-08-22 2018-07-13 平安科技(深圳)有限公司 Data processing task executes method and apparatus
CN108345971A (en) * 2017-01-23 2018-07-31 北京金山云网络技术有限公司 A kind of information-pushing method and device
CN107515804A (en) * 2017-09-08 2017-12-26 郑州云海信息技术有限公司 A kind of system of selection of task engine, system and automatization test system
CN111611066A (en) * 2020-06-30 2020-09-01 平安银行股份有限公司 Task execution method, task execution server, and storage medium
CN113239059A (en) * 2021-05-28 2021-08-10 北京达佳互联信息技术有限公司 Switching method and device of distributed lock, server and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103677973A (en) * 2013-09-01 2014-03-26 西安重装渭南光电科技有限公司 Distributed multi-task scheduling management system
CN104468174A (en) * 2013-09-25 2015-03-25 北京新媒传信科技有限公司 Method and device for cluster servers to execute task
CN104734923A (en) * 2013-12-18 2015-06-24 青岛海尔空调器有限总公司 Execution control method and system of application task and information server

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103166911B (en) * 2011-12-09 2017-06-13 阿里巴巴集团控股有限公司 A kind of version management server right management method and equipment
CN103209090A (en) * 2012-01-17 2013-07-17 中兴通讯股份有限公司 Remote network management system and business operation method thereof
CN103812685B (en) * 2012-11-15 2018-02-27 腾讯科技(深圳)有限公司 Online statistics system and statistical method simultaneously

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103677973A (en) * 2013-09-01 2014-03-26 西安重装渭南光电科技有限公司 Distributed multi-task scheduling management system
CN104468174A (en) * 2013-09-25 2015-03-25 北京新媒传信科技有限公司 Method and device for cluster servers to execute task
CN104734923A (en) * 2013-12-18 2015-06-24 青岛海尔空调器有限总公司 Execution control method and system of application task and information server

Also Published As

Publication number Publication date
CN105100280A (en) 2015-11-25

Similar Documents

Publication Publication Date Title
CN105100280B (en) Method for allocating tasks and device
CN110221918A (en) A kind of correlating method, the apparatus and system of NS and VNF
CN103067293A (en) Method and system for multiplex and connection management of a load balancer
CN103366022B (en) Information handling system and disposal route thereof
CN107205248B (en) Resource allocation method and system
US20140201356A1 (en) Monitoring system of managing cloud-based hosts and monitoring method using for the same
EP1654649A2 (en) On demand node and server instance allocation and de-allocation
CN104348928B (en) A kind of method, management equipment, request equipment and the system of distribution address resource
CN114666333A (en) Control method for cloud computing resource scheduling problem based on multi-tenant theory
WO2016095524A1 (en) Resource allocation method and apparatus
CN111597024B (en) Cross-domain cluster processing method and device, electronic equipment and storage medium
JP2019507990A (en) Resource authorization method for VNF deployment, VNFM and NFVO
CN103259813A (en) Method of automatically expanding virtual machines
JP3983619B2 (en) Parallel processing system, server, parallel processing method, program, and recording medium
CN107534678B (en) Method, device and system for establishing connection between VNFM and VIM
CN111784185A (en) Distributed power distribution communication network timed task scheduling system
CN115102610B (en) Sharing method and device of Beidou RDSS equipment
CN105793838B (en) Reusable area
CN109819059B (en) Method, device, equipment and storage medium for managing network equipment
CN104063451A (en) Database connection management method and system
CN110855465B (en) Message processing method and device
JP3942979B2 (en) Parallel processing system, server, parallel processing method, program, and recording medium
CN108322425B (en) Man-machine interaction method and system for industrial equipment
CN113067869B (en) Node control method and device, node management method and device and distributed system
CN116028234B (en) Distributed database load balancing method, device, equipment 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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 510660 Guangzhou City, Guangzhou, Guangdong, Whampoa Avenue, No. 315, self - made 1-17

Applicant after: Guangzhou KuGou Networks Co., Ltd.

Address before: 510000 B1, building, No. 16, rhyme Road, Guangzhou, Guangdong, China 13F

Applicant before: Guangzhou KuGou Networks Co., Ltd.

GR01 Patent grant
GR01 Patent grant