CN107423131B - Sharing method and server - Google Patents

Sharing method and server Download PDF

Info

Publication number
CN107423131B
CN107423131B CN201710198853.4A CN201710198853A CN107423131B CN 107423131 B CN107423131 B CN 107423131B CN 201710198853 A CN201710198853 A CN 201710198853A CN 107423131 B CN107423131 B CN 107423131B
Authority
CN
China
Prior art keywords
task
identification code
queue
execution server
processed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710198853.4A
Other languages
Chinese (zh)
Other versions
CN107423131A (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.)
Nubia Technology Co Ltd
Original Assignee
Nubia Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nubia Technology Co Ltd filed Critical Nubia Technology Co Ltd
Priority to CN201710198853.4A priority Critical patent/CN107423131B/en
Publication of CN107423131A publication Critical patent/CN107423131A/en
Application granted granted Critical
Publication of CN107423131B publication Critical patent/CN107423131B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers

Abstract

The embodiment of the invention discloses a sharing method and a server, which are used for acquiring a first task corresponding to an object to be processed and judging whether the first task is a first task issued by the object to be processed; wherein the first task is used for processing the object to be processed; when the first task is not the first task issued by the object to be processed, the first task and the first identification code are sent to the execution server cluster; the first identification code is a judgment identifier for judging whether to execute the task, and is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function.

Description

