Task processing method and device

By building a distributed cluster, the master node obtains task information and automatically divides or copies tasks, solving the problem of insufficient electronic equipment resources, realizing collaborative processing of multiple devices, and improving resource utilization and task efficiency.

CN114528104BActive Publication Date: 2025-09-19VIVO MOBILE COMM CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210135580.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-14
Publication Date
2025-09-19
Estimated Expiration
2042-02-14

AI Technical Summary

Technical Problem

When processing large tasks in electronic devices, the problem of insufficient hardware resources leads to resource waste and low task processing efficiency, especially when there are multiple electronic devices in the home but resource distribution is uneven.

Method used

By building a distributed cluster and utilizing multiple electronic devices to form a distributed system, the master node obtains the application scenario information and distributed mode information of the task, automatically divides or copies the task, and realizes the collaborative processing of multiple devices.

Benefits of technology

It improves the resource utilization of idle electronic devices, enhances task processing efficiency, avoids resource waste, and simplifies user operation processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114528104B_ABST
    Figure CN114528104B_ABST
Patent Text Reader

Abstract

The present application discloses a task processing method and device, which belongs to the field of communication technology. The method includes: an electronic device receives a user's first request information; the electronic device obtains a task to be processed in response to the first request information, wherein the electronic device is a node in a constructed distributed cluster, and the distributed cluster is a distributed system constructed based on multiple electronic devices; the master node of the distributed cluster obtains application scenario information and distributed mode information of the task to be processed; the master node processes the task to be processed based on the application scenario information and the distributed mode information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of communication technology, and specifically relates to a task processing method and device. Background Art

[0002] With the development of hardware technology, the memory, running memory and other hardware of electronic devices are being improved. However, when performing larger tasks on electronic devices or storing some large-capacity data, such as data downloading, data uploading, data calculation, blockchain and other large tasks, or storing large files such as videos, music, and documents, there will still be insufficient resources such as CPU, memory, running memory, etc. Therefore, no matter how the hardware of a single electronic device is improved, there will be bottlenecks in its use.

[0003] Nowadays, many families often have multiple electronic devices, some of which are used frequently and have insufficient resources, while others are used less frequently and have sufficient resources. The resources of the idle electronic devices that are used less frequently cannot be utilized, resulting in a waste of resources. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to provide a task processing method and device that can solve the defect of insufficient hardware resources when electronic devices process large tasks under the existing technology, while improving the resource utilization of idle electronic devices, thereby improving task processing efficiency.

[0005] In a first aspect, an embodiment of the present application provides a task processing method, the method comprising:

[0006] The electronic device receives first request information from the user;

[0007] The electronic device obtains a task to be processed in response to the first request information, wherein the electronic device is a node in a constructed distributed cluster, and the distributed cluster is a distributed system constructed based on multiple electronic devices;

[0008] The master node of the distributed cluster obtains application scenario information and distributed mode information of the task to be processed;

[0009] The master node processes the pending tasks based on the application scenario information and the distributed mode information.

[0010] In a second aspect, an embodiment of the present application provides a task processing device, the device comprising:

[0011] A request receiving module, configured to enable the electronic device to receive first request information from a user;

[0012] a first acquisition module, configured to enable the electronic device to obtain a task to be processed in response to the first request information, wherein the electronic device is a node in a constructed distributed cluster, and the distributed cluster is a distributed system constructed based on multiple electronic devices;

[0013] A second acquisition module is used to enable the master node of the distributed cluster to obtain application scenario information and distribution mode information of the task to be processed;

[0014] The task processing module is used to enable the master node to process the to-be-processed task based on the application scenario information and the distributed mode information.

[0015] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0017] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the method described in the first aspect.

[0018] In an embodiment of the present application, user requests are received by electronic devices of a distributed cluster to obtain tasks to be processed. The master node of the distributed cluster obtains application scenario information and distributed mode information of the tasks to be processed, and processes the tasks to be processed based on the application scenario information and the distributed mode information, thereby making full use of idle electronic devices and realizing the function of distributed utilization of multiple electronic devices, so that multiple electronic devices can jointly process a task, thereby improving the resource utilization of idle electronic devices and improving the task processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A flowchart of a task processing method provided in an embodiment of the present application;

[0020] Figure 2 A schematic diagram of a distributed cluster provided in an embodiment of the present application;

[0021] Figure 3 A schematic diagram of the interaction between the master node and the slave node provided in an embodiment of the present application;

[0022] Figure 4One of the flowcharts of the master node processing pending tasks provided in an embodiment of the present application;

[0023] Figure 5 The second flowchart of the master node processing pending tasks provided in the embodiment of the present application;

[0024] Figure 6 A schematic diagram of the structure of a task processing device provided in an embodiment of the present application;

[0025] Figure 7 is a structural diagram of an electronic device provided in an embodiment of the present application;

[0026] Figure 8 This is a hardware diagram of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field are within the scope of protection of this application.

[0028] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.

[0029] In the embodiments of the present application, the term "multiple units" refers to two or more units, and other quantifiers are similar.

[0030] Under existing technologies, there are several ways to handle large tasks in electronic devices:

[0031] One approach is to manually split large tasks, assigning them to multiple phones and devices to execute them simultaneously, and then manually merge the results. For example, if a user needs to download 10 episodes of a movie, they would manually divide the episodes into several parts, operate multiple devices to download their parts simultaneously, and then merge the data using data cables, the Internet, Bluetooth, or other methods. This approach requires manual task splitting, device operation, and final data integration, making the entire process relatively complex.

[0032] Another approach is to increase the storage capacity of mobile phones, upload data to the cloud, or back up data to a hard drive or memory card when the storage resources of a single electronic device are insufficient. However, the storage resources of a single mobile phone are limited, and cloud data also carries risks such as privacy leakage and data loss. Retrieving data from the hard drive or memory card requires manual operation, such as copying and importing the data, which is not convenient for obtaining the desired data.

[0033] In order to solve the above problems, the present application provides a task processing method, device and electronic device.

[0034] The task processing method provided in the embodiment of the present application is described in detail below with reference to some embodiments and their application scenarios in conjunction with the accompanying drawings. The task processing method provided in the embodiment of the present application, the execution subject can be an electronic device or a functional module or functional entity in the electronic device that can implement the task processing method. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, wearable devices, etc. The task processing method provided in the embodiment of the present application is described below using an electronic device as an example of the execution subject.

[0035] Figure 1 The flowchart of the task processing method provided in the embodiment of the present application is as follows: Figure 1 As shown, the method includes:

[0036] Step 101: The electronic device receives a first request from a user.

[0037] It can be understood that when the electronic device operates normally, the user can send the first request information through the electronic device to request the electronic device to execute the task to be processed.

[0038] Step 102: The electronic device obtains a task to be processed in response to the first request information.

[0039] The electronic device is a node in a constructed distributed cluster, and the distributed cluster is a distributed system constructed based on multiple electronic devices;

[0040] It should be noted that traditional distributed systems only exist in servers and are generally aimed at enterprise-level data processing. There is very little distributed application software, especially in the mobile field. There is currently no better method for utilizing distributed resources and solving "personal use" scenarios.

[0041] Distributed systems enable distributed computing and distributed network storage. Distributed computing is a research area in computer science that explores how to break a problem requiring enormous computing power into many smaller ones, distribute these smaller problems across multiple computers, and finally combine the results to produce the final result. Distributed network storage involves storing data in a decentralized manner across multiple independent machines and devices.

