WO2019196250A1 - 一种任务处理方法、存储介质、服务器和装置 - Google Patents

一种任务处理方法、存储介质、服务器和装置 Download PDF

Info

Publication number
WO2019196250A1
WO2019196250A1 PCT/CN2018/097096 CN2018097096W WO2019196250A1 WO 2019196250 A1 WO2019196250 A1 WO 2019196250A1 CN 2018097096 W CN2018097096 W CN 2018097096W WO 2019196250 A1 WO2019196250 A1 WO 2019196250A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
timed
execution
execution node
task execution
Prior art date
Application number
PCT/CN2018/097096
Other languages
English (en)
French (fr)
Inventor
杨海勇
陈天豪
谢晓华
袁少雄
金鑫
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019196250A1 publication Critical patent/WO2019196250A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Definitions

  • the present application relates to the field of information processing technologies, and in particular, to a task processing method, a storage medium, a server, and a device.
  • timing tasks there are usually two ways to implement timing tasks: one is implemented using the Timer tool that comes with the Java Development Kit (JDK), and the other is using an open source.
  • JDK's own Timer can implement the simplest timing task, check the task class state at regular intervals, so that the specified Task class can be triggered by the specified repeat execution time and number of repeated executions.
  • Quartz can implement a more complete timing task, which uses multiple sub-threads to execute the specified Jab class.
  • the cron expression can be used in the configuration file to specify the trigger time of the task.
  • the above two ways of implementing the timing task need to hard code the trigger time of the specified job, and each task update needs to redeploy the program, which takes a lot of time, resulting in inefficient development.
  • the existing timing task mode needs to hard code the trigger time of the specified job.
  • Each task update needs to redeploy the program, which takes a lot of time and leads to low development efficiency.
  • the embodiment of the present application provides a task processing method, a storage medium, a server, and a device, so as to solve the problem that the existing timing task needs to hard code the trigger time of the specified job, and each task update needs to be redeployed. A lot of time leads to inefficient development.
  • a first aspect of the embodiments of the present application provides a task processing method, including:
  • the timed task is allocated to the task execution node corresponding to the execution information according to the execution information, so that the task execution node loads and executes the timed task.
  • a second aspect of an embodiment of the present application provides a server comprising a memory and a processor, the memory storing computer readable instructions executable on the processor, the processor executing the computer readable instructions The following steps are implemented:
  • the timed task is allocated to the task execution node corresponding to the execution information according to the execution information, so that the task execution node loads and executes the timed task.
  • a third aspect of embodiments of the present application provides a computer readable storage medium storing computer readable instructions that, when executed by a processor, implement the following steps:
  • the timed task is allocated to the task execution node corresponding to the execution information according to the execution information, so that the task execution node loads and executes the timed task.
  • a fourth aspect of the embodiments of the present application provides a task processing apparatus, including:
  • a file package obtaining unit configured to acquire a timed task file package uploaded by the user from the user operation interface
  • a scanning unit configured to scan the timed task file package, and acquire a timed task in the timed task file package
  • An information acquiring unit acquiring execution information of the timed task
  • a task processing unit when the timed task is started, assigning the timed task to a task execution node corresponding to the execution information according to the execution information, so that the task execution node loads and executes the timed task.
  • the timed task file package uploaded by the user from the user operation interface is obtained, and the timed task file package is scanned to obtain a timed task in the timed task file package, and the timed task is independent of the execution program, and does not affect each other. And acquiring the execution information of the timed task, and when the timed task is started, assigning the timed task to the task execution node corresponding to the execution information according to the execution information, so that the task execution node is loaded.
  • the scheduled task is executed.
  • the solution adopts distributed deployment. The execution of the scheduled task is not affected by the failure of the single-point server. It is not necessary to redeploy the program when updating the task, which improves the efficiency of the task execution and improves the development efficiency.
  • FIG. 1 is a flowchart of an implementation of a task processing method provided by an embodiment of the present application
  • FIG. 3 is a specific implementation flowchart of S104 when the execution information includes performance requirements in the task processing method provided by the embodiment of the present application;
  • FIG. 5 is a flowchart of a specific implementation of triggering a scheduled task when the execution information includes a task dependency in the task processing method provided by the embodiment of the present application;
  • FIG. 6 is a flowchart of an implementation of a task processing method according to another embodiment of the present application.
  • FIG. 7 is a structural block diagram of a task processing apparatus according to an embodiment of the present application.
  • FIG. 7.1 is a structural block diagram of another task processing apparatus according to an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a server provided by an embodiment of the present application.
  • FIG. 1 shows an implementation flow of a task processing method provided by an embodiment of the present application, where the method flow includes steps S101 to S104.
  • the specific implementation principles of each step are as follows:
  • S101 Acquire a timed task file package uploaded by the user from the user operation interface.
  • the task processing method provided by the embodiment of the present application is applied to a distributed system cluster.
  • distributed coordination technology ZooKeeper, ZK
  • ZK distributed coordination technology
  • the central server, the task console, and the task execution node are included, and the distributed system cluster supports the task execution node self-discovery function as dynamic capacity expansion.
  • the task console is configured to set execution information of the scheduled task, and is further configured to monitor the task execution node.
  • the central server assigns a scheduled task in the scheduled task file package to the task execution node.
  • the timed task file package includes a timed task, which is written in a computer language, such as a jar package that can be written and packaged in Java, and can also be written in other computer languages such as Python, PHP, etc., and The prepared timing task is packaged to generate a timed task file package, and the programming language of the timed task is not limited herein.
  • the timed task file package uploaded by the user from the user operation interface is stored in the file server, and the timed task file package is scanned to generate a timed task. More than one scheduled task can be included in a timed task package.
  • the timed task is packaged into an independent timed task file package, which is uploaded to the file storage by the user through the user operation interface, and the timed task is independently separated from the task execution node, so that the server of each timed task and task execution node is made. Do not affect each other.
  • S102 Scan the timed task file package to obtain a timed task in the timed task file package.
  • the timed task file package includes interface information
  • the central server generates the timing task by scanning the timed task file package to obtain interface information.
  • the execution information of the scheduled task includes an execution start time, an execution period, and a task parameter, and may further include a specified task execution node.
  • the task parameters include the location where the scheduled task file package is stored, and the task parameters are automatically generated when the scheduled task file package is uploaded to the file server.
  • the execution information of the scheduled task may be set by the user through the task console, that is, the user specifies the execution period of the scheduled task and the task execution node and the like on the task console.
  • the execution information of the scheduled task may be directly added when the timing task is initially written.
  • S104 When the timed task is started, assign the timed task to a task execution node corresponding to the execution information according to the execution information, so that the task execution node loads and executes the timed task.
  • the central server records the execution information after acquiring the execution information of the timed task. Further, the timer is set according to the execution start time in the execution information, and the countdown is started, and the central server allocates the timing task on time.
  • the server allocates the timed task to the task execution node corresponding to the execution information according to the execution information, and if the execution information includes the task execution node specified by the timed task, directly
  • the timing task is assigned to the designated task execution node such that the task execution node loads to execute the execution task. Further, the task execution node acquires the location of the timing task according to the task parameter in the execution information, and loads and executes the timing task.
  • the designation is first obtained.
  • the task execution node state information includes an idle state and a busy state, the idle state is an unexecuted task, the busy state indicates that the task is being executed, and the state information of the specified task execution node is determined according to the status information. Whether the task execution node is idle. If the specified task execution node is in an idle state, the scheduled task to be allocated is allocated to the specified task execution node for loading execution. If the specified task execution node is in a busy state, suspending the scheduled task to be allocated until the specified task execution node enters an idle state.
  • the execution information includes an implementation language of a timed task
  • FIG. 2 shows a specific implementation flow of the task processing method step S104 provided by the embodiment of the present application, which is described in detail below. :
  • A1 When the timed task is started, the timed task is parsed, and the written statement of the timed task is obtained.
  • A2 Perform language format matching on the written statement to determine an implementation language of the timed task.
  • the language format matching refers to finding a language format matching the written statement in a preset language library, thereby determining an implementation language of the timed task.
  • A3 assign the timed task to a task execution node supporting the implementation language according to an implementation language of the timed task, so that the task execution node loads and executes the timed task.
  • the task execution nodes in the distributed cluster all have language tags, and the language tags are used to identify computer voices supported by the task execution nodes.
  • the timing task is written in JAVA, Python, PHP, C language or other computer language, so if the timed task
  • the execution information does not include the specified task execution node, and the scheduled task can be assigned to different task execution nodes according to the language implemented by the timed task.
  • the scheduled task is allocated to the implementation language supporting the timed task.
  • the task execution node loads and executes to improve the efficiency of timing task execution.
  • the timed task may be allocated according to the priority of the task execution node or the state information of the task execution node.
  • the task execution node when the task execution node is in the working state, acquiring the number of the executed scheduled tasks, the number of the tasks includes the number of the scheduled tasks being executed, and the scheduled task to be executed by the task execution node. Number.
  • the priority of each task execution node is set according to the number of scheduled tasks. When the number of the scheduled tasks of the task execution node is the same, the time required for the task execution node to complete the task to enter the idle state is acquired, and the priority of the task execution node is set according to the time required to enter the idle state.
  • the execution information includes a performance requirement
  • FIG. 3 shows a specific implementation flow of the task processing method S104 provided by the embodiment of the present application, which is described in detail as follows:
  • the performance information of the task execution node includes one or more of a memory usage of the execution node server, a log record, a CPU performance, and a network speed.
  • the VM memory usage may be monitored by jstat, or each task execution node may be provided with a shell script to periodically obtain performance information such as a CPU, a memory, a hard disk, and the like of the server of the task execution node.
  • B2 Compare performance of the task execution node according to performance information of the task execution node, and sort the task execution nodes from high to low according to performance.
  • the timing task assigning the timing task to a task execution node that satisfies the performance requirement according to the performance requirement in the execution information and the task execution node sorted by performance from high to low, so that the task execution node loads Perform the scheduled task. For example, if the execution information includes a requirement for running memory, view the arrangement of the memory allocation of the currently assignable task execution node from high to low, and assign the timing task to the task execution node that satisfies the requirement of the running memory. Load execution. If the execution information includes a requirement for running memory and a network speed, the task task is assigned to a task execution node load execution that satisfies the requirements of the running memory and satisfies the requirements of the network speed.
  • the timing task is reasonably allocated according to the performance requirement of the task execution node in the execution information of the timed task, so as to improve the efficiency of the timed task execution.
  • the execution information includes a specified task execution node
  • FIG. 4 shows a specific implementation flow of the task processing method S104 provided by the embodiment of the present application, which is described in detail as follows:
  • each timed task is a permanent process.
  • each timed task execution node applies the same path information to the Zookeeper cluster according to the same path naming rule, and the task execution node that obtains the write right obtains the task execution. Permission, the task will be executed, and the task execution node that has not obtained the write right will not have the task execution permission, and can only abandon the execution of the scheduled task.
  • each timed task execution node repeats the above operation.
  • the task execution node that obtains the scheduled task execution permission assigns the scheduled task
  • the task execution node that does not obtain the scheduled task execution permission does not assign the scheduled task until the next preset time point, and reclaims the scheduled task. Execute permissions.
  • the task execution node applies for the same path information to the cluster in accordance with the same path naming rules.
  • the path naming rule includes: generating a node path according to the timed task file package name, the class name, and the current timestamp. For example, the timing task of "cn.knet.timing.TcpTask" is scheduled to be executed at 15:30 on April 5, 2018. The generated path should be "/cn/knet/timing/tcptask/ 201008052030".
  • the task execution node when multiple timing tasks are running at the same time, only one timed task execution node performs the task at the expected time point.
  • the cluster distributed lock mechanism when there are multiple timed task execution nodes at the same time, only one is guaranteed.
  • the task execution node can obtain execution rights, which makes the timed task cluster easier to deploy and maintain.
  • the timing calculation of the timing task is started. Specifically, when each timing task performs timing calculation, a distributed lock mechanism is adopted, and a temporary node is applied to the cluster according to the same path naming rule, and the sequence numbers of all created nodes under the temporary node are obtained, according to the sequence number of the temporary node. And determine whether the lock is successfully obtained to determine whether to perform timing calculation. Time synchronization is maintained when each task execution node starts. According to the package name and class name of the timed task, the cluster is shared by different timing tasks.
  • the execution information includes a task dependency.
  • the specific steps of triggering the timing task in the task processing method provided by the embodiment of the present application are as follows:
  • the execution information includes a task dependency
  • acquiring execution information of other timing tasks that the timing task depends on the task dependency means that the triggering of the scheduled task execution depends on other timing tasks.
  • the timing task execution including the task dependency is triggered when the other timing task execution meets the preset condition.
  • D2 Monitor the other timing tasks according to execution information of the other timing tasks.
  • the other timing tasks refer to timing tasks other than the scheduled tasks including task dependencies.
  • the dependency condition on which the task depends may be preset. For example, if the dependency condition that the task depends on is that other scheduled tasks are completed, when the other scheduled tasks are detected to be completed, the scheduled task is triggered to start. If the task depends on the dependency condition that the other timing tasks are executed halfway, the timing task is triggered to start when it is detected that the other timing tasks are half done.
  • the task in the execution information of the timed task depends on acquiring execution information of other timed tasks on which the execution of the timed task depends, and monitoring the other timed tasks to trigger the timing in time.
  • the task is started, and the timing task is prevented from being executed in advance or delayed.
  • the timed task file package uploaded by the user from the user operation interface is obtained, and the timed task file package is scanned to obtain a timed task in the timed task file package, and the timed task is independent of the execution program, and does not affect each other. And acquiring the execution information of the timed task, and when the timed task is started, assigning the timed task to the task execution node corresponding to the execution information according to the execution information, so that the task execution node is loaded.
  • the scheduled task is executed.
  • the solution adopts distributed deployment. The execution of the scheduled task is not affected by the failure of the single-point server. It is not necessary to redeploy the program when updating the task, which improves the efficiency of the task execution and improves the development efficiency.
  • FIG. 6 shows a task processing method including an alert prompt provided by an embodiment of the present application, which is described in detail as follows:
  • S201 Acquire a timed task file package uploaded by the user from the user operation interface.
  • S202 Scan the timed task file package to obtain a timed task in the timed task file package.
  • S203 Acquire execution information of the timed task.
  • step S201 to the step S204 For the specific steps of the step S201 to the step S204, refer to the steps S101 to S104 of the foregoing embodiment, and details are not described herein again.
  • S205 Obtain a task execution log recorded by the task execution node that executes the timed task in real time.
  • the task execution log includes a situation when the task execution node performs a task.
  • S206 Scan the task execution log periodically to detect whether the task execution node has an abnormality when executing the timed task.
  • the abnormality includes a performance abnormality of the task execution node when performing the timing task.
  • S207 Send an alarm prompt if the task execution node has an abnormality when performing the timed task.
  • the form of the alert prompt includes, but is not limited to, a mail prompt, an audible alarm prompt, and an information prompt.
  • the developer first implements the specified scheduling platform interface, completes the function development, packages the scheduled task into a jar, uploads the jar in the user operation interface to complete the task submission, and the central server uploads the jar to the file. Server, and scan all interfaces in the jar to generate scheduled tasks.
  • the execution information of the scheduled task is obtained from the task console, including the execution period of the scheduled task, the task parameter, or the specified task execution node, and even the task dependency of the scheduled task.
  • a jar may have multiple tasks.
  • the scheduled task When the scheduled task is started, the scheduled task is assigned to the task execution node according to the execution information of the scheduled task, and the task execution node acquires the jar from the file server according to the execution information of the scheduled task, and loads.
  • the timing task The task execution ends when the task execution cycle arrives.
  • the central server obtains the task execution log recorded by the task execution node executing the scheduled task in real time, records the task execution log when the task node executes the task, and periodically scans the task execution log, if the task execution node is If an abnormality occurs when the scheduled task is executed, an alarm prompt is sent to solve the abnormality in time and improve the efficiency of task processing.
  • the timed task file package uploaded by the user from the user operation interface is obtained, and the timed task file package is scanned to obtain a timed task in the timed task file package, and the timed task is independent of the execution program, and does not affect each other. And acquiring the execution information of the timed task, and when the timed task is started, assigning the timed task to the task execution node corresponding to the execution information according to the execution information, so that the task execution node is loaded.
  • Performing the timed task after the timed task is allocated, acquiring a task execution log recorded by the task execution node executing the timed task in real time, periodically scanning the task execution log, and detecting that the task execution node is performing the timing If there is an abnormality in the task, if the task execution node has an abnormality when executing the timed task, an alert is sent, and the solution is distributed.
  • the execution of the scheduled task is not affected by the failure of the single-point server. No need to redeploy the program and execute on the task execution node Service of process monitoring, found abnormal alarm notification is sent, in order to promptly resolve exceptions, at the same time improve the efficiency of task execution can improve the efficiency of development.
  • FIG. 7 is a structural block diagram of the task processing apparatus provided by the embodiment of the present application. For the convenience of description, only parts related to the embodiment of the present application are shown.
  • the task processing apparatus includes: a file package acquisition unit 71, a scanning unit 72, an information acquisition unit 73, and a task processing unit 74, wherein:
  • a file package obtaining unit 71 configured to acquire a timed task file package uploaded by the user from the user operation interface
  • the scanning unit 72 is configured to scan the timed task file package to obtain a timed task in the timed task file package.
  • the information obtaining unit 73 acquires execution information of the timed task
  • the task processing unit 74 when the timed task is started, allocates the timed task to the task execution node corresponding to the execution information according to the execution information, so that the task execution node loads and executes the timed task.
  • the task processing unit 74 includes:
  • a voice parsing module configured to parse the timed task when the timed task is started, and obtain a written statement of the timed task
  • a voice determining module configured to perform language format matching on the written statement, and determine an implementation language of the timed task
  • a first task assigning module configured to allocate the timed task to a task execution node that supports the implementation language according to an implementation language of the timed task, so that the task execution node loads and executes the timed task.
  • the task processing unit 74 includes:
  • a performance information obtaining module configured to acquire performance information of the task execution node when the timed task is started
  • a sorting module configured to compare performance of the task execution node according to performance information of the task execution node, and sort the task execution nodes from high to low according to performance
  • a second task assigning module configured to allocate the timing task to a task execution node that satisfies the performance requirement according to performance requirements in the execution information and the task execution node sorted by performance from high to low, so that The task execution node loads and executes the timing task.
  • the task processing unit 74 includes:
  • a permission detecting module configured to determine, when the scheduled task is started, whether the specified task execution node has a scheduled task execution permission
  • a third task assignment module configured to: if the specified task execution node has a scheduled task execution permission, assign the scheduled task to the specified scheduled task execution node;
  • the fourth task assignment module is configured to: if the specified task execution node does not have the scheduled task execution permission, assign the scheduled task to the task execution node that has the scheduled task execution authority and is in an idle state.
  • the task processing apparatus further includes:
  • the execution information acquiring unit 75 is configured to acquire execution information of other timing tasks that the timing task depends on if the execution information includes a task dependency, where the task dependency means that the triggering of the timing task execution depends on other timing tasks. Specifically, the timing task execution including the task dependency is triggered when the other timing task execution meets the dependency condition;
  • the monitoring unit 76 is configured to monitor the other timing tasks according to execution information of the other timing tasks;
  • the task triggering unit 77 is configured to trigger the timing task to be started if it is detected that the execution of the other timing task satisfies the dependency condition of the task dependency.
  • the task processing apparatus further includes:
  • the log obtaining unit 78 is configured to acquire, in real time, a task execution log recorded by the task execution node that executes the timed task;
  • the abnormality detecting unit 79 is configured to periodically scan the task execution log, and detect whether the task execution node has an abnormality when executing the timing task.
  • the alarm prompting unit 710 is configured to send an alarm prompt if the task execution node has an abnormality when performing the timing task.
  • the timed task file package uploaded by the user from the user operation interface is obtained, and the timed task file package is scanned to obtain a timed task in the timed task file package, and the timed task is independent of the execution program, and does not affect each other. And acquiring the execution information of the timed task, and when the timed task is started, assigning the timed task to the task execution node corresponding to the execution information according to the execution information, so that the task execution node is loaded.
  • the scheduled task is executed.
  • the solution adopts distributed deployment. The execution of the scheduled task is not affected by the failure of the single-point server. It is not necessary to redeploy the program when updating the task, which improves the efficiency of the task execution and improves the development efficiency.
  • FIG. 8 is a schematic diagram of a server according to an embodiment of the present application.
  • the server 8 of this embodiment includes a processor 80, a memory 81, and computer readable instructions 82, such as task processing programs, stored in the memory 81 and executable on the processor 80.
  • the processor 80 executes the computer readable instructions 82 to implement the steps in the various task processing method embodiments described above, such as steps 101 through 104 shown in FIG.
  • the processor 80 when executing the computer readable instructions 82, implements the functions of the various modules/units in the various apparatus embodiments described above, such as the functions of the units 71-74 shown in FIG.
  • the computer readable instructions 82 may be partitioned into one or more modules/units that are stored in the memory 81 and executed by the processor 80, To complete this application.
  • the one or more modules/units may be a series of computer readable instruction instruction segments capable of performing a particular function for describing the execution of the computer readable instructions 82 in the server 8.
  • the server 8 can be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the server may include, but is not limited to, a processor 80, a memory 81. It will be understood by those skilled in the art that FIG. 8 is merely an example of the server 8, does not constitute a limitation of the server 8, may include more or less components than those illustrated, or combine some components, or different components, such as
  • the server may also include an input and output device, a network access device, a bus, and the like.
  • the processor 80 can be a central processing unit (Central) Processing Unit, CPU), can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
  • the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
  • the memory 81 may be an internal storage unit of the server 8, such as a hard disk or a memory of the server 8.
  • the memory 81 may also be an external storage device of the server 8, such as a plug-in hard disk equipped with the server 8, a smart memory card (SMC), and a Secure Digital (SD) card. Flash card (Flash Card) and so on. Further, the memory 81 may also include both an internal storage unit of the server 8 and an external storage device.
  • the memory 81 is used to store the computer readable instructions and other programs and data required by the server.
  • the memory 81 can also be used to temporarily store data that has been output or is about to be output.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated modules/units if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium.
  • the present application implements all or part of the processes in the foregoing embodiments, and may also be implemented by computer readable instructions, which may be stored in a computer readable storage medium.
  • the computer readable instructions when executed by a processor, may implement the steps of the various method embodiments described above. It should be noted that the content contained in the computer readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in a jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, computer readable media Does not include electrical carrier signals and telecommunication signals.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本申请提供了一种任务处理方法、存储介质、服务器和装置,包括:获取用户从用户操作界面上传的定时任务文件包;扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;获取所述定时任务的执行信息;当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。本申请定时任务独立于执行程序,定时任务的执行不会被单点服务器的故障影响,在更新任务时无需重新部署程序,提高任务执行的效率的同时可提高开发的效率。

Description

一种任务处理方法、存储介质、服务器和装置
本申请要求于2018年04月09日提交中国专利局、申请号为CN 201810309682.2、发明名称为“一种任务处理方法、存储介质和服务器”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及信息处理技术领域,尤其涉及一种任务处理方法、存储介质、服务器和装置。
背景技术
在使用Java的应用系统中,通常实现定时任务通过两种方式:一种是使用Java开发工具集(Java Development Kit,JDK)自带的定时器(Timer)工具实现,另一种是使用开放源代码组织(opensymphony)的Quartz定时任务框架实现。JDK自带的Timer能实现最简单的定时任务,以有规律的时间间隔来检查任务(Task)类状态,这样就能按指定的重复执行时间和重复执行次数来触发指定的Task类。Quartz能实现比较完善的定时任务,其使用多个子线程来执行指定的Jab类,只要开发人员的作业实现了Jab类,就能在配置文件中用cron表达式来指定时任务的触发时间。然而,上述两种实现定时任务的方式在使用时需要硬编码指定作业的触发时间,每次任务更新都需要重新部署程序,耗费大量的时间,导致开发效率低下。
技术问题
现有定时任务的方式在使用时需要硬编码指定作业的触发时间,每次任务更新都需要重新部署程序,耗费大量的时间,导致开发效率低下的问题。
技术解决方案
本申请实施例提供了一种任务处理方法、存储介质、服务器和装置,以解决现有定时任务的方式在使用时需要硬编码指定作业的触发时间,每次任务更新都需要重新部署程序,耗费大量的时间,导致开发效率低下的问题。
本申请实施例的第一方面提供了一种任务处理方法,包括:
获取用户从用户操作界面上传的定时任务文件包;
扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
获取所述定时任务的执行信息;
当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
本申请实施例的第二方面提供了一种服务器,包括存储器以及处理器,所述存储器存储有可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:
获取用户从用户操作界面上传的定时任务文件包;
扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
获取所述定时任务的执行信息;
当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
本申请实施例的第三方面提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,所述计算机可读指令被处理器执行时实现如下步骤:
获取用户从用户操作界面上传的定时任务文件包;
扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
获取所述定时任务的执行信息;
当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
本申请实施例的第四方面提供了一种任务处理装置,包括:
文件包获取单元,用于获取用户从用户操作界面上传的定时任务文件包;
扫描单元,用于扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
信息获取单元,获取所述定时任务的执行信息;
任务处理单元,当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
有益效果
本申请实施例中,通过获取用户从用户操作界面上传的定时任务文件包,扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务,定时任务独立于执行程序,互不影响,再获取所述定时任务的执行信息,当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,本方案采用分布式部署,定时任务的执行不会被单点服务器的故障影响,在更新任务时无需重新部署程序,提高任务执行的效率的同时可提高开发的效率。
附图说明
图1是本申请实施例提供的任务处理方法的实现流程图;
图2是本申请实施例提供的任务处理方法中执行信息包括定时任务的实现语言时S104的具体实现流程图;
图3是本申请实施例提供的任务处理方法中执行信息包括性能需求时S104的具体实现流程图;
图4是本申请实施例提供的任务处理方法中执行信息包括指定的任务执行节点时S104的具体实现流程图;
图5是本申请实施例提供的任务处理方法中执行信息包括任务依赖时触发定时任务启动的具体实现流程图;
图6是本申请另一实施例提供的任务处理方法的实现流程图;
图7是本申请实施例提供的任务处理装置的结构框图;
图7.1是本申请实施例提供的另一种任务处理装置的结构框图;
图8是本申请实施例提供的服务器的示意图。
本发明的实施方式
图1示出了本申请实施例提供的任务处理方法的实现流程,该方法流程包括步骤S101至S104。各步骤的具体实现原理如下:
S101:获取用户从用户操作界面上传的定时任务文件包。
本申请实施例提供的任务处理方法应用于分布式系统集群中。在分布式系统集群中,采用分布式协调技术(ZooKeeper,ZK)来协调整个集群。在该分布式系统集群中,包括中心服务器、任务控制台和任务执行节点,且该分布式系统集群支持任务执行节点自发现功能作为动态扩容。所述任务控制台用于设置定时任务的执行信息,还用于对所述任务执行节点进行监控。所述中心服务器将定时任务文件包中的定时任务分配至任务执行节点。
其中,所述定时任务文件包中包括定时任务,所述定时任务是使用计算机语言编写的,如可使用Java编写打包后生成jar包,还可以使用如Python、PHP等其他计算机语言编写,并将编写的定时任务打包生成定时任务文件包,定时任务的编写语言在此不作限定。在本申请实施例中,用户从用户操作界面上传的定时任务文件包存储在文件服务器中,扫描所述定时任务文件包,生成定时任务。一个定时任务文件包中可包括不止一个定时任务。
在本申请实施例中,将定时任务打包成独立的定时任务文件包由用户通过用户操作界面上传至文件存储器,定时任务从任务执行节点中独立出来,从而使得各个定时任务和任务执行节点的服务器互不影响。
S102:扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务。
在本申请实施例中,所述定时任务文件包中包括接口信息,中心服务器通过扫描所述定时任务文件包获取接口信息生成定时任务。
S103:获取所述定时任务的执行信息。
其中,所述定时任务的执行信息包括执行启动时间、执行周期和任务参数,还可以包括指定的任务执行节点。任务参数包括定时任务文件包存储的位置,任务参数在定时任务文件包上传至文件服务器时自动生成。在本申请实施例中,所述定时任务的执行信息可由用户通过任务控制台设置,即用户在所述任务控制台上指定所述定时任务的执行周期和任务执行节点等执行信息。
可选地,可以在一开始编写定时任务时直接加入所述定时任务的执行信息。
S104:当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
具体地,中心服务器在获取所述定时任务的执行信息后,记录所述执行信息。进一步地,根据所述执行信息中的执行启动时间设置定时器,并启动倒计时,中心服务器准时分配所述定时任务。当所述定时任务启动时,服务器根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,若所述执行信息包括所述定时任务指定的任务执行节点,则直接将所述定时任务分配至所述指定的任务执行节点,以使得所述任务执行节点加载执行所述执行任务。进一步地,所述任务执行节点根据所述执行信息中的任务参数获取所述定时任务的位置,并加载执行所述定时任务。
可选地,在本申请实施例中,为避免任务执行冲突,在一个时间点只分配一个定时任务至一个任务执行节点,因此,在将定时任务分配至任务执行节点之前,先获取所述指定的任务执行节点的状态信息,任务执行节点的状态信息包括空闲状态和忙碌状态,空闲状态即为未执行任务,忙碌状态表示正在执行任务,根据所述指定的任务执行节点的状态信息判断所述任务执行节点是否处于空闲状态。若所述指定的任务执行节点处于空闲状态,将待分配的所述定时任务分配至所述指定的任务执行节点进行加载执行。若所述指定的任务执行节点处于忙碌状态,则挂起待分配的所述定时任务,直至所述指定的任务执行节点进入空闲状态。
在本申请实施例中,作为本申请的一个实施例,所述执行信息包括定时任务的实现语言,图2示出了本申请实施例提供的任务处理方法步骤S104的具体实现流程,详述如下:
A1:当所述定时任务启动时,解析所述定时任务,获取所述定时任务的编写语句。
A2:将所述编写语句进行语言格式匹配,确定所述定时任务的实现语言。具体地,语言格式匹配是指在预设的语言库查找与所述编写语句匹配的语言格式,从而确定所述定时任务的实现语言。
A3:根据所述定时任务的实现语言,将所述定时任务分配至支持所述实现语言的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。具体地,在分布式集群中的任务执行节点都具有语言标签,所述语言标签用于标识所述任务执行节点所支持的计算机语音。
在本申请实施例中,由于本实施例中可支持多种计算机语言实现定时任务,所述定时任务是使用JAVA、Python、PHP、C语言或者其他计算机语言编写的,因此,若所述定时任务的执行信息不包括指定的任务执行节点,则可根据定时任务实现的语言的不同,将定时任务分配至不同的任务执行节点,具体地,将定时任务分配至支持所述定时任务的实现语言的任务执行节点加载执行,以提高定时任务执行的效率。
可选地,若支持所述定时任务的实现语音的任务执行节点不止一个,则可根据任务执行节点的优先级或者任务执行节点的状态信息分配所述定时任务。
可选地,当任务执行节点处于工作状态时,获取所述执行的定时任务的个数,任务的个数包括正在执行的定时任务的个数,还包括所述任务执行节点待执行的定时任务个数。根据定时任务的个数设置各个任务执行节点的优先级。当所说任务执行节点的定时任务的个数相同时,获取任务执行节点执行完任务进入空闲状态需要的时间,根据进入空闲状态需要的时间设置任务执行节点的优先级。
作为本申请的一个实施例,所述执行信息包括性能需求,图3示出了本申请实施例提供的任务处理方法S104的具体实现流程,详述如下:
B1:当所述定时任务启动时,获取所述任务执行节点的性能信息。所述任务执行节点的性能信息包括执行节点服务器的内存占用情况、日志记录、CPU性能以及网络速度中的一项或者多项。具体地,可通过jstat对VM内存使用量进行监控,或者,在每个任务执行节点设有shell脚本定时获取任务执行节点的服务器的cpu、内存,硬盘等性能信息。
B2:根据所述任务执行节点的性能信息,比较所述任务执行节点的性能,并将所述任务执行节点按性能从高到低排序。
B3:根据所述执行信息中的性能需求与所述按性能从高到低排序的任务执行节点,分配所述定时任务至满足所述性能需求的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。例如,若所述执行信息包括对运行内存的要求,则查看当前可分配的任务执行节点的内存占用从高到低的排列情况,将定时任务分配至满足所述运行内存的要求的任务执行节点加载执行。若所述执行信息包括对运行内存的要求以及网络速度的要求,则将定时任务分配至满足所述运行内存的要求并且满足所述网络速度的要求的任务执行节点加载执行。
在本申请实施例中,根据定时任务的执行信息中对任务执行节点的性能需求,合理分配所述定时任务,以提高定时任务执行的效率。
作为本申请的一个实施例,所述执行信息包括指定的任务执行节点,图4示出了本申请实施例提供的任务处理方法S104的具体实现流程,详述如下:
C1:当所述定时任务启动时,判断所述指定的任务执行节点是否具有定时任务执行权限。
C2:若所述指定的任务执行节点具备定时任务执行权限,则将所述定时任务分配至所述指定的定时任务执行节点。
C3:若所述指定的任务执行节点不具备定时任务执行权限,则将所述定时任务分配至具备定时任务执行权限且处于空闲状态的任务执行节点。
通过判断所述定时任务指定的任务执行节点是否具有定时任务执行权限,再决定是否将定时任务分配至所述指定的任务执行节点,从而避免分配失败,导致任务的执行效率降低。
具体地,各定时任务为永驻进程,到指定时间点,各个定时任务执行节点按照相同的路径命名规则向 Zookeeper 集群申请写入相同的路径信息,获得写入权的任务执行节点即获得任务执行权限,将执行定时任务,而未获得写入权的任务执行节点则未获的任务执行权限,只能放弃执行定时任务,等到下一个指定时间点,各定时任务执行节点再重复上述操作。当定时任务启动时,为获得定时任务执行权限的任务执行节点分配定时任务,而未获得定时任务执行权限的任务执行节点不分配定时任务,直到下一个预设的时间点,再循环获取定时任务执行权限。
示例性地,任务执行节点按照相同的路径命名规则向集群内申请写入相同的路径信息。路径命名规则包括:根据定时任务文件包包名、类名以及当前时间戳,生成节点路径。例如:“cn.knet.timing.TcpTask”这一定时任务,按计划要在2018年4月5号15点30分执行定时计算,则生成的路径应该为“/cn/knet/timing/tcptask/201008052030”。
可选地,当多个定时任务同时运行,在预期时间点,只有一个定时任务执行节点执行任务,通过采用集群分布式锁机制,在同时具有多个定时任务执行节点的情况下,保证只有一个任务执行节点可以获得执行权限,从而使定时任务集群在部署及维护上更加简单便捷。
可选地,当任务执行节点处理开始执行任务时,开启定时任务的定时计算。具体地,各个定时任务执行定时计算时,采用分布式锁机制,按照相同的路径命名规则,向集群内申请创建一个临时节点,并获得临时节点下的所有创建节点的序号,根据临时节点的序号,判断是否获得锁成功以确定是否执行定时计算。各个任务执行节点启动时保持时间同步。根据对定时任务的包名以及类名进行区分,以实现不同的定时任务共享集群。各定时任务执行定时计算时,先按照相同的路径命名规则,向分布式集群申请创建一个临时节点,并获得这个节点下所有创建节点的序号,如果自己的节点序号最小,则视为获得锁,继续执行定时计算,计算完毕删除临时节点;如果自己节点序号不是最小,则视为获得锁失败,删除临时节点,取消本次定时计算。
可选地,所述执行信息包括任务依赖,如图5所示,本申请实施例提供的任务处理方法中定时任务的触发的具体步骤如下:
D1:若所述执行信息包括任务依赖,获取所述定时任务依赖的其他定时任务的执行信息,所述任务依赖是指所述定时任务执行的触发依赖于其他定时任务。具体地,当所述其他定时任务执行满足预设条件时才触发包括任务依赖的定时任务执行。
D2:根据所述其他定时任务的执行信息监控所述其他定时任务。所述其他定时任务是指除包括任务依赖的所述定时任务以外的定时任务
D3:若检测到所述其他定时任务的执行满足所述任务依赖的依赖条件,则触发所述定时任务启动。所述任务依赖的依赖条件可以预先设定。例如,若所述任务依赖的依赖条件是其他定时任务完成,则当检测到所述其他定时任务完成时,触发所述定时任务启动。若所述任务依赖的依赖条件是其他定时任务执行到一半,则当检测到所述其他定时任务完成到一半时,触发所述定时任务启动。
在本申请实施例中,通过定时任务的执行信息中的任务依赖获取所述定时任务的执行所依赖的其他定时任务的执行信息,并对所述其他定时任务进行监控,以便及时触发所述定时任务启动,避免提前或者延迟启动所述定时任务而导致所述定时任务执行失败。
本申请实施例中,通过获取用户从用户操作界面上传的定时任务文件包,扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务,定时任务独立于执行程序,互不影响,再获取所述定时任务的执行信息,当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,本方案采用分布式部署,定时任务的执行不会被单点服务器的故障影响,在更新任务时无需重新部署程序,提高任务执行的效率的同时可提高开发的效率。
作为本申请的一个实施例,图6示出了本申请实施例提供的一种包括告警提示的任务处理方法,详述如下:
S201:获取用户从用户操作界面上传的定时任务文件包。
S202:扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务。
S203:获取所述定时任务的执行信息。
S204:当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
本实施例中,步骤S201至步骤S204的具体步骤参见上述实施例步骤S101至步骤S104,在此不再赘述。
S205:实时获取执行所述定时任务的任务执行节点记录的任务执行日志。
具体地,所述任务执行日志包括任务执行节点在执行任务时的情况。
S206:定时扫描所述任务执行日志,检测所述任务执行节点在执行所述定时任务时是否存在异常。
具体地,所述异常包括所述任务执行节点在执行所述定时任务时的性能异常。
S207:若所述任务执行节点在执行所述定时任务时存在异常,则发送告警提示。
其中,告警提示的形式包括但不限于邮件提示、声音警报提示、信息提示。
示例性地,以jar任务文件包为例,开发人员先实现指定的调度平台接口,完成功能开发,将定时任务打包成jar,在用户操作界面上传jar完成任务提交,中心服务器将jar上传至文件服务器,并扫描jar里面的所有接口生成定时任务。从任务控制台获取所述定时任务的执行信息,包括定时任务的执行周期、任务参数,或者指定的任务执行节点,甚至还有所述定时任务的任务依赖等。一个jar可以有多个任务,当定时任务启动时候,根据定时任务的执行信息将所述定时任务分配至任务执行节点,任务执行节点根据所述任定时任务的执行信息从文件服务器获取jar,加载该定时任务。当任务执行周期到达时结束任务执行。在任务执行过程中,中心服务器实时获取执行所述定时任务的任务执行节点记录的任务执行日志,记录任务节点执行任务时的任务执行日志,并定时扫描任务执行日志,若所述任务执行节点在执行所述定时任务时存在异常,则发送告警提示,以便及时解决异常,提高任务处理的效率。
本申请实施例中,通过获取用户从用户操作界面上传的定时任务文件包,扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务,定时任务独立于执行程序,互不影响,再获取所述定时任务的执行信息,当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,在分配完定时任务之后,再实时获取执行所述定时任务的任务执行节点记录的任务执行日志,定时扫描所述任务执行日志,检测所述任务执行节点在执行所述定时任务时是否存在异常,若所述任务执行节点在执行所述定时任务时存在异常,则发送告警提示,本方案采用分布式部署,定时任务的执行不会被单点服务器的故障影响,在更新任务时无需重新部署程序,并在对任务执行节点执行任务的过程进行监控,在发现异常时发送告警提示,以便及时解决异常,提高任务执行的效率的同时可提高开发的效率。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
对应于上文实施例所述的任务处理方法,图7示出了本申请实施例提供的任务处理装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。
参照图7,该任务处理装置包括:文件包获取单元71,扫描单元72,信息获取单元73,任务处理单元74,其中:
文件包获取单元71,用于获取用户从用户操作界面上传的定时任务文件包;
扫描单元72,用于扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
信息获取单元73,获取所述定时任务的执行信息;
任务处理单元74,当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
可选地,所述任务处理单元74包括:
语音解析模块,用于当所述定时任务启动时,解析所述定时任务,获取所述定时任务的编写语句;
语音确定模块,用于将所述编写语句进行语言格式匹配,确定所述定时任务的实现语言;
第一任务分配模块,用于根据所述定时任务的实现语言,将所述定时任务分配至支持所述实现语言的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
可选地,所述任务处理单元74包括:
性能信息获取模块,用于当所述定时任务启动时,获取所述任务执行节点的性能信息;
排序模块,用于根据所述任务执行节点的性能信息,比较所述任务执行节点的性能,并将所述任务执行节点按性能从高到低排序;
第二任务分配模块,用于根据所述执行信息中的性能需求与所述按性能从高到低排序的任务执行节点,分配所述定时任务至满足所述性能需求的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
可选地,所述任务处理单元74包括:
权限检测模块,用于当所述定时任务启动时,判断所述指定的任务执行节点是否具有定时任务执行权限;
第三任务分配模块,用于若所述指定的任务执行节点具备定时任务执行权限,则将所述定时任务分配至所述指定的定时任务执行节点;
第四任务分配模块,用于若所述指定的任务执行节点不具备定时任务执行权限,则将所述定时任务分配至具备定时任务执行权限且处于空闲状态的任务执行节点。
可选地,如图7.1所示,所述任务处理装置还包括:
执行信息获取单元75,用于若所述执行信息包括任务依赖,获取所述定时任务依赖的其他定时任务的执行信息,所述任务依赖是指所述定时任务执行的触发依赖于其他定时任务。具体地,当所述其他定时任务执行满足依赖条件时才触发包括任务依赖的定时任务执行;
监控单元76,用于根据所述其他定时任务的执行信息监控所述其他定时任务;
任务触发单元77,用于若检测到所述其他定时任务的执行满足所述任务依赖的依赖条件,则触发所述定时任务启动。
可选地,所述任务处理装置还包括:
日志获取单元78,用于实时获取执行所述定时任务的任务执行节点记录的任务执行日志;
异常检测单元79,用于定时扫描所述任务执行日志,检测所述任务执行节点在执行所述定时任务时是否存在异常;
告警提示单元710,用于若所述任务执行节点在执行所述定时任务时存在异常,则发送告警提示。
本申请实施例中,通过获取用户从用户操作界面上传的定时任务文件包,扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务,定时任务独立于执行程序,互不影响,再获取所述定时任务的执行信息,当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,本方案采用分布式部署,定时任务的执行不会被单点服务器的故障影响,在更新任务时无需重新部署程序,提高任务执行的效率的同时可提高开发的效率。
图8是本申请一实施例提供的服务器的示意图。如图8所示,该实施例的服务器8包括:处理器80、存储器81以及存储在所述存储器81中并可在所述处理器80上运行的计算机可读指令82,例如任务处理程序。所述处理器80执行所述计算机可读指令82时实现上述各个任务处理方法实施例中的步骤,例如图1所示的步骤101至104。或者,所述处理器80执行所述计算机可读指令82时实现上述各装置实施例中各模块/单元的功能,例如图7所示单元71至74的功能。
示例性的,所述计算机可读指令82可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器81中,并由所述处理器80执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机可读指令指令段,该指令段用于描述所述计算机可读指令82在所述服务器8中的执行过程。
所述服务器8可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述服务器可包括,但不仅限于,处理器80、存储器81。本领域技术人员可以理解,图8仅仅是服务器8的示例,并不构成对服务器8的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述服务器还可以包括输入输出设备、网络接入设备、总线等。
所述处理器80可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器 (Digital Signal Processor,DSP)、专用集成电路 (Application Specific Integrated Circuit,ASIC)、现成可编程门阵列 (Field-Programmable Gate Array,FPGA) 或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器81可以是所述服务器8的内部存储单元,例如服务器8的硬盘或内存。所述存储器81也可以是所述服务器8的外部存储设备,例如所述服务器8上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器81还可以既包括所述服务器8的内部存储单元也包括外部存储设备。所述存储器81用于存储所述计算机可读指令以及所述服务器所需的其他程序和数据。所述存储器81还可以用于暂时地存储已经输出或者将要输出的数据。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一计算机可读存储介质中,该计算机可读指令在被处理器执行时,可实现上述各个方法实施例的步骤。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种任务处理方法,其特征在于,包括:
    获取用户从用户操作界面上传的定时任务文件包;
    扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
    获取所述定时任务的执行信息;
    当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  2. 根据权利要求1所述的任务处理方法,其特征在于,所述执行信息包括定时任务的实现语言,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,解析所述定时任务,获取所述定时任务的编写语句;
    将所述编写语句进行语言格式匹配,确定所述定时任务的实现语言;
    根据所述定时任务的实现语言,将所述定时任务分配至支持所述实现语言的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  3. 根据权利要求1所述的任务处理方法,其特征在于,所述执行信息包括性能需求,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,获取所述任务执行节点的性能信息;
    根据所述任务执行节点的性能信息,比较所述任务执行节点的性能,并将所述任务执行节点按性能从高到低排序;
    根据所述执行信息中的性能需求与所述按性能从高到低排序的任务执行节点,分配所述定时任务至满足所述性能需求的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  4. 根据权利要求1所述的任务处理方法,其特征在于,所述执行信息包括指定的任务执行节点,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,判断所述指定的任务执行节点是否具有定时任务执行权限;
    若所述指定的任务执行节点具备定时任务执行权限,则将所述定时任务分配至所述指定的定时任务执行节点;
    若所述指定的任务执行节点不具备定时任务执行权限,则将所述定时任务分配至具备定时任务执行权限且处于空闲状态的任务执行节点。
  5. 根据权利要求1至4任一项所述的任务处理方法,其特征在于,所述任务处理方法还包括:
    实时获取执行所述定时任务的任务执行节点记录的任务执行日志;
    定时扫描所述任务执行日志,检测所述任务执行节点在执行所述定时任务时是否存在异常;
    若所述任务执行节点在执行所述定时任务时存在异常,则发送告警提示。
  6. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现如权下步骤:
    获取用户从用户操作界面上传的定时任务文件包;
    扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
    获取所述定时任务的执行信息;
    当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  7. 根据权利要求6所述的计算机可读存储介质,其特征在于,所述执行信息包括定时任务的实现语言,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,解析所述定时任务,获取所述定时任务的编写语句;
    将所述编写语句进行语言格式匹配,确定所述定时任务的实现语言;
    根据所述定时任务的实现语言,将所述定时任务分配至支持所述实现语言的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  8. 根据权利要求6所述的计算机可读存储介质,其特征在于,所述执行信息包括性能需求,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,获取所述任务执行节点的性能信息;
    根据所述任务执行节点的性能信息,比较所述任务执行节点的性能,并将所述任务执行节点按性能从高到低排序;
    根据所述执行信息中的性能需求与所述按性能从高到低排序的任务执行节点,分配所述定时任务至满足所述性能需求的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  9. 根据权利要求6所述的计算机可读存储介质,其特征在于,所述执行信息包括指定的任务执行节点,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,判断所述指定的任务执行节点是否具有定时任务执行权限;
    若所述指定的任务执行节点具备定时任务执行权限,则将所述定时任务分配至所述指定的定时任务执行节点;
    若所述指定的任务执行节点不具备定时任务执行权限,则将所述定时任务分配至具备定时任务执行权限且处于空闲状态的任务执行节点。
  10. 根据权利要求6至9任一项所述的计算机可读存储介质,其特征在于,所述计算机可读存储介质执行时还实现如下步骤:
    实时获取执行所述定时任务的任务执行节点记录的任务执行日志;
    定时扫描所述任务执行日志,检测所述任务执行节点在执行所述定时任务时是否存在异常;
    若所述任务执行节点在执行所述定时任务时存在异常,则发送告警提示。
  11. 一种服务器,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:
    获取用户从用户操作界面上传的定时任务文件包;
    扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
    获取所述定时任务的执行信息;
    当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  12. 如权利要求11所述的服务器,其特征在于,所述执行信息包括定时任务的实现语言,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,解析所述定时任务,获取所述定时任务的编写语句;
    将所述编写语句进行语言格式匹配,确定所述定时任务的实现语言;
    根据所述定时任务的实现语言,将所述定时任务分配至支持所述实现语言的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  13. 如权利要求11所述的服务器,其特征在于,所述执行信息包括性能需求,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,获取所述任务执行节点的性能信息;
    根据所述任务执行节点的性能信息,比较所述任务执行节点的性能,并将所述任务执行节点按性能从高到低排序;
    根据所述执行信息中的性能需求与所述按性能从高到低排序的任务执行节点,分配所述定时任务至满足所述性能需求的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  14. 如权利要求11所述的服务器,其特征在于,,所述执行信息包括指定的任务执行节点,所述当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务,包括:
    当所述定时任务启动时,判断所述指定的任务执行节点是否具有定时任务执行权限;
    若所述指定的任务执行节点具备定时任务执行权限,则将所述定时任务分配至所述指定的定时任务执行节点;
    若所述指定的任务执行节点不具备定时任务执行权限,则将所述定时任务分配至具备定时任务执行权限且处于空闲状态的任务执行节点。
  15. 如权利要求11至14任一项所述的服务器,其特征在于,所述处理器执行所述计算机可读指令时还实现如下步骤:
    实时获取执行所述定时任务的任务执行节点记录的任务执行日志;
    定时扫描所述任务执行日志,检测所述任务执行节点在执行所述定时任务时是否存在异常;
    若所述任务执行节点在执行所述定时任务时存在异常,则发送告警提示。
  16. 一种任务处理装置,其特征在于,包括:
    文件包获取单元,用于获取用户从用户操作界面上传的定时任务文件包;
    扫描单元,用于扫描所述定时任务文件包,获取所述定时任务文件包中的定时任务;
    信息获取单元,获取所述定时任务的执行信息;
    任务处理单元,当所述定时任务启动时,根据所述执行信息将所述定时任务分配至与所述执行信息对应的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  17. 根据权利要求16所述的任务处理装置,其特征在于,所述任务处理单元包括:
    语音解析模块,用于当所述定时任务启动时,解析所述定时任务,获取所述定时任务的编写语句;
    语音确定模块,用于将所述编写语句进行语言格式匹配,确定所述定时任务的实现语言;
    第一任务分配模块,用于根据所述定时任务的实现语言,将所述定时任务分配至支持所述实现语言的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  18. 根据权利要求16所述的任务处理装置,其特征在于,所述任务处理单元包括:
    性能信息获取模块,用于当所述定时任务启动时,获取所述任务执行节点的性能信息;
    排序模块,用于根据所述任务执行节点的性能信息,比较所述任务执行节点的性能,并将所述任务执行节点按性能从高到低排序;
    第二任务分配模块,用于根据所述执行信息中的性能需求与所述按性能从高到低排序的任务执行节点,分配所述定时任务至满足所述性能需求的任务执行节点,以使得所述任务执行节点加载执行所述定时任务。
  19. 根据权利要求16所述的任务处理装置,其特征在于,所述任务处理单元包括:
    权限检测模块,用于当所述定时任务启动时,判断所述指定的任务执行节点是否具有定时任务执行权限;
    第三任务分配模块,用于若所述指定的任务执行节点具备定时任务执行权限,则将所述定时任务分配至所述指定的定时任务执行节点;
    第四任务分配模块,用于若所述指定的任务执行节点不具备定时任务执行权限,则将所述定时任务分配至具备定时任务执行权限且处于空闲状态的任务执行节点。
  20. 根据权利要求16至19任一项所述的任务处理装置,其特征在于,所述任务处理装置还包括:
    日志获取单元,用于实时获取执行所述定时任务的任务执行节点记录的任务执行日志;
    异常检测单元,用于定时扫描所述任务执行日志,检测所述任务执行节点在执行所述定时任务时是否存在异常;
    告警提示单元,用于若所述任务执行节点在执行所述定时任务时存在异常,则发送告警提示。
PCT/CN2018/097096 2018-04-09 2018-07-25 一种任务处理方法、存储介质、服务器和装置 WO2019196250A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810309682.2A CN108710537A (zh) 2018-04-09 2018-04-09 一种任务处理方法、存储介质和服务器
CN201810309682.2 2018-04-09

Publications (1)

Publication Number Publication Date
WO2019196250A1 true WO2019196250A1 (zh) 2019-10-17

Family

ID=63866471

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/097096 WO2019196250A1 (zh) 2018-04-09 2018-07-25 一种任务处理方法、存储介质、服务器和装置

Country Status (2)

Country Link
CN (1) CN108710537A (zh)
WO (1) WO2019196250A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110764894A (zh) * 2019-10-24 2020-02-07 北京锐安科技有限公司 一种定时任务管理方法、装置、设备及存储介质
CN111984384A (zh) * 2020-08-24 2020-11-24 北京思特奇信息技术股份有限公司 一种守护类和定时类作业共存调度机制方法及相关装置

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109558234B (zh) * 2018-11-30 2021-06-04 中国联合网络通信集团有限公司 一种定时任务调度方法和装置
CN109783224B (zh) * 2018-12-10 2022-10-14 平安科技(深圳)有限公司 基于负载调配的任务分配方法、装置及终端设备
CN109656699A (zh) * 2018-12-14 2019-04-19 平安医疗健康管理股份有限公司 分布式计算方法、装置、系统、设备及可读存储介质
CN109684063B (zh) * 2018-12-26 2021-03-26 亚信科技(中国)有限公司 一种任务调度方法和装置
CN109800070A (zh) * 2019-01-02 2019-05-24 深圳壹账通智能科技有限公司 任务处理方法和系统
CN111026541B (zh) * 2019-05-22 2020-09-29 珠海随变科技有限公司 渲染资源调度方法、装置、设备及存储介质
CN110196765A (zh) * 2019-05-30 2019-09-03 苏州浪潮智能科技有限公司 定时任务处理方法、装置、设备及计算机可读存储介质
CN110231998B (zh) * 2019-06-13 2021-07-20 泰康保险集团股份有限公司 分布式定时任务的检测方法、装置及存储介质
CN110389961A (zh) * 2019-07-26 2019-10-29 苏州浪潮智能科技有限公司 定时任务处理方法、装置、设备及计算机可读存储介质
CN110532083A (zh) * 2019-09-04 2019-12-03 深圳市思迪信息技术股份有限公司 定时任务调度方法及装置
CN110888739B (zh) * 2019-11-22 2020-10-20 南京甄视智能科技有限公司 延迟任务的分布式处理方法与装置
CN111475272A (zh) * 2020-04-07 2020-07-31 四川虹美智能科技有限公司 控制Java Web应用定时任务的方法、装置及任务调度平台

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101604242A (zh) * 2009-07-17 2009-12-16 深圳市珍爱网信息技术有限公司 Java应用系统中实现定时任务的系统
CN106874094A (zh) * 2017-02-17 2017-06-20 广州爱九游信息技术有限公司 定时任务处理方法、装置及计算设备

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103744724A (zh) * 2014-02-19 2014-04-23 互联网域名系统北京市工程研究中心有限公司 定时任务集群方法及其装置
CN107748695B (zh) * 2017-10-24 2020-11-24 平安科技(深圳)有限公司 定时任务处理方法、装置、存储介质和计算机设备

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101604242A (zh) * 2009-07-17 2009-12-16 深圳市珍爱网信息技术有限公司 Java应用系统中实现定时任务的系统
CN106874094A (zh) * 2017-02-17 2017-06-20 广州爱九游信息技术有限公司 定时任务处理方法、装置及计算设备

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110764894A (zh) * 2019-10-24 2020-02-07 北京锐安科技有限公司 一种定时任务管理方法、装置、设备及存储介质
CN111984384A (zh) * 2020-08-24 2020-11-24 北京思特奇信息技术股份有限公司 一种守护类和定时类作业共存调度机制方法及相关装置
CN111984384B (zh) * 2020-08-24 2024-01-05 北京思特奇信息技术股份有限公司 一种守护类和定时类作业共存调度机制方法及相关装置

Also Published As

Publication number Publication date
CN108710537A (zh) 2018-10-26

Similar Documents

Publication Publication Date Title
WO2019196250A1 (zh) 一种任务处理方法、存储介质、服务器和装置
CN108845884B (zh) 物理资源分配方法、装置、计算机设备和存储介质
US8161453B2 (en) Method and apparatus for implementing task management of computer operations
US9582312B1 (en) Execution context trace for asynchronous tasks
US20180150326A1 (en) Method and apparatus for executing task in cluster
WO2018028580A1 (en) Automatically detecting distributed concurrency errors in cloud systems
CN110532074B (zh) 一种多租户模式SaaS服务集群环境的任务调度方法及系统
CN108710532B (zh) 跨调度平台的依赖实现方法、装置、设备和存储介质
CN109614167B (zh) 一种管理插件的方法和系统
CN113220431B (zh) 跨云的分布式数据任务调度方法、设备及存储介质
WO2013156877A1 (en) Application installation
CN111324423B (zh) 容器内进程的监控方法、装置、存储介质和计算机设备
CN109254765B (zh) 定时任务管理方法、装置、计算机设备及存储介质
CN107577527B (zh) 任务生成、调度方法及装置
US9015534B2 (en) Generation of memory dump of a computer process without terminating the computer process
CN110990136B (zh) 一种任务处理方法和任务调度器
WO2019117767A1 (en) Method, function manager and arrangement for handling function calls
US20230281299A1 (en) Computing device for establishing a trusted execution environment
CN114006815B (zh) 云平台节点的自动化部署方法、装置、节点及存储介质
CN110968406B (zh) 处理任务的方法、装置、存储介质和处理器
CN116382694A (zh) 一种提升容器环境下Maven工程编译速度的方法
CN114791884A (zh) 测试环境的构建方法、装置、存储介质及电子设备
US20220405104A1 (en) Cross platform and platform agnostic accelerator remoting service
CN115220887A (zh) 调度信息的处理方法、任务处理系统、处理器和电子设备
CN114328722A (zh) 一种支持多数据源的数据同步方法、装置及计算机设备

Legal Events

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

Ref document number: 18914051

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 25.01.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 18914051

Country of ref document: EP

Kind code of ref document: A1