Sharing method and server
Technical Field
The present invention relates to task sharing technologies, and in particular, to a sharing method and a server.
Background
When the access amount of a user is continuously increased, in order to relieve the pressure of a single server, a plurality of servers are usually required to be deployed, the deployment of the plurality of servers can effectively share the work of large data, and the pressure of each server is reduced, so that the service life of the server is prolonged. In the process of deploying multiple servers for large-scale data processing, each task to be processed needs to be forwarded and distributed, for example, task 1 is distributed to server a for execution, task 3 is distributed to server D for execution, and the like.
Since the process of forwarding and allocating tasks to the object to be processed is invisible, that is, the allocation server responsible for forwarding and allocating tasks allocates different tasks corresponding to the object to be processed to the execution server cluster, and since the execution server cluster is provided with a plurality of execution servers at the same time, it cannot be ensured that different tasks corresponding to the object to be processed are allocated to the same execution server for execution, thereby causing a situation of task processing failure, further wasting network resources, and reducing task processing rate.
Disclosure of Invention
In view of this, embodiments of the present invention provide a sharing method and a server, where a plurality of execution servers share a task of a to-be-processed object by subscribing to a same sharing queue, so that under a condition that different tasks corresponding to the to-be-processed object are allocated to different execution servers, task sharing among the execution servers is implemented, thereby solving a defect of resource waste and improving a task processing rate.
The technical scheme of the embodiment of the invention is realized as follows:
the embodiment of the invention provides a sharing method, which is applied to a distribution server and comprises the following steps:
acquiring a first task corresponding to an object to be processed, and judging whether the first task is a first task issued to the object to be processed; wherein the first task is used for processing the object to be processed;
when the first task is not a first task issued to the object to be processed, sending the first task and a first identification code to an execution server cluster; the first identification code is a judgment identifier for judging whether to execute a task, and the first identification code is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function.
In the foregoing solution, when the first task is not a first task issued to the to-be-processed object, before the acquiring the first task corresponding to the to-be-processed object, the method further includes:
acquiring a second task corresponding to the object to be processed; wherein the second task is used for processing the object to be processed for the first time;
sending the second task to the execution server cluster;
and receiving the first identification code which is sent by the execution server cluster and responds to the second task.
The embodiment of the invention provides a sharing method, which is applied to a first execution server, wherein the first execution server is one execution server in an execution server cluster subscribing a shared queue, and the method comprises the following steps:
receiving a first task and a first identification code sent by a distribution server; wherein the first task is used for processing an object to be processed; the first identification code is a judgment identifier for judging whether to execute the task;
judging whether to execute the first task according to the first identification code and the first local identification code; the first local identification code is a judgment identifier for judging whether the first execution server executes the task or not;
when the first identification code is different from the first local identification code, determining a first queue corresponding to the first task according to a preset corresponding relation between the task and the queue type and the first task; wherein the first queue is a queue of a task type in the shared queue;
synchronizing the first identifier to the first queue.
In the foregoing solution, after the determining whether to execute the first task according to the first identifier and the first local identifier, the method further includes:
and when the first identification code is the same as the first local identification code, executing the first task.
The embodiment of the invention provides a sharing method, which is applied to a second execution server, wherein the second execution server is an execution server which is different from a first execution server in an execution server cluster subscribed to a sharing queue, and the method comprises the following steps:
acquiring a first identification code in a first queue according to a preset time interval; wherein the first queue is a queue of a task type in the shared queue; the first identification code is a judgment identifier for judging whether to execute the task;
determining a first task corresponding to the first queue according to a preset corresponding relation between the task and the queue type and the first queue; the first task is a task which does not process the object to be processed for the first time;
judging whether to execute the first task according to the first identification code and the second local identification code; the second local identification code is a judgment identifier for judging whether the second execution server executes the task or not;
and when the first identification code and the second local identification code are the same, executing the first task.
In the foregoing solution, before the first identification code in the first queue is obtained according to the preset time interval, the method includes:
receiving a second task sent by the distribution server; wherein the second task is used for processing the object to be processed for the first time;
executing the second task, generating and storing the second local identification code corresponding to the second task;
and sending the second local identification code as the first identification code to the distribution server.
An embodiment of the present invention provides a distribution server, where the distribution server includes: a first obtaining unit, a first judging unit, a first sending unit,
the first acquisition unit is used for acquiring a first task corresponding to an object to be processed; wherein the first task is used for processing the object to be processed;
the first judging unit is used for judging whether the first task is a first task issued to the object to be processed;
the first sending unit is used for sending the first task and the first identification code to an execution server cluster when the first task is not a first task issued to the object to be processed; the first identification code is a judgment identifier for judging whether to execute a task, and the first identification code is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function.
In the above solution, the distribution server further includes: a first receiving unit for receiving the first data,
the first obtaining unit is further configured to, when the first task is not a first task issued to the object to be processed, obtain a second task corresponding to the object to be processed before obtaining the first task corresponding to the object to be processed; wherein the second task is used for processing the object to be processed for the first time;
the first sending unit is further configured to send the second task to the execution server cluster;
the first receiving unit is configured to receive the first identifier sent by the execution server cluster and responding to the second task.
The embodiment of the present invention provides a first execution server, where the first execution server is an execution server in an execution server cluster subscribing to a shared queue, and the first execution server includes: a second receiving unit, a second judging unit, a first determining unit and a synchronizing unit,
the second receiving unit is used for receiving the first task and the first identification code sent by the distribution server; wherein the first task is used for processing the object to be processed; the first identification code is a judgment identifier for judging whether to execute the task;
the second judging unit is configured to judge whether to execute the first task according to the first identification code and the first local identification code; the first local identification code is a judgment identifier for judging whether the first execution server executes the task or not;
the first determining unit is configured to determine, when the first identification code is different from the first local identification code, a first queue corresponding to the first task according to a preset correspondence between a task and a queue type and the first task; wherein the first queue is a queue of a task type in the shared queue;
the synchronization unit is configured to synchronize the first identifier to the first queue.
In the foregoing solution, the first execution server further includes: a first execution unit for executing the first execution unit,
the first execution unit is configured to, after determining whether to execute the first task according to the first identifier and the first local identifier, execute the first task when the first identifier is identical to the first local identifier.
The embodiment of the present invention provides a second execution server, where the second execution server is an execution server different from the first execution server in an execution server cluster subscribing to a shared queue, and the second execution server includes: a second obtaining unit, a second determining unit, a third judging unit and a second executing unit,
the second obtaining unit is used for obtaining the first identification code in the first queue according to a preset time interval; wherein the first queue is a queue of a task type in the shared queue; the first identification code is a judgment identifier for judging whether to execute the task;
the second determining unit is configured to determine the first task corresponding to the first queue according to a preset correspondence between a task and a queue type and the first queue; the first task is a task which does not process the object to be processed for the first time;
the third judging unit is configured to judge whether to execute the first task according to the first identification code and the second local identification code; the second local identification code is a judgment identifier for judging whether the second execution server executes the task or not;
the second execution unit is configured to execute the first task when the first identifier is the same as the second local identifier.
In the foregoing solution, the second execution server further includes: a third receiving unit, a storage unit, a second transmitting unit,
the third receiving unit is configured to receive a second task sent by the distribution server before the first identification code in the first queue is obtained according to the preset time interval; wherein the second task is used for processing the object to be processed for the first time;
the second execution unit is further configured to execute the second task;
the storage unit is used for generating and storing the second local identification code corresponding to the second task after the second task is executed;
the second sending unit is configured to send the second local identification code to the distribution server as the first identification code.
Therefore, in the technical scheme of the embodiment of the invention, the first task corresponding to the object to be processed is obtained, and whether the first task is a first task issued by the object to be processed is judged; wherein the first task is used for processing the object to be processed; when the first task is not the first task issued by the object to be processed, the first task and the first identification code are sent to the execution server cluster; the first identification code is a judgment identifier for judging whether to execute the task, and is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function. Therefore, compared with the prior art, according to the sharing method and the server provided by the embodiment of the invention, the tasks of the to-be-processed object are shared by the multiple execution servers through subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the to-be-processed object are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
Drawings
Fig. 1 is a first schematic flow chart illustrating an implementation of a sharing method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart illustrating an implementation process of the sharing method according to the embodiment of the present invention;
fig. 3 is a schematic flow chart of an implementation of the sharing method according to the embodiment of the present invention;
fig. 4 is a schematic flow chart of an implementation of the sharing method according to the embodiment of the present invention;
fig. 5 is a schematic flow chart illustrating an implementation of the sharing method according to the embodiment of the present invention;
fig. 6 is a schematic flow chart illustrating a sixth implementation process of the sharing method according to the embodiment of the present invention;
fig. 7 is a seventh schematic flow chart illustrating an implementation of the sharing method according to the embodiment of the present invention;
fig. 8 is a schematic flow chart illustrating an implementation flow of the sharing method according to the embodiment of the present invention;
fig. 9 is a schematic flowchart illustrating an implementation flow of the sharing method according to the embodiment of the present invention;
FIG. 10 is a diagram of a prior art system architecture for tasking and deskewing SQL;
FIG. 11 is a schematic structural diagram of a system for executing and canceling SQL tasks according to an embodiment of the present invention;
FIG. 12 is a schematic diagram of an implementation flow of a method for executing SQL tasks and canceling task sharing according to an embodiment of the present invention;
fig. 13 is a first schematic structural diagram of a distribution server according to an embodiment of the present invention;
fig. 14 is a schematic structural diagram of a distribution server according to an embodiment of the present invention;
fig. 15 is a first schematic structural diagram of a first execution server according to an embodiment of the present invention;
fig. 16 is a schematic structural diagram of a first execution server according to an embodiment of the present invention;
fig. 17 is a first schematic structural diagram of a second execution server according to an embodiment of the present invention;
fig. 18 is a schematic structural diagram of a second execution server according to an embodiment of the present invention.
Detailed Description
It should be understood that the embodiments described herein are only for explaining the technical solutions of the present invention, and are not intended to limit the scope of the present invention.
Example one
Fig. 1 is a schematic flow chart of an implementation process of the sharing method provided in the embodiment of the present invention, and as shown in fig. 1, in a specific embodiment of the present invention, the sharing method may include the following steps:
step 101, acquiring a first task corresponding to an object to be processed, and judging whether the first task is a first task issued by the object to be processed; wherein the first task is for processing the object to be processed.
In a specific embodiment of the present invention, a distribution server obtains a first task corresponding to an object to be processed, and then determines whether the first task is a task issued to the object to be processed for the first time. The distribution server may be various processors having functions of receiving and distributing tasks, and preferably, the distribution server may be a Nginx, which is a lightweight Web server, a reverse proxy server, and an email (IMAP/POP3) proxy server.
Further, in an embodiment of the present invention, the allocation server may determine whether the first task is a first task issued to the to-be-processed object through a plurality of methods, for example, the allocation server may determine whether the first task is a first task issued to the to-be-processed object by querying a current state of the to-be-processed object.
It should be noted that, in an embodiment of the present invention, the object to be processed may be multiple different types of executed objects, for example, the object to be processed may be a file to be processed; accordingly, the first task may be a plurality of different types of tasks for processing the object to be processed, for example, when the queue to be processed is a file a, the first task may be to store the file a, or to delete the file a, or the like.
102, when the first task is not the first task issued by the object to be processed, sending the first task and the first identification code to the execution server cluster; the first identification code is a judgment identifier for judging whether to execute the task, and is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function.
In a specific embodiment of the present invention, after the allocation server obtains the first task and determines whether the first task is a task that is first issued to the to-be-processed object, when the first task is not a first task that is first issued to the to-be-processed object, the allocation server sends the first task and the first identifier to the execution server cluster.
It should be noted that, in an embodiment of the present invention, the first identifier is a determination identifier, which is acquired by the allocation server from the execution server cluster and used by the execution server cluster to determine whether to execute the task, that is, after receiving the first task, the execution server cluster may determine whether to execute the first task according to the first identifier.
Further, in an embodiment of the present invention, the first Identifier may be one of multiple types of identifiers, and preferably, in an embodiment of the present invention, the first Identifier may be a Universal Unique Identifier (UUID).
It should be noted that, in an embodiment of the present invention, the execution server cluster may be a server cluster in which a plurality of execution servers are deployed, and each execution server in the execution server cluster subscribes to the same shared queue having the identifier sharing function.
Further, in an embodiment of the present invention, the shared queue subscribed by each execution server in the execution server cluster may be a queue having a subscription function and a publishing function. Preferably, in an embodiment of the present invention, the shared queue may be a rabbitmq queue, where the rabbitmq queue may perform publishing and subscribing of messages, each execution server in the execution server cluster binds the same exchange with the identity of a consumer, and specifies a queue name of the execution server, and when a producer of the rabbitmq synchronizes data to the exchange, the execution server can synchronize to the queues of the servers.
It should be noted that, in an embodiment of the present invention, the shared queue must be one of various queues having a subscription function and a publishing function, for example, although a redis queue may be used for storage, since a device does not have a subscription function and a publishing function, the redis queue may not be used as the shared queue.
It should be noted that, in an embodiment of the present invention, the shared queue may include queues of a plurality of different task types, that is, when the execution server cluster subscribes to the shared queue, the execution server cluster may subscribe to all queues of different task types in the shared queue, so that a task corresponding to a current queue may be determined to be executed according to a task type of the current queue. For example, when an execution server a in the execution server cluster needs to execute a certain task on a to-be-processed object corresponding to the identifier a in the queue a, if the task type of the queue a is delete, then the execution server a executes a delete operation on the to-be-processed object.
The sharing method provided by the embodiment of the invention obtains a first task corresponding to the object to be processed, and judges whether the first task is a first task issued by the object to be processed; wherein the first task is used for processing the object to be processed; when the first task is not the first task issued by the object to be processed, the first task and the first identification code are sent to the execution server cluster; the first identification code is a judgment identifier for judging whether to execute the task, and is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function. Therefore, compared with the prior art, according to the sharing method provided by the embodiment of the invention, the tasks of the objects to be processed are shared by the multiple execution servers through subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the objects to be processed are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
Example two
Based on the first embodiment, fig. 2 is a schematic flow chart of an implementation process of the sharing method provided in the second embodiment of the present invention, as shown in fig. 2, in a specific embodiment of the present invention, when a first task is not a first task issued to a to-be-processed object, before the allocation server obtains the first task corresponding to the to-be-processed object, that is, before step 101, the sharing method may further include the following steps:
103, when the first task is not the first task issued by the object to be processed, acquiring a second task corresponding to the object to be processed before acquiring the first task corresponding to the object to be processed; wherein the second task is used for processing the object to be processed for the first time.
In an embodiment of the present invention, if the first task is not a first task issued to the to-be-processed object, the allocation server first acquires a first task, that is, a second task, issued to the to-be-processed object before acquiring the first task corresponding to the to-be-processed object.
Further, in an embodiment of the present invention, the second task may be a plurality of different types of tasks for processing the object to be processed for the first time, and the second task is issued before the first task is issued, and the second task and the first task are corresponding processes performed on the object to be processed, for example, when the object to be processed is a file a, the second task may be reading the file a, and accordingly, the second task may be stopping reading the file a.
And 104, sending a second task to the execution server cluster.
In a specific embodiment of the present invention, after the allocation server obtains the second task issued to the to-be-processed object, the allocation server sends the second task to the execution server cluster.
It should be noted that, in the specific embodiment of the present invention, since the second task is a task for processing the to-be-processed object for the first time, after receiving the second task, the execution server cluster does not need to determine whether the second task needs to be executed, but directly executes the second task, and therefore, after acquiring the second task, the allocation server only needs to send the second task to the execution server cluster.
And 105, receiving a first identification code which is sent by the execution server cluster and responds to the second task.
In an embodiment of the present invention, after sending the second task to the execution server cluster, the allocation server receives the first identification code sent by the execution server cluster and used for responding to the second task.
It should be noted that, in an embodiment of the present invention, the first identification code is obtained after the allocation server sends the task for processing the to-be-processed object to the execution server cluster for the first time, and further, when the allocation server sends the task for processing the to-be-processed object to the execution server cluster again, the allocation server sends the first identification code to the execution server cluster together.
According to the sharing method provided by the embodiment of the invention, the plurality of execution servers share the tasks of the to-be-processed object by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the to-be-processed object are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
EXAMPLE III
A third embodiment of the present invention provides a sharing method, which is applied to a first execution server, where the first execution server is an execution server in an execution server cluster that subscribes to a shared queue, and fig. 3 is a schematic diagram illustrating an implementation flow of the sharing method provided in the third embodiment of the present invention, and as shown in fig. 3, in a specific embodiment of the present invention, the sharing method may include the following steps:
step 201, receiving a first task and a first identification code sent by a distribution server; wherein the first task is used for processing the object to be processed; the first identification code is a judgment identification for whether to execute the task.
In a specific embodiment of the present invention, the first execution server receives the first task and the first identification code sent by the distribution server; the first execution server serves one execution server in a server cluster, and specifically, the server cluster may be a server cluster in which a plurality of execution servers are deployed, and each execution server in the execution server cluster subscribes to the same sharing queue having the identifier sharing function.
It should be noted that, in an embodiment of the present invention, the object to be processed may be multiple different types of executed objects, for example, the object to be processed may be a file to be processed; accordingly, the first task may be a plurality of different types of tasks for processing the object to be processed, for example, when the queue to be processed is a file a, the first task may be to store the file a, or to delete the file a, or the like.
It should be noted that, in an embodiment of the present invention, the first identifier is used as a determination identifier for the execution server cluster to determine whether to execute the task, that is, after receiving the first task, the execution server cluster may determine whether to execute the first task according to the first identifier.
Further, in an embodiment of the present invention, the first Identifier may be one of multiple types of identifiers, and preferably, in an embodiment of the present invention, the first Identifier may be a Universal Unique Identifier (UUID).
Step 202, judging whether to execute a first task according to the first identification code and the first local identification code; the first local identification code is a judgment mark for judging whether the first execution server executes the task or not.
In an embodiment of the present invention, after the first execution server receives the first task and the first identification code sent by the distribution server, the first execution server may determine whether to execute the first task according to the first identification code and the first local identification code.
Further, in an embodiment of the present invention, the first local identification code is an identification code of the first execution server, and the first local identification code is a determination flag for determining whether the first execution server executes the task.
It should be noted that, in an embodiment of the present invention, the first local Identifier may be one of multiple types of identifiers, and preferably, in an embodiment of the present invention, the first local Identifier may be a Universally Unique Identifier (UUID).
Further, in the embodiment of the present invention, the first execution server may determine whether to execute the first task through a plurality of methods, and preferably, the first execution server may compare the first identification code and the first local identification code, and then determine whether to execute the first task according to a comparison result.
It should be noted that, in the specific embodiment of the present invention, when the first identification code and the first local identification code are the same, it may be considered that the first execution server has already processed the object to be processed for the first time before acquiring the first task, and therefore it is determined that the first execution server can execute the first task.
Step 203, when the first identification code is different from the first local identification code, determining a first queue corresponding to the first task according to a preset corresponding relationship between the task and the queue type and the first task; wherein the first queue is a queue of a task type in the shared queue.
In a specific embodiment of the present invention, after the first execution server determines whether to execute the first task according to the first identification code and the first local identification code, when the first identification code is different from the first local identification code, the first execution server determines a first queue corresponding to the first task according to a preset correspondence between the task and the queue type and the first task; wherein the first queue is a queue of a task type in the shared queue.
Further, in the embodiment of the present invention, when the first identification code and the first local identification code are different, it may be considered that the first execution server does not perform the first processing on the object to be processed before the first task is acquired, and therefore it is determined that the first execution server may not execute the first task.
Further, in an embodiment of the present invention, when the first identifier and the first local identifier are different, that is, when the first execution server may not execute the first task, the first execution server may determine the first queue corresponding to the first task according to a preset correspondence between the task and the queue type and the first task, that is, when the first execution server may not execute the first task, the first execution server needs to determine the first queue corresponding to the first task according to the current first task, so as to synchronize the first identifier to a subsequent operation of the first queue.
It should be noted that, in an embodiment of the present invention, the shared queue may include queues of a plurality of different task types, that is, when the execution server cluster subscribes to the shared queue, the execution server cluster may subscribe to all queues of different task types in the shared queue, so that a task corresponding to a current queue may be determined to be executed according to a task type of the current queue. For example, when an execution server a in the execution server cluster needs to execute a certain task on a to-be-processed object corresponding to the identifier a in the queue a, if the task type of the queue a is delete, then the execution server a executes a delete operation on the to-be-processed object.
Specifically, in the specific embodiment of the present invention, for example, the first task is a delete task, and when the first identification code is different from the first local identification code, that is, when the first execution server cannot execute the first task, the first execution server may determine, according to a preset correspondence between the task and the queue type, the first queue corresponding to the delete task, that is, the queue type of the first queue is the delete queue.
Step 204, synchronizing the first identification code to the first queue.
In an embodiment of the present invention, after the first execution server determines the first queue corresponding to the first task, the first execution server may synchronize the received first identifier to the first queue.
Further, in an embodiment of the present invention, when the first identifier and the first local identifier are different, that is, when the first execution server cannot execute the first task, the first execution server may first determine a first queue corresponding to the first task, that is, a first queue of a queue type corresponding to the first task, and then the first execution server may synchronize the first identifier into the first queue.
According to the sharing method provided by the embodiment of the invention, the plurality of execution servers share the tasks of the to-be-processed object by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the to-be-processed object are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
Example four
Based on the third embodiment, fig. 4 is a schematic flow chart illustrating an implementation flow of the sharing method according to the third embodiment of the present invention, as shown in fig. 4, in an embodiment of the present invention, after the first execution server determines whether to execute the first task according to the first identifier and the first local identifier, and after step 202, the sharing method may further include the following steps:
step 205, when the first identification code and the first local identification code are the same, executing a first task.
In a specific embodiment of the present invention, after the first execution server determines whether to execute the first task based on the first identification code and the first local identification code, if it is determined that the first identification code and the first local identification code are the same, the first execution server executes the first task.
It should be noted that, in the embodiment of the present invention, when the first identification code and the first local identification code are the same, it may be considered that the first execution server has performed the first processing on the object to be processed before acquiring the first task, and therefore it is determined that the first execution server can execute the first task, and the first execution server executes the first task.
According to the sharing method provided by the embodiment of the invention, the plurality of execution servers share the tasks of the to-be-processed object by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the to-be-processed object are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
EXAMPLE five
An embodiment of the present invention provides a sharing method, which is applied to a second execution server, where the second execution server is an execution server different from a first execution server in an execution server cluster subscribing to a shared queue, and fig. 5 is a schematic diagram of an implementation flow of the sharing method provided in the embodiment of the present invention, as shown in fig. 5, in a specific embodiment of the present invention, the sharing method may include the following steps:
301, acquiring a first identification code in a first queue according to a preset time interval; the first queue is a task type queue in the shared queue; the first identification code is a judgment identification for whether to execute the task.
In a specific embodiment of the present invention, the second execution server obtains the first identification code in the first queue according to a preset time interval; the second execution server is an execution service different from the first execution server in the server cluster, and specifically, the server cluster may be a server cluster in which a plurality of execution servers are deployed, and each execution server in the execution server cluster subscribes to the same sharing queue having the identifier sharing function.
It should be noted that, in an embodiment of the present invention, the first queue is a task type queue in the shared queue subscribed by the server cluster. Specifically, the shared queue may include queues of a plurality of different task types, that is, when subscribing to the shared queue, the execution server cluster may subscribe to all queues of different task types in the shared queue, so as to determine to execute a task corresponding to a current queue according to a task type of the current queue. For example, when an execution server a in the execution server cluster needs to execute a certain task on a to-be-processed object corresponding to the identifier a in the queue a, if the task type of the queue a is delete, then the execution server a executes a delete operation on the to-be-processed object.
It should be noted that, in an embodiment of the present invention, the first identifier is used as a determination identifier for the execution server cluster to determine whether to execute the task, that is, after receiving the first task, the execution server cluster may determine whether to execute the first task according to the first identifier.
Further, in an embodiment of the present invention, the first Identifier may be one of multiple types of identifiers, and preferably, in an embodiment of the present invention, the first Identifier may be a Universal Unique Identifier (UUID).
Further, in an embodiment of the present invention, the time interval is a time period, which is preset by the execution server cluster, for acquiring the identification code in the shared queue, for example, when the time interval is 5s, all execution servers in the execution server cluster may perform an operation of acquiring the identification code in the shared queue once every 5 s.
Step 302, determining a first task corresponding to the first queue according to a preset corresponding relationship between the task and the queue type and the first queue, wherein the first task is a task which does not process the object to be processed for the first time.
In a specific embodiment of the present invention, after the second execution server obtains the first identification code in the first queue, the second execution server may determine, according to a preset correspondence between a task and a queue type and the first queue, a first task corresponding to the first queue, where the first task is a task that does not process the object to be processed for the first time.
Further, in an embodiment of the present invention, the second execution server obtains the first identifier in the first queue, and does not obtain the first task sent by the allocation server, so that the second execution server needs to determine the first task to be executed first. For example, when the queue type of the first queue is a delete type, the second execution server may determine that the first task is a delete task.
Step 303, judging whether to execute the first task according to the first identification code and the second local identification code; the second local identification code is a judgment mark for judging whether the second execution server executes the task or not.
In an embodiment of the invention, after the second execution server determines the first task corresponding to the first queue, the second execution server may determine whether to execute the first task according to the first identifier and the second local identifier.
Further, in an embodiment of the present invention, the second local identification code is an identification code of the second execution server having a local area, and the second local identification code is a determination flag for determining whether the second execution server executes the task.
It should be noted that, in an embodiment of the present invention, the second local Identifier may be one of multiple types of identifiers, and preferably, in an embodiment of the present invention, the second local Identifier may be a Universally Unique Identifier (UUID).
Further, in the embodiment of the present invention, the second execution server may determine whether to execute the first task through a plurality of methods, and preferably, the second execution server may compare the first identification code and the second local identification code, and then determine whether to execute the first task according to a comparison result.
Step 304, when the first identification code and the second local identification code are the same, executing a first task.
In an embodiment of the present invention, after the second execution server determines whether to execute the first task according to the first identifier and the second local identifier, if it is determined that the first identifier and the second local identifier are the same, the second execution server executes the first task.
It should be noted that, in the embodiment of the present invention, when the first identification code is the same as the second local identification code, it may be considered that the second execution server has already processed the object to be processed for the first time before acquiring the first identification code, and therefore it is determined that the second execution server can execute the first task, and the first execution server executes the first task.
Accordingly, in the embodiment of the present invention, when the first identification code and the second local identification code are different, it may be considered that the second execution server does not perform the first processing on the object to be processed before the first identification code is acquired, and therefore it is determined that the second execution server may not execute the first task.
According to the sharing method provided by the embodiment of the invention, the plurality of execution servers share the tasks of the to-be-processed object by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the to-be-processed object are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
EXAMPLE six
Based on the fifth embodiment, fig. 6 is a schematic flow diagram six illustrating an implementation flow of the sharing method according to the fifth embodiment of the present invention, as shown in fig. 6, in a specific embodiment of the present invention, before the second execution server obtains the first identifier in the first queue according to a preset time interval, that is, before step 301, the sharing method may further include the following steps:
step 305, receiving a second task sent by the distribution server; wherein the second task is used for processing the object to be processed for the first time.
In a specific embodiment of the present invention, before the second execution server obtains the first identification code in the first queue according to the preset time interval, the second execution server first receives a first task, that is, a second task, sent by the allocation server and issued by the object to be processed.
Further, in an embodiment of the present invention, the second task may be a plurality of different types of tasks for processing the object to be processed for the first time, and the second task is issued before the first task is issued, and the second task and the first task are corresponding processes performed on the object to be processed, for example, when the object to be processed is a file a, the second task may be reading the file a, and accordingly, the second task may be stopping reading the file a.
And step 306, executing the second task, and generating and storing a second local identification code corresponding to the second task.
In a specific embodiment of the present invention, after the second execution server receives the second task sent by the distribution server, the second execution server executes the second task, then generates a second local identification code corresponding to the second task, and stores the second local identification code to the local.
It should be noted that, in an embodiment of the present invention, since the second task is a task for processing the to-be-processed object for the first time, after receiving the second task, the second execution server does not need to determine whether the second task needs to be executed, but directly executes the second task, and the generated second local identification code can be used to determine whether to execute the task again on the to-be-processed object.
Step 307, the second local identification code is sent to the distribution server as the first identification code.
In a specific embodiment of the present invention, after the second execution server executes the second task and generates and stores the second local identification code corresponding to the second task, the second execution server may transmit the second local identification code to the distribution server as the first identification code.
Further, in an embodiment of the present invention, after the second execution server executes the second task, the second local identification code is stored locally, and at the same time, the second local identification code is sent to the distribution server as the first identification code, so that when the distribution server issues the first task corresponding to the object to be processed again, the second execution server can determine whether the first task needs to be executed by comparing the second local identification code with the first identification code sent by the distribution server.
According to the sharing method provided by the embodiment of the invention, the plurality of execution servers share the tasks of the to-be-processed object by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the to-be-processed object are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
EXAMPLE seven
Fig. 7 is a seventh schematic flow chart illustrating an implementation process of the sharing method according to the seventh embodiment of the present invention, as shown in fig. 7, where in a specific embodiment of the present invention, the sharing method may include the following steps:
step 401, a distribution server obtains a first task corresponding to an object to be processed, and judges whether the first task is a first task issued by the object to be processed; wherein the first task is for processing the object to be processed.
In a specific embodiment of the present invention, a distribution server obtains a first task corresponding to an object to be processed, and then determines whether the first task is a task issued to the object to be processed for the first time.
Step 402, when the first task is not the first task issued by the object to be processed, the allocation server sends the first task and the first identification code to the execution server cluster; the first identification code is a judgment identifier for judging whether to execute the task, and is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function.
In a specific embodiment of the present invention, after the allocation server obtains the first task and determines whether the first task is a task that is first issued to the to-be-processed object, when the first task is not a first task that is first issued to the to-be-processed object, the allocation server sends the first task and the first identifier to the execution server cluster.
In step 403, the first execution server determines whether to execute the first task according to the first identifier and the first local identifier.
In an embodiment of the present invention, after the first execution server receives the first task and the first identification code sent by the distribution server, the first execution server may determine whether to execute the first task according to the first identification code and the first local identification code. The first execution server serves one execution server in a server cluster, and specifically, the server cluster may be a server cluster in which a plurality of execution servers are deployed, and each execution server in the execution server cluster subscribes to the same sharing queue having the identifier sharing function.
Step 404, when the first identification code is different from the first local identification code, the first execution server determines a first queue corresponding to the first task according to a preset corresponding relationship between the task and the queue type and the first task; wherein the first queue is a queue of a task type in the shared queue.
In a specific embodiment of the present invention, after the first execution server determines whether to execute the first task according to the first identification code and the first local identification code, when the first identification code is different from the first local identification code, the first execution server determines a first queue corresponding to the first task according to a preset correspondence between the task and the queue type and the first task; wherein the first queue is a queue of a task type in the shared queue.
Step 405, the first execution server synchronizes the first identifier to the first queue.
In an embodiment of the present invention, after the first execution server determines the first queue corresponding to the first task, the first execution server may synchronize the received first identifier to the first queue.
Step 406, the second execution server obtains the first identification code in the first queue according to a preset time interval.
In a specific embodiment of the present invention, the second execution server obtains the first identification code in the first queue according to a preset time interval; the second execution server is an execution service different from the first execution server in the server cluster, and specifically, the server cluster may be a server cluster in which a plurality of execution servers are deployed, and each execution server in the execution server cluster subscribes to the same sharing queue having the identifier sharing function.
Step 407, the second execution server determines a first task corresponding to the first queue according to a preset correspondence between the task and the queue type and the first queue.
In an embodiment of the present invention, after the second execution server obtains the first identification code in the first queue, the second execution server may determine the first task corresponding to the first queue according to a preset correspondence between the task and the queue type and the first queue.
Step 408, the second execution server judges whether to execute the first task according to the first identification code and the second local identification code; the second local identification code is a judgment mark for judging whether the second execution server executes the task or not.
In an embodiment of the invention, after the second execution server determines the first task corresponding to the first queue, the second execution server may determine whether to execute the first task according to the first identifier and the second local identifier.
Step 409, when the first identification code and the second local identification code are the same, the second execution server executes the first task.
In an embodiment of the present invention, after the second execution server determines whether to execute the first task according to the first identifier and the second local identifier, if it is determined that the first identifier and the second local identifier are the same, the second execution server executes the first task.
Fig. 8 is a schematic view illustrating an implementation flow of the sharing method according to an embodiment of the present invention, as shown in fig. 8, in an embodiment of the present invention, after the first execution server determines whether to execute the first task according to the first identifier and the first local identifier, that is, after step 404, the sharing method may further include the following steps:
step 4010, when the first identification code and the first local identification code are the same, the first execution server executes the first task.
In a specific embodiment of the present invention, after the first execution server determines whether to execute the first task based on the first identification code and the first local identification code, if it is determined that the first identification code and the first local identification code are the same, the first execution server executes the first task.
The sharing method provided by the embodiment of the invention obtains a first task corresponding to the object to be processed, and judges whether the first task is a first task issued by the object to be processed; wherein the first task is used for processing the object to be processed; when the first task is not the first task issued by the object to be processed, the first task and the first identification code are sent to the execution server cluster; the first identification code is a judgment identifier for judging whether to execute the task, and is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function. Therefore, compared with the prior art, according to the sharing method provided by the embodiment of the invention, the tasks of the objects to be processed are shared by the multiple execution servers through subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the objects to be processed are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
Example eight
Based on the seventh embodiment, as shown in fig. 9, in a specific embodiment of the present invention, when the first task is not the first task issued to the object to be processed, the allocating server obtains the first task corresponding to the object to be processed, and determines whether the first task is the first task issued to the object to be processed, that is, before step 401, the sharing method may include the following steps:
step 4011, the distribution server obtains a second task corresponding to the object to be processed; wherein the second task is used for processing the object to be processed for the first time.
In an embodiment of the present invention, if the first task is not a first task issued to the to-be-processed object, the allocation server first acquires a first task, that is, a second task, issued to the to-be-processed object before acquiring the first task corresponding to the to-be-processed object.
And 4012, the distribution server sends the second task to the execution server cluster.
In a specific embodiment of the present invention, after the allocation server obtains the second task issued to the to-be-processed object, the allocation server sends the second task to the execution server cluster.
And 4013, the second execution server executes the second task, and generates and stores a second local identification code corresponding to the second task.
In a specific embodiment of the present invention, after the second execution server receives the second task sent by the distribution server, the second execution server executes the second task, then generates a second local identification code corresponding to the second task, and stores the second local identification code to the local.
Step 4014, the second execution server sends the second local identification code as the first identification code to the distribution server.
In a specific embodiment of the present invention, after the second execution server executes the second task and generates and stores the second local identification code corresponding to the second task, the second execution server may transmit the second local identification code to the distribution server as the first identification code.
According to the sharing method provided by the embodiment of the invention, the plurality of execution servers share the tasks of the to-be-processed object by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the to-be-processed object are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
Example nine
Based on the seventh embodiment and the eighth embodiment, the ninth embodiment takes the execution task and the cancellation task of Structured Query Language (SQL) as an example, and proposes a sharing method. Correspondingly, the object to be processed is SQL, the first task is a cancel task, and the second task is an execute task.
Fig. 10 is a structural diagram of a system for executing and canceling SQL tasks in the prior art, and as shown in fig. 10, an execution server a, an execution server and an execution server C are deployed in an execution server cluster, and after an allocation server obtains an SQL execution task, the allocation server allocates the SQL execution task to the execution server a; after the allocation server obtains the SQL cancellation task, the allocation server allocates the SQL cancellation task to the execution server C again, and at this time, the execution server C does not execute the SQL execution task and the execution servers in the execution server cluster do not communicate with each other, so the SQL cancellation task allocated to the execution server C fails.
Fig. 11 is a schematic structural diagram of a system for executing and canceling SQL tasks according to an embodiment of the present invention, and as shown in fig. 11, an execution server a, an execution server, and an execution server C are deployed in an execution server cluster, and each execution server in the execution server cluster subscribes to the same shared queue.
Fig. 12 is a schematic flow chart illustrating an implementation process of the method for performing task execution and task cancellation on SQL according to the embodiment of the present invention, as shown in fig. 12, in a specific embodiment of the present invention, the method for performing task execution and task cancellation on SQL may include the following steps:
step 501, the distribution server distributes the SQL execution task to the execution server A.
In the embodiment of the present invention, after the interface 1 of the distribution server is called and the execution task of SQL is acquired, the distribution server distributes the execution task of SQL to the execution server a.
Step 502, the execution server a executes the execution task of SQL, generates and stores the second local identification code, and sends the second local identification code to the distribution server as the first identification code.
In a specific embodiment of the present invention, the execution server a generates the second local identification code after executing the execution task of SQL, then stores the second local identification code locally, and sends the second local identification code as the first identification code to the distribution server.
Step 503, the distribution server distributes the SQL cancellation task and the first identification code to the execution server C.
In the embodiment of the present invention, after the interface 2 of the distribution server is called and the SQL cancel task is acquired, the distribution server distributes the SQL cancel task and the first identification code to the execution server C again.
Step 504, the execution server C synchronizes the first identifier to the first queue.
In an embodiment of the present invention, since the execution server C does not execute the SQL execution task, the first local identifier stored in the execution server C is not the same as the first identifier, that is, the execution server C does not cancel the SQL cancellation task, but synchronizes the received first identifier to a first queue in a shared queue subscribed by the execution server cluster, where a queue task type of the first queue is a cancellation task type.
Step 505, the execution server cluster may obtain the first identification code in the first queue, and the execution server a executes the SQL cancel task.
In the specific embodiment of the present invention, the execution server cluster may obtain the first identification code in the first queue, and since the second local identification code in the execution server a is the same as the first local identification code and the queue task type of the first queue is the cancel task type, the execution server a may perform the cancel task operation on the SQL corresponding to the second local identification code.
According to the sharing method provided by the embodiment of the invention, the plurality of execution servers share the tasks of the to-be-processed object by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the to-be-processed object are distributed to different execution servers, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
Example ten
Based on the first embodiment and the second embodiment, a tenth embodiment of the present invention provides a distribution server. Fig. 13 is a schematic structural diagram of a first configuration of a distribution server according to an embodiment of the present invention, and as shown in fig. 13, in an embodiment of the present invention, a distribution server 1 includes: a first acquiring unit 11, a first judging unit 12 and a first transmitting unit 13.
A first obtaining unit 11, configured to obtain a first task corresponding to an object to be processed; wherein the first task is for processing the object to be processed.
The first determining unit 12 is configured to determine whether the first task is a first task issued by the object to be processed after the first acquiring unit 11 acquires the first task corresponding to the object to be processed.
A first sending unit 13, configured to send the first task and the first identification code to the execution server cluster when the first task is not the first task issued to the object to be processed after the first determining unit 12 determines whether the first task is the first task issued to the object to be processed; the first identification code is a judgment identifier for judging whether to execute the task, and is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function.
Fig. 14 is a schematic structural diagram of a second configuration of a distribution server according to an embodiment of the present invention, and as shown in fig. 14, in an embodiment of the present invention, a distribution server 1 includes: a first receiving unit 14.
The first acquiring unit 11 is further configured to, when the first task is not a first task issued to the object to be processed, acquire a second task corresponding to the object to be processed before acquiring the first task corresponding to the object to be processed; wherein the second task is used for processing the object to be processed for the first time.
The first sending unit 13 is further configured to send the second task to the execution server cluster after the first obtaining unit 11 obtains the second task corresponding to the object to be processed.
The first receiving unit 14 is configured to receive the first identification code sent by the execution server cluster in response to the second task after the first sending unit 13 sends the second task to the execution server cluster.
The first obtaining unit 11, the first judging unit 12, the first sending unit 13, and the first receiving unit 14 provided in the embodiment of the present invention may all be implemented in the form of program codes by executing corresponding functions by a processor in the mobile terminal; of course, the implementation can also be realized through a specific logic circuit; in the course of a particular embodiment, the processor may be a Central Processing Unit (CPU), a Microprocessor (MPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), or the like.
The allocation server provided by the embodiment of the invention acquires the first task corresponding to the object to be processed and judges whether the first task is a first task issued by the object to be processed; wherein the first task is used for processing the object to be processed; when the first task is not the first task issued by the object to be processed, the first task and the first identification code are sent to the execution server cluster; the first identification code is a judgment identifier for judging whether to execute the task, and is obtained from the execution server cluster; and the execution server cluster subscribes to the same shared queue with the sharing function. Therefore, compared with the prior art, according to the distribution server provided by the embodiment of the invention, the tasks of the objects to be processed are shared by the multiple execution servers through subscribing the same sharing queue, so that under the condition that different tasks corresponding to the objects to be processed are distributed to different execution servers, the task sharing among the execution servers can be realized, the defect of resource waste is further overcome, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
EXAMPLE eleven
Based on the third embodiment and the fourth embodiment, an eleventh embodiment of the present invention provides a first execution server. Fig. 15 is a first schematic structural diagram of a composition structure of a first execution server according to an embodiment of the present invention, as shown in fig. 15, in an embodiment of the present invention, a first execution server 2 includes: second receiving section 21, second determining section 22, first determining section 23, and synchronizing section 24.
A second receiving unit 21, configured to receive the first task and the first identification code sent by the distribution server; wherein the first task is used for processing the object to be processed; the first identification code is a judgment identification for whether to execute the task.
A second judging unit 22, configured to judge whether to execute the first task according to the first identification code and the first local identification code after the second receiving unit 21 receives the first task and the first identification code sent by the distribution server; the first local identification code is a judgment mark for judging whether the first execution server executes the task or not.
A first determining unit 23, configured to determine, after the second determining unit 22 determines whether to execute the first task according to the first identification code and the first local identification code, a first queue corresponding to the first task according to a preset correspondence between the task and the queue type and the first task when the first identification code and the first local identification code are different; wherein the first queue is a queue of a task type in the shared queue.
A synchronization unit 24 for synchronizing the first identification code into the first queue after the first determination unit 23 determines the first queue corresponding to the first task.
Fig. 16 is a schematic structural diagram of a composition structure of a first execution server according to an embodiment of the present invention, as shown in fig. 16, in an embodiment of the present invention, the first execution server 2 further includes: a first execution unit 25.
A first executing unit 25, configured to execute the first task when the first identification code and the first local identification code are the same after the second judging unit 22 judges whether to execute the first task according to the first identification code and the first local identification code.
The second receiving unit 21, the second judging unit 22, the first determining unit 23, the synchronizing unit 24, and the first executing unit 25 provided in the embodiment of the present invention may all be implemented in the form of program codes by executing corresponding functions by a processor in the mobile terminal; of course, the implementation can also be realized through a specific logic circuit; in the course of a particular embodiment, the processor may be a Central Processing Unit (CPU), a Microprocessor (MPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), or the like.
According to the first execution server provided by the embodiment of the invention, the plurality of execution servers share the tasks of the objects to be processed by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the objects to be processed are distributed to different execution servers, the defect of resource waste is further solved, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
Example twelve
Based on the fifth embodiment and the sixth embodiment, a twelfth embodiment of the present invention provides a second execution server. Fig. 17 is a first schematic structural diagram of a composition structure of a second execution server according to an embodiment of the present invention, as shown in fig. 17, in an embodiment of the present invention, a second execution server 3 includes: a second acquiring unit 31, a second determining unit 32, a third judging unit 33, and a second executing unit 34.
A second obtaining unit 31, configured to obtain the first identification code in the first queue according to a preset time interval; the first queue is a task type queue in the shared queue; the first identification code is a judgment identification for whether to execute the task.
The second determining unit 32 is configured to determine, after the second obtaining unit 31 obtains the first identification code in the first queue according to the preset time interval, the first task corresponding to the first queue according to the preset correspondence between the task and the queue type and the first queue, where the first task is a task that does not process the object to be processed for the first time.
A third judging unit 33 configured to judge whether to execute the first task based on the first identification code and the second local identification code after the second determining unit 32 determines the first task corresponding to the first queue; the second local identification code is a judgment mark for judging whether the second execution server executes the task or not.
A second executing unit 34, configured to execute the first task when the first identifier and the second local identifier are the same after the third determining unit 33 determines whether to execute the first task according to the first identifier and the second local identifier.
Fig. 18 is a schematic structural diagram of a second component of the second execution server according to an embodiment of the present invention, as shown in fig. 18, in an embodiment of the present invention, the second execution server 3 further includes: a third receiving unit 35, a storage unit 36, and a second transmitting unit 37.
A third receiving unit 35, configured to receive the second task sent by the distribution server before the second obtaining unit 31 obtains the first identification code in the first queue according to the preset time interval; wherein the second task is used for processing the object to be processed for the first time.
The second executing unit 34 is further configured to execute the second task after the third receiving unit 35 receives the second task sent by the distribution server.
And a storage unit 36 for generating and storing a second local identification code corresponding to the second task after the second execution unit 34 executes the second task.
A second sending unit 37, configured to send the second local identification code as the first identification code to the distribution server.
The second obtaining unit 31, the second determining unit 32, the third determining unit 33, the second executing unit 34, the third receiving unit 35, the storing unit 36 and the second sending unit 37 provided in the embodiment of the present invention may be implemented in the form of program codes by executing corresponding functions by a processor in the mobile terminal; of course, the implementation can also be realized through a specific logic circuit; in the course of a particular embodiment, the processor may be a Central Processing Unit (CPU), a Microprocessor (MPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), or the like.
According to the second execution server provided by the embodiment of the invention, the plurality of execution servers share the tasks of the objects to be processed by subscribing the same sharing queue, so that the task sharing among the execution servers can be realized under the condition that different tasks corresponding to the objects to be processed are distributed to different execution servers, the defect of resource waste is further solved, and the task processing rate is improved. Moreover, the method is simple and convenient to realize, convenient to popularize and wide in application range.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present invention. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in various embodiments of the present invention, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention. The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units; can be located in one place or distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all the functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media that can store program codes, such as a removable Memory device, a Read Only Memory (ROM), a magnetic disk, or an optical disk.
Alternatively, the integrated unit of the present invention may be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as a separate product. Based on such understanding, the technical solutions of the embodiments of the present invention may be essentially implemented or a part contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: a removable storage device, a ROM, a magnetic or optical disk, or other various media that can store program code.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (8)