[0042] It can be understood that the electronic device that receives the first request information may be any electronic device in the distributed cluster. The electronic device parses the user request and obtains the task to be processed.

[0043] The tasks to be processed are distributed computing tasks or distributed storage tasks, such as downloading, uploading or storage tasks.

[0044] It can be understood that a distributed computing task refers to distributing the task to be processed to other electronic devices, so that multiple electronic devices jointly complete the task to be processed; a distributed storage task refers to storing data or files in other electronic devices.

[0045] Step 103: The master node of the distributed cluster obtains application scenario information and distribution mode information of the task to be processed.

[0046] It should be noted that distributed systems generally adopt a master-slave design, that is, setting up a master node and at least one slave node, the purpose of which is to ensure data consistency. The master-slave design is the most intuitive data consistency guarantee mechanism.

[0047] In an embodiment of the present application, the functions of the master node include at least one of the following: splitting tasks to be processed, applying for resources for the distributed cluster, task allocation, task monitoring, and data merging.

[0048] The functions of the slave node include at least one of the following: notifying the master node of resource status, processing tasks assigned by the master node, and feeding back the task processing status to the master node.

[0049] In one implementation, before sending the first request information, the user manually sets application scenario information of the task to be processed in the electronic device.

[0050] It should be noted that the master node can automatically identify and obtain application scenario information of the task to be processed through the task parser.

[0051] The task parser may be a program including multiple different strategies, each of which can identify corresponding application scenario information.

[0052] The application scenario information of the pending tasks obtained by the master node includes one of the following:

[0053] 1) External network data interaction scenario;

[0054] In one embodiment, the application scenario information of the pending task obtained by the master node is a data interaction scenario; for example, the pending task is downloading network files (video, music, novels), downloading network software, uploading local files to the Internet, etc.

[0055] 2) Caching scenarios where users interact with applications;

[0056] In one embodiment, the application scenario information for the pending task obtained by the master node is the caching scenario of the user's interaction with the application. For example, caching content that has already been interacted with: while the user is watching a video or novel, the electronic device caches the content the user has already watched. For example, caching content that is about to be interacted with: while the user is watching a video, the electronic device caches the video that has not yet been watched, or while the user is reading a novel, the electronic device caches the content of the chapters that have not yet been read. These caching operations do not need to be performed solely by the current electronic device; they can be distributed and performed by other electronic devices.

[0057] 3) Data loss and damage prevention scenarios;

[0058] In one embodiment, the application scenario information of the task to be processed obtained by the master node is a data loss prevention and damage prevention scenario; for example: a piece of data is stored in multiple electronic devices at the same time, and the data stored in each electronic device is a complete piece of data, thereby increasing data security.

[0059] 4) Data distributed storage scenario;

[0060] In one embodiment, the application scenario information of the task to be processed obtained by the master node is a data distributed storage scenario; for example: the data stored in any electronic device in the distributed cluster is automatically split, and the split data is automatically and actively stored in different devices, thereby solving the problem of insufficient storage resources in a single electronic device.

[0061] 5) Distributed data collection scenario;

[0062] In one embodiment, the application scenario information of the task to be processed obtained by the master node is a distributed data collection scenario; for example: any electronic device in the distributed cluster collects data from the external Internet of Things or sensors, such as human body data collected by smart bracelets and watches, video, monitoring data collected by language monitoring, operating status data of smart homes, etc., and these data are distributedly stored or shared.

[0063] It can be understood that each application scenario information corresponds one-to-one to a scenario ID.

[0064] It should be noted that the distributed mode information of the tasks to be processed needs to be manually set by the user in the electronic device.

[0065] For example, a user can set distributed mode information on any electronic device in a distributed cluster for an application, folder, or file that requires distributed processing on that electronic device. If distributed processing is performed on an application, the application must authorize the electronic device to access the application's data storage path and log storage path. Authorization is not required for distributed processing of folders or files.

[0066] The distributed mode information of the pending tasks obtained by the master node includes one of the following:

[0067] 1) Normal mode;

[0068] In one implementation, the distributed mode information of the task to be processed obtained by the master node is a normal mode.

[0069] It's important to note that the normal mode divides the task into multiple subtasks and assigns each of these subtasks to multiple electronic devices in the cluster for processing. In this mode, the data generated after the task is processed is also divided into multiple copies and stored in different electronic devices. This mode is simple, convenient, and automated, maximizing the utilization of multiple electronic devices in the cluster to assist in processing.

[0070] 2) Manual mode;

[0071] In one implementation, the distributed mode information of the task to be processed obtained by the master node is a manual mode.

[0072] It's important to note that manual mode, also known as resource adjustment mode, requires the user to manually specify which electronic device will handle storage and computing operations. In this mode, data generated after the pending task is processed is ultimately stored only on the designated electronic device. This flexible and convenient mode allows users to prioritize tasks on devices with sufficient resources.

[0073] 3) Anti-loss mode;

[0074] In one embodiment, the distributed mode information of the task to be processed obtained by the master node is an anti-loss mode;

[0075] It's important to note that anti-loss mode, also known as security mode, stores the complete data obtained after the pending task is processed on multiple electronic devices in a distributed cluster. In this mode, each electronic device stores a complete copy of the data. This ensures that important data is stored in a complete copy across multiple devices.

[0076] It is understandable that each distributed pattern information corresponds to a pattern id.

[0077] Step 104: The master node processes the pending task based on the application scenario information and the distributed mode information.

[0078] It can be understood that when processing a task, the master node needs to consider both the application scenario information of the task and the distribution mode information of the task.

[0079] It should be noted that the master node processes pending tasks, which means that the master node selects at least one available node from the slave nodes of the distributed cluster based on application scenario information and distributed mode information, performs processing operations such as division or replication on the pending tasks according to the number of available nodes, and then distributes the tasks after the division or replication processing operations to the available nodes. The available nodes process the assigned tasks separately, thereby achieving the purpose of multiple slave nodes distributing the same task.

[0080] In this embodiment, user requests are received by electronic devices of a distributed cluster to obtain tasks to be processed. The master node of the distributed cluster obtains application scenario information and distributed mode information of the tasks to be processed, and processes the tasks to be processed based on the application scenario information and the distributed mode information, thereby making full use of idle electronic devices and realizing the function of distributed utilization of multiple electronic devices, so that resources are scheduled and storage is shared among multiple electronic devices, and a task is processed together, thereby improving the resource utilization rate of idle electronic devices and also improving the task processing efficiency.

[0081] Optionally, the method further comprises constructing the distributed cluster,

[0082] The constructing of the distributed cluster includes:

[0083] Determining one master node and N-1 slave nodes from N electronic devices that meet a first preset condition, where N is a positive integer and N ≥ 2, and the first preset condition includes at least one of the following: the N electronic devices are in the same network environment, the N electronic devices use the same operating system, and the N electronic devices are connected using TCP;

[0084] The electronic device distributed cluster is constructed based on the one master node and the N-1 slave nodes.

[0085] In the embodiment of the present application, N electronic devices can be placed in the same network environment using WiFi, Bluetooth, or a mobile communication network of the same operator.

[0086] In one embodiment, a Linux operating system is installed and used in N electronic devices. For example, when the N electronic devices are all mobile phones, AidLux software can be pre-installed in the system. This is a lightweight complete Linux system that occupies relatively little memory and storage.

