CN115373822A - Task scheduling method, task processing method, device, electronic equipment and medium - Google Patents

Task scheduling method, task processing method, device, electronic equipment and medium Download PDF

Info

Publication number
CN115373822A
CN115373822A CN202211056429.3A CN202211056429A CN115373822A CN 115373822 A CN115373822 A CN 115373822A CN 202211056429 A CN202211056429 A CN 202211056429A CN 115373822 A CN115373822 A CN 115373822A
Authority
CN
China
Prior art keywords
task
processed
thread
scheduler
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211056429.3A
Other languages
Chinese (zh)
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.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech 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 CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202211056429.3A priority Critical patent/CN115373822A/en
Publication of CN115373822A publication Critical patent/CN115373822A/en
Pending legal-status Critical Current

Links

Images

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)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The disclosure provides a task scheduling method, a task processing device, electronic equipment and a medium, which can be applied to the technical field of computers and the technical field of finance. The task scheduling method comprises the following steps: responding to a task obtaining request received from a scheduler, and determining a task set according to the task obtaining request, wherein the task obtaining request comprises a scheduler identifier corresponding to the scheduler, the task set comprises at least one piece of to-be-processed task information corresponding to the to-be-processed task, and each piece of to-be-processed task information in the at least one piece of to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and sending the task set to a scheduler corresponding to the scheduler identifier, so that the scheduler sends at least one to-be-processed task in the task set to a target thread in a thread pool in sequence according to the task creation time information.

Description