1. A sharing method is applied to a distribution server, and is characterized in that the method comprises the following steps:
acquiring a first task corresponding to an object to be processed, and judging whether the first task is a first task issued to the object to be processed; wherein the first task is used for processing the object to be processed;
when the first task is not a first task issued to the object to be processed, sending the first task and a first identification code to an execution server cluster; the first identification code is a judgment identifier for judging whether to execute a task, and the first identification code is obtained from the execution server cluster; the execution server cluster subscribes to the same sharing queue with the sharing function;
when the first task is not a first task issued to the object to be processed, and before the acquiring the first task corresponding to the object to be processed, the method further includes:
acquiring a second task corresponding to the object to be processed; wherein the second task is used for processing the object to be processed for the first time;
sending the second task to the execution server cluster;
and receiving the first identification code which is sent by the execution server cluster and responds to the second task.
2. A sharing method is applied to a first execution server, wherein the first execution server is one execution server in a cluster of execution servers subscribed to a shared queue, and the method comprises the following steps:
receiving a first task and a first identification code sent by a distribution server; wherein the first task is used for processing an object to be processed; the first identification code is a judgment identifier for judging whether to execute the task;
judging whether to execute the first task according to the first identification code and the first local identification code; the first local identification code is a judgment identifier for judging whether the first execution server executes the task or not;
when the first identification code is different from the first local identification code, determining a first queue corresponding to the first task according to a preset corresponding relation between the task and the queue type and the first task; wherein the first queue is a queue of a task type in the shared queue;
synchronizing the first identification code into the first queue;
before receiving the first task and the first identification code sent by the distribution server, the method further includes:
receiving a second task sent by the distribution server; wherein the second task is used for processing the object to be processed for the first time;
executing the second task, generating and storing the first local identification code corresponding to the second task;
and sending the first local identification code as the first identification code to the distribution server.
3. The method of claim 2, wherein after determining whether to execute the first task according to the first identifier and the first local identifier, the method further comprises:
and when the first identification code is the same as the first local identification code, executing the first task.
4. A sharing method applied to a second execution server, where the second execution server is an execution server different from a first execution server in a cluster of execution servers subscribed to a shared queue, and the method includes:
acquiring a first identification code in a first queue according to a preset time interval; wherein the first queue is a queue of a task type in the shared queue; the first identification code is a judgment identifier for judging whether to execute the task;
determining a first task corresponding to the first queue according to a preset corresponding relation between the task and the queue type and the first queue; the first task is a task which does not process the object to be processed for the first time;
judging whether to execute the first task according to the first identification code and the second local identification code; the second local identification code is a judgment identifier for judging whether the second execution server executes the task or not;
when the first identification code and the second local identification code are the same, executing the first task;
before the obtaining the first identification code in the first queue according to the preset time interval, the method further includes:
receiving a second task sent by the distribution server; wherein the second task is used for processing the object to be processed for the first time;
executing the second task, generating and storing the second local identification code corresponding to the second task;
and sending the second local identification code as the first identification code to the distribution server.
5. A distribution server, characterized in that the distribution server comprises: a first obtaining unit, a first judging unit, a first sending unit,
the first acquisition unit is used for acquiring a first task corresponding to an object to be processed; wherein the first task is used for processing the object to be processed;
the first judging unit is used for judging whether the first task is a first task issued to the object to be processed;
the first sending unit is used for sending the first task and the first identification code to an execution server cluster when the first task is not a first task issued to the object to be processed; the first identification code is a judgment identifier for judging whether to execute a task, and the first identification code is obtained from the execution server cluster; the execution server cluster subscribes to the same sharing queue with the sharing function;
the distribution server further comprises: a first receiving unit for receiving the first data,
the first obtaining unit is further configured to, when the first task is not a first task issued to the object to be processed, obtain a second task corresponding to the object to be processed before obtaining the first task corresponding to the object to be processed; wherein the second task is used for processing the object to be processed for the first time;
the first sending unit is further configured to send the second task to the execution server cluster;
the first receiving unit is configured to receive the first identifier sent by the execution server cluster and responding to the second task.
6. A first execution server, wherein the first execution server is one execution server in a cluster of execution servers that subscribe to a shared queue, the first execution server comprising: a second receiving unit, a second judging unit, a first determining unit and a synchronizing unit,
the second receiving unit is used for receiving the first task and the first identification code sent by the distribution server; wherein the first task is used for processing an object to be processed; the first identification code is a judgment identifier for judging whether to execute the task;
the second judging unit is configured to judge whether to execute the first task according to the first identification code and the first local identification code; the first local identification code is a judgment identifier for judging whether the first execution server executes the task or not;
the first determining unit is configured to determine, when the first identification code is different from the first local identification code, a first queue corresponding to the first task according to a preset correspondence between a task and a queue type and the first task; wherein the first queue is a queue of a task type in the shared queue;
the synchronization unit is configured to synchronize the first identifier to the first queue;
the first execution server further comprises: a first execution unit, a first storage unit, a second transmission unit,
the second receiving unit is further configured to receive a second task sent by the distribution server before the first task and the first identification code sent by the distribution server are received; wherein the second task is used for processing the object to be processed for the first time;
the first execution unit is used for executing the second task;
the first storage unit is used for generating and storing the first local identification code corresponding to the second task after the second task is executed;
the second sending unit is configured to send the first local identification code to the distribution server as the first identification code.
7. The first execution server of claim 6,
the first execution unit is further configured to execute the first task when the first identifier is the same as the first local identifier after determining whether to execute the first task according to the first identifier and the first local identifier.
8. A second execution server, wherein the second execution server is a different execution server from the first execution server in a cluster of execution servers that subscribe to a shared queue, the second execution server comprising: a second obtaining unit, a second determining unit, a third judging unit and a second executing unit,
the second obtaining unit is used for obtaining the first identification code in the first queue according to a preset time interval; wherein the first queue is a queue of a task type in the shared queue; the first identification code is a judgment identifier for judging whether to execute the task;
the second determining unit is used for determining a first task corresponding to the first queue according to a preset corresponding relation between the task and the queue type and the first queue; the first task is a task which does not process the object to be processed for the first time;
the third judging unit is configured to judge whether to execute the first task according to the first identification code and the second local identification code; the second local identification code is a judgment identifier for judging whether the second execution server executes the task or not;
the second execution unit is configured to execute the first task when the first identifier is the same as the second local identifier;
the second execution server further includes: a third receiving unit, a second storage unit, a third transmitting unit,
the third receiving unit is configured to receive a second task sent by the distribution server before the first identification code in the first queue is obtained according to the preset time interval; wherein the second task is used for processing the object to be processed for the first time;
the second execution unit is further configured to execute the second task;
the second storage unit is used for generating and storing the second local identification code corresponding to the second task after the second task is executed;
the third sending unit is configured to send the second local identifier to the distribution server as the first identifier.
CN201710198853.4A 2017-03-29 2017-03-29 Sharing method and server Active CN107423131B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710198853.4A CN107423131B (en) 2017-03-29 2017-03-29 Sharing method and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710198853.4A CN107423131B (en) 2017-03-29 2017-03-29 Sharing method and server