[0087] Figure 2 A schematic diagram of a distributed cluster provided in an embodiment of the present application is shown as follows: Figure 2 As shown in the figure, the distributed cluster includes four mobile phones and one network-attached storage. Among them, mobile phone 1 is the master node, and mobile phones 2, 3, 4 and the network-attached storage are slave nodes. The four mobile phones and the network-attached storage are in the same network environment through a router. At the same time, the Android systems of the four mobile phones are pre-installed with AidLux software and a Linux system is built (not shown in the figure). In the same network, the four mobile phones and the network-attached storage are connected via TCP (not shown in the figure). Figure 2 The network attached storage is a device connected to the network with storage function. It is an optional slave node. When it is necessary to improve the fault tolerance of the distributed cluster, other nodes in the distributed cluster can store data in this device to further save storage resources. This device can also be used for data backup and improve data stability.

[0088] It can be understood that N electronic devices that meet the first preset condition can interconnect and communicate with each other in the same network, and each electronic device is a node that can process tasks and store data.

[0089] It should be noted that determining one master node and N-1 slave nodes among N electronic devices means using an election algorithm to determine a master node among the N electronic devices, and using the remaining electronic devices as slave nodes. For example, the Raft algorithm, ZAB algorithm, Zookeeper algorithm, or other lightweight election algorithms can be used to perform the election function to determine the master node.

[0090] After the master node and slave nodes are determined, the mobile distributed cluster is successfully built.

[0091] It should be understood that when an electronic device among N electronic devices exits the cluster or the determined master node fails, the master node of the cluster needs to be re-determined; when an electronic device joins the cluster, the master node of the cluster does not need to be re-determined.

[0092] It is understandable that there is only one master node and at least one slave node in a distributed cluster.

[0093] Figure 3 A schematic diagram of the interaction between the master node and the slave node provided in the embodiment of the present application is shown in FIG. Figure 3 As shown: a. The master node applies for resources from the slave node; b. The slave node receives the master node's application and notifies the master node of its resource status; c. The master node assigns tasks to the slave node; d. The slave node receives the tasks assigned by the master node and processes the tasks; e. The master node monitors the task processing status of the slave node; f. The slave node feeds back the task processing status of the node to the master node in real time.

[0094] In this embodiment, a distributed cluster is constructed by determining the master node and slave nodes in N electronic devices, establishing an operational basis for subsequent distributed processing tasks. Moreover, the structure of the distributed cluster is concise and the construction process is simple. Compared with traditional computer clusters, due to the limited resources of electronic devices, some lightweight applications can be used to build a distributed cluster of electronic devices. At the same time, electronic devices can be easily and quickly incorporated into the distributed cluster, which is conducive to the horizontal expansion of the distributed cluster.

[0095] Optionally, the master node of the distributed cluster obtains application scenario information and distribution mode information of the task to be processed, including:

[0096] In a case where the electronic device is a slave node of the constructed distributed cluster, the distributed node sends the to-be-processed task to the master node, and the master node receives the to-be-processed task and saves the to-be-processed task to the first queue; or, in a case where the electronic device is a master node of the constructed distributed cluster, the master node saves the to-be-processed task to the first queue;

[0097] In a case where the task to be processed is the head element of the first queue, the master node obtains application scenario information and distribution mode information of the task to be processed.

[0098] It is understandable that after the slave node obtains the pending tasks, it needs to send the pending tasks to the master node.

[0099] It should be understood that the first queue uses the "first in, first out" principle of the queue to save the tasks received by the master node from each slave node. When the task corresponding to the head element of the first queue is processed, the task is dequeued, and the next task becomes the head element and is processed by the master node.

[0100] In this embodiment, by using the first queue and adopting the "first in, first out" principle of the queue, the master node can simultaneously receive the pending tasks sent by each distributed node. The master node obtains the application scenario information and distributed mode information of each task in the first queue in turn, so as to subsequently process the pending tasks, thereby ensuring the orderly processing of tasks.

[0101] Optionally, the master node processes the to-be-processed task based on the application scenario information and the distributed mode information, including:

[0102] The master node determines whether the to-be-processed task needs to be divided based on the application scenario information and the distributed mode information;

[0103] In the case where the task to be processed needs to be divided, the master node divides the task to be processed into multiple subtasks to be processed, and distributes the multiple subtasks to be processed to the slave nodes of the distributed cluster;

[0104] In the case that the to-be-processed task does not need to be divided, the master node determines an available node that can execute the to-be-processed task and allocates the to-be-processed task to the available node.

[0105] It should be understood that the master node determines whether the task to be processed is a distributed computing task or a distributed storage task based on the application scenario information and distributed mode information of the task to be processed. When the type of the task to be processed is a distributed computing task, the master node needs to divide the task to be processed into multiple sub-tasks to be processed, and each sub-task to be processed is processed separately by multiple slave nodes of the distributed cluster; when the type of the task to be processed is a distributed storage task, the master node determines the available nodes in the distributed cluster that can execute the task to be processed, and the available nodes store the data involved in the task to be processed.

[0106] It should be noted that when the distributed mode information is manual mode or anti-loss mode, the pending tasks do not need to be divided. When the distributed mode information is normal mode, it is also necessary to combine the application scenario information to determine whether the pending tasks need to be divided.

[0107] In one implementation, when the distributed mode information is a normal mode and when the application scenario information is an external network data interaction scenario, the tasks to be processed need to be divided.

[0108] In one implementation, when the distributed mode information is a normal mode and the application scenario information is a cache scenario in which a user interacts with an application program, the tasks to be processed need to be divided.

[0109] In one implementation, when the distributed mode information is a normal mode and when the application scenario information is a data distributed storage scenario, the tasks to be processed need to be divided.

[0110] In one implementation, when the distributed mode information is a normal mode and the application scenario information is a data loss prevention and damage prevention scenario, the tasks to be processed do not need to be divided.

[0111] In one implementation, when the distributed mode information is a normal mode and the application scenario information is a distributed data collection scenario, the tasks to be processed do not need to be divided.

[0112] It can be understood that the division of tasks to be processed is related to application scenario information and distribution mode information.

[0113] It should be noted that traditional task division is mostly aimed at enterprise-level task processing or special data processing needs, and cannot be performed based on the user's application scenario information. In the embodiment of the present application, tasks are actively divided based on the user's application scenario information.

[0114] In this embodiment, the master node determines whether the task to be processed needs to be divided based on the application scenario information and distributed mode information of the task to be processed, and then performs corresponding processing operations on the task to be processed. It can automatically find an adapted node from the distributed cluster to process the task to be processed, thereby accelerating the task processing speed.

[0115] Figure 4 This is one of the flow charts of the master node processing pending tasks provided in the embodiment of the present application. Figure 4 As shown:

[0116] Optionally, when the task to be processed needs to be divided, the master node divides the task to be processed into multiple subtasks to be processed, and distributes the multiple subtasks to be processed to the slave nodes of the distributed cluster, including:

[0117] Step 401: When the to-be-processed task needs to be divided, the master node determines P available nodes based on the CPU idle states of the N-1 slave nodes and a first constraint condition.

[0118] The first constraint condition is a constraint condition that maximizes the P value.

[0119] It should be noted that when the tasks to be processed need to be divided, the master node actively applies for resources. The master node sends a request to each slave node to obtain the current resource status of each node. Each slave node responds to the request and sends the resource status of the node to the master node. For example, the slave node sends the CPU idle status and storage space and other resource status of the node to the master node.

[0120] It should be understood that when the slave node CPU is in use, the master node determines that the node is an unavailable node; when the slave node CPU is idle, the master node determines that the node is an applicable node; the master node determines P available nodes from multiple applicable nodes.