Task scheduling method, task processing method, device, electronic equipment and medium
Technical Field
The present disclosure relates to the field of computer technology and the field of financial technology, and more particularly, to a task scheduling method, a task processing method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product.
Background
With the development of computer technology, under a distributed architecture, task scheduling can be performed through a task scheduler and a task executor to ensure high availability of services. Task scheduling may refer to a process in which a system executes a task at a preset time in order to automatically complete a certain task.
In implementing the disclosed concept, the inventors found that there are at least the following problems in the related art: the efficiency and the accuracy of task scheduling cannot be well guaranteed by adopting the related technology.
Disclosure of Invention
In view of the above, the present disclosure provides a task scheduling method, a task processing method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product.
According to an aspect of the present disclosure, there is provided a task scheduling method, including:
in response to receiving a task obtaining request from a scheduler, determining a task set according to the task obtaining request, wherein the task obtaining request comprises a scheduler identifier corresponding to the scheduler, the task set comprises at least one piece of to-be-processed task information corresponding to a to-be-processed task, and each piece of to-be-processed task information in the at least one piece of to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and
and sending the task set to the scheduler corresponding to the scheduler identifier, so that the scheduler sends the at least one to-be-processed task in the task set to a target thread in a thread pool in sequence according to the task creation time information.
According to an embodiment of the present disclosure, the task state information includes a to-be-selected state and a selection completion state.
According to an embodiment of the present disclosure, the determining a task set according to the task obtaining request includes:
when the task state information is in the state to be selected, sequencing the tasks to be processed according to the task creation time information to obtain a task sequence to be processed;
determining a preset number of candidate tasks to be processed according to the task sequence to be processed; and
and determining the task set according to the preset number of candidate tasks to be processed.
According to an embodiment of the present disclosure, before determining the task set according to the preset number of the candidate to-be-processed tasks, the method further includes:
and updating the task state information corresponding to each of the preset number of the candidate tasks to be processed into the selection completion state.
According to an embodiment of the present disclosure, the scheduler and the thread pool are provided in the same process.
According to an aspect of the present disclosure, there is provided a task processing method including:
in response to receiving a task processing request from a scheduler, determining a target thread in a thread pool according to the task processing request, wherein the task processing request comprises to-be-processed task information corresponding to a to-be-processed task, and the to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and
and processing the task to be processed by using the target thread to obtain a task processing result.
According to an embodiment of the present disclosure, the task state information includes an executing state and an execution completion state.
According to an embodiment of the present disclosure, after determining a target thread in a thread pool according to the task processing request, the method further includes:
and updating the task state information to the executing state.
According to an embodiment of the present disclosure, after the target thread is used to process the task to be processed to obtain a task processing result, the method further includes:
and updating the task state information to the execution completion state.
According to an embodiment of the present disclosure, the thread pool is created by:
determining thread pool parameters, wherein the thread pool parameters comprise at least one of the number of core threads, a thread number threshold, the type of a work queue and the preset capacity of the work queue, and the thread number threshold is set according to the number of the core threads; and
and creating the thread pool according to the thread pool parameters.
According to an embodiment of the present disclosure, in a case that the thread pool parameter includes the number of core threads, the determining, according to the task processing request, a target thread in the thread pool includes:
determining the number of current threads in the thread pool;
under the condition that the number of the current threads is smaller than the number of the core threads, creating a first thread; and
the first line Cheng Que is defined as the target thread.
According to an embodiment of the present disclosure, in case the thread pool parameters include the number of core threads, the type of the work queue and the preset capacity of the work queue,
the determining a target thread in a thread pool according to the task processing request comprises:
creating a second thread under the condition that the number of the current threads is larger than or equal to the number of the core threads and the work queue reaches the preset capacity; and
and determining the second thread as the target thread.
According to an embodiment of the present disclosure, the task processing method further includes:
and adding the task to be processed to the work queue under the condition that the number of the current threads is greater than or equal to the number of the core threads and the work queue does not reach the preset capacity.
According to an embodiment of the present disclosure, in a case that the thread pool parameter includes the thread number threshold, the task processing method further includes:
determining the number of current threads in the thread pool; and
and rejecting the processing of the task to be processed under the condition that the number of the current threads is greater than or equal to the thread number threshold value.
According to another aspect of the present disclosure, there is provided a task scheduling apparatus including:
the system comprises a first determining module, a second determining module and a processing module, wherein the first determining module is used for responding to a task obtaining request from a scheduler and determining a task set according to the task obtaining request, the task obtaining request comprises a scheduler identifier corresponding to the scheduler, the task set comprises at least one piece of to-be-processed task information corresponding to a to-be-processed task, and each piece of to-be-processed task information in the at least one piece of to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and
and a sending module, configured to send the task set to the scheduler corresponding to the scheduler identifier, so that the scheduler sends the at least one to-be-processed task in the task set to a target thread in a thread pool in sequence according to the task creation time information.
According to another aspect of the present disclosure, there is provided a task processing apparatus including:
a second determining module, configured to determine a target thread in a thread pool according to a task processing request received from a scheduler according to the task processing request, where the task processing request includes to-be-processed task information corresponding to a to-be-processed task, and the to-be-processed task information includes a task identifier, task information, task creation time information, and task state information; and
and the processing module is used for processing the task to be processed by utilizing the target thread to obtain a task processing result.
According to another aspect of the present disclosure, there is provided an electronic device including:
one or more processors;
a memory to store one or more instructions that,
wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to implement a method as described in this disclosure.
According to another aspect of the present disclosure, there is provided a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to implement a method as described in the present disclosure.
According to another aspect of the present disclosure, there is provided a computer program product comprising computer executable instructions for implementing a method as described in the present disclosure when executed.
According to the embodiment of the disclosure, batch tasks can be acquired at a single time by determining the task set according to the task acquisition request. In addition, by sending the task set to the scheduler, the scheduler can send at least one task to be processed to the target thread in the thread pool in sequence according to the task creation time information, and resource consumption can be reduced. In addition, the task information to be processed comprises the task identification, the task creating time information and the task state information, so that the task creating time and the task state can be accurately distinguished. Based on the technical means, the technical problem that the efficiency and the accuracy of task scheduling cannot be well guaranteed by adopting related technologies is at least partially solved, so that the efficiency and the accuracy of task scheduling are improved.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure with reference to the accompanying drawings, in which:
fig. 1 schematically shows a system architecture to which a task scheduling method and a task processing method may be applied according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a task scheduling method according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow chart of a method of task processing according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates an example diagram of a process of determining a target thread in accordance with an embodiment of this disclosure;
FIG. 5 schematically shows a working timing diagram of a task scheduling method and a task processing method according to an embodiment of the present disclosure;
FIG. 6 schematically shows a block diagram of a task scheduling apparatus according to an embodiment of the present disclosure;
FIG. 7 schematically shows a block diagram of a task processing device according to an embodiment of the present disclosure; and
fig. 8 schematically shows a block diagram of an electronic device adapted to implement a task scheduling method and a task processing method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "A, B and at least one of C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include, but not be limited to, systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a convention analogous to "A, B or at least one of C, etc." is used, in general such a construction should be interpreted in the sense one having ordinary skill in the art would understand the convention (e.g., "a system having at least one of A, B or C" would include but not be limited to systems that have a alone, B alone, C alone, a and B, a and C, B and C, and/or A, B, C, etc.).
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, necessary security measures are taken, and the customs of the public order is not violated.
In the technical scheme of the disclosure, before the personal information of the user is acquired or collected, the authorization or the consent of the user is acquired.
Since the scheduler acquires the task whose status is to be processed according to the fixed frequency, the task acquired by the scheduler is not necessarily the task that the current machine needs to execute. In addition, since the optimistic lock mechanism is usually adopted to update the task state, the task state can be executed only after the update is successful, which affects the execution efficiency of task scheduling.
In summary, in the process of implementing the disclosed concept, the inventors found that at least the following problems exist in the related art: the efficiency and accuracy of task scheduling cannot be guaranteed.
In order to at least partially solve the technical problems in the related art, the present disclosure provides a task scheduling method, a task processing method, an apparatus, an electronic device, and a medium, which can be applied to the field of computer technology and the field of financial technology. The task scheduling method comprises the following steps: responding to a task obtaining request received from a scheduler, and determining a task set according to the task obtaining request, wherein the task obtaining request comprises a scheduler identifier corresponding to the scheduler, the task set comprises at least one piece of to-be-processed task information corresponding to the to-be-processed task, and each piece of to-be-processed task information in the at least one piece of to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and sending the task set to a scheduler corresponding to the scheduler identifier, so that the scheduler sends at least one to-be-processed task in the task set to a target thread in a thread pool in sequence according to the task creation time information.
It should be noted that the task scheduling method, the task processing method, and the device provided in the embodiments of the present disclosure may be applied to the fields of computer technology and financial technology, for example, to task scheduling and task processing. The task scheduling method, the task processing method and the task processing device provided by the embodiment of the disclosure can also be used in any fields except the computer technology field and the financial technology field, for example, the application to enterprise operation and maintenance. The application fields of the task scheduling method, the task processing method and the device provided by the embodiment of the disclosure are not limited.
Fig. 1 schematically shows a system architecture to which a task scheduling method and a task processing method can be applied according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of a system architecture to which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, and does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. Network 104 is the medium used to provide communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired and/or wireless communication links, and so forth.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as a shopping-like application, a web browser application, a search-like application, an instant messaging tool, a mailbox client, and/or social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (for example only) providing support for websites browsed by users using the terminal devices 101, 102, 103. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the task scheduling method provided by the embodiment of the present disclosure may be generally executed by the terminal device 101, 102, or 103, or may be executed by another terminal device different from the terminal device 101, 102, or 103. Accordingly, the task scheduling apparatus provided by the embodiment of the present disclosure may be disposed in the terminal device 101, 102, or 103, or in another terminal device different from the terminal device 101, 102, or 103.
Alternatively, the task scheduling method provided by the embodiment of the present disclosure may also be executed by the server 105. Accordingly, the task scheduling device provided by the embodiment of the present disclosure may also be disposed in the server 105. The task scheduling method provided by the embodiment of the present disclosure may also be performed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Correspondingly, the task scheduling apparatus provided in the embodiment of the present disclosure may also be disposed in a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be noted that the task processing method provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the task processing device provided by the embodiment of the present disclosure may be generally disposed in the server 105. The task processing method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the task processing device provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
Alternatively, the task processing method provided by the embodiment of the present disclosure may also be executed by the terminal device 101, 102, or 103, or may also be executed by another terminal device different from the terminal device 101, 102, or 103. Accordingly, the task processing apparatus provided by the embodiment of the present disclosure may also be disposed in the terminal device 101, 102, or 103, or in another terminal device different from the terminal device 101, 102, or 103.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
It should be noted that the sequence numbers of the respective operations in the following methods are merely used as representations of the operations for description, and should not be construed as representing the execution order of the respective operations. The method need not be performed in the exact order shown, unless explicitly stated.
Fig. 2 schematically shows a flow chart of a task scheduling method according to an embodiment of the present disclosure.
As shown in FIG. 2, the task scheduling method 200 includes operations S210-S220.
In operation S210, in response to receiving a task obtaining request from a scheduler, a task set is determined according to the task obtaining request, where the task obtaining request includes a scheduler identifier corresponding to the scheduler, the task set includes at least one piece of to-be-processed task information corresponding to a to-be-processed task, and each piece of to-be-processed task information in the at least one piece of to-be-processed task information includes a task identifier, task information, task creation time information, and task state information.
In operation S220, the task set is sent to the scheduler corresponding to the scheduler identifier, so that the scheduler sequentially sends at least one to-be-processed task in the task set to a target thread in the thread pool according to the task creation time information.
According to an embodiment of the present disclosure, a scheduler may send a task acquisition request to a terminal device, and the terminal device may receive the task acquisition request. The task obtaining request may include a request message sent by the scheduler to the terminal device. After receiving the request message, the terminal device may determine a task set.
According to the embodiment of the disclosure, the task obtaining request may include a scheduler identifier corresponding to a scheduler, and after the terminal device determines the task set, the task set may be sent to the corresponding scheduler according to the scheduler identifier.
According to the embodiment of the disclosure, a worker can input data to be processed and the like into a database in a task form in advance, and after a terminal device receives a task obtaining request from a scheduler, a task set can be determined in the database according to the task obtaining request.
According to the embodiment of the disclosure, at least one piece of to-be-processed task information corresponding to the to-be-processed task can be included in the task set. Each piece of to-be-processed task information in the at least one piece of to-be-processed task information may include a task identifier, task information, task creation time information, and task state information.
According to an embodiment of the present disclosure, the task identification may be used to identify the task to be processed. The task information may include basic information of the task, input parameter information of the task, type information of the task, and the like. The task creation time information may include a creation time of the to-be-processed task. The task state information may be used to characterize a state of the task, and the task state information may include at least one of: a to-be-selected state, a selection-completed state, an executing state, an execution-completed state, and the like.
According to the embodiment of the disclosure, the scheduler may sequentially send at least one task to be processed in the task set to a target thread in the thread pool according to the task creation time information of each task to be processed in the task set. Alternatively, the scheduler may also issue at least one to-be-processed task in the task set to a message queue in sequence, and the message queue sends the to-be-processed task to the executor according to the balanced allocation algorithm.
According to an embodiment of the present disclosure, the pending task information may be stored in a database. The database may comprise a relational database, such as Oracle, SQLServer, sybase, informix, access, DB2, or mysql, among others. The database may also be a non-relational database, such as Hbase, cassandra, simpleDB, couchDB, mongoDB, redis, or the like.
According to the embodiment of the disclosure, after the scheduler sends each task to be processed in the task set to the target thread in the thread pool, the scheduler may sleep for a preset time.
According to the embodiment of the disclosure, batch tasks can be acquired at a single time by determining the task set according to the task acquisition request. In addition, by sending the task set to the scheduler, the scheduler can send at least one task to be processed to the target thread in the thread pool in sequence according to the task creation time information, and resource consumption can be reduced. In addition, the task information to be processed comprises the task identification, the task creating time information and the task state information, so that the task creating time and the task state can be accurately distinguished. Based on the technical means, the technical problem that the efficiency and the accuracy of task scheduling cannot be guaranteed well by adopting related technologies is at least partially solved, so that the efficiency and the accuracy of task scheduling are improved.
According to an embodiment of the present disclosure, the task state information includes a to-be-selected state and a selection completion state.
According to an embodiment of the present disclosure, operation S210 may include the following operations.
And under the condition that the task state information is in the state to be selected, sequencing the tasks to be processed according to the task creation time information to obtain a task sequence to be processed. And determining a preset number of candidate tasks to be processed according to the sequence of the tasks to be processed. And determining a task set according to the candidate tasks to be processed in the preset number.
According to the embodiment of the disclosure, the to-be-processed tasks with the task state information being in the to-be-selected state can be screened from the to-be-processed tasks stored in the database, the to-be-processed tasks are sorted according to the task creation time information, and according to the obtained to-be-processed task sequence, a preset number of candidate to-be-processed tasks are determined and a task set is determined. The specific numerical value of the preset number may be set according to actual requirements, and the embodiment of the present disclosure does not limit this.
According to the embodiment of the disclosure, after the task set is determined, row lock locking of an exclusive type can be performed on rows involved in the task set through a query form of the set in, namely, selection xxx from jobs where id in (..) is executed for update to perform batch task locking. The inquired lines can be processed by the current transaction, and other concurrent transactions are blocked when executing the same select xxx for update, until the transaction which preempts the line lock is finished, the line lock is released, and the tasks related to the task set can be ensured to be mutually exclusive accessed by each scheduler.
According to the embodiment of the disclosure, when the task state information is in the to-be-selected state, the to-be-processed tasks are sequenced according to the task creation time information, and according to the obtained to-be-processed task sequence, a preset number of candidate to-be-processed tasks are determined and a task set is determined. Through the technical means, batch tasks can be locked by utilizing a row lock technology, so that the task scheduling and executing efficiency is improved.
According to an embodiment of the present disclosure, the task scheduling method 200 may further include the following operations.
And updating the task state information corresponding to each candidate task to be processed in the preset number of candidate tasks to be processed into a selection completion state.
According to an embodiment of the present disclosure, before determining the task set, task state information corresponding to each candidate to-be-processed task of the preset number of candidate to-be-processed tasks may be updated to a selection completion state. For example, the to-be-selected state is set to 0, the selection completion state is set to 1, and in the case where a preset number of candidate to-be-processed tasks are determined, the corresponding task state information, i.e., update status, may be set to 1.
According to the embodiment of the disclosure, by updating the task state information from the to-be-selected state to the selection completion state, the condition that other schedulers acquire the same to-be-processed task after the current scheduler submits the transaction and releases the exclusive row lock is avoided, the repeated execution of the task is avoided, and the task execution efficiency is improved.
According to an embodiment of the present disclosure, the scheduler and the thread pool are provided in the same process.
According to the embodiment of the disclosure, a process may refer to an application program in operation, each process has an independent memory space, and one application program can start a plurality of processes at the same time. A thread may refer to the smallest unit that an operating system can perform, a thread is contained within a process, and is the actual unit of execution in a run. A thread is a single sequential control flow in a process, multiple threads can be executed in parallel in a process, and each thread can execute different tasks in parallel.
According to the embodiment of the disclosure, the scheduler and the executor may be set in the same process, the scheduler is set as a separate thread, and the executor is set as an initialized thread pool, so that resource sharing between the scheduler and the thread pool may be achieved, that is, the scheduler may locally invoke a target thread of the executor.
According to the embodiment of the disclosure, a Spring framework transaction implementation mechanism can be utilized to open database transactions. The ways of implementing transaction control in the Spring framework include programmatic transactions and declarative transactions. Declarative transactions may include annotation based approaches.
The above is only an exemplary embodiment, but is not limited thereto, and other task scheduling methods known in the art may be included as long as task scheduling can be implemented.
Fig. 3 schematically shows a flow chart of a task processing method according to an embodiment of the present disclosure.
As shown in fig. 3, the task processing method 300 includes operations S310 to S320.
In operation S310, in response to receiving a task processing request from the scheduler, a target thread is determined in the thread pool according to the task processing request, where the task processing request includes to-be-processed task information corresponding to a to-be-processed task, and the to-be-processed task information includes a task identifier, task information, task creation time information, and task state information.
In operation S320, the target thread is used to process the to-be-processed task, so as to obtain a task processing result.
According to an embodiment of the present disclosure, the scheduler may transmit a task processing request to the server, and the server may receive the task processing request. The task processing request may include a request message sent by the scheduler to the server. The server, after receiving the request message, may determine a target thread in the thread pool.
According to an embodiment of the present disclosure, the thread pool may include at least one of: the number of core threads, a thread number threshold, thread survival time, type of work queue, and a preset capacity of work queue.
According to the embodiment of the disclosure, the task processing request may include to-be-processed task information corresponding to the to-be-processed task, and after the server determines the target thread, the target thread may be used to process the to-be-processed task corresponding to the to-be-processed task information, so as to obtain a task processing result.
According to an embodiment of the present disclosure, the to-be-processed task information may include a task identifier, task information, task creation time information, and task state information. The task identification may be used to identify the pending task. The task information may include basic information of the task, input parameter information of the task, type information of the task, and the like. The task creation time information may include a creation time of the to-be-processed task. The task state information may be used to characterize a state of the task, and the task state information may include at least one of: a to-be-selected state, a selection-completed state, an executing state, an execution-completed state, and the like.
According to the embodiment of the disclosure, the target thread is determined in the thread pool according to the task processing request, and the task to be processed is processed by using the target thread to obtain the task processing result, so that resource and time consumption caused by thread creation can be avoided. In addition, the task information to be processed comprises the task identification, the task creating time information and the task state information, so that the task creating time and the task state can be accurately distinguished. Based on the technical means, the thread pool technology is adopted for thread multiplexing, so that the task scheduling efficiency is improved.
Referring now to FIG. 4, a task processing method 300 according to an embodiment of the present disclosure is further described.
According to an embodiment of the present disclosure, the task state information includes an executing state and an execution completing state.
According to an embodiment of the present disclosure, the task processing method 300 may further include the following operations.
And updating the task state information to the executing state.
According to an embodiment of the present disclosure, the task processing method 300 may further include the following operations.
And updating the task state information into an execution completion state.
According to the embodiment of the disclosure, by updating the task state information from the selection completion state to the execution state and updating the task state information from the execution state to the execution completion state, the state of the task can be known in real time, so that the task execution efficiency is improved.
According to an embodiment of the present disclosure, a thread pool may be created in the following manner.
Thread pool parameters are determined. The thread pool parameters may include at least one of a number of core threads, a thread number threshold, a type of work queue, and a preset capacity of the work queue. The thread number threshold is set based on the number of core threads. And creating a thread pool according to the thread pool parameters.
According to embodiments of the present disclosure, the thread pool parameters may also include thread survival time and rejection policy. The number of core threads may be characterized as corePoolSize, the thread number threshold may be characterized as maximumPoolSize, the thread survival time may be characterized as keepalivietime, and the work queue may be characterized as workQueue. The type of work queue may include at least one of: a synchronization queue, bounded threads, unbounded thread queues, and task priority queues.
In a case where the thread pool parameter includes the number of core threads, operation S310 may include the following operations according to an embodiment of the present disclosure.
The current number of threads in the thread pool is determined. In the case that the current thread number is less than the core thread number, a first thread is created. The first thread is determined to be the target thread.
According to the embodiment of the disclosure, after receiving a task processing request from a scheduler, the relation between the current thread number and the core thread number can be determined. In the case that the current thread number is less than the core thread number, a first thread may be created to process the task to be processed.
In accordance with an embodiment of the present disclosure, in the case that the thread pool parameters include the number of core threads, the type of work queue, and the preset capacity of the work queue, operation S310 may include the following operations.
And creating a second thread under the condition that the number of the current threads is greater than or equal to the number of the core threads and the work queue reaches the preset capacity. The second thread is determined to be the target thread.
According to the embodiment of the disclosure, after receiving a task processing request from a scheduler, the relation between the current thread number and the core thread number can be determined. In the case where the current number of threads is greater than or equal to the number of core threads, it may be determined whether the work queue has reached a preset capacity. In the event that the work queue reaches a preset capacity, a second thread may be created to process the task to be processed.
According to an embodiment of the present disclosure, the task processing method 300 may further include the following operations.
And adding the tasks to be processed to the work queue under the conditions that the number of the current threads is larger than or equal to the number of the core threads and the work queue does not reach the preset capacity.
According to the embodiment of the disclosure, after receiving a task processing request from a scheduler, the relation between the current thread number and the core thread number can be determined. In the case where the current number of threads is greater than or equal to the number of core threads, it may be determined whether the work queue has reached a preset capacity. And under the condition that the work queue does not reach the preset capacity, the tasks to be processed can be added into the work queue, and the idle core threads are waited to process the tasks to be processed.
In accordance with an embodiment of the present disclosure, where the thread pool parameter includes a thread number threshold, the task processing method 300 may further include the following operations.
The current number of threads in the thread pool is determined. And if the current thread number is larger than or equal to the thread number threshold value, rejecting the processing of the task to be processed.
According to an embodiment of the present disclosure, after receiving a task processing request from a scheduler, a relationship of a current thread number to a thread number threshold may be determined. In the event that the current number of threads is greater than or equal to the thread number threshold, processing of the pending task may be denied.
According to the embodiment of the disclosure, in the case that the number of current threads is greater than the number of core threads, the threads exceeding the thread survival time may be destroyed until the number of current threads in the thread pool is less than or equal to the number of core threads.
According to the embodiment of the disclosure, the thread pool is created according to the thread pool parameters, and the target thread is determined in the thread pool according to the task processing request, so that thread multiplexing can be realized, the resource consumption of frequent creation and destruction of the thread is reduced, and the task execution efficiency is improved.
FIG. 4 schematically illustrates an example schematic diagram of a method of determining a target thread according to an embodiment of this disclosure.
As shown in FIG. 4, the determine target thread method 400 may include operations S411-S418.
In operation S411, the current number of threads in the thread pool may be determined.
In operation S412, it may be determined whether the current thread number is less than the core thread number.
In the case where it is determined that the current thread number is less than the core thread number, operation S413 may be performed. In operation S413, a first thread may be created and determined as a target thread.
In the case where it is determined that the current thread number is greater than or equal to the core thread number, operation S414 may be performed. In operation S414, it may be determined whether the work queue reaches the preset capacity.
In a case where it is determined that the work queue does not reach the preset capacity, operation S415 may be performed. In operation S415, the task to be processed may be added to the work queue.
In the case where it is determined that the work queue reaches the preset capacity, operation S416 may be performed. In operation S416, it may be determined whether the current number of threads is less than a thread number threshold.
In the case that the current thread number is less than the thread number threshold, operation S417 may be performed. In operation S417, a second thread may be created and determined as the target thread.
In the case that the current thread number is greater than or equal to the thread number threshold, operation S418 may be performed. In operation S418, processing of the to-be-processed task may be denied.
The above is only an exemplary embodiment, but is not limited thereto, and other task processing methods known in the art may be included as long as the task processing can be achieved.
Fig. 5 schematically shows a working timing diagram of a task scheduling method and a task processing method according to an embodiment of the present disclosure.
As shown in fig. 5, in operation S501, the scheduler may transmit a task acquisition request to the terminal device.
In operation S502, after receiving the task obtaining request from the scheduler, the terminal device may sort the to-be-processed tasks according to the task creation time information under the condition that the task state information is in the to-be-selected state, so as to obtain a to-be-processed task sequence.
In operation S503, the terminal device may determine a preset number of candidate tasks to be processed according to the sequence of tasks to be processed.
In operation S504, the terminal device may update task state information corresponding to each candidate to-be-processed task of the preset number of candidate to-be-processed tasks to a selection completion state.
In operation S505, the terminal device may determine a task set according to a preset number of candidate tasks to be processed.
In operation S506, the terminal device may send the set of tasks to the scheduler corresponding to the scheduler identification.
In operation S507, the scheduler may transmit a task processing request to the server after receiving the task set from the terminal device.
In operation S508, the server may determine a target thread in the thread pool according to the task processing request after receiving the task processing request from the scheduler.
In operation S509, the server may update the task state information to the executing state after determining the target thread in the thread pool according to the task processing request.
In operation S510, the server may process the task to be processed by using the target thread, and obtain a task processing result.
In operation S511, after the server processes the task to be processed by using the target thread and obtains a task processing result, the server may update the task state information to an execution completion state.
Fig. 6 schematically shows a block diagram of a task scheduling device according to an embodiment of the present disclosure.
As shown in fig. 6, the task scheduler 600 may include a first determining module 601 and a transmitting module 602.
The first determining module 601 is configured to determine a task set according to a task obtaining request in response to receiving the task obtaining request from a scheduler, where the task obtaining request includes a scheduler identifier corresponding to the scheduler, the task set includes at least one piece of to-be-processed task information corresponding to a to-be-processed task, and each piece of to-be-processed task information in the at least one piece of to-be-processed task information includes a task identifier, task information, task creation time information, and task state information.
A sending module 602, configured to send the task set to a scheduler corresponding to the scheduler identifier, so that the scheduler sends at least one to-be-processed task in the task set to a target thread in the thread pool in sequence according to the task creation time information.
According to an embodiment of the present disclosure, the task state information includes a to-be-selected state and a selection completion state.
According to an embodiment of the present disclosure, the first determining module 601 may include a sorting unit, a first determining unit, and a second determining unit.
And the sequencing unit is used for sequencing the tasks to be processed according to the task creation time information under the condition that the task state information is in the state to be selected, so as to obtain a task sequence to be processed.
The first determining unit is used for determining a preset number of candidate tasks to be processed according to the task sequence to be processed.
And the second determining unit is used for determining the task set according to the preset number of candidate tasks to be processed.
According to an embodiment of the present disclosure, the first determining module 601 may further include an updating unit.
And the updating unit is used for updating the task state information corresponding to each candidate task to be processed in the preset number of candidate tasks to be processed into a selection completion state.
According to an embodiment of the present disclosure, the scheduler and the thread pool are provided in the same process.
Fig. 7 schematically shows a block diagram of a task processing device according to an embodiment of the present disclosure.
As shown in fig. 7, the task processing device 700 may include a second determining module 701 and a processing module 702.
The second determining module 701 is configured to determine, in response to receiving a task processing request from a scheduler, a target thread in a thread pool according to the task processing request, where the task processing request includes to-be-processed task information corresponding to a to-be-processed task, and the to-be-processed task information includes a task identifier, task information, task creation time information, and task state information.
The processing module 702 is configured to process the task to be processed by using the target thread to obtain a task processing result.
According to an embodiment of the present disclosure, the task state information includes an executing state and an execution completing state.
According to an embodiment of the present disclosure, the task processing device 700 may further include a first update module.
And the first updating module is used for updating the task state information into an executing state.
According to an embodiment of the present disclosure, the task processing device 700 may further include a second update module.
And the second updating module is used for updating the task state information into an execution completion state.
According to an embodiment of the present disclosure, a thread pool may be created in the following manner.
Determining thread pool parameters, wherein the thread pool parameters comprise the number of core threads, a thread number threshold, the type of a work queue and the preset capacity of the work queue, and the thread number threshold is set according to the number of the core threads. And creating a thread pool according to the thread pool parameters.
According to an embodiment of the present disclosure, the second determining module 701 may include a third determining unit, a first creating unit, and a fourth determining unit.
And the third determining unit is used for determining the current thread number in the thread pool.
And the first creating unit is used for creating the first thread under the condition that the number of the current threads is less than the number of the core threads.
And the fourth determining unit is used for determining the first thread as the target thread.
According to an embodiment of the present disclosure, the second determining module 701 may further include a second creating unit and a fifth determining unit.
And the second creating unit is used for creating a second thread under the condition that the number of the current threads is greater than or equal to the number of the core threads and the work queue reaches the preset capacity.
And a fifth determining unit for determining the second thread as the target thread.
According to an embodiment of the present disclosure, the second determining module 701 may further include an adding unit.
And the adding unit is used for adding the tasks to be processed to the work queue under the condition that the number of the current threads is greater than or equal to that of the core threads and the work queue does not reach the preset capacity.
According to an embodiment of the present disclosure, the second determining module 701 may further include a sixth determining unit and a rejecting unit.
And the sixth determining unit is used for determining the current thread number in the thread pool.
And the rejection unit is used for rejecting the processing of the task to be processed under the condition that the number of the current threads is greater than or equal to the thread number threshold value.
Any number of modules, sub-modules, units, sub-units, or at least part of the functionality of any number thereof according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in any other reasonable manner of hardware or firmware by integrating or packaging a circuit, or in any one of or a suitable combination of software, hardware, and firmware implementations. Alternatively, one or more of the modules, sub-modules, units, sub-units according to embodiments of the disclosure may be at least partially implemented as a computer program module, which when executed may perform the corresponding functions.
For example, any number of the first determining module 601, the sending module 602, the second determining module 701 and the processing module 702 may be combined and implemented in one module/unit/sub-unit, or any one of the modules/units/sub-units may be split into multiple modules/units/sub-units. Alternatively, at least part of the functionality of one or more of these modules/units/sub-units may be combined with at least part of the functionality of other modules/units/sub-units and implemented in one module/unit/sub-unit. According to an embodiment of the present disclosure, at least one of the first determining module 601, the sending module 602, the second determining module 701, and the processing module 702 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware by any other reasonable manner of integrating or packaging a circuit, or may be implemented in any one of three implementations of software, hardware, and firmware, or in a suitable combination of any of them. Alternatively, at least one of the first determining module 601, the sending module 602, the second determining module 701 and the processing module 702 may be at least partly implemented as a computer program module, which when executed may perform a corresponding function.
It should be noted that, the task scheduling apparatus portion in the embodiment of the present disclosure corresponds to the task scheduling method portion in the embodiment of the present disclosure, and the description of the task scheduling apparatus portion specifically refers to the task scheduling method portion, which is not described herein again. The task processing device part in the embodiment of the present disclosure corresponds to the task processing method part in the embodiment of the present disclosure, and the description of the task processing device part specifically refers to the task processing method part, which is not described herein again.
Fig. 8 schematically shows a block diagram of an electronic device adapted to implement a task scheduling method and a task processing method according to an embodiment of the present disclosure. The electronic device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 8, a computer electronic device 800 according to an embodiment of the present disclosure includes a processor 801 which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage section 809 into a Random Access Memory (RAM) 803. The processor 801 may include, for example, a general purpose microprocessor (e.g., CPU), an instruction set processor and/or related chip sets and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flows according to embodiments of the present disclosure.
In the RAM 803, various programs and data necessary for the operation of the electronic apparatus 800 are stored. The processor 801, the ROM802, and the RAM 803 are connected to each other by a bus 804. The processor 801 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM802 and/or RAM 803. Note that the programs may also be stored in one or more memories other than the ROM802 and RAM 803. The processor 801 may also perform various operations of method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 800 may also include input/output (I/O) interface 805, input/output (I/O) interface 805 also connected to bus 804, according to an embodiment of the present disclosure. Electronic device 800 may also include one or more of the following components connected to I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a signal such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 808 including a hard disk and the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. A drive 810 is also connected to the I/O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as necessary, so that the computer program read out therefrom is mounted on the storage section 808 as necessary.
According to embodiments of the present disclosure, method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program, when executed by the processor 801, performs the above-described functions defined in the system of the embodiments of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples may include, but are not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM802 and/or RAM 803 described above and/or one or more memories other than the ROM802 and RAM 803.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method provided by the embodiments of the present disclosure, when the computer program product runs on an electronic device, the program code is configured to cause the electronic device to implement the task scheduling method and the task processing method provided by the embodiments of the present disclosure.
The computer program, when executed by the processor 801, performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted in the form of a signal on a network medium, distributed, downloaded and installed via communication section 809, and/or installed from removable media 811. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.