Publications (2)

Publication Number Publication Date
CN107423131A CN107423131A (en) 2017-12-01
CN107423131B true CN107423131B (en) 2021-01-15

Family

ID=60423937

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710198853.4A Active CN107423131B (en) 2017-03-29 2017-03-29 Sharing method and server

Country Status (1)

Country Link
CN (1) CN107423131B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110308976B (en) * 2018-03-27 2022-02-11 阿里巴巴(中国)有限公司 Task processing method and device
CN111309456B (en) * 2018-12-12 2023-04-18 深圳市茁壮网络股份有限公司 Task execution method and system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685416A (en) * 2012-09-20 2014-03-26 联想(北京)有限公司 Distributed task allocation and claim method and electronic devices
CN106528275A (en) * 2015-09-10 2017-03-22 网易(杭州)网络有限公司 Processing method of data tasks and task scheduler

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI349204B (en) * 2003-01-10 2011-09-21 Panasonic Corp Group admission system and server and client therefor
CN103209223B (en) * 2013-04-27 2016-08-10 中国农业银行股份有限公司 distributed application session information sharing method, system and application server
CN105204921B (en) * 2014-06-25 2019-03-01 北京奇虎科技有限公司 Method for allocating tasks, device, system and server
CN106357778A (en) * 2016-09-27 2017-01-25 山东浪潮商用系统有限公司 Session information sharing method, device and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685416A (en) * 2012-09-20 2014-03-26 联想(北京)有限公司 Distributed task allocation and claim method and electronic devices
CN106528275A (en) * 2015-09-10 2017-03-22 网易(杭州)网络有限公司 Processing method of data tasks and task scheduler