[0121] Wherein, the first constraint condition includes the first principle, the second principle and the third principle;

[0122] The first principle is the file integrity principle, which means that a file cannot be split into multiple subtasks to be processed;

[0123] The second principle is based on the first principle and is the principle of minimum standard deviation of the final distribution;

[0124] The third principle is based on the second principle and is the principle of maximum P value.

[0125] The purpose of setting the first constraint condition is to allow as many slave nodes as possible to jointly process the tasks to be processed, thereby improving task processing efficiency.

[0126] Step 402: The master node divides the pending task into P pending subtasks, saves the P pending subtasks into a second queue, and generates a task processing table for each pending subtask.

[0127] Wherein, P is a positive integer, and 1≤P≤N-1.

[0128] It is understandable that, when the tasks to be processed need to be divided, the master node first determines the number of available nodes and divides the tasks to be processed according to the number of available nodes.

[0129] It can be understood that the data size of any processing subtask is smaller than the data size of the task to be processed.

[0130] It should be understood that the second queue is used to store all pending subtasks of a pending task.

[0131] It should be noted that the master node generates a task processing table for each pending subtask. As shown in Table 1 below, the task processing table includes the following fields: pending task ID field, pending subtask ID field, mode ID field, scenario ID field, operation step list field, available node ID field, and whether it has been assigned field.

[0132] Table 1 Fields included in the task processing table and their meanings

[0133] Field Name Field meaning job_id Pending task id task_id Pending subtask id model_id Mode ID use_case_id Scene ID actions List of steps for the operation available_word_id Available node ids is_distribut Has it been allocated?

[0134] In the task processing table, the mode id represents the distributed mode information of the task to be processed; the scenario id represents the application scenario information of the task to be processed; the operation step list is used to record the steps of processing the task to be processed to obtain the corresponding subtask to be processed; the available node id represents the ids of all available nodes that have been determined in the current distributed cluster; whether it has been assigned is used to indicate whether a subtask to be processed has been assigned to any node among the available nodes. If so, this field indicates "yes", otherwise, it indicates "no".

[0135] Step 403: Based on the task processing table, the master node takes out the P pending subtasks from the second queue and distributes the P pending subtasks to the P available nodes, so that the P available nodes process their respective allocated pending subtasks.

[0136] The master node allocates the P to-be-processed subtasks in a manner including timed allocation or triggered allocation.

[0137] Among them, timed allocation means that the master node queries the task processing table once every period of time, finds out the unassigned pending subtasks and allocates them.

[0138] Triggered allocation means that after the division of a pending task is completed, the master node actively triggers task allocation and allocates each pending subtask.

[0139] In this embodiment, the master node determines whether the pending task needs to be divided through application scenario information and distributed mode information. If the pending task needs to be divided, the master node determines the available nodes and divides the pending task into multiple pending sub-tasks, and generates a task processing table for each pending sub-task for allocating the pending sub-task to the available nodes. According to the application scenario information usually used by the user, some tasks that require large-capacity storage space or occupy the CPU for a long time are automatically split, thereby realizing distributed computing of electronic devices. Users do not need to manually operate multiple devices, which speeds up task processing and improves task processing efficiency.

[0140] Figure 5 The second flow chart of the master node processing pending tasks provided in the embodiment of the present application. Figure 5 As shown:

[0141] Optionally, when the task to be processed does not need to be divided, the master node determines an available node that can execute the task to be processed and allocates the task to the available node, including:

[0142] Step 501: When the task to be processed does not need to be divided, the master node determines whether it is necessary to collect data from N nodes according to the task to be processed.

[0143] Step 502: When data needs to be collected from N nodes, the master node collects data from the N nodes and integrates the collected data into complete data.

[0144] It should be understood that the use of data loss prevention and damage prevention scenarios in manual mode, anti-loss mode, and normal mode does not require the division of tasks to be processed, but it is necessary to collect data from distributed nodes according to the tasks to be processed and integrate the collected data into a complete set of data; in normal mode, the use of distributed data collection scenarios does not require the division of tasks to be processed or the integration of data.

[0145] It should be noted that in traditional distributed task processing, the master node directly assigns tasks to the slave node, and the master node does not perform any operations. The master node provided in the embodiment of the present application automatically determines whether the master node needs to operate based on application scenario information and application mode. When the task to be processed does not need to be divided but data needs to be integrated, the master node performs integration operations on the data from the slave nodes.

[0146] Step 503: The master node determines whether the task to be processed involves a designated node, and obtains a determination result.

[0147] It should be understood that pending tasks involving designated nodes means that the master node needs to assign the pending tasks to the designated nodes for processing; in manual mode or anti-loss mode, the pending tasks involve designated nodes, and in normal mode using data loss prevention and damage prevention scenarios, the pending tasks do not involve designated nodes.

[0148] Step 504: The master node determines P available nodes based on the judgment result and the complete data, obtains P first subtasks to be processed, saves the P first subtasks to be processed to the second queue, and generates a task processing table for each subtask to be processed.

[0149] It should be noted that in step 504, the master node determines P available nodes based on the judgment result and the complete data, and obtains P first subtasks to be processed, including:

[0150] Step 5041: When the task to be processed involves a designated node, the master node determines that the designated node is an available node.

[0151] Step 5042: The master node obtains the first subtask to be processed according to the complete data, saves the first subtask to be processed to the second queue, and generates a task processing table for the first subtask to be processed.

[0152] It should be noted that, when the pending task does not need to be divided, the pending task involving a designated node means that the data obtained after the processing of the pending task is completed needs to be sent to a designated electronic device.

[0153] In one embodiment, a user uses any electronic device to request to read data, the master node collects data from each slave node and integrates the collected data into a complete data set and sends it to the electronic device. At this time, the designated node is the electronic device currently used by the user.

[0154] In one embodiment, a user uses any distributed node to request that data be stored in a designated node. The master node collects data from each slave node and integrates the collected data into a complete set of data and sends it to the designated node.

[0155] It is understandable that, when a task to be processed involves a designated node, the master node obtains a subtask to be processed.

[0156] or;

[0157] Step 5043: When the task to be processed does not involve a designated node, the master node determines P available nodes based on the CPU idle status and storage space of N-1 slave nodes, copies the complete data P-1 times to obtain P subtasks to be processed, and saves the P subtasks to be processed to the second queue, and generates a task processing table for each task to be assigned.

[0158] Wherein, P is a positive integer, and 1≤P≤N-1.

[0159] It should be noted that, when the task to be processed does not need to be divided, the task to be processed does not involve a designated node means that the data obtained after the task to be processed is processed is stored in at least one electronic device.

[0160] It should be noted that the master node determines P available nodes based on the CPU idle status and storage space of N-1 slave nodes. This means that when the CPU of a slave node is idle, the master node determines that the slave node is an applicable node, and when the storage space of the applicable node is larger than the data size of the complete data, the master node determines that the slave node is an available node, thereby determining P available nodes from the N-1 slave nodes; when the CPU of the slave node is in use, the slave node is an unavailable node.

[0161] It is understandable that, when the task to be processed does not involve a designated node, the master node obtains at least one subtask to be processed.

[0162] Step 505: Based on the task processing table, the master node takes out the P first pending subtasks corresponding to the pending task from the second queue, and distributes the P first pending subtasks to the P available nodes, so that the P available nodes can process their respective assigned first pending subtasks.

