Summary of the invention
In view of the above problems, it proposes on the present invention overcomes the above problem or at least be partially solved in order to provide one kindState the technical solution of problem:
A kind of task status management method, comprising:
Obtain waiting task;
The waiting task is subjected to segment processing according to preset rules, obtains multiple subtasks;
A signature identification is respectively distributed for each subtask and records the ordinal relation of each signature identification;
The subtask is successively executed, when a certain subtask executes failure, re-executes current subtask, untilAfter the completion of all the subtask executes, the subtask is combined by goal task according to the signature identification.
It is optionally, described successively to execute the subtask, comprising:
Determine the type of the subtask;
For each type, one consuming thread is set;
The subtask is distributed according to the type to the corresponding consuming thread;
The consuming thread executes the subtask, and different consuming threads is mutually indepedent.
Optionally, it is described successively execute the subtask after, the method for state management further include:
It obtains and characterizes the status indicator that the subtask executes state;
Judge whether the status indicator is preset completion mark, if so, determining that the subtask executes completion;IfIt is no, then the subtask is re-executed, until the status indicator is the preset completion mark.
It is optionally, described that the subtask is combined by goal task according to the signature identification, comprising:
Obtain the sequential bits of the signature identification;
According to the sequential bits, the subtask is combined.
A kind of task status managing device, comprising:
Module is obtained, for obtaining waiting task;
Module is split, for the waiting task to be carried out segment processing according to preset rules, obtains multiple subtasks;
Mark module, for respectively distributing a signature identification for each subtask and recording each signature identificationOrdinal relation;
Execution module, when a certain subtask executes failure, re-executes and works as successively executing the subtaskPreceding subtask, until the subtask is combined into target according to the signature identification after the completion of all the subtask executesTask.
Optionally, the execution module, comprising:
Determination unit, for determining the type of the subtask;
Setting unit, for a consuming thread to be arranged for each type;
Allocation unit, for distributing the subtask according to the type to the corresponding consuming thread;
Execution unit executes the subtask for the consuming thread, and different consuming threads is mutually indepedent.
Optionally, the execution module, further includes:
Acquiring unit, for obtaining the status indicator for characterizing the subtask and executing state;
Judging unit, for judging whether the status indicator is preset completion mark, if so, determining that the son is appointedBusiness executes completion;If it is not, the subtask is then re-executed, until the status indicator is the preset completion mark.
Optionally, the execution module, further includes:
Processing unit, for obtaining the sequential bits of the signature identification;
Assembled unit, for being combined to the subtask according to the sequential bits.
A kind of storage medium, the storage medium include the program of storage, wherein in described program operation described in controlEquipment where storage medium executes the above-mentioned task status management method of any one.
A kind of processor, the processor is for running program, wherein it is above-mentioned that any one is executed when described program is runTask status management method.
By above-mentioned technical proposal, a kind of task status management method provided by the invention, first acquisition waiting task,And the waiting task is subjected to segment processing according to preset rules, multiple subtasks are obtained, are then appointed for each sonIt is engaged in one signature identification of each distribution and recording the ordinal relation of each signature identification, successively executes the subtask later,When a certain subtask executes failure, current subtask is re-executed, until after the completion of all the subtask executes, rootThe subtask is combined into goal task according to the signature identification.As it can be seen that in the present solution, task is split into subtask and onlyIt is vertical to execute, when one of mission failure, the task only need to be re-executed, without re-executing all subtasks, is reducedThe quantity of data processing reduces the time for restoring prepolymerization task, reduces the resource occupation of system.
The above description is only an overview of the technical scheme of the present invention, in order to better understand the technical means of the present invention,And it can be implemented in accordance with the contents of the specification, and in order to allow above and other objects of the present invention, feature and advantage canIt is clearer and more comprehensible, the followings are specific embodiments of the present invention.
Specific embodiment
Exemplary embodiments of the present disclosure are described in more detail below with reference to accompanying drawings.Although showing the disclosure in attached drawingExemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth hereIt is limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosureIt is fully disclosed to those skilled in the art.
The embodiment of the invention provides a kind of task status management methods, referring to Fig. 1, showing the task status managementThe flow diagram of method may include:
S11, waiting task is obtained.
As described in background, when thread pool performance objective task execution object, it can call run function, then, holdThe row goal task executes task of including in object.However, it is found by the inventors that after task execution failure, thread pool meetingThe task is re-executed, but the data in task are identical, for example, current task occurs to execute mistake when going to 90%,Cause entire task needs to re-execute, i.e., executed since 1%, until 100% executes completion.
It will be apparent, however, that preceding the 90% of first time task execution has been performed one time again, cause to increase at dataThe quantity of reason extends the time for restoring prepolymerization task.Therefore, a kind of task status management method is present embodiments provided,Task to be processed is obtained first, which is that goal task executes task of including in current thread pool in object.
S12, the waiting task is subjected to segment processing according to preset rules, obtains multiple subtasks.
After step S11 gets waiting task, the present embodiment by the task according to preset fractionation rule process atMultiple subtasks, it should be noted that preset rules can be customized according to the progress of the data volume of task, or according to presetNumerical value is split, and e.g., a task is divided into five subtasks or every 200M is divided into a subtask, orAccording to the processing capacity of thread pool, task is subjected to non-uniform subtask fractionation, or, class is divided according to different tasksType divides task, and e.g., a task is to obtain the resource of a film, it is possible to which the audio of the film is carried outIt extracts, is divided into a subtask.
However, either that division mode, as long as task is split into multiple subtasks by the present embodiment, and this realityApply the fractionation rule that example does not limit subtask.
Schematically, it is assumed that the task that a data volume is 900M is got, then the task is carried out cutting by this step,Such as, splitting rule is 5 subtasks of equal part, then, each subtask is that data volume is 180M;For another example, split rule for according to200M data are split, then, which splits into the subtask of four 200M and the subtask of a 100M;For another example, it tears openDivider is then to be split according to the processing capacity of thread pool, it is assumed that there are three thread pool, there are two for sky, one is handling and appointsBusiness, it is possible to the task of 900M preferentially be split into the subtask of two 400M and the subtask of a 100M, by twoTwo empty thread pool processing are distributed in the subtask of 400M, and the subtask of 100M is distributed to the thread of the task of processingPond is waited to be processed.It is, of course, also possible to which task directly to be split into the subtask of two 450M, and the two subtasks are distributedTo two empty thread pool processing, subtask can be handled by different thread pools in this way, so that at the entirety of a taskTime shortening is managed, the processing speed of data is accelerated.
Wherein, the fractionation that subtask is carried out according to the processing capacity of thread pool, can be with specifically:
The processing status of each thread pool and the task scheduled time of present are obtained first, manage shape body according to thisAnd the scheduled time, determine that each thread pool receives the proportion of task, then basis should split into multiple sons with the task is comparedTask.
S13, a signature identification is respectively distributed for each subtask and records the sequence pass of each signature identificationSystem.
During task is split into multiple subtasks, it is randomly assigned a signature identification for each subtask, and rememberRecord the corresponding relationship of each signature identification and subtask.It should be noted that between this feature mark, there are ordinal relations, and are somebody's turn to doSubtask is combined into built-up sequence when entire task by sequential attribute.
For example, for it is above-mentioned the task of 900M is divided into four subtasks 200M and a subtask 100M in the case where,Can sequence to each subtask distribute a signature identification, be followed successively by mark 1, mark 2, mark 3, mark 4 and mark 5,So, it then subtask is in combination, is combined according to the sequence of mark 1-5.
Or a signature identification can be distributed to each subtask at random, such as it is followed successively by mark c, mark g, markR, a and mark m is identified, then record identification c is the signature identification of first subtask 200M, and mark g is second 200MThe signature identification of subtask, mark r are the signature identification of the subtask third 200M, and mark a is the 4th subtask 200MSignature identification, mark m be the subtask 100M signature identification, then, when subtask is combined, in sequence c, g, r, a,M is combined.
S14, the subtask is successively executed, when a certain subtask executes failure, re-executes current subtask,Until the subtask is combined into goal task according to the signature identification after the completion of all the subtask executes.
Each subtask is independently executed, specifically, present embodiments providing a kind of reality of successively subtaskingExisting mode, as shown in Fig. 2, comprising steps of
S21, the type for determining the subtask;
S22, one consuming thread is set for each type;
S23, the subtask is distributed according to the type to the corresponding consuming thread;
S24, the consuming thread execute the subtask, and different consuming threads is mutually indepedent.
Task is split into multiple subtasks by above-mentioned steps, then, this step is will be according to the type of subtaskDifference carries out the distribution of thread to subtask, and e.g., a task splits into five subtasks, and five subtasks are according to classThe division of type is divided into three types, and e.g., subtask 1 is type one, and subtask 2 is type two, and subtask 3 is type one, and son is appointedBusiness 4 is type three, and subtask 5 is type two, then, subtask 1 and subtask 3 are one group, are assigned to first consumption lineIt is handled in journey, subtask 2 and subtask 5 are one group, are assigned in second consuming thread and handle, subtask 4 is assigned toIt is handled in third consuming thread.It can guarantee that a consuming thread handles the subtask of the same type in this way, so that dataTreatment effeciency improves.
On the basis of the above embodiments, multiple subtasks are independently executed in the present embodiment, then in every heightAfter the completion of task is performed both by, subtask is combined according to above-mentioned signature identification.And subtask is during execution,For some reason, such as network interruption, data load malfunction, it may appear that the case where task execution fails, then, this programme existsWhen there is subtask execution failure, the subtask can be re-executed, and, other subtasks to run succeeded are not required to repeatExecute, only need to wait for the execution failure subtask re-execute successfully after, carry out the combination of subtask.
Specifically, the present embodiment additionally provides a kind of method whether judgement subtask executes completion, this method is describedAfter successively executing the subtask, as shown in figure 3, the method for state management further comprises the steps of:
S31, the status indicator for characterizing the subtask execution state is obtained;
S32, judge whether the status indicator is preset completion mark, if so, determining that the subtask has executedAt;If it is not, the subtask is then re-executed, until the status indicator is the preset completion mark.
Wherein, status indicator may include completing mark and unsuccessfully identifying, and the present embodiment need to only judge that status indicator isIt is no to be identified for completion, after being to complete mark, it is determined that the subtask executes completion.It should be noted that judging taskWhether execution complete mode there are many, the present embodiment is only for the purpose of illustration, and however, it is not limited to this.
In one possible implementation, as shown in figure 4, for task status management method provided by the above embodimentIn, how the detailed process that the subtask is combined into goal task to be illustrated according to the signature identification, comprising steps of
S41, the sequential bits for obtaining the signature identification;
S42, according to the sequential bits, the subtask is combined.
In conjunction with the citing in above-described embodiment, when signature identification is mark 1, mark 2, mark 3, mark 4 and mark 5When, sequential bits are followed successively by 1-5, and then, subtask is combined in combination according to the sequence of mark 1-5.
If signature identification is such as to be followed successively by mark c, mark g, mark to the signature identification of each subtask distribution at randomKnow r, mark a and mark m, then record identification c is the signature identification of first subtask 200M, and mark g is secondThe signature identification of the subtask 200M, mark r are the signature identification of the subtask third 200M, and mark a is that the 4th 200M is appointedThe signature identification of business, mark m are the signature identification of the subtask 100M, then, sequential bits are followed successively by c, g, r, a, m, then, in sonWhen task is combined, c, g, r, a, m are combined in sequence.
As it can be seen that a kind of task status management method provided by the invention, first acquisition waiting task, and by described wait locateReason task carries out segment processing according to preset rules, obtains multiple subtasks, then respectively distributes one for each subtaskSignature identification and the ordinal relation for recording each signature identification, successively execute the subtask, when a certain son laterWhen task execution fails, current subtask is re-executed, until after the completion of all the subtask executes, according to the feature markKnow and the subtask is combined into goal task.As it can be seen that in the present solution, task being split into subtask and is independently executed, when itIn a mission failure when, only need to re-execute the task, without re-executing all subtasks, reduce the number of data processingAmount reduces the time for restoring prepolymerization task, reduces the resource occupation of system.
It except this, on the basis of the above embodiments, corresponds to the above method, the embodiment of the invention also provides one kind to appointCondition managing device of being engaged in referring to Fig. 5, showing the structural schematic diagram of the task status managing device may include:
Module 51 is obtained, for obtaining waiting task;
Module 52 is split, for the waiting task to be carried out segment processing according to preset rules, multiple sons is obtained and appointsBusiness;
Mark module 53, for respectively distributing a signature identification for each subtask and recording each feature markThe ordinal relation of knowledge;
Execution module 54, for successively executing the subtask, after the completion of the subtask executes, according to the featureThe subtask is combined into goal task by mark.
Optionally, as shown in fig. 6, the execution module 54, comprising:
Determination unit 61, for determining the type of the subtask;
Setting unit 62, for a consuming thread to be arranged for each type;
Allocation unit 63, for distributing the subtask according to the type to the corresponding consuming thread;
And execution unit 64, the subtask is executed for the consuming thread, and different consuming threads is mutually onlyIt is vertical.
Optionally, as shown in fig. 7, the execution module 54, further includes:
Acquiring unit 71, for obtaining the status indicator for characterizing the subtask and executing state;
Judging unit 72, for judging whether the status indicator is preset completion mark, if so, determining the sonTask execution is completed;If it is not, the subtask is then re-executed, until the status indicator is the preset completion mark.
Optionally, as shown in figure 8, the execution module 54, further includes:
Processing unit 81, for obtaining the sequential bits of the signature identification;
Assembled unit 82, for being combined to the subtask according to the sequential bits.
The task status managing device includes processor and memory, and above-mentioned acquisition module splits module, label mouldBlock, execution module etc. store in memory as program unit, execute above-mentioned journey stored in memory by processorSequence unit realizes corresponding function.
Include kernel in processor, is gone in memory to transfer corresponding program unit by kernel.Kernel can be set oneOr more, prepolymerization is improved when mission failure occurs by adjusting kernel parameter, reduces the time for restoring prepolymerization task,The resource occupation of reduction system.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/Or the forms such as Nonvolatile memory, if read-only memory (ROM) or flash memory (flash RAM), memory include that at least one is depositedStore up chip.
The embodiment of the invention provides a kind of storage mediums, are stored thereon with program, real when which is executed by processorThe existing task status management method.
The embodiment of the invention provides a kind of processor, the processor is for running program, wherein described program operationTask status management method described in Shi Zhihang.
The embodiment of the invention provides a kind of equipment, equipment include processor, memory and storage on a memory and canThe program run on a processor, processor perform the steps of when executing program
Obtain waiting task;
The waiting task is subjected to segment processing according to preset rules, obtains multiple subtasks;
A signature identification is respectively distributed for each subtask and records the ordinal relation of each signature identification;
The subtask is successively executed, when a certain subtask executes failure, re-executes current subtask, untilAfter the completion of all the subtask executes, the subtask is combined by goal task according to the signature identification.
It is optionally, described successively to execute the subtask, comprising:
Determine the type of the subtask;
For each type, one consuming thread is set;
The subtask is distributed according to the type to the corresponding consuming thread;
The consuming thread executes the subtask, and different consuming threads is mutually indepedent.
Optionally, it is described successively execute the subtask after, the method for state management further include:
It obtains and characterizes the status indicator that the subtask executes state;
Judge whether the status indicator is preset completion mark, if so, determining that the subtask executes completion;IfIt is no, then the subtask is re-executed, until the status indicator is the preset completion mark.
It is optionally, described that the subtask is combined by goal task according to the signature identification, comprising:
Obtain the sequential bits of the signature identification;
According to the sequential bits, the subtask is combined.
Equipment herein can be server, PC, PAD, mobile phone etc..
Present invention also provides a kind of computer program products, when executing on data processing equipment, are adapted for carrying out justThe program of beginningization there are as below methods step: waiting task is obtained;
The waiting task is subjected to segment processing according to preset rules, obtains multiple subtasks;
A signature identification is respectively distributed for each subtask and records the ordinal relation of each signature identification;
The subtask is successively executed, when a certain subtask executes failure, re-executes current subtask, untilAfter the completion of all the subtask executes, the subtask is combined by goal task according to the signature identification.
It is optionally, described successively to execute the subtask, comprising:
Determine the type of the subtask;
For each type, one consuming thread is set;
The subtask is distributed according to the type to the corresponding consuming thread;
The consuming thread executes the subtask, and different consuming threads is mutually indepedent.
Optionally, it is described successively execute the subtask after, the method for state management further include:
It obtains and characterizes the status indicator that the subtask executes state;
Judge whether the status indicator is preset completion mark, if so, determining that the subtask executes completion;IfIt is no, then the subtask is re-executed, until the status indicator is the preset completion mark.
It is optionally, described that the subtask is combined by goal task according to the signature identification, comprising:
Obtain the sequential bits of the signature identification;
According to the sequential bits, the subtask is combined.
It should be understood by those skilled in the art that, embodiments herein can provide as method, system or computer programProduct.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the applicationApply the form of example.Moreover, it wherein includes the computer of computer usable program code that the application, which can be used in one or more,The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) producesThe form of product.
The application is referring to method, the process of equipment (system) and computer program product according to the embodiment of the present applicationFigure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructionsThe combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programsInstruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produceA raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for realThe device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spyDetermine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram orThe function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that countingSeries of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer orThe instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram oneThe step of function of being specified in a box or multiple boxes.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, netNetwork interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/Or the forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable JieThe example of matter.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any methodOr technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), movesState random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasableProgrammable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devicesOr any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculatesMachine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludabilityIt include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrapInclude other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic wantElement.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including elementThere is also other identical elements in process, method, commodity or equipment.
It will be understood by those skilled in the art that embodiments herein can provide as method, system or computer program product.Therefore, complete hardware embodiment, complete software embodiment or embodiment combining software and hardware aspects can be used in the applicationForm.It is deposited moreover, the application can be used to can be used in the computer that one or more wherein includes computer usable program codeThe shape for the computer program product implemented on storage media (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)Formula.
The above is only embodiments herein, are not intended to limit this application.To those skilled in the art,Various changes and changes are possible in this application.It is all within the spirit and principles of the present application made by any modification, equivalent replacement,Improve etc., it should be included within the scope of the claims of this application.