Also Published As

Publication number Publication date
CN107423131A (en) 2017-12-01

Similar Documents

Publication Publication Date Title
EP3648401B1 (en) Method, device, and computer readable storage medium for managing network slice
CN109618005B (en) Method for calling server and proxy server
CN110290180B (en) Distributed task scheduling method and device, computer equipment and storage medium
CN108449410B (en) Message management method, system and related device in cloud platform
WO2020177533A1 (en) Electronic invoice identifier allocation method, and electronic ticket generating method, device and system
US8032780B2 (en) Virtualization based high availability cluster system and method for managing failure in virtualization based high availability cluster system
CN110896355B (en) Network slice selection method and device
CN102469033B (en) Message subscription system and message sending method
CN106371889B (en) Method and device for realizing high-performance cluster system of scheduling mirror image
CN103150213B (en) Balancing method of loads and device
CN110868465A (en) Load balancing system and method for container cloud
CN110336848B (en) Scheduling method, scheduling system and scheduling equipment for access request
CN107423131B (en) Sharing method and server
US20160183229A1 (en) Ip phone network system, server apparatus, ip exchange and resource capacity expansion method
CN111200606A (en) Deep learning model task processing method, system, server and storage medium
CN110677475A (en) Micro-service processing method, device, equipment and storage medium
CN115086330A (en) Cross-cluster load balancing system
CN116149821A (en) Cluster multi-task sliding window scheduling processing method, system, equipment and medium
CN110138753B (en) Distributed message service system, method, apparatus, and computer-readable storage medium
CN111176812A (en) Clustered timing task scheduling system
CN113364888B (en) Service scheduling method, system, electronic device and computer readable storage medium
CN109167819B (en) Data synchronization system, method, device and storage medium
CN113806177A (en) Cluster monitoring method and device, electronic equipment and storage medium
CN112416559A (en) Scheduling policy updating method, service scheduling method, storage medium and related apparatus
US20170139808A1 (en) Method and dispatcher node for server processing management

Legal Events

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