[0163] The master node allocates the P first to-be-processed subtasks in a manner including timed allocation or triggered allocation.

[0164] It should be noted that the master node provided in the embodiment of the present application automatically determines whether the master node is required to perform computing operations based on application scenario information and application mode. When the tasks to be processed do not need to be divided and the tasks to be processed need to integrate data, the master node actively performs computing operations, collects data from distributed nodes and integrates data, and the slave nodes do not perform computing operations.

[0165] In this embodiment, through application scenario information and distributed mode information, the master node determines whether the pending task needs to collect data, or whether the pending subtask corresponding to the pending task needs to be assigned to the node specified by the user. It can automatically copy multiple copies of complete data, which not only provides users with personalized choices, but also eliminates the need for users to manually back up data. At the same time, it accelerates the task processing speed and thus improves the task processing efficiency.

[0166] Optionally, after the master node determines whether the to-be-processed task needs to be divided based on the application scenario information and the distributed mode information, the method further includes:

[0167] In the case where data does not need to be collected from N nodes, the master node determines M available nodes based on the data involved in the task to be processed, obtains a second subtask to be processed, saves the second subtask to be processed to a second queue, and generates a task processing table for the second subtask to be processed;

[0168] Based on the task processing table, the master node takes the second to-be-processed subtask from the second queue and distributes the second to-be-processed subtask to a target available node among the M available nodes, so that the target available node processes the second to-be-processed subtask;

[0169] Wherein, M is a positive integer, and 1≤M≤N-1, and the allocation method of the master node to allocate the second to-be-processed subtask includes timed allocation or triggered allocation.

[0170] It should be understood that the master node determines M available nodes based on the data involved in the task to be processed, which means that the master node first determines whether the slave node is an applicable node based on the CPU idle status of each slave node. When the CPU of the slave node is in an idle state, when the storage space of the slave node is larger than the data size involved in the task to be processed, the slave node is an available node, thereby determining M available nodes; when the CPU of the slave node is in use, the slave node is an unavailable node.

[0171] It should be noted that when the tasks to be processed do not need to be divided and do not need to collect data, the master node obtains a task to be assigned based on the data involved in the task to be processed, saves the task to be assigned in the second queue, and waits for the master node to assign it to any of the M available nodes.

[0172] In this embodiment, by applying scenario information and distributed mode information, the master node treats the data involved in the task to be processed as a subtask to be processed when the task to be processed does not need to collect data, and automatically selects at least one available node from the distributed cluster for the subtask to be processed, so that the available node can process the subtask to be processed, thereby improving the task processing efficiency.

[0173] Optionally, the master node allocates the subtasks to be processed in a manner including timed allocation or triggered allocation.

[0174] Among them, timing allocation includes:

[0175] The master node periodically queries the task processing table of any pending subtask according to a preset time to obtain a query result;

[0176] Based on the query result, the master node allocates the pending subtasks from the second queue to an available node, and generates a task allocation table for the pending subtasks;

[0177] The available node processes the to-be-processed subtask based on the application scenario information.

[0178] It can be understood that the master node queries the task processing table of any pending subtask at preset time intervals, randomly assigns the pending subtask that is unassigned as a result of the query to an available node, and generates a task allocation table for the pending subtask until all pending subtasks corresponding to the pending task are assigned.

[0179] It should be understood that, since the storage space of each available node is larger than the data size obtained after processing the pending subtasks, each pending subtask can be randomly assigned to any available node.

[0180] It should be noted that the preset time can be customized according to actual needs; for example, the preset time is set to 1s.

[0181] It should be noted that the available nodes process the tasks to be assigned based on the application scenario information, including one of the following:

[0182] When the application scenario information is an external network data interaction scenario, the available nodes can calculate the subtasks to be processed;

[0183] In the case where the application scenario information is a cache scenario of user interaction with an application, the available nodes can calculate the subtasks to be processed;

[0184] When the application scenario information is a data loss prevention and damage prevention scenario, the available nodes may receive data involved in the subtask to be processed.

[0185] When the application scenario information is a data distributed storage scenario, the available nodes receive data involved in the subtask to be processed.

[0186] In one embodiment, when the application scenario information is an external network data interaction scenario, the nodes can be used to calculate the subtasks to be processed.

[0187] In one embodiment, when the application scenario information is a cache scenario of user interaction with an application program, the available nodes may be used to calculate the subtasks to be processed.

[0188] In one embodiment, when the application scenario information is a data loss prevention or damage prevention scenario, the available nodes may receive data related to the subtask to be processed.

[0189] In one embodiment, when the application scenario information is a data distributed storage scenario, the available nodes receive data involved in the subtask to be processed.

[0190] It should be noted that after the master node assigns the subtasks to be processed to the slave nodes, it monitors the task processing status of each slave node. During the task processing process, each slave node maintains real-time communication with the master node and feeds back the subtask processing status to the master node.

[0191] It is understood that having multiple electronic devices jointly process a task can fully utilize the hardware resources of idle electronic devices, accelerate the execution of specific tasks, and utilize the storage of idle electronic devices, thereby achieving the effect of distributed resource utilization. For example, this can be applied to file downloads, data storage, blockchain, or audio and video playback.

[0192] It should be noted that after the available nodes complete the computation of pending subtasks, the resources are released, for example, CPU resources.

[0193] It should be noted that the task allocation table includes the following fields: pending task id field, pending subtask id field, mode id field, scenario id field, operation step list field, available node id field, whether it has been allocated field and allocated node id field.

[0194] Table 2 Fields of the task allocation table and their corresponding meanings

[0195] Field Name Field meaning job_id Pending task id task_id Pending subtask id model_id Mode ID use_case_id Scene ID actions List of steps for the operation available_word_id Available node ids is_distribut Has it been allocated? distribut_id Assigned node id

[0196] Compared to the task processing table, the task assignment table adds a field for the assigned node ID. In the task assignment table, the operation step list records the steps involved in processing the pending task, obtaining the corresponding pending subtasks, and assigning the subtask to one of the available nodes. The assigned node ID indicates the ID of the available node to which the subtask was assigned.

[0197] In this embodiment, by setting a preset time, the main node actively allocates the subtasks to be processed to the available nodes according to the preset time and the task processing table. The available nodes process the subtasks to be processed according to the application scenario information of the tasks to be processed, so that task processing is combined with application scenario information, thereby realizing distributed processing of the same task on electronic devices.

[0198] Triggered allocations include:

[0199] After the subtasks to be processed are saved in the second queue, the master node allocates the subtasks to be processed to available nodes based on the storage order of the subtasks to be processed in the second queue and the task processing table, and generates a task allocation table for each subtask to be processed;

[0200] Each available node processes each to-be-processed subtask based on the application scenario information.

[0201] It can be understood that the master node actively triggers task allocation after all pending subtasks corresponding to the pending task are saved to the second queue, and allocates the pending subtasks in sequence according to the "first in, first out" principle of the queue, randomly allocates each pending subtask to an available node based on the task processing table, and generates a task allocation table for each pending subtask.

[0202] In this embodiment, after the subtask to be processed is saved to the second queue, the main node distributes each subtask to be processed to the available nodes in order according to the task processing table. The available nodes process the subtask according to the application scenario information of the task to be processed, so that the task processing is combined with the application scenario information, thereby realizing distributed processing of the same task on the electronic device.

[0203] The task processing method provided in the embodiment of the present application can be executed by a task processing device. In the embodiment of the present application, the task processing device provided in the embodiment of the present application is described by taking the task processing method executed by the task processing device as an example.

[0204] Figure 6 A structural diagram of a task processing device provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the device includes:

[0205] The request receiving module 601 is configured to enable the electronic device to receive the first request information of the user;

[0206] A first acquisition module 602 is configured to enable the electronic device to obtain a task to be processed in response to the first request information, wherein the electronic device is a node in a constructed distributed cluster, and the distributed cluster is a distributed system constructed based on multiple electronic devices;

[0207] The second acquisition module 603 is configured to enable the master node of the distributed cluster to acquire application scenario information and distribution mode information of the task to be processed;

[0208] The task processing module 604 is configured to enable the master node to process the pending task based on the application scenario information and the distributed mode information.

[0209] Optionally, the device further comprises:

[0210] The cluster building module is used to build the distributed cluster, including:

[0211] a node determination subunit, configured to determine one master node and N-1 slave nodes from N electronic devices that meet a first preset condition, where N is a positive integer and N ≥ 2, and the first preset condition includes at least one of the following: the N electronic devices are in the same network environment, the N electronic devices use the same operating system, and the N electronic devices are connected using TCP;

[0212] The cluster construction subunit is used to construct the electronic device distributed cluster based on the one master node and the N-1 slave nodes.

[0213] Optionally, the master node of the constructed distributed cluster of electronic devices obtains the application scenario information and the distributed mode information of the task to be processed, including:

[0214] In a case where the distributed node is a slave node of the constructed electronic device distributed cluster, the distributed node sends the to-be-processed task to the master node, and the master node receives the to-be-processed task and saves the to-be-processed task to a first queue; or, in a case where the distributed node is a master node of the constructed electronic device distributed cluster, the master node saves the to-be-processed task to the first queue;

[0215] In a case where the task to be processed is the head element of the first queue, the master node obtains application scenario information and distribution mode information of the task to be processed.

[0216] Optionally, the master node processes the to-be-processed task based on the application scenario information and the distributed mode information, including:

[0217] The master node determines whether the to-be-processed task needs to be divided based on the application scenario information and the distributed mode information;

[0218] In the case where the task to be processed needs to be divided, the master node divides the task to be processed into multiple subtasks to be processed, and distributes the multiple subtasks to be processed to the slave nodes of the distributed cluster;

[0219] In the case that the to-be-processed task does not need to be divided, the master node determines an available node that can execute the to-be-processed task and allocates the to-be-processed task to the available node.

[0220] Optionally, when the task to be processed needs to be divided, the master node divides the task to be processed into multiple subtasks to be processed, and distributes the multiple subtasks to be processed to the slave nodes of the distributed cluster, including:

[0221] In the case where the to-be-processed task needs to be divided, the master node determines P available nodes based on the CPU idle states of the N-1 slave nodes and a first constraint condition, wherein the first constraint condition is a constraint condition that maximizes the P value;

[0222] The master node divides the pending task into P pending subtasks, saves the P pending subtasks into a second queue, and generates a task processing table for each pending subtask;

[0223] Based on the task processing table, the master node takes out the P to-be-processed subtasks from the second queue and distributes the P to-be-processed subtasks to the P available nodes, so that the P available nodes process the respectively distributed to-be-processed subtasks;

[0224] Wherein, P is a positive integer, and 1≤P≤N-1, and the allocation method of the master node to allocate the P to-be-processed subtasks includes timed allocation or triggered allocation.

[0225] Optionally, when the task to be processed does not need to be divided, the master node determines an available node that can execute the task to be processed and allocates the task to the available node, including:

[0226] In the case that the task to be processed does not need to be divided, the master node determines whether it is necessary to collect data from N nodes according to the task to be processed;

[0227] In the case where data needs to be collected from N nodes, the master node collects data from the N nodes and integrates the collected data into complete data;

[0228] The master node determines whether the task to be processed involves a designated node and obtains a determination result;

[0229] The master node determines P available nodes based on the judgment result and the complete data, obtains P first subtasks to be processed, saves the P first subtasks to be processed to a second queue, and generates a task processing table for each of the first subtasks to be processed;

[0230] Based on the task processing table, the master node retrieves P first to-be-processed subtasks corresponding to the to-be-processed task from the second queue, and distributes the P first to-be-processed subtasks to the P available nodes, so that the P available nodes process the first to-be-processed subtasks respectively distributed thereto;

[0231] Wherein, P is a positive integer, and 1≤P≤N-1, and the allocation method of the master node to allocate the P first subtasks to be processed includes timed allocation or triggered allocation.

[0232] Optionally, after the master node determines whether the to-be-processed task needs to be divided based on the application scenario information and the distributed mode information, the method further includes:

[0233] In the case that the task to be processed does not need to be divided, the master node determines whether it is necessary to collect data from N nodes according to the task to be processed;

[0234] In the case where data does not need to be collected from N nodes, the master node determines M available nodes based on the data involved in the task to be processed, obtains a second subtask to be processed, saves the second subtask to be processed to a second queue, and generates a task processing table for the second subtask to be processed;

[0235] Based on the task processing table, the master node takes the second to-be-processed subtask from the second queue and distributes the second to-be-processed subtask to a target available node among the M available nodes, so that the target available node processes the second to-be-processed subtask;

[0236] Wherein, M is a positive integer, and 1≤M≤N-1, and the allocation method of the master node to allocate the second to-be-processed subtask includes timed allocation or triggered allocation.

[0237] The task processing device in the embodiment of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or a device other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a mobile Internet device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc. It can also be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., and the embodiment of the present application does not specifically limit it.

[0238] The task processing device provided in the embodiment of the present application can achieve Figures 1 to 5 To avoid repetition, the various processes of implementing the task processing method in the method embodiment will not be described here.

[0239] The task processing device provided in the embodiments of the present application receives user requests through distributed nodes of a distributed cluster of electronic devices to obtain pending tasks. The master node of the distributed cluster of electronic devices obtains application scenario information and distributed mode information of the pending tasks and processes the pending tasks based on the application scenario information and distributed mode information. This implements the distributed utilization of multiple electronic devices, enabling resource scheduling and storage sharing among multiple electronic devices to jointly process a single task, thereby improving resource utilization of idle electronic devices and enhancing task processing efficiency.

[0240] Alternatively, as Figure 7As shown, an embodiment of the present application also provides an electronic device 700, including a processor 701, a memory 702, and a program or instruction stored in the memory 702 and executable on the processor 701. When the program or instruction is executed by the processor 701, each process of the above-mentioned task processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0241] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0242] Figure 8 A schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.

[0243] The electronic device 800 includes but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809 and a processor 810.

[0244] Those skilled in the art will understand that the electronic device 800 may also include a power source (such as a battery) to power each component, and the power source may be logically connected to the processor 810 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system. Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be repeated here.

[0245] The user input unit 807 is used to enable the electronic device to receive the user's first request information;

[0246] Processor 810 is configured to enable the electronic device to obtain a task to be processed in response to the first request information, wherein the electronic device is a node in a constructed distributed cluster, and the distributed cluster is a distributed system constructed based on multiple electronic devices;

[0247] The processor 810 is further configured to enable the master node of the distributed cluster to obtain application scenario information and distribution mode information of the task to be processed;

[0248] The processor 810 is further configured to enable the master node to process the pending task based on the application scenario information and the distributed mode information.

[0249] According to the electronic device provided in the embodiment of the present application, a user request is received through the electronic device of the distributed cluster to obtain the task to be processed. The main node of the distributed cluster obtains the application scenario information and distributed mode information of the task to be processed, and processes the task to be processed based on the application scenario information and the distributed mode information, thereby making full use of idle electronic devices and realizing the function of distributed utilization of multiple electronic devices, so that multiple electronic devices can jointly process a task, thereby improving the resource utilization of idle electronic devices and also improving the task processing efficiency.

[0250] Optionally, the processor 810 is further configured to construct the distributed cluster.

[0251] The constructing of the distributed cluster includes:

[0252] Determining one master node and N-1 slave nodes from N electronic devices that meet a first preset condition, where N is a positive integer and N ≥ 2, and the first preset condition includes at least one of the following: the N electronic devices are in the same network environment, the N electronic devices use the same operating system, and the N electronic devices are connected using TCP;

[0253] The electronic device distributed cluster is constructed based on the one master node and the N-1 slave nodes.

[0254] Optionally, the processor 810 is further configured to, when the distributed node is a slave node of the constructed electronic device distributed cluster, send the to-be-processed task to the master node, and the master node receives the to-be-processed task and saves the to-be-processed task to the first queue; or, when the distributed node is the master node of the constructed electronic device distributed cluster, save the to-be-processed task to the first queue;

[0255] In a case where the task to be processed is the head element of the first queue, the master node obtains application scenario information and distribution mode information of the task to be processed.

[0256] Optionally, the processor 810 is further configured to enable the master node to determine whether the to-be-processed task needs to be divided based on the application scenario information and the distributed mode information;

[0257] In the case where the task to be processed needs to be divided, the master node divides the task to be processed into multiple subtasks to be processed, and distributes the multiple subtasks to be processed to the slave nodes of the distributed cluster;

[0258] In the case that the to-be-processed task does not need to be divided, the master node determines an available node that can execute the to-be-processed task and allocates the to-be-processed task to the available node.

[0259] Optionally, the processor 810 is further configured to, when the to-be-processed task needs to be divided, cause the master node to determine P available nodes based on the CPU idle states of the N-1 slave nodes and a first constraint, where the first constraint is a constraint that maximizes the P value;

[0260] The master node divides the pending task into P pending subtasks, saves the P pending subtasks into a second queue, and generates a task processing table for each pending subtask;

[0261] Based on the task processing table, the master node takes out the P to-be-processed subtasks from the second queue and distributes the P to-be-processed subtasks to the P available nodes, so that the P available nodes process the respectively distributed to-be-processed subtasks;

[0262] Wherein, P is a positive integer, and 1≤P≤N-1, and the allocation method of the master node to allocate the P to-be-processed subtasks includes timed allocation or triggered allocation.

[0263] Optionally, the processor 810 is further configured to, when the task to be processed does not need to be divided, enable the master node to determine whether it is necessary to collect data from N nodes according to the task to be processed;

[0264] In the case where data needs to be collected from N nodes, the master node collects data from the N nodes and integrates the collected data into complete data;

[0265] The master node determines whether the task to be processed involves a designated node and obtains a determination result;

[0266] The master node determines P available nodes based on the judgment result and the complete data, obtains P first subtasks to be processed, saves the P first subtasks to be processed to a second queue, and generates a task processing table for each of the first subtasks to be processed;

[0267] Based on the task processing table, the master node retrieves P first to-be-processed subtasks corresponding to the to-be-processed task from the second queue, and distributes the P first to-be-processed subtasks to the P available nodes, so that the P available nodes process the first to-be-processed subtasks respectively distributed thereto;

[0268] Wherein, P is a positive integer, and 1≤P≤N-1, and the allocation method of the master node to allocate the P first subtasks to be processed includes timed allocation or triggered allocation.

[0269] Optionally, the processor 810 is further configured to, when the task to be processed does not need to be divided, enable the master node to determine whether it is necessary to collect data from N nodes according to the task to be processed;

[0270] In the case where data does not need to be collected from N nodes, the master node determines M available nodes based on the data involved in the task to be processed, obtains a second subtask to be processed, saves the second subtask to be processed to a second queue, and generates a task processing table for the second subtask to be processed;

[0271] Based on the task processing table, the master node takes the second to-be-processed subtask from the second queue and distributes the second to-be-processed subtask to a target available node among the M available nodes, so that the target available node processes the second to-be-processed subtask;

[0272] Wherein, M is a positive integer and 1≤M≤N-1. The master node allocates the second subtask to be processed in a manner including timed allocation or triggered allocation.

[0273] It should be understood that in an embodiment of the present application, the input unit 804 may include a graphics processing unit (GPU) 8041 and a microphone 8042, and the graphics processor 8041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 806 may include a display panel 8061, and the display panel 8061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 807 includes a touch panel 8071 and at least one of other input devices 8072. The touch panel 8071 is also called a touch screen. The touch panel 8071 may include two parts: a touch detection device and a touch controller. Other input devices 8072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0274] The memory 809 can be used to store software programs and various data. The memory 809 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 809 may include a volatile memory or a non-volatile memory, or the memory 809 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The memory 809 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0275] Processor 810 may include one or more processing units. Optionally, processor 810 integrates an application processor and a modem processor. The application processor primarily handles operations related to the operating system, user interface, and application programs, while the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into processor 810.

[0276] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned task processing method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0277] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0278] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned task processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0279] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0280] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0281] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0282] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. A task processing method, characterized in that: include: The electronic device receives first request information from the user; The electronic device obtains a task to be processed in response to the first request information, wherein the electronic device is a node in a constructed distributed cluster, and the distributed cluster is a distributed system constructed based on multiple electronic devices; The master node of the distributed cluster obtains the application scenario information and distributed mode information of the task to be processed; each application scenario information corresponds to a scenario ID; each distributed mode information corresponds to a mode ID; The master node processes the pending task based on the application scenario information and the distributed mode information, including: the master node determines whether the pending task needs to be divided based on the application scenario information and the distributed mode information; if the pending task needs to be divided, the master node divides the pending task into multiple pending subtasks and distributes the multiple pending subtasks to the slave nodes of the distributed cluster; if the pending task does not need to be divided, the master node determines an available node that can execute the pending task and distributes the pending task to the available node; The master node determines whether the task to be processed needs to be divided based on the application scenario information and the distributed mode information, including: when the distributed mode information is a manual mode or an anti-loss mode, determining that the task to be processed does not need to be divided; when the distributed mode information is a normal mode, determining whether the task to be processed needs to be divided in combination with the application scenario information, and when the application scenario information is a data loss and damage prevention scenario or a distributed data collection scenario, determining that the task to be processed does not need to be divided; The normal mode is a mode in which the pending task is divided into multiple subtasks and processed separately; the manual mode is a mode in which storage and calculation operations are performed by a designated electronic device, and the data obtained after the pending task is processed is stored in the designated electronic device; the anti-loss mode is a mode in which the data obtained after the pending task is processed is completely stored in multiple electronic devices.

2. The task processing method according to claim 1, characterized in that: The method further includes constructing the distributed cluster, The constructing of the distributed cluster includes: Determine one master node and N-1 slave nodes from N electronic devices that meet a first preset condition, where N is a positive integer and N ≥ 2, and the first preset condition includes at least one of the following: the N electronic devices are in the same network environment, the N electronic devices use the same operating system, and the N electronic devices are connected using TCP; The electronic device distributed cluster is constructed based on the one master node and the N-1 slave nodes.

3. The task processing method according to claim 1, characterized in that: The master node of the distributed cluster obtains application scenario information and distribution mode information of the task to be processed, including: In a case where the electronic device is a slave node of the constructed distributed cluster, the electronic device sends the to-be-processed task to the master node, and the master node receives the to-be-processed task and saves the to-be-processed task to a first queue; or, in a case where the electronic device is a master node of the constructed distributed cluster, the master node saves the to-be-processed task to the first queue; In a case where the task to be processed is the head element of the first queue, the master node obtains application scenario information and distribution mode information of the task to be processed.

4. The task processing method according to claim 1, characterized in that: When the task to be processed needs to be divided, the master node divides the task to be processed into multiple subtasks to be processed, and distributes the multiple subtasks to be processed to the slave nodes of the distributed cluster, including: In the case where the to-be-processed task needs to be divided, the master node determines P available nodes based on the CPU idle states of the N-1 slave nodes and a first constraint condition, wherein the first constraint condition is a constraint condition that maximizes the P value; The master node divides the pending task into P pending subtasks, saves the P pending subtasks into a second queue, and generates a task processing table for each pending subtask; Based on the task processing table, the master node takes out the P to-be-processed subtasks from the second queue and distributes the P to-be-processed subtasks to the P available nodes, so that the P available nodes process the respectively distributed to-be-processed subtasks; Wherein, P is a positive integer, and 1≤P≤N-1, and the allocation method of the master node to allocate the P to-be-processed subtasks includes timed allocation or triggered allocation.

5. The task processing method according to claim 1, characterized in that: When the to-be-processed task does not need to be divided, the master node determines an available node capable of executing the to-be-processed task and allocates the to-be-processed task to the available node, including: In the case that the task to be processed does not need to be divided, the master node determines whether it is necessary to collect data from N nodes according to the task to be processed; In the case where data needs to be collected from N nodes, the master node collects data from the N nodes and integrates the collected data into complete data; The master node determines whether the task to be processed involves a designated node and obtains a determination result; The master node determines P available nodes based on the judgment result and the complete data, obtains P first subtasks to be processed, saves the P first subtasks to be processed to a second queue, and generates a task processing table for each of the first subtasks to be processed; Based on the task processing table, the master node takes out P first to-be-processed subtasks corresponding to the to-be-processed task from the second queue, and distributes the P first to-be-processed subtasks to the P available nodes, so that the P available nodes process the first to-be-processed subtasks respectively distributed thereto; Wherein, P is a positive integer, and 1≤P≤N-1, and the allocation method of the master node to allocate the P first subtasks to be processed includes timed allocation or triggered allocation.

6. A task processing device, characterized in that: include: A request receiving module, configured to enable the electronic device to receive first request information from a user; a first acquisition module, configured to enable the electronic device to obtain a task to be processed in response to the first request information, wherein the electronic device is a node in a constructed distributed cluster, and the distributed cluster is a distributed system constructed based on multiple electronic devices; A second acquisition module is configured to enable the master node of the distributed cluster to acquire application scenario information and distributed mode information of the task to be processed; each application scenario information corresponds to a scenario ID; each distributed mode information corresponds to a mode ID; The task processing module is used to enable the master node to process the pending task based on the application scenario information and the distributed mode information, including: the master node determines whether the pending task needs to be divided based on the application scenario information and the distributed mode information; if the pending task needs to be divided, the master node divides the pending task into multiple pending subtasks and distributes the multiple pending subtasks to the slave nodes of the distributed cluster; if the pending task does not need to be divided, the master node determines an available node that can execute the pending task and distributes the pending task to the available node; The master node determines whether the task to be processed needs to be divided based on the application scenario information and the distributed mode information, including: when the distributed mode information is a manual mode or an anti-loss mode, determining that the task to be processed does not need to be divided; when the distributed mode information is a normal mode, determining whether the task to be processed needs to be divided in combination with the application scenario information, and when the application scenario information is a data loss and damage prevention scenario or a distributed data collection scenario, determining that the task to be processed does not need to be divided; The normal mode is a mode in which the pending task is divided into multiple subtasks and processed separately; the manual mode is a mode in which storage and calculation operations are performed by a designated electronic device, and the data obtained after the pending task is processed is stored in the designated electronic device; the anti-loss mode is a mode in which the data obtained after the pending task is processed is completely stored in multiple electronic devices.

7. The task processing device according to claim 6, characterized in that: The device also includes a cluster building module for building the distributed cluster. The constructing of the distributed cluster includes: Determine one master node and N-1 slave nodes from N electronic devices that meet a first preset condition, where N is a positive integer and N ≥ 2, and the first preset condition includes at least one of the following: the N electronic devices are in the same network environment, the N electronic devices use the same operating system, and the N electronic devices are connected using TCP; The electronic device distributed cluster is constructed based on the one master node and the N-1 slave nodes.

8. The task processing device according to claim 6, characterized in that: The master node of the distributed cluster obtains application scenario information and distribution mode information of the task to be processed, including: In a case where the electronic device is a slave node of the constructed distributed cluster, the electronic device sends the to-be-processed task to the master node, and the master node receives the to-be-processed task and saves the to-be-processed task to a first queue; or, in a case where the electronic device is a master node of the constructed distributed cluster, the master node saves the to-be-processed task to the first queue; In a case where the task to be processed is the head element of the first queue, the master node obtains application scenario information and distribution mode information of the task to be processed.

9. The task processing device according to claim 6, characterized in that: When the task to be processed needs to be divided, the master node divides the task to be processed into multiple subtasks to be processed, and distributes the multiple subtasks to be processed to the slave nodes of the distributed cluster, including: In the case where the to-be-processed task needs to be divided, the master node determines P available nodes based on the CPU idle states of the N-1 slave nodes and a first constraint condition, wherein the first constraint condition is a constraint condition that maximizes the P value; The master node divides the pending task into P pending subtasks, saves the P pending subtasks into a second queue, and generates a task processing table for each pending subtask; Based on the task processing table, the master node takes out the P to-be-processed subtasks from the second queue and distributes the P to-be-processed subtasks to the P available nodes, so that the P available nodes process the respectively distributed to-be-processed subtasks; Wherein, P is a positive integer, and 1≤P≤N-1, and the allocation method of the master node to allocate the P to-be-processed subtasks includes timed allocation or triggered allocation.

10. The task processing device according to claim 6, characterized in that: When the to-be-processed task does not need to be divided, the master node determines an available node capable of executing the to-be-processed task and allocates the to-be-processed task to the available node, including: In the case that the task to be processed does not need to be divided, the master node determines whether it is necessary to collect data from N nodes according to the task to be processed; In the case where data needs to be collected from N nodes, the master node collects data from the N nodes and integrates the collected data into complete data; The master node determines whether the task to be processed involves a designated node and obtains a determination result; The master node determines P available nodes based on the judgment result and the complete data, obtains P first subtasks to be processed, saves the P first subtasks to be processed to a second queue, and generates a task processing table for each of the first subtasks to be processed; Based on the task processing table, the master node takes out P first to-be-processed subtasks corresponding to the to-be-processed task from the second queue, and distributes the P first to-be-processed subtasks to the P available nodes, so that the P available nodes process the first to-be-processed subtasks respectively distributed thereto; Wherein, P is a positive integer, and 1≤P≤N-1, and the allocation method of the master node to allocate the P first subtasks to be processed includes timed allocation or triggered allocation.

Citation Information

Patent Citations

  • Task processing method and device for terminal cooperation and electronic equipment

    CN109992387A