Claims (16)

1. A task scheduling method comprises the following steps:
in response to receiving a task obtaining request from a scheduler, determining a task set according to the task obtaining request, wherein the task obtaining request comprises a scheduler identifier corresponding to the scheduler, the task set comprises at least one piece of to-be-processed task information corresponding to a to-be-processed task, and each piece of to-be-processed task information in the at least one piece of to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and
and sending the task set to the scheduler corresponding to the scheduler identifier, so that the scheduler sends the at least one to-be-processed task in the task set to a target thread in a thread pool in sequence according to the task creation time information.
2. The method of claim 1, wherein the task state information includes a to-select state and a select complete state;
the determining a task set according to the task obtaining request includes:
under the condition that the task state information is the state to be selected, sequencing the tasks to be processed according to the task creation time information to obtain a task sequence to be processed;
determining a preset number of candidate tasks to be processed according to the task sequence to be processed; and
and determining the task set according to the preset number of candidate tasks to be processed.
3. The method of claim 2, further comprising, prior to said determining the set of tasks according to the preset number of the candidate pending tasks:
and updating the task state information corresponding to each candidate task to be processed in the preset number of the candidate tasks to be processed into the selection completion state.
4. The method of any of claims 1-3, wherein the scheduler and the thread pool are provided in the same process.
5. A method of task processing, comprising:
in response to receiving a task processing request from a scheduler, determining a target thread in a thread pool according to the task processing request, wherein the task processing request comprises to-be-processed task information corresponding to a to-be-processed task, and the to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and
and processing the task to be processed by using the target thread to obtain a task processing result.
6. The method of claim 5, wherein the task state information includes an executing state and an execution completed state;
after determining a target thread in a thread pool according to the task processing request:
updating the task state information to the executing state;
after the target thread is utilized to process the task to be processed to obtain a task processing result:
and updating the task state information to the execution completion state.
7. The method of claim 5 or 6, wherein the thread pool is created by:
determining thread pool parameters, wherein the thread pool parameters comprise at least one of the number of core threads, a thread number threshold, the type of a work queue and the preset capacity of the work queue, and the thread number threshold is set according to the number of the core threads; and
and creating the thread pool according to the thread pool parameters.
8. The method of claim 7, wherein, where the thread pool parameter comprises a number of core threads,
the determining a target thread in a thread pool according to the task processing request comprises:
determining the number of current threads in the thread pool;
under the condition that the number of the current threads is smaller than the number of the core threads, creating a first thread; and
determining the first thread as the target thread.
9. The method of claim 7, wherein, where the thread pool parameters include a number of core threads, a type of the work queue, and a preset capacity of the work queue,
the determining a target thread in a thread pool according to the task processing request comprises:
creating a second thread under the condition that the number of the current threads is greater than or equal to the number of the core threads and the work queue reaches the preset capacity of the work queue; and
determining the second thread as the target thread.
10. The method of claim 9, further comprising:
and adding the tasks to be processed to the work queue under the conditions that the number of the current threads is larger than or equal to the number of the core threads and the work queue does not reach the preset capacity of the work queue.
11. The method of claim 7, wherein, in the case that the thread pool parameter comprises the number of threads threshold, the method further comprises:
determining the number of current threads in the thread pool; and
and if the current thread number is larger than or equal to the thread number threshold value, rejecting the processing of the task to be processed.
12. A task scheduling apparatus comprising:
the system comprises a first determining module, a second determining module and a task processing module, wherein the first determining module is used for responding to a task obtaining request from a scheduler and determining a task set according to the task obtaining request, the task obtaining request comprises a scheduler identifier corresponding to the scheduler, the task set comprises at least one piece of to-be-processed task information corresponding to a to-be-processed task, and each piece of to-be-processed task information in the at least one piece of to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and
and the sending module is used for sending the task set to the scheduler corresponding to the scheduler identifier so that the scheduler can send the at least one to-be-processed task in the task set to a target thread in a thread pool in sequence according to the task creation time information.
13. A task processing device comprising:
the second determining module is used for responding to a task processing request received from the scheduler and determining a target thread in the thread pool according to the task processing request, wherein the task processing request comprises to-be-processed task information corresponding to the to-be-processed task, and the to-be-processed task information comprises a task identifier, task information, task creation time information and task state information; and
and the processing module is used for processing the task to be processed by utilizing the target thread to obtain a task processing result.
14. An electronic device, comprising:
one or more processors;
a memory to store one or more instructions that,
wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-11.
15. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 11.
16. A computer program product comprising computer executable instructions for implementing the method of any one of claims 1 to 11 when executed.
CN202211056429.3A 2022-08-31 2022-08-31 Task scheduling method, task processing method, device, electronic equipment and medium Pending CN115373822A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211056429.3A CN115373822A (en) 2022-08-31 2022-08-31 Task scheduling method, task processing method, device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211056429.3A CN115373822A (en) 2022-08-31 2022-08-31 Task scheduling method, task processing method, device, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN115373822A true CN115373822A (en) 2022-11-22

Family

ID=84070049

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211056429.3A Pending CN115373822A (en) 2022-08-31 2022-08-31 Task scheduling method, task processing method, device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN115373822A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116822629A (en) * 2023-05-19 2023-09-29 北京百度网讯科技有限公司 Text reasoning task processing method, device, equipment and storage medium
CN117193990A (en) * 2023-11-08 2023-12-08 建信金融科技有限责任公司 Scheduling management method, device, equipment and storage medium of http interface

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116822629A (en) * 2023-05-19 2023-09-29 北京百度网讯科技有限公司 Text reasoning task processing method, device, equipment and storage medium
CN117193990A (en) * 2023-11-08 2023-12-08 建信金融科技有限责任公司 Scheduling management method, device, equipment and storage medium of http interface
CN117193990B (en) * 2023-11-08 2024-02-23 建信金融科技有限责任公司 Scheduling management method, device, equipment and storage medium of http interface

Similar Documents

Publication Publication Date Title
US20190146830A1 (en) Template-driven multi-tenant workflow processing
CN115373822A (en) Task scheduling method, task processing method, device, electronic equipment and medium
CN109214741B (en) Early warning method and early warning system for monitoring indexes
CN109471718B (en) Computing resource configuration method, device, equipment and medium based on face recognition
CN109710624B (en) Data processing method, device, medium and electronic equipment
US20220222266A1 (en) Monitoring and alerting platform for extract, transform, and load jobs
CN110673959A (en) System, method and apparatus for processing tasks
CN114416378A (en) Data processing method and device, electronic equipment and storage medium
CN106452815A (en) Informatization management method, device and system
CN113076224A (en) Data backup method, data backup system, electronic device and readable storage medium
CN107657155B (en) Method and device for authenticating user operation authority
CN115760013A (en) Operation and maintenance model construction method and device, electronic equipment and storage medium
CN114201508A (en) Data processing method, data processing apparatus, electronic device, and storage medium
CN114782013A (en) Request processing method and device for process modeling and electronic equipment
CN113918525A (en) Data exchange scheduling method, system, electronic device, medium, and program product
CN114168607A (en) Global serial number generation method, device, equipment, medium and product
CN114254301A (en) PaC-based security policy management method and device
US20140201839A1 (en) Identification and alerting of network devices requiring special handling maintenance procedures
CN117193990B (en) Scheduling management method, device, equipment and storage medium of http interface
CN118152364A (en) Database transformation method, device, equipment, medium and program product
US11481130B2 (en) Method, electronic device and computer program product for processing operation commands
CN116860796A (en) Data matching method and device, storage medium and electronic equipment
CN114201297A (en) Data processing method and device, electronic equipment and storage medium
CN118170811A (en) Data query method, device, apparatus, medium and program product
CN114266547A (en) Method, device, equipment, medium and program product for identifying business processing strategy

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination