CN110543354A - Task scheduling method, device, equipment and storage medium - Google Patents

Task scheduling method, device, equipment and storage medium Download PDF

Info

Publication number
CN110543354A
CN110543354A CN201910838376.2A CN201910838376A CN110543354A CN 110543354 A CN110543354 A CN 110543354A CN 201910838376 A CN201910838376 A CN 201910838376A CN 110543354 A CN110543354 A CN 110543354A
Authority
CN
China
Prior art keywords
task
executed
tasks
state
control node
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.)
Granted
Application number
CN201910838376.2A
Other languages
Chinese (zh)
Other versions
CN110543354B (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.)
Tencent Technology Shanghai Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910838376.2A priority Critical patent/CN110543354B/en
Publication of CN110543354A publication Critical patent/CN110543354A/en
Application granted granted Critical
Publication of CN110543354B publication Critical patent/CN110543354B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a task scheduling method, a task scheduling device and a task scheduling storage medium, wherein the method comprises the following steps: when the state of the control node changes, the control node determines a task set to be executed corresponding to the changed state; sequencing the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed to obtain a task sequence to be executed; and sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed so as to realize the scheduling of the task to be executed. Therefore, the context maintenance efficiency of task scheduling can be improved, and the maintenance cost can be reduced.

Description

Task scheduling method, device, equipment and storage medium
Technical Field
the embodiment of the application relates to the technical field of internet, and relates to but is not limited to a task scheduling method, a task scheduling device and a task scheduling storage medium.
Background
At present, when a task running on a computer is scheduled, a conventional state mechanism usually sets a two-dimensional matrix state table, and identifies the validity of a jump between state machines through the two-dimensional matrix state table, so as to implement a recursive jump between states and execute the task of each state. Namely, under the condition of limited states, the jump can be quickly and effectively realized, and a series of tasks corresponding to the states are executed when one state is entered each time.
However, when a state changes, for example, a state is added or deleted, a corresponding task also changes, and at this time, all contexts of the state machine need to be maintained, that is, reconstruction is needed for the changed state.
Disclosure of Invention
The embodiment of the application provides a task scheduling method, a task scheduling device and a task scheduling storage medium, which can ensure context logic of task scheduling and improve context maintenance efficiency of task scheduling.
The technical scheme of the embodiment of the application is realized as follows:
The embodiment of the application provides a task scheduling method, which comprises the following steps: when the state of the control node changes, the control node determines a task set to be executed corresponding to the changed state; sequencing the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed to obtain a task sequence to be executed; and sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed so as to realize the scheduling of the task to be executed.
The embodiment of the application provides a task scheduling method, which comprises the following steps: the distributed node receives tasks to be executed which are sequentially sent by the control node according to a task sequence to be executed, wherein the task sequence to be executed is obtained by the control node sequencing the tasks to be executed according to the task starting time of each task to be executed in a task set to be executed corresponding to the changed state when the state of the control node is changed; and executing the task to be executed.
An embodiment of the present application provides a task scheduling device, including: the determining module is used for determining a task set to be executed corresponding to the changed state when the state of the control node changes; the sequencing module is used for sequencing the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed to obtain a task sequence to be executed; and the distribution module is used for sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed so as to realize the scheduling of the task to be executed.
An embodiment of the present application provides a task scheduling device, including: the system comprises a receiving module, a processing module and a processing module, wherein the receiving module is used for receiving tasks to be executed which are sequentially sent by a control node according to a task sequence to be executed, and the task sequence to be executed is obtained by the control node by sequencing the tasks to be executed according to the task starting time of each task to be executed in a task set to be executed corresponding to the changed state when the state of the control node is changed; and the execution module is used for executing the task to be executed.
An embodiment of the present application provides a task scheduling device, including: a memory for storing executable instructions; a processor for implementing the above-described method when executing the executable instructions stored in the memory. The embodiment of the application provides a storage medium, which stores executable instructions for causing a processor to implement the method when executing.
The embodiment of the application has the following beneficial effects: when the state of the control node changes, the control node determines a task set to be executed corresponding to the changed state; and sequencing the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed to obtain a task sequence to be executed. Therefore, due to the fact that the tasks to be executed after the state change are sequenced, a task sequence to be executed with a certain sequence can be formed, when the tasks are scheduled, the tasks to be executed can be distributed to the distributed nodes in sequence according to the task sequence to be executed, the context logic of task scheduling does not need to be maintained, and therefore the context maintenance efficiency of the task scheduling can be improved.
Drawings
FIG. 1A is a schematic diagram of an alternative architecture of a task scheduling system according to an embodiment of the present application;
Fig. 1B is an alternative structural diagram of the distributed system applied to the blockchain system according to the embodiment of the present application;
Fig. 1C is an alternative schematic diagram of a block structure provided in the present application;
Fig. 2 is a schematic structural diagram of a terminal provided in an embodiment of the present application;
fig. 3 is an alternative flowchart of a task scheduling method according to an embodiment of the present application;
Fig. 4A is an alternative flowchart of a task scheduling method according to an embodiment of the present application;
Fig. 4B is an alternative flowchart of a task scheduling method according to an embodiment of the present application;
FIG. 5 is an alternative flowchart of a task scheduling method according to an embodiment of the present disclosure;
Fig. 6A is an alternative flowchart of a task scheduling method according to an embodiment of the present application;
fig. 6B is an alternative flowchart illustrating a task scheduling method according to an embodiment of the present application
FIG. 7 is an alternative flowchart of a task scheduling method according to an embodiment of the present disclosure;
FIG. 8A is an alternative schematic diagram of an interaction between a trigger and a receiver provided in the embodiments of the present application;
FIG. 8B is an alternative schematic diagram of an interaction between a trigger and a receiver according to an embodiment of the present disclosure
Fig. 9 is a schematic structural diagram of a control node according to an embodiment of the present application;
FIG. 10 is a flowchart illustrating scheduling of tasks in chronological order according to an embodiment of the present application;
FIG. 11 is a schematic diagram illustrating an implementation process of role extension according to an embodiment of the present application;
Fig. 12 is a schematic diagram of an implementation process of parallel expansion according to an embodiment of the present application.
Detailed Description
In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described in further detail with reference to the attached drawings, the described embodiments should not be considered as limiting the present application, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the embodiments of the present application belong. The terminology used in the embodiments of the present application is for the purpose of describing the embodiments of the present application only and is not intended to be limiting of the present application.
Before further detailed description of the embodiments of the present application, terms and expressions referred to in the embodiments of the present application will be described, and the terms and expressions referred to in the embodiments of the present application will be used for the following explanation.
1) the control node: the method is a process located on a terminal device, wherein a control node is a central node of a service process, and the control node is unique when the current service process is realized. The control node may send the task to be performed to the distributed nodes in a broadcast manner, for example, the control node may send the task to the distributed nodes through a trigger in the control node.
2) Distributed node: compared with the control node, the method is a process of crossing services and Internet Protocol addresses (IP) and physical machines. The number of distributed nodes is not unique, there may be a plurality of distributed nodes, and the function of each distributed node is asymmetric. Each distributed node is provided with a receiver and used for receiving tasks sent by the control node, and the distributed nodes comprise instruction lists corresponding to the tasks. After any distributed node receives the task broadcasted by the control node, the corresponding operation instruction is searched in the instruction list, and the operation instruction is executed, so that the execution of the task sent by the control node is completed.
3) a trigger: and the control node is positioned on the control node and forms the control node together with the task list. The trigger is used for sending broadcast signals to receivers in the distributed nodes to realize the broadcast task to the distributed nodes.
4) A receiver: and the distributed nodes are positioned on the distributed nodes and form the distributed nodes together with the instruction list. The receiver is used for receiving the broadcast signal sent by the trigger and searching the corresponding operation instruction in the instruction list.
In order to better understand the task scheduling method provided in the embodiment of the present application, first, a task scheduling method in the related art is explained.
In the related art, when task scheduling is performed, a two-dimensional matrix state table, such as table 1 below, is usually set, in which current states (e.g., s0 state, s1 state, and s2 state) are recorded on horizontal rows; recording events that trigger a change in state (e.g., e0 events, e1 events, and e2 events) in a religious column; "- -" indicates null (no action, no state transition); "an/sn" means that the action an is performed while the state jumps to sn.
the state-hopping process shown in table 1 may be: in the s0 state, if the e0 event happens, the a0 action is executed, the state is kept unchanged, and the s0 state is maintained; if an e1 event occurs, then the a1 action is performed and the state is jumped to the s1 state; if an e2 event occurs, then the a2 action is performed and the state is transitioned to the s2 state. At the s1 state, if an e2 event occurs, then the a2 action is performed and the state jumps to the s2 state; in the s2 state, if an e0 event occurs, then the a0 action is performed and the state jumps to the s0 state.
TABLE 1 two-dimensional matrix State Table
In the related art, the validity of jump among state machines can be identified through the two-dimensional matrix state table, so that recursive jump among states is realized, and a task of each state is executed. Under the condition of limited state, the jump can be realized quickly and effectively. When entering a state, a series of tasks corresponding to the state are executed once. The related technology has the characteristics of flexible state jump and capability of carrying out unordered scheduling on tasks in time.
However, in the state jump process based on the two-dimensional matrix state table in the related art, the context of each state needs to be maintained, i.e., the history state before the current state needs to be explicitly jumped to, the event occurred when the current state is jumped to, and the action performed when the current state is jumped to. Obviously, the relationship between each state is deterministic and also non-modifiable. Then, when a state change occurs, for example, when a state is added or deleted, it is necessary to specify the relationship between the added or deleted state and the other states, that is, to specify the context logic between the added or deleted state and the other states. That is, for the changed states, reconstruction is required to ensure the legitimacy of mutual jumping between all other states and the other remaining states after the new state or the deleted state, obviously, the cost for maintaining the context logic between the states and the legitimacy of the jumping between the states in the related art is extremely high, and the efficiency in maintenance is low because reconstruction between the states is required.
based on at least one of the above problems in the related art, embodiments of the present application provide a method, an apparatus, a device, and a storage medium for task scheduling, which can improve the context maintenance efficiency of task scheduling and reduce the maintenance cost.
An exemplary application of the task scheduling apparatus provided by the embodiments of the present application is described below, and the apparatus provided by the embodiments of the present application may be implemented as various types of user terminals such as a notebook computer, a tablet computer, a desktop computer, a mobile device (e.g., a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, and a portable game device). In the following, an exemplary application will be explained when the device is implemented as a terminal.
referring to fig. 1A, fig. 1A is an alternative architecture diagram of a task scheduling system 10 provided in this embodiment of the present application, in order to implement scheduling between a control node and a distributed node, a terminal 100 (an example of which shows a terminal 100-1 and a terminal 100-2) is connected to a server 300 through a network 200, where the network 200 may be a wide area network or a local area network, or a combination of the two.
The terminal 100 displays a current interface of an Application (APP) on a task presentation page 110 (a task presentation page 110-1 and a task presentation page 110-2 are exemplarily shown), for example, the APP may be a game APP. The process of the control node 120 is run in the terminal 100-1, and the function of the control node in the present application can be implemented, and the process of the distributed node 130 is run in the terminal 100-2, and the function of the distributed node in the present application can be implemented. Of course, the control node and the distributed node may also operate on the same terminal, or a plurality of distributed nodes may operate on the same terminal. When the state of the control node 120 on the terminal 100-1 changes, the control node 120 acquires a task to be executed from the server 300 through the network 200, and determines a task set to be executed corresponding to the changed state; then, sequencing the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed to obtain a task sequence to be executed; and finally, sequentially distributing each task to be executed to the distributed nodes 130 on the terminal 100-2 through the network 200 according to the task sequence to be executed, so as to realize the scheduling of the task to be executed to the distributed nodes 130 on the terminal 100-2. When the distributed node 130 completes the task, an acknowledge completion signal is returned to the control node 120 via the network 200.
The task scheduling system 10 related to the embodiment of the present application may also be a distributed system formed by connecting a client (e.g., a client of a game APP), a plurality of nodes (any form of computing devices in an access network, such as a server and a user terminal) through a network communication form.
here, taking a distributed system as an example of a blockchain system, referring To fig. 1B, fig. 1B is an optional structural schematic diagram of a distributed system 101 applied To a blockchain system provided in this embodiment of the present application, and is formed by a plurality of nodes 102 (computing devices in any form in an access network, such as servers and user terminals) and clients 103, a Peer-To-Peer (P2P) network is formed between the nodes, and a P2P Protocol is an application layer Protocol operating on a Transmission Control Protocol (TCP). In a distributed system, any machine, such as a server or a terminal, can join to become a node, and the node comprises a hardware layer, a middle layer, an operating system layer and an application layer.
referring to the functions of each node in the blockchain system shown in fig. 1B, the functions involved include:
1) routing, a basic function that a node has, is used to support communication between nodes.
Besides the routing function, the node may also have the following functions:
2) The application is used for being deployed in a block chain, realizing specific services according to actual service requirements, recording data related to the realization functions to form recording data, carrying a digital signature in the recording data to represent a source of task data, and sending the recording data to other nodes in the block chain system, so that the other nodes add the recording data to a temporary block when the source and integrity of the recording data are verified successfully.
For example, the services implemented by the application include:
2.1) wallet, for providing the function of transaction of electronic money, including initiating transaction (i.e. sending the transaction record of current transaction to other nodes in the blockchain system, after the other nodes are successfully verified, storing the record data of transaction in the temporary blocks of the blockchain as the response of confirming the transaction is valid; of course, the wallet also supports the querying of the electronic money remaining in the electronic money address.
And 2.2) sharing the account book, wherein the shared account book is used for providing functions of operations such as storage, query and modification of account data, record data of the operations on the account data are sent to other nodes in the block chain system, and after the other nodes verify the validity, the record data are stored in a temporary block as a response for acknowledging that the account data are valid, and confirmation can be sent to the node initiating the operations.
2.3) Intelligent contracts, computerized agreements, which can enforce the terms of a contract, implemented by codes deployed on a shared ledger for execution when certain conditions are met, for completing automated transactions according to actual business requirement codes, such as querying the logistics status of goods purchased by a buyer, transferring the buyer's electronic money to the merchant's address after the buyer signs for the goods; of course, smart contracts are not limited to executing contracts for trading, but may also execute contracts that process received information.
3) And the Block chain comprises a series of blocks (blocks) which are mutually connected according to the generated chronological order, new blocks cannot be removed once being added into the Block chain, and recorded data submitted by nodes in the Block chain system are recorded in the blocks.
4) Consensus (Consensus), a process in a blockchain network, is used to agree on transactions in a block among a plurality of nodes involved, the agreed block is to be appended to the end of the blockchain, and the mechanisms for achieving Consensus include Proof of workload (Proof of Work, PoW), Proof of rights of interest (Proof of stamp, PoS), Proof of grant of shares (released Proof-of-stamp, DPoS), Proof of Elapsed amount of Time (Proof of Elapsed Time, PoET), and so on.
Referring to fig. 1C, fig. 1C is an optional schematic diagram of a Block Structure (Block Structure) provided in this embodiment, where each Block includes a hash value of a transaction record (hash value of the Block) stored in the Block and a hash value of a previous Block, and the blocks are connected by the hash values to form a Block chain. The block may include information such as a time stamp at the time of block generation. A block chain (Blockchain), which is essentially a decentralized database, is a string of data blocks associated by using cryptography, and each data block contains related information for verifying the validity (anti-counterfeiting) of the information and generating a next block.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a terminal 100 according to an embodiment of the present application, where the terminal 100 shown in fig. 2 includes: at least one processor 210, memory 250, at least one network interface 220, and a user interface 230. The various components in terminal 100 are coupled together by a bus system 240. It is understood that the bus system 240 is used to enable communications among the components. The bus system 240 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as bus system 240 in fig. 2.
the Processor 210 may be an integrated circuit chip having Signal processing capabilities, such as a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like, wherein the general purpose Processor may be a microprocessor or any conventional Processor, or the like.
The user interface 230 includes one or more output devices 231, including one or more speakers and/or one or more visual display screens, that enable the presentation of media content. The user interface 230 also includes one or more input devices 232, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
The memory 250 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, and the like. Memory 250 optionally includes one or more storage devices physically located remotely from processor 210. The memory 250 includes volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read Only Memory (ROM), and the volatile Memory may be a Random Access Memory (RAM). The memory 250 described in embodiments herein is intended to comprise any suitable type of memory. In some embodiments, memory 250 is capable of storing data, examples of which include programs, modules, and data structures, or a subset or superset thereof, to support various operations, as exemplified below.
An operating system 251 including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
a network communication module 252 for communicating to other computing devices via one or more (wired or wireless) network interfaces 220, exemplary network interfaces 220 including: bluetooth, wireless compatibility authentication (WiFi), and Universal Serial Bus (USB), etc.;
an input processing module 253 for detecting one or more user inputs or interactions from one of the one or more input devices 232 and translating the detected inputs or interactions.
In some embodiments, the apparatus provided by the embodiments of the present application may be implemented in software, and fig. 2 shows a task scheduling device 254 stored in the memory 250, where the task scheduling device 254 may be a task scheduling device in the terminal 100-1 including the control node, and may be software in the form of programs and plug-ins, and includes the following software modules: a determination module 2541, a ranking module 2542 and a distribution module 2543, which are logical and therefore can be arbitrarily combined or further split depending on the functionality implemented. The functions of the respective modules will be explained below.
Of course, in other embodiments, the task scheduling device may also be a task scheduling device (not shown in the figure) in the terminal 100-2 including the distributed node, and it may also be software in the form of programs and plug-ins, etc., including the following software modules: the device comprises a receiving module and an executing module.
In other embodiments, the apparatus provided in this embodiment may be implemented in hardware, and for example, the apparatus provided in this embodiment may be a processor in the form of a hardware decoding processor, which is programmed to execute the task scheduling method provided in this embodiment, for example, the processor in the form of the hardware decoding processor may be one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field-Programmable Gate arrays (FPGAs), or other electronic components.
The task scheduling method provided by the embodiment of the present application will be described below with reference to an exemplary application and implementation of the terminal provided by the embodiment of the present application.
Referring to fig. 3, fig. 3 is an alternative flowchart of a task scheduling method provided in an embodiment of the present application, and will be described with reference to the steps shown in fig. 3.
Step S301, when the state of the control node changes, the control node determines a task set to be executed corresponding to the changed state.
Here, the control node may be one node in a blockchain system. Before the state of the control node changes, the control node is in a history state, and when the control node is in the history state, at least one history task to be executed is correspondingly arranged. When the state of the control node changes, the state of the control node changes from a historical state to a current state, the current state corresponds to at least one task to be executed, and the at least one task to be executed may include all the historical tasks to be executed, may also include part of the historical tasks to be executed, and may not include the historical tasks to be executed.
in the embodiment of the present application, the at least one task to be executed forms the task set to be executed.
Step S302, according to the task starting time of each task to be executed in the task set to be executed, the tasks to be executed are sequenced to obtain a task sequence to be executed.
Here, each task to be executed has attribute information, which may include at least one of: the method comprises the steps of starting a task to be executed, ending the task, identifying a task (Identification, ID), triggering a time period, repeatedly executing intervals, whether the task is blocked, executing duration and the like.
The task starting time refers to that when the current time reaches the task starting time, the task is sent to the distributed nodes through the trigger of the control node so as to implement the execution of the task; the task ending time refers to that when the current time exceeds the task ending time, the task is marked to be completed, and the task is not scheduled to the distributed node; the triggering time period is a time period with the starting time as the task starting time and the ending time as the task ending time; the repeated execution interval refers to that when the currently executed task is a blocking task, for the non-executed blocking task, the distributed nodes are repeatedly triggered to execute the non-executed blocking task according to the repeated execution interval within the trigger time period until the task is executed; whether the task is blocked or not is judged to be a blocked task or a non-blocked task; the execution time duration refers to the time duration between the time when the task is sent to the distributed node and the time when the distributed node returns an execution completion signal.
In the embodiment of the application, all tasks to be executed in a task set to be executed are sequenced according to the time sequence of the task starting time of each task to be executed to form the task sequence to be executed, the tasks to be executed are sequenced according to the sequence of the task starting time in the task sequence to be executed, and the task to be executed which is earlier than the task starting time is positioned at the top of the task sequence to be executed.
According to the task sequence to be executed formed after sequencing, only the task starting time of the task to be executed is concerned, and other context information such as the trigger event jumping to the state corresponding to the current task and the action executed when jumping to the state corresponding to the current task is not concerned any more, so that less content needs to be maintained in the task sequence to be executed.
In some embodiments, the to-be-executed tasks and attribute information for each to-be-executed task may both be stored in the blockchain.
Step S303, sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed, so as to implement scheduling of the task to be executed.
After the task sequence to be executed is determined, according to the arrangement sequence of all tasks to be executed in the task sequence to be executed, the tasks to be executed are sequentially sent to the distributed nodes from the task to be executed whose task starting time is closest to the current time.
It should be noted that the distributed node may also be a node in the blockchain system. The distributed nodes may be one or more, when there is one distributed node, the control node sends the task to be executed to the determined one distributed node, and when there are multiple distributed nodes, the control node sends the task to be executed to multiple distributed nodes at the same time, for example, the control node may broadcast the task to be executed to multiple distributed nodes in a broadcast manner.
In this embodiment of the present application, the trigger in the control node may broadcast the to-be-executed task to the distributed node, and the receiver in the distributed node receives the to-be-executed task broadcast by the control node.
It should be noted that, after the receiver of the distributed node receives the task to be executed, the receiver analyzes the task to be executed, matches an operation instruction corresponding to the task to be executed in an instruction list of the distributed node, and executes the operation instruction. That is to say, in the embodiment of the present application, the step of executing the task to be executed by the distributed node may be executing an operation instruction corresponding to the task to be executed.
In the embodiment of the application, the control node sequentially sends the tasks to be executed in the task sequence to be executed to the distributed nodes, so that the tasks to be executed are dispatched to the distributed nodes.
according to the task scheduling method provided by the embodiment of the application, when the state of the control node changes, the control node determines a task set to be executed corresponding to the changed state; and sequencing the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed to obtain a task sequence to be executed, and then performing task scheduling according to the task sequence to be executed. Therefore, due to the fact that the tasks to be executed after the state change are sequenced, the task sequence to be executed which is sequenced according to the task starting time can be formed, when the tasks are scheduled, the tasks to be executed can be sequentially distributed to the distributed nodes according to the task sequence to be executed, the context logic of task scheduling does not need to be maintained, and therefore the context maintenance efficiency of the task scheduling can be improved.
In some embodiments, the state change of the control node may be adding a new state or states to the control node, and then, referring to fig. 4A, fig. 4A is an optional flowchart of a task scheduling method provided in this embodiment, and fig. 4A shows that step S301 in fig. 3 may be implemented by the following steps:
Step S401, when the control node adds a new state, the control node determines a task to be executed corresponding to the new state.
Step S402, forming the task set to be executed through the task to be executed corresponding to the new state and the historical task to be executed before the new state is added.
in the embodiment of the application, when a new state is added, the task to be executed corresponding to the new state is determined, and any set to be executed is determined according to the task to be executed corresponding to the new state and the historical task to be executed, that is, the new task to be executed corresponding to the new state is added to the historical task set to be executed.
For example, the states of the control node include a state a, a state B, and a state C, where the tasks to be executed corresponding to the state a include tasks a1 and a2, the tasks to be executed corresponding to the state B include tasks B1 and B2, and the tasks to be executed corresponding to the state C include tasks C1 and C2. Now, a state D is newly added to the control node, and the to-be-executed tasks corresponding to the state D include tasks D1 and D2, then the historical to-be-executed tasks are tasks a1, a2, B1, B2, C1, and C2, and the new to-be-executed tasks are tasks D1 and D2, so that the formed to-be-executed task set includes tasks a1, a2, B1, B2, C1, C2, D1, and D2.
In some embodiments, the state change of the control node may be to delete one or more states for the control node, then referring to fig. 4B, fig. 4B is an optional flowchart of a task scheduling method provided in this embodiment, and fig. 4B shows that step S301 in fig. 3 may also be implemented by the following steps: step S411, when the control node deletes the state, the control node determines the remaining tasks to be executed corresponding to the state remaining after the state is deleted. Step S412, forming the task set to be executed by the remaining tasks to be executed.
In the embodiment of the application, when the state is deleted, the remaining tasks to be executed corresponding to the state remaining after the state is deleted are determined, any set to be executed is determined according to the remaining tasks to be executed, that is, the tasks to be executed corresponding to the deleted state are deleted, and the remaining tasks to be executed corresponding to the remaining state are reserved.
For example, the states of the control node include a state a, a state B, and a state C, where the tasks to be executed corresponding to the state a include tasks a1 and a2, the tasks to be executed corresponding to the state B include tasks B1 and B2, and the tasks to be executed corresponding to the state C include tasks C1 and C2. Now, the state C is deleted from the control node, and then, the remaining states include states a and B, and the remaining tasks to be executed include tasks a1, a2, B1, and B2, and thus, the formed set of tasks to be executed includes tasks a1, a2, B1, and B2.
In some embodiments, the change of the state of the control node may be updating the state of the control node, where updating refers to updating any state of the control node to another state.
for example, the states of the control node include a state a, a state B, and a state C, where the tasks to be executed corresponding to the state a include tasks a1 and a2, the tasks to be executed corresponding to the state B include tasks B1 and B2, and the tasks to be executed corresponding to the state C include tasks C1 and C2. Now, the state of the control node is updated, the state C is updated to the state D, and the task to be executed corresponding to the state D includes tasks D1 and D2, then the current state of the control node includes states A, B and D, and the formed task set to be executed includes tasks a1, a2, B1, B2, D1, and D2.
in some embodiments, referring to fig. 5, fig. 5 is an optional flowchart of a task scheduling method provided in an embodiment of the present application, and fig. 5 shows that step S303 in fig. 3 may be implemented by the following steps:
Step S501, determining a trigger time period of each task to be executed in the task sequence to be executed. Here, the starting time of the trigger time period is a task starting time of the task to be executed, and the ending time of the trigger time period is a task ending time of the task to be executed. And in the trigger time period, the task to be executed can be sent to the distributed nodes.
Step S502, determining the task to be executed in the trigger time period including the current moment as the target task to be executed.
Here, the trigger time period includes the task to be executed at the current time, which means that the current time is within the trigger time period of the task to be executed, for example, the trigger time period of a certain task to be executed K0 is 8:00 to 9:00, and the current time is 8:30, so that the task to be executed K0 can be determined as the target task to be executed. In some embodiments, the target to-be-performed task may also be stored in the blockchain.
in some embodiments, step S502 may also be implemented by:
step S5021, determining the task to be executed, which is not executed by any distributed node and includes the current time in the trigger time period, as the target task to be executed.
Here, when determining the target to-be-executed task, the to-be-executed tasks that are not executed by the distributed nodes in the to-be-executed task sequence may be determined first, and then the target to-be-executed task is determined among the non-executed to-be-executed tasks.
Step S503, sequentially distributing the target task to be executed and other tasks to be executed after the target task to be executed in the task sequence to at least one distributed node, so as to implement scheduling of the task to be executed to each distributed node.
Here, after determining the target task to be executed, the target task to be executed is a task to be executed which is currently to be sent to the distributed nodes, and other tasks to be executed after the target task to be executed are also to be sent to the distributed nodes in sequence, so that the target task to be executed and other tasks to be executed which are located after the target task to be executed in the task sequence to be executed are distributed to at least one distributed node in sequence.
According to the task scheduling method provided by the embodiment of the application, the task to be executed, which contains the current time and is not executed by any distributed node, is determined as the target task to be executed, and the target task to be executed and other tasks to be executed after the target task to be executed are sequentially sent to the distributed nodes. Therefore, the tasks to be executed sent to the distributed nodes are all effective tasks, the tasks to be executed are sent in order, and overtime tasks or overdue tasks are prevented from being sent to the distributed nodes.
In some embodiments, the task to be performed comprises a blocking task; the blocked task means that all tasks subsequent to the blocked task cannot be executed without completing the blocked task. Referring to fig. 6A, fig. 6A is an optional flowchart of a task scheduling method provided in an embodiment of the present application, and fig. 6A shows that step S303 in fig. 3 may be implemented by the following steps:
step S601, when the task to be executed sent to the at least one distributed node is the blocking task, waiting to receive an execution completion signal corresponding to the blocking task returned by each distributed node.
Here, when the distributed node finishes executing the task to be executed, the distributed node returns the execution completion signal to inform the control node of completing the task to be executed.
Step S602, after receiving the execution completion signal returned by each distributed node, sequentially distributing the to-be-executed task after the blocking task in the to-be-executed task sequence to the at least one distributed node.
Here, when receiving an execution completion signal returned by each distributed node, it indicates that the blocking task broadcast by the control node has been executed and completed by all distributed nodes, so that a next task to be executed may be sent, and if the next task to be executed is also a blocking task, the next task to be executed may be sent after the distributed node returns an execution completion signal corresponding to the next task to be executed; if the next task to be executed is not the blocking task, the distributed node does not need to wait for the execution completion signal corresponding to the next task to be executed to return, and the next task to be executed can be sent to the task to be executed as long as the task starting time of the next task to be executed is reached.
Step S603, when an execution completion signal corresponding to the blocking task returned by any distributed node is not received after a preset time period elapses, sending the blocking task to the at least one distributed node again.
here, in order to avoid that the blocking task is not executed effectively, after a preset time period, if the execution completion signal is not received, it indicates that the blocking task may not be normally received by the distributed node, or the blocking task is not normally executed by the distributed node, and therefore, the blocking task is sent to the distributed node again to ensure that the blocking task can be executed effectively.
According to the task scheduling method provided by the embodiment of the application, for the blocking task, only after the blocking task is executed, the subsequent task to be executed can be sent and executed, and under the condition that the blocking task is not completed, all the tasks subsequent to the blocking task cannot be executed, so that the key task can be accurately and effectively executed and completed, and the key task is prevented from being omitted or not normally executed.
In some embodiments, the task to be performed comprises a non-blocking task; the non-blocking task refers to the execution of all tasks subsequent to the non-blocking task, and does not depend on the state of the non-blocking task. Referring to fig. 6B, fig. 6B is an optional flowchart schematic diagram of a task scheduling method provided in an embodiment of the present application, and fig. 6B illustrates a step of sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed in step S303 in fig. 3, which may be implemented by the following steps:
Step S611, when the task to be executed sent to the at least one distributed node is the non-blocking task, sending the non-blocking task to the at least one distributed node at the task start time of each non-blocking task.
In the embodiment of the application, if the task to be executed is a non-blocking task, it is not necessary to wait for the task to be executed completely, that is, it is not necessary to wait for the control node to receive the execution completion signal, and as long as the task start time of the next task to be executed comes, the next task to be executed is normally sent to the distributed node, so that the non-blocking task can be timely sent to the distributed node.
Referring to fig. 7, fig. 7 is an alternative flowchart of a task scheduling method provided in an embodiment of the present application, and will be described with reference to the steps shown in fig. 7.
Step S701, when the state of the control node changes, the control node determines a set of tasks to be executed corresponding to the changed state.
step S702, the tasks to be executed are sequenced according to the task starting time of each task to be executed in the task set to be executed, and a task sequence to be executed is obtained.
Step S703, sequentially distributing each task to be executed to a distributed node according to the task sequence to be executed, so as to implement scheduling of the task to be executed to the distributed node. Steps S701 to S703 are the same as steps S301 to S303, and the embodiment of the present application is not repeated.
Step S704, the distributed node determines at least one operation instruction corresponding to the task to be executed in a preset operation instruction library according to the identifier of the task to be executed.
Here, after the distributed node receives the task to be executed sent by the control node, the task to be executed is executed. The task to be executed corresponds to at least one operation instruction, and the operation instruction is used for indicating an operation action required to be executed by the distributed node. In some embodiments, the identifier of the task to be executed and the operation instruction corresponding to the task to be executed may also be stored in the block chain.
In the embodiment of the present application, the distributed node includes a receiver for receiving the task to be executed and a preset operation instruction library (i.e., an instruction list), where the preset operation instruction library includes at least one operation instruction. When the distributed node receives the identifier of the task to be executed, the task to be executed is analyzed, the identifier of the task to be executed is determined, the operating instruction corresponding to the identifier is searched in the preset operating instruction library of the distributed node according to the identifier, and the searched operating instruction is the operating instruction corresponding to the task to be executed.
Step S705, the distributed node executes the at least one operation instruction corresponding to the task to be executed.
Here, after the operation instruction corresponding to the task to be executed is found, the distributed node executes the at least one operation instruction.
Step S706, when each operation instruction corresponding to the task to be executed is executed, the distributed node returns an execution completion signal of the corresponding operation instruction to the control node.
Here, after completing one operation instruction per execution, an execution completion signal of the operation instruction is returned to the control node. For example, when the distributed node finds that the operation instructions corresponding to the currently received task E are E1 and E2, the distributed node first executes the operation instruction E1, and after the operation instruction E1 is executed, returns an E1 execution completion signal to the control node; the operation command E2 is executed again, and after the operation command E2 is executed, an E2 execution completion signal is returned to the control node.
It should be noted that, since the control node may broadcast the task to be executed to the plurality of distributed nodes, each distributed node executes steps S704 to S706 after receiving the task to be executed.
In some embodiments, the task to be performed comprises a blocking task; correspondingly, the method further comprises:
Step S710, when the task to be executed received by the distributed node is the blocking task, execute the blocking task, and return an execution completion signal to the control node.
Here, when the distributed node finishes executing the task to be executed, the distributed node returns the execution completion signal to inform the control node of completing the task to be executed.
Step S711, after returning the execution completion signal, receives the to-be-executed task after the blocking task in the to-be-executed task sequence sent by the control node.
here, since the task to be executed is a blocking task, only after the blocking task is executed, the control node continues to send the next task to be executed to the distributed node, and therefore, when the distributed node returns an execution completion signal of the blocking task, the task to be executed after the blocking task in the task sequence to be executed, which is sent by the control node, can be received.
In some embodiments, the task to be performed comprises a non-blocking task; correspondingly, the method further comprises:
Step S712, when the task to be executed received by the distributed node is the non-blocking task, receiving and executing the non-blocking task at the task start time of each non-blocking task.
In the embodiment of the application, when the task to be executed is a non-blocking task, it is not necessary to wait for the task to be executed completely, that is, it is not necessary to wait for the distributed node to send an execution completion signal, and as long as the start time of the task of the next task to be executed comes, the distributed node normally receives the next task to be executed sent by the control node, so as to ensure that the non-blocking task can be received in time.
Next, an exemplary application of the embodiment of the present application in a practical application scenario will be described.
The task scheduling method described in the embodiment of the present application serializes tasks to be executed in all states, schedules the tasks according to a time sequence, and sets each task as a blocking task or a non-blocking task. The execution of each task is time dependent, and it is detected whether the blocking task of the previous step has been completed. If the blocking task is not completed, the last blocking task is repeatedly scheduled at a set interval until the last blocking task is completed, or the blocking task is released only when the last blocking task is overtime.
The task scheduling method of the embodiment of the application has the characteristics of stable and reliable state, fault tolerance of task execution and order in time. For the addition and deletion of the tasks, only the context of the current task needs to be maintained, and the context relation among all the tasks does not need to be maintained.
In the embodiment of the application, a distributed scheduling mode is adopted, the trigger and the receiver are used as middleware, the trigger is called by the global control node for the task and is transmitted to the receiver of the distributed node through the network, and the receiver receives the task instruction and executes the respective task.
the task scheduling method in the embodiment of the application can be used in at least the following internet scenes based on the design requirement of fixed time:
The first method comprises the following steps: dynamic creation of network game copies. Most of the servers of the current online games are distributed deployment schemes, and a series of state change requirements can be involved in the copy activity process, and the method of the embodiment of the application can realize the following processes: data migration and rollback of roles; role Control Protocol (TCP) connection migration and rollback; switching the distributed service state; and dynamically calculating and creating the number of the replica servers.
and the second method comprises the following steps: dynamic creation of large internet marketing campaigns. For online relay activities, such as torch delivery, marketing activities generate fire according to user behaviors, delivery is carried out in a specific time, and marketing rewards are generated when specific time nodes are reached.
And the third is that: distributed computing. In a partial scene of the internet, a large amount of computing needs may be met, and distributed computing needs to consume more computing elements, such as a Central Processing Unit (CPU), a server, and other computing elements, compared to single-core computing or single-server computing.
Fig. 8A is an alternative interaction diagram of a trigger and a receiver provided in the embodiment of the present application, and as shown in fig. 8A, the trigger 81 and the receiver 82 are a pair of cooperative components, the trigger 81 sends a task signal 811 containing a task to be executed to the receiver 82, and after the receiver 82 receives the signal, the receiver sends an acknowledgement signal 821 in reverse direction to the trigger 81 to indicate that the task signal 811 has been received.
Fig. 8B is an alternative interaction diagram of a trigger and a receiver provided in this embodiment of the present application, as shown in fig. 8B, a task and an instruction are objects of a working service of the trigger 81, when a certain task is executed, a service process in which the trigger is located sends a specified signal to the trigger 81, the trigger 81 notifies all receivers 82 in a broadcast manner, and executes an instruction corresponding to the task, such as a broadcast signal 813 in fig. 8B. The task may be any task in the task list 812, and as shown in fig. 8B, the task list 812 includes task 1 and task 2 … …, i.e., task N.
After receiving the instruction, the receiver 82 finds an instruction corresponding to the task in the operation instruction list 822 (corresponding to the preset operation instruction library) and executes the instruction, as shown in fig. 8B, where the operation instruction list 822 includes instruction 1 and instruction 2 … …, i.e., instruction N. After completion of execution, an acknowledgement completion signal 823 is sent by the receiver 82 back to the trigger 81 indicating that the task has been completed.
Fig. 9 is a schematic structural diagram of a control node according to an embodiment of the present application, and as shown in fig. 9, the control node 90 includes the aforementioned trigger 81 and the task list 812.
The control node 90 is a central node for task scheduling, and the main working principle includes the following aspects:
In a first aspect: a task list is maintained.
Here, the main maintenance contents are: task ID, task name, task start time, task end time, task execution time, whether it is a blocking task and the interval of repeated execution of the task.
here, the task start time refers to the time when the current time reaches the task start time, and the task is executed through the trigger; the task ending time means that when the current time exceeds the task ending time, the task is marked to be completed, and the task is not triggered to be executed any more; the task execution time means that the task execution time is recorded when the receiver reversely sends the task execution completion, and the task completion is represented.
Whether the task is a blocking task, wherein the blocking task must be executed, and the non-executed blocking task is repeatedly executed according to the execution interval within the executable time period until the task is executed completely or the end time is exceeded. And, during the executable time period, all subsequent tasks are not executed. The non-blocking task is repeatedly executed at execution intervals within an executable time period, execution time is not recorded, and subsequent tasks can be executed.
In a second aspect: and scheduling the tasks according to the time sequence. The task scheduling of the control node is to traverse the task list once at a fixed clock period (e.g., 5 seconds), starting with the first task node in the list, and each task node performs the logical processing as shown in fig. 10.
As shown in fig. 10, for each task node, the following logical processing steps are performed:
step S1001, traversing the task from the current task to the end position of the task list.
Step S1002, determine whether the current task is a blocking task. If the judgment result is yes, executing step S1003; if the judgment result is no, step S1007 is executed.
In step S1003, it is determined whether the current task has been executed and completed. If the judgment result is yes, returning to execute the step S1001; if the judgment result is no, step S1004 is executed.
Step S1004, determining whether the current time is within the triggerable time period of the current task.
If the judgment result is yes, executing step S1005; and if the judgment result is negative, ending the traversal.
step S1005, the current task is triggered.
in step S1006, it is determined whether the triggered task is a blocking task. If the judgment result is yes, the traversal is finished; if the judgment result is no, the step S1001 is executed again.
Step S1007, determining whether the current time is within the triggerable time period of the current task. If the judgment result is yes, executing step S1008; if the judgment result is no, the step S1001 is executed again.
In step S1008, it is determined whether the trigger interval is exceeded. If the judgment result is yes, executing step S1005; if the judgment result is no, the step S1001 is executed again.
in a third aspect: blocked tasks and trial and error.
For the blocking task, after triggering once, if the trigger does not receive the reverse acknowledgement completion signal of the receiver, when the next trigger time arrives, the trigger will trigger for the second time, and so on until receiving the reverse acknowledgement completion signal to indicate that the task is completed.
In the embodiment of the application, the distributed node is an actual executor of the task, and comprises a receiver and an operation instruction list, wherein the operation instruction list takes the signal ID of the task signal as an index.
The working principle of the distributed node comprises the following steps: acquiring the signal ID through a receiver; executing a corresponding operation instruction according to the signal ID; after execution is complete, the call receiver notifies the instruction execution completion back.
In the embodiment of the application, the distributed nodes support role expansion and parallel expansion.
the principle of role expansion is as follows: as shown in fig. 11, when the same task signal S1 is triggered from the control node 90, the task signal S1 is sent to each distributed node (e.g., distributed node A, B, C, where the receivers 82 corresponding to the distributed node A, B, C are receivers 82A, 82B, and 82C, respectively) of different roles in a broadcast manner, the receivers 82A, 82B, and 82C receive the task signal S1 at the same time, find a corresponding operation instruction according to the task signal S1 for execution, and after completion, the receivers send a message to the trigger 81 of the control node in the reverse direction. For example, the control node broadcasts a message "flag ceremony start", distributed node a is a whole elementary school of grade one, and the corresponding operation is "wear green scarf". The distributed node B is a pupil of more than three grades of the whole, and the corresponding operation is "wear red scarf". Distributed node C is a middle school student in the universe, and the corresponding operation is "standing".
while the above is an example of the application of the role-based extension, the following example will describe the application of the parallel extension, and the distributed node C is subdivided into "middle school, compound's attaching middle", and "build-up-middle school", and each middle school student receives the instruction and executes the operation of "singing national songs" at the same time. With continued reference to fig. 11, distributed nodes B and C may be two role extension nodes of distributed node a. Distributed node a represents a grade one pupil, B represents a grade three pupil, and C represents a college student, as exemplified above.
FIG. 12 is a diagram that simplifies the internal construction of a distributed node, depicting the logical structure of parallel expansion nodes. Wherein the distributed nodes A2 and A3 are parallel extension nodes of A1; distributed node B2, B3 are parallel expansion nodes of B1; the distributed nodes C2, C3 are parallel expansion nodes of C1. For example, C1 represents middle school student toward middle school, C2 represents middle school student in double-den appendix, and C3 represents middle school student in build-level middle school.
in the embodiment of the application, the process design of the task scheduling method includes the following contents: setting a task list; a time-ordered task scheduling method; distinguishing between blocking tasks and non-blocking tasks; and repeating the triggering.
When setting up the task list, the task list is written in chronological order, the start time must be arranged in ascending chronological order, and the repeat interval can be filled for non-blocking tasks. Here, the task list is exemplified by a flag-raising ceremony, and refer to the task list of table 2.
TABLE 2 task List
Task ID name(s) Starting time End time whether or not to block Repetition interval
1 Students enter playground 1 point 2 point whether or not 5 minutes
2 Flag-raising ceremony preparation 2 point 3 point Whether or not 5 minutes
3 Flag-raising ceremony 3 point 4 points Is that Is free of
4 Early exercise 3 point 4 points Is that Is free of
5 ending of flag-raising ceremony 3 point 4 points is that 5 minutes
In other embodiments, when setting the instruction list, the instruction list maintains the instruction operation corresponding to the task ID, such as the instruction list shown in table 3 below, and when receiving the task signal, the instruction list may execute the corresponding operation instruction according to the task ID.
TABLE 3 instruction List
In the embodiment of the application, the time-ordered task scheduling method is that tasks are executed according to the time sequence, and as shown in table 2, if the current time reaches the start time of task execution, a signal of the task starts to be triggered; and for the task which does not arrive at the current time, not executing the task. If the time slot configurations of a plurality of tasks coincide, it is necessary to determine whether execution is possible according to the blocking state of the tasks.
after the designated task is set to the blocking mode, all subsequent tasks cannot be executed without completing the task, for example, flag raising and early operation in table 2 are set to the blocking mode, which indicates that the two tasks are critical tasks and cannot be skipped, and if the task is not completed, all the following tasks cannot be executed. Non-blocking is the state that after a specified task is set to a non-blocking mode, all subsequent tasks are executed independently of the task. For example, the "flag-raising ceremony" task in table 2 is executed independently of the completion status of "student enters playground" and "flag-raising ceremony preparation".
The triggered task is repeatedly triggered and works in two conditions:
The first condition is as follows: in the case of a task set to "non-blocking mode", such as the task "students enter the playground" in table 2, the triggering may be repeated every 5 minutes, which ensures that all students can gradually enter the playground within a period of 1 hour until the current time reaches the end time.
Case two: in the case that the task is set to "block mode", for example, the task of "singing guogong" in table 2, once triggered, it takes 10 minutes to complete, then the control node does not receive the reverse signal of the receiver immediately when triggering the task, so that the task signal is triggered repeatedly at 5 minutes intervals until the command is completed, which indicates that the task is completed, and the "early operation" stage is entered.
In the following, an exemplary application of the embodiment of the present application in another practical application scenario will be described, and the method of the embodiment of the present application may also be applied to dynamically creating a game copy, since the main core of the game copy is the concept of having a scenario, for example, a character may go from a normal scenario of normal play to a smaller game copy scenario, and then a small part of people may be gathered in this scenario. Wherein the game transcript scene is isolated from the normal scene and is therefore referred to as a transcript.
The copy belongs to an extension of a resource on the architecture of a server (corresponding to the control node), and is an extension of a server resource, for example, an extension of a process or an extension of a memory may also be used. The main core of the copy is to isolate existing resources, and the copy needs to be created and scheduled across processes (i.e. multiple distributed nodes).
In addition, when the game copy is created, the life cycle of the copy also needs to be considered, the copy is created when needed, and the copy is recycled after being used up. For example, creating a game copy requires a new server (i.e., a distributed node) independent of a currently used server, deploying a new game process on the new server, and starting a certain shared memory, so that a game operation in a scene corresponding to the game copy can be implemented when a character enters the scene, and when the game is finished and the character returns to a normal scene, the process of the game copy is flushed or recycled by the shared memory.
it should be noted that the states of the copies are mutually exclusive, and the states between each copy are inconsistent. Therefore, when a game copy is dynamically created by using the method of the embodiment of the present application, when a game scene corresponding to a new copy is switched from a current copy, a state corresponding to the copy at this time changes, and thus, a plurality of to-be-executed game tasks (corresponding to the to-be-executed tasks) corresponding to the new copy are determined, for example, the to-be-executed game tasks may include: and selecting prop tasks, selecting equipment tasks, executing specific tasks, attacking and the like in the game copy. Then determining the starting time of each game task, and sequencing all game tasks to be executed according to the starting time of each game task to obtain a game task sequence (corresponding to the task sequence to be executed); and finally, distributing the game tasks to the distributed nodes in sequence according to the game task sequence, wherein the distributed nodes can be terminals running the game copies, namely the distributed nodes can be terminals used by users playing the game, and the game tasks are sent to the users playing the game, so that the users execute the game tasks through the terminals, and the game tasks in the game task sequence are scheduled. For a plurality of copies in the game, the task scheduling method is circularly adopted to carry out task scheduling, so that the plurality of copies of the game process can be scheduled, and a plurality of task mechanisms can be realized.
the task scheduling method provided by the embodiment of the application can definitely specify the time point for completing a specific task for the orderly and reliable check mechanism of each node state in the distributed system, combines the blocking type setting, has strong fault tolerance, and can ensure the context logic of task scheduling. And in the task list, tasks are deleted and added, only the preposed task and the subsequent task of the current task need to be checked, and whether the tasks are arranged in an ascending order in time is determined, so that the checking workload can be effectively reduced, and the task scheduling efficiency is improved.
Continuing with the exemplary structure of the implementation of the task scheduler 254 as a software module provided by the embodiments of the present application, in some embodiments, as shown in fig. 2, the software modules stored in the task scheduler 254 of the memory 250 may include:
A determining module 2541, configured to determine, when the state of the control node changes, a set of tasks to be executed corresponding to the changed state;
A sequencing module 2542, configured to sequence the to-be-executed tasks according to a task start time of each to-be-executed task in the to-be-executed task set, so as to obtain a to-be-executed task sequence;
A distributing module 2543, configured to sequentially distribute each to-be-executed task to at least one distributed node according to the to-be-executed task sequence, so as to implement scheduling of the to-be-executed task to each distributed node.
In some embodiments, the determining module is further configured to: when the control node increases a new state, the control node determines a task to be executed corresponding to the new state; and forming the task set to be executed according to the task to be executed corresponding to the new state and the historical task to be executed before the new state is added.
in some embodiments, the determining module is further configured to: when the control node deletes the state, the control node determines the remaining tasks to be executed corresponding to the states remaining after the state is deleted; and forming the task set to be executed through the residual tasks to be executed.
in some embodiments, the distribution module is further to: determining a trigger time period of each task to be executed in the task sequence to be executed, wherein the starting time of the trigger time period is the task starting time of the task to be executed, and the ending time of the trigger time period is the task ending time of the task to be executed; determining the task to be executed in the trigger time period including the current moment as a target task to be executed; and sequentially distributing the target task to be executed and other tasks to be executed positioned behind the target task to be executed in the task sequence to at least one distributed node.
In some embodiments, the distribution module is further to: and determining the task to be executed which is not executed by any distributed node and contains the current moment in the trigger time period as the target task to be executed.
In some embodiments, the apparatus further comprises: the adding module is used for adding an execution completion identifier for the task to be executed when receiving an execution completion signal corresponding to the task to be executed and returned by any distributed node; and the forbidding module is used for forbidding sending the task with the execution completion identifier to the distributed nodes.
in some embodiments, the task to be performed comprises a blocking task; correspondingly, the distribution module is further configured to: when the task to be executed sent to the at least one distributed node is the blocking task, waiting to receive an execution completion signal corresponding to the blocking task returned by each distributed node; and after receiving the execution completion signal returned by each distributed node, sequentially distributing the tasks to be executed after the blocking tasks in the task sequence to be executed to the at least one distributed node.
In some embodiments, the apparatus further comprises: and the sending module is used for sending the blocking task to the at least one distributed node again when an execution completion signal corresponding to the blocking task returned by any distributed node is not received after a preset time length.
In some embodiments, the task to be performed comprises a non-blocking task; correspondingly, the distribution module is further configured to: and when the task to be executed sent to the at least one distributed node is the non-blocking task, sending the non-blocking task to the at least one distributed node at the task starting time of each non-blocking task.
In other embodiments, the task scheduling device may also be a task scheduling device in the terminal 100-2 including the distributed node in fig. 1, and it may also be software in the form of programs and plug-ins, etc., including the following software modules:
The system comprises a receiving module, a processing module and a processing module, wherein the receiving module is used for receiving tasks to be executed which are sequentially sent by a control node according to a task sequence to be executed, and the task sequence to be executed is obtained by the control node by sequencing the tasks to be executed according to the task starting time of each task to be executed in a task set to be executed corresponding to the changed state when the state of the control node is changed; and the execution module is used for executing the task to be executed.
In some embodiments, the apparatus further comprises: the operation instruction determining module is used for determining at least one operation instruction corresponding to the task to be executed in a preset operation instruction library according to the identifier of the task to be executed; correspondingly, the execution module is further configured to: and executing the at least one operation instruction corresponding to the task to be executed.
In some embodiments, the apparatus further comprises: and the execution completion signal returning module is used for returning an execution completion signal of the corresponding operation instruction to the control node when each operation instruction corresponding to the task to be executed is executed.
In some embodiments, the task to be performed comprises a blocking task; correspondingly, the device further comprises: the first processing module is used for executing the blocking task and returning an execution completion signal to the control node when the task to be executed received by the distributed node is the blocking task; and after the execution completion signal is returned, receiving the task to be executed after the blocking task in the task sequence to be executed, which is sent by the control node.
In some embodiments, the task to be performed comprises a non-blocking task; correspondingly, the device further comprises: and the second processing module is used for receiving and executing the non-blocking task at the task starting time of each non-blocking task when the task to be executed received by the distributed node is the non-blocking task.
it should be noted that the description of the apparatus in the embodiment of the present application is similar to the description of the method embodiment, and has similar beneficial effects to the method embodiment, and therefore, the description is not repeated. For technical details not disclosed in the embodiments of the apparatus, reference is made to the description of the embodiments of the method of the present application for understanding.
Embodiments of the present application provide a storage medium having stored therein executable instructions, which when executed by a processor, will cause the processor to perform a method provided by embodiments of the present application, for example, the method as illustrated in fig. 3.
In some embodiments, the storage medium may be a Memory such as a Ferroelectric Random Access Memory (FRAM), a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read Only Memory (EPROM), a charged Erasable Programmable Read Only Memory (EEP ROM), a flash Memory, a magnetic surface Memory, an optical disc, or a Compact disc Read Only Memory (CD-ROM); or may be various devices including one or any combination of the above memories.
In some embodiments, executable instructions may be written in any form of programming language (including compiled or interpreted languages), in the form of programs, software modules, scripts or code, and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
By way of example, executable instructions may, but need not, correspond to files in a file system, and may be stored in a portion of a file that holds other programs or data, such as in one or more scripts in a hypertext Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code). By way of example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.
The above description is only an example of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims (15)

1. A method for task scheduling, comprising:
When the state of the control node changes, the control node determines a task set to be executed corresponding to the changed state;
Sequencing the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed to obtain a task sequence to be executed;
And sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed so as to realize the scheduling of the task to be executed.
2. The method according to claim 1, wherein when the state of the control node changes, the control node determines a set of tasks to be executed corresponding to the changed state, including:
When the control node increases a new state, the control node determines a task to be executed corresponding to the new state;
And forming the task set to be executed according to the task to be executed corresponding to the new state and the historical task to be executed before the new state is added.
3. The method according to claim 1, wherein when the state of the control node changes, the control node determines a set of tasks to be executed corresponding to the changed state, including:
when the control node deletes the state, the control node determines the remaining tasks to be executed corresponding to the states remaining after the state is deleted;
and forming the task set to be executed through the residual tasks to be executed.
4. The method according to claim 1, wherein said distributing each of the tasks to be executed to at least one distributed node in sequence according to the task sequence to be executed comprises:
Determining a trigger time period of each task to be executed in the task sequence to be executed, wherein the starting time of the trigger time period is the task starting time of the task to be executed, and the ending time of the trigger time period is the task ending time of the task to be executed;
Determining the task to be executed in the trigger time period including the current moment as a target task to be executed;
And sequentially distributing the target task to be executed and other tasks to be executed positioned behind the target task to be executed in the task sequence to at least one distributed node.
5. The method according to claim 4, wherein the determining that the task to be executed, of which the trigger time period includes the current time, is the target task to be executed comprises:
And determining the task to be executed which is not executed by any distributed node and contains the current moment in the trigger time period as the target task to be executed.
6. The method of claim 1, further comprising:
When an execution completion signal corresponding to a task to be executed and returned by any distributed node is received, adding an execution completion identifier for the task to be executed;
And forbidding sending the task with the execution completion identification to the distributed node.
7. The method according to any one of claims 1 to 6, wherein the task to be executed comprises a blocking task;
Correspondingly, the sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed includes:
When the task to be executed sent to the at least one distributed node is the blocking task, waiting to receive an execution completion signal corresponding to the blocking task returned by each distributed node;
And after receiving the execution completion signal returned by each distributed node, sequentially distributing the tasks to be executed after the blocking tasks in the task sequence to be executed to the at least one distributed node.
8. the method of claim 7, further comprising:
And when the execution completion signal corresponding to the blocking task returned by any distributed node is not received after the preset time length, the blocking task is sent to the at least one distributed node again.
9. The method according to any one of claims 1 to 6, wherein the task to be performed comprises a non-blocking task;
Correspondingly, the sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed includes:
And when the task to be executed sent to the at least one distributed node is the non-blocking task, sending the non-blocking task to the at least one distributed node at the task starting time of each non-blocking task.
10. a method for task scheduling, comprising:
The distributed node receives the tasks to be executed which are sequentially sent by the control node according to the task sequence to be executed,
When the state of a control node changes, the control node sequences the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed corresponding to the changed state;
and executing the task to be executed.
11. The method of claim 10, further comprising:
Determining at least one operation instruction corresponding to the task to be executed in a preset operation instruction library according to the identifier of the task to be executed;
Correspondingly, the executing the task to be executed includes:
And executing the at least one operation instruction corresponding to the task to be executed.
12. A task scheduling apparatus, comprising:
The determining module is used for determining a task set to be executed corresponding to the changed state when the state of the control node changes;
The sequencing module is used for sequencing the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed to obtain a task sequence to be executed;
And the distribution module is used for sequentially distributing each task to be executed to at least one distributed node according to the task sequence to be executed so as to realize the scheduling of the task to be executed.
13. A task scheduling apparatus, comprising:
A receiving module, which is used for receiving the tasks to be executed which are sequentially sent by the control node according to the task sequence to be executed,
When the state of a control node changes, the control node sequences the tasks to be executed according to the task starting time of each task to be executed in the task set to be executed corresponding to the changed state;
and the execution module is used for executing the task to be executed.
14. a task scheduling apparatus, comprising:
A memory for storing executable instructions; a processor for implementing the method of any one of claims 1 to 9, or 10 or 11, when executing executable instructions stored in the memory.
15. a storage medium having stored thereon executable instructions for causing a processor to perform the method of any one of claims 1 to 9, or claims 10 or 11, when executed.
CN201910838376.2A 2019-09-05 2019-09-05 Task scheduling method, device, equipment and storage medium Active CN110543354B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910838376.2A CN110543354B (en) 2019-09-05 2019-09-05 Task scheduling method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910838376.2A CN110543354B (en) 2019-09-05 2019-09-05 Task scheduling method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110543354A true CN110543354A (en) 2019-12-06
CN110543354B CN110543354B (en) 2023-06-13

Family

ID=68712589

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910838376.2A Active CN110543354B (en) 2019-09-05 2019-09-05 Task scheduling method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110543354B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111857983A (en) * 2020-04-29 2020-10-30 国家计算机网络与信息安全管理中心 Task scheduling method and device based on distributed data acquisition
CN112148445A (en) * 2020-09-09 2020-12-29 倍智智能数据运营有限公司 Distributed task scheduling method based on big data technology
CN112181625A (en) * 2020-10-12 2021-01-05 联通智网科技有限公司 Task scheduling method, system, device, storage medium and computer equipment
CN113010285A (en) * 2021-03-12 2021-06-22 北京百度网讯科技有限公司 Method, apparatus, device, medium and product for processing data
CN113067898A (en) * 2021-06-02 2021-07-02 支付宝(杭州)信息技术有限公司 Method for scheduling computing services for business process contracts
CN113312167A (en) * 2021-08-02 2021-08-27 中电长城网际安全技术研究院(北京)有限公司 Service control method and device, electronic equipment and computer readable medium
CN113448710A (en) * 2021-07-01 2021-09-28 星辰天合(北京)数据科技有限公司 Distributed application system based on business resources

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070220517A1 (en) * 2005-09-30 2007-09-20 Lippett Mark D Scheduling in a multicore processor
CN102799486A (en) * 2012-06-18 2012-11-28 北京大学 Data sampling and partitioning method for MapReduce system
CN103078941A (en) * 2012-12-31 2013-05-01 中金数据系统有限公司 Task scheduling method and system for distributed computing system
CN104239144A (en) * 2014-09-22 2014-12-24 珠海许继芝电网自动化有限公司 Multilevel distributed task processing system
JP2015001828A (en) * 2013-06-14 2015-01-05 富士通株式会社 Allocation program, allocation device, and allocation method
CN107688496A (en) * 2017-07-24 2018-02-13 上海壹账通金融科技有限公司 Task distribution formula processing method, device, storage medium and server
CN108132840A (en) * 2017-11-16 2018-06-08 浙江工商大学 Resource regulating method and device in a kind of distributed system
US20190042303A1 (en) * 2015-09-24 2019-02-07 Wangsu Science & Technology Co.,Ltd. Distributed storage-based file delivery system and method
CN109710407A (en) * 2018-12-21 2019-05-03 浪潮电子信息产业股份有限公司 Distributed system real-time task scheduling method, device, equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070220517A1 (en) * 2005-09-30 2007-09-20 Lippett Mark D Scheduling in a multicore processor
CN102799486A (en) * 2012-06-18 2012-11-28 北京大学 Data sampling and partitioning method for MapReduce system
CN103078941A (en) * 2012-12-31 2013-05-01 中金数据系统有限公司 Task scheduling method and system for distributed computing system
JP2015001828A (en) * 2013-06-14 2015-01-05 富士通株式会社 Allocation program, allocation device, and allocation method
CN104239144A (en) * 2014-09-22 2014-12-24 珠海许继芝电网自动化有限公司 Multilevel distributed task processing system
US20190042303A1 (en) * 2015-09-24 2019-02-07 Wangsu Science & Technology Co.,Ltd. Distributed storage-based file delivery system and method
CN107688496A (en) * 2017-07-24 2018-02-13 上海壹账通金融科技有限公司 Task distribution formula processing method, device, storage medium and server
CN108132840A (en) * 2017-11-16 2018-06-08 浙江工商大学 Resource regulating method and device in a kind of distributed system
CN109710407A (en) * 2018-12-21 2019-05-03 浪潮电子信息产业股份有限公司 Distributed system real-time task scheduling method, device, equipment and storage medium

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111857983A (en) * 2020-04-29 2020-10-30 国家计算机网络与信息安全管理中心 Task scheduling method and device based on distributed data acquisition
CN111857983B (en) * 2020-04-29 2023-02-28 国家计算机网络与信息安全管理中心 Task scheduling method and device based on distributed data acquisition
CN112148445A (en) * 2020-09-09 2020-12-29 倍智智能数据运营有限公司 Distributed task scheduling method based on big data technology
CN112181625A (en) * 2020-10-12 2021-01-05 联通智网科技有限公司 Task scheduling method, system, device, storage medium and computer equipment
CN113010285A (en) * 2021-03-12 2021-06-22 北京百度网讯科技有限公司 Method, apparatus, device, medium and product for processing data
CN113010285B (en) * 2021-03-12 2023-08-04 北京百度网讯科技有限公司 Method, apparatus, device, medium, and article for processing data
CN113067898A (en) * 2021-06-02 2021-07-02 支付宝(杭州)信息技术有限公司 Method for scheduling computing services for business process contracts
CN113448710A (en) * 2021-07-01 2021-09-28 星辰天合(北京)数据科技有限公司 Distributed application system based on business resources
CN113448710B (en) * 2021-07-01 2024-04-09 北京星辰天合科技股份有限公司 Distributed application system based on business resources
CN113312167A (en) * 2021-08-02 2021-08-27 中电长城网际安全技术研究院(北京)有限公司 Service control method and device, electronic equipment and computer readable medium
CN113312167B (en) * 2021-08-02 2021-12-10 中电长城网际安全技术研究院(北京)有限公司 Service control method and device, electronic equipment and computer readable medium

Also Published As

Publication number Publication date
CN110543354B (en) 2023-06-13

Similar Documents

Publication Publication Date Title
CN110543354B (en) Task scheduling method, device, equipment and storage medium
CN107370786B (en) General information management system based on micro-service architecture
CN111405304B (en) Anchor interaction method and device, computer equipment and storage medium
CN109951547B (en) Transaction request parallel processing method, device, equipment and medium
CN112073269B (en) Block chain network testing method, device, server and storage medium
CN109710243B (en) Block chain development method, device, server and medium based on visual platform
CN112711526B (en) UI test method, device, equipment and storage medium
CN106170777A (en) Reduce the book durability state of block-based storage
CN105359147A (en) Online database migration
CN111240732B (en) Method, device, equipment and storage medium for distributing distributed microservice
CN109886693B (en) Consensus realization method, device, equipment and medium for block chain system
CN101248416A (en) Component architecture
CN107665154A (en) Authentic data analysis method based on RDMA and message transmission
CN110298754A (en) A kind of common recognition method applied to block chain
CN111639309B (en) Data processing method and device, node equipment and storage medium
JP6830528B2 (en) How and system to share user activity information
CN103250145A (en) Techniques for capturing data sets
CN112966311A (en) Intelligent contract checking method and device and electronic equipment
CN110225087A (en) Cloud access method, device and storage medium based on global load balancing
CN113407284A (en) Navigation interface generation method and device, storage medium and electronic equipment
CN113641591A (en) Test case generation method and device and test method and device
CN111026945B (en) Multi-platform crawler scheduling method, device and storage medium
CN113360215A (en) Program running method and device and computer readable storage medium
CN113542323B (en) Service processing method, device, equipment and computer readable storage medium
CN116521509A (en) Intelligent contract testing method, device, equipment, storage medium and product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40016256

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20210127

Address after: 5 / F, area C, 1801 Hongmei Road, Xuhui District, Shanghai, 201200

Applicant after: Tencent Technology (Shanghai) Co.,Ltd.

Address before: 518000 Tencent Building, No. 1 High-tech Zone, Nanshan District, Shenzhen City, Guangdong Province, 35 Floors

Applicant before: TENCENT TECHNOLOGY (SHENZHEN) Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant