A file processing method and cluster system
Through consistent hashing algorithm and hash value sorting, the problems of resource waste and speed impact in cloud platform file processing services are solved, ensuring that each file is uniquely processed in different container groups, improving system resource utilization and file processing speed. .
Patent Information
- Application Number
- CN202210422291.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-04-21
AI Technical Summary
The cloud platform lacks a load balancing strategy for file processing services. As a result, applications deployed in different containers may access and process the same files at the same time, resulting in a waste of resources and an impact on file processing speed.
Use a consistent hash algorithm to calculate the hash value of the container group, determine the effective container group, and allocate files to the corresponding container group by sorting the hash value range to ensure that each file is processed in a different container group to avoid conflicts and improve Resource utilization and processing speed.
It achieves unique processing of each file, improves system resource utilization and file processing speed, and avoids resource waste and load balancing problems.
Smart Images

Figure CN114780487B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a file processing method and a cluster system. Background Art
[0002] As cloud platforms can support rapid deployment of applications and provide various resources required by applications on demand according to user needs and application load, more and more enterprises are deploying applications on cloud platforms. For WebService services, cloud platforms provide load balancing strategies so that different containers providing the same service can respond to different user requests.
[0003] However, for file processing services, the cloud platform does not provide a load balancing strategy similar to the WebService service, which means that applications deployed in different containers may access and process files in a directory at the same time, leading to the problem of repeated processing of the same file, causing a waste of system resources, increasing the burden on the database server, and affecting the file processing speed. Summary of the invention
[0004] This application provides the following technical solutions:
[0005] On one hand, the present application provides a file processing method, comprising:
[0006] The first container group obtains first information of the first container group and second information of at least one second container group from a database, wherein the first information at least includes a hash value of the first container group, and the second information at least includes a hash value of the second container group, and the hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application;
[0007] The first container group determines at least one valid container group from the first container group and at least one second container group based on the first information and the second information of at least one second container group;
[0008] The first container group sorts the hash value of at least one of the valid container groups, and uses the hash value range between the hash values of every two adjacent valid container groups as the target file hash value range;
[0009] The first container group reads at least one file from the to-be-processed file directory, and calculates a hash value of the file using the consistent hash algorithm;
[0010] If the hash value of the file is within the target file hash value range, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups;
[0011] Among them, searching in a clockwise direction, the position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is located before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
[0012] Optionally, the first information further includes: the registration time and the number of task scheduling of the first container group, and the second information further includes: the registration time and the number of task scheduling of the second container group;
[0013] The first container group determines at least one valid container group from the first container group and at least one second container group based on the first information and the first information of at least one second container group, including:
[0014] The first container group searches for a container group whose difference between the registration time and the current time is within a set threshold range from the first container group and at least one of the second container groups;
[0015] From the container groups whose difference between the registration time and the current time is within a set threshold range, find the container group whose task scheduling times are within an expected value range, and use the found container group as a valid container group.
[0016] Optionally, the method further includes:
[0017] The first container group updates the registration time of the first container group in the database to the current time, and updates the task scheduling number of the first container group in the database to the sum of the task scheduling number of the first container group and 1.
[0018] Optionally, the method further includes:
[0019] The scheduling node in the cluster to which the first container group and at least one of the second container groups belong responds to the new deployment request of the application, and adds the third container group to the cluster to which the first container group and at least one of the second container groups belong;
[0020] The third container group writes its third information into the database, where the third information at least includes: an identifier of the third container group, a hash value, a registration interval, and a task scheduling frequency, and the hash value of the third container group is calculated based on the consistent hashing algorithm on the identifier of the third container group.
[0021] Optionally, the method further includes:
[0022] A scheduling node in the cluster to which the first container group and at least one of the second container groups belong, after at least one of the first container group and at least one of the second container groups is deleted, deletes information of the deleted container group from the database.
[0023] On the other hand, the present application provides a file processing cluster system, including: a first container group, at least one second container group and a scheduling node;
[0024] The first container group is used for:
[0025] Acquire first information of the first container group and second information of at least one second container group from a database, wherein the first information at least includes a hash value of the first container group, and the second information at least includes a hash value of the second container group, the hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application;
[0026] determining at least one valid container group from the first container group and at least one second container group based on the first information and second information of at least one second container group;
[0027] By sorting the hash values of at least one of the valid container groups, a hash value range between the hash values of every two adjacent valid container groups is used as a target file hash value range;
[0028] Read at least one file from the to-be-processed file directory, and calculate the hash value of the file using the consistent hash algorithm;
[0029] If the hash value of the file is within the target file hash value range, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups;
[0030] Among them, searching in a clockwise direction, the position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is located before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
[0031] Optionally, the first information further includes: the registration time and the number of task scheduling of the first container group, and the second information further includes: the registration time and the number of task scheduling of the second container group;
[0032] The first container group can be specifically used for:
[0033] Searching, from the first container group and at least one of the second container groups, a container group whose difference between the registration time and the current time is within a set threshold range;
[0034] From the container groups whose difference between the registration time and the current time is within a set threshold range, find the container group whose task scheduling times are within an expected value range, and use the found container group as a valid container group.
[0035] Optionally, the first container group is further used to update the registration time of the first container group in the database to the current time, and update the task scheduling number of the first container group in the database to the sum of the task scheduling number of the first container group and 1.
[0036] Optionally, the scheduling node is configured to respond to a new deployment request of the application and add a third container group to the cluster to which the first container group and at least one of the second container groups belong;
[0037] The third container group is used to write its third information into the database, where the third information at least includes: an identifier of the third container group, a hash value, a registration interval, and a task scheduling number, and the hash value of the third container group is calculated based on the consistent hashing algorithm on the identifier of the third container group.
[0038] Optionally, the scheduling node is further used to:
[0039] After at least one container group among the first container group and at least one of the second container groups is deleted, information of the deleted container group is deleted from the database.
[0040] In the present application, the first container group obtains first information of the first container group and second information of at least one second container group from a database, and the hash value of the first container group in the first information and the second hash value of the second container group in the second information are respectively calculated based on the consistent hashing algorithm to obtain the identifier of the first container group and the identifier of the second container group. The first container group determines at least one valid container group from the first container group and the at least one second container group based on the first information and the second information of the at least one second container group. The first container group sorts the hash values of at least one of the valid container groups, and uses the hash value range between the hash values of each two adjacent valid container groups as the target file hash value range, so as to ensure that each target file The hash value ranges of the files do not conflict with each other. On this basis, the first container group reads at least one file from the to-be-processed file directory, and uses the consistent hash algorithm to calculate the hash value of the file. If the hash value of the file is within the hash value range of the target file, the file is used as the to-be-processed file of the target valid container group in every two adjacent valid container groups, and is searched in a clockwise direction. The position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm, so that the to-be-processed files of each valid container group are different, thereby achieving the purpose of improving the utilization of system resources and improving the file processing speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0042] Figure 1 It is a flowchart of a file processing method provided in Example 1 of the present application;
[0043] Figure 2 This is a schematic diagram of a distribution scenario of a hash value of a container group provided by this application;
[0044] Figure 3 This is a schematic diagram of a distribution scenario of hash values of a container group and a file provided by the present application;
[0045] Figure 4 It is a flowchart of a file processing method provided in Example 2 of the present application;
[0046] Figure 5 It is a flowchart of a file processing method provided in Example 3 of the present application;
[0047] Figure 6 It is a flowchart of a file processing method provided in Example 4 of the present application. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only 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 without creative work are within the scope of protection of this application.
[0049] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0050] Reference Figure 1 , is a flowchart of a file processing method provided in Example 1 of the present application, such as Figure 1 As shown, the method may include but is not limited to the following steps:
[0051] Step S11: The first container group obtains first information of the first container group and second information of at least one second container group from a database.
[0052] The first information includes at least a hash value of the first container group, and the second information includes at least a hash value of the second container group, the hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application.
[0053] The first container group may include one or more first containers; the second container group may include one or more second containers.
[0054] In this embodiment, the first container group may be, but is not limited to, one of the container groups in Kubernetes, and the second container group is a container group in Kubernetes that is different from the first container group.
[0055] Correspondingly, the first container group can be the first Pod, and the second container group can be the second Pod. Kubernetes can be understood as: open source, used to manage containerized applications on multiple hosts in the cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and efficient. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance. Pod can be understood as the smallest and simplest unit that can be created and deployed in Kubernetes. A Pod represents a process running in a cluster. Pod represents a unit of deployment, an instance of an application in Kubernetes, which may be composed of one or more containers combined to share resources.
[0056] In this embodiment, the process of calculating the identifier of the first container group based on the consistent hashing algorithm to obtain the hash value of the first container group may include:
[0057] Through the relationship i = hash(s i )%2 ^32 (i=1, 2... or n), calculate the hash value of the first container group;
[0058] key i Indicates the hash value of the first container group, s i Indicates the identifier of the first container group.
[0059] The identifier of the first container group may be, but is not limited to, an IP address of the first container group.
[0060] The process of calculating the identifier of the second container group based on the consistent hashing algorithm to obtain the hash value of the second container group may include:
[0061] Through relational binary key j = hash(s j )%2 ^32 (j=1,2...n), calculate the hash value of the second container group;
[0062] j is different from i, key j Indicates the hash value of the second container group, s j Indicates the identifier of the second container group.
[0063] The hash value of the first container group and the hash value of the second container group can be organized into a virtual ring space, such as Figure 2 As shown, the hash value of the first container group and the hash value of the second container group are located at different positions in the virtual annular space. Figure 2Wherein h1 is the hash value of the first container group identified as s1, h2 is the hash value of the second container group identified as s2, and h3 is the hash value of the second container group identified as s3.
[0064] It should be noted that Figure 2 This is only one example of mapping the hash value of the first container group and the hash value of the second container group into the virtual annular space, and is not intended to limit the locations where the hash value of the first container group and the hash value of the second container group are mapped into the virtual annular space.
[0065] Step S12: The first container group determines at least one valid container group from the first container group and at least one second container group based on the first information and the second information of at least one second container group.
[0066] In this embodiment, the first information may further include: the registration time and the number of task scheduling of the first container group; the second information may further include: the registration time and the number of task scheduling of the second container group.
[0067] This step may include but is not limited to:
[0068] S121: The first container group searches for a container group whose difference between the registration time and the current time is within a set threshold range from the first container group and at least one of the second container groups, and uses the searched container group as a valid container group.
[0069] Alternatively, this step may include but is not limited to:
[0070] S122: The first container group searches for a container group whose difference between the registration time and the current time is within a set threshold range from the first container group and at least one of the second container groups.
[0071] The threshold range can be set as needed and is not limited in this application.
[0072] Step S123: Searching for a container group whose task scheduling times are within an expected range from the container groups whose difference between the registration time and the current time is within a set threshold range, and taking the found container group as a valid container group.
[0073] In this embodiment, the expected value range corresponding to the first container group setting may be different from the expected value range corresponding to the second container group setting. Specifically, the expected value range corresponding to the first container group setting may be (0, +∞), and the expected value range corresponding to the second container group setting may be [0, +∞).
[0074] Accordingly, searching for a container group whose task scheduling times are within an expected value range from the container groups whose difference between the registration time and the current time is within a set threshold range, and using the found container group as a valid container group may include:
[0075] From the container groups whose difference between the registration time and the current time is within the set threshold range, search for the first container group whose task scheduling times are within (0, +∞) and the second container group whose task scheduling times are within [0, +∞). If found, the first container group whose task scheduling times are within (0, +∞) and the second container group whose task scheduling times are within [0, +∞) are respectively used as valid container groups.
[0076] Step S13: The first container group sorts the hash value of at least one of the valid container groups, and uses the hash value range between the hash values of every two adjacent valid container groups as the target file hash value range.
[0077] In this embodiment, the hash values of at least one of the valid container groups are sorted. The hash values of at least one of the valid container groups may be sorted in ascending order of the hash values, or the hash values of at least one of the valid container groups may be sorted in descending order of the hash values.
[0078] Step S14: The first container group reads at least one file from the to-be-processed file directory, and calculates a hash value of the file using the consistent hashing algorithm.
[0079] In this embodiment, calculating the hash value of the file using the consistent hashing algorithm may include:
[0080] Using the relationship three j =hash(name j )%2 ^32 , calculating a hash value of the file;
[0081] f j Indicates the hash value of the file, name j Indicates the file name of the file.
[0082] The pending file directory may be, but is not limited to: a pending file directory in the Pass cloud platform.
[0083] Step S15: If the hash value of the file is within the range of the target file hash value, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups, and the search is performed in a clockwise direction. The position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
[0084] The range of hash values of the files to be processed in the target valid container group can be expressed as:
[0085]
[0086] Where L i Indicates the range of files to be processed in the target valid container group, h i Indicates the hash value of the target valid container group, h i-1 represents the hash value of each adjacent valid container group except the target valid container group, f j Represents the hash value of the file.
[0087] It should be noted that the hash values of the first container group, the second container group and the file are calculated by the consistent hashing algorithm and mapped to the virtual annular space, 0 and 2 32 -1 coincides with the zero point of the virtual annular space. Accordingly, the hash value is 2 32 The position of the container group with a hash value of -1 in the virtual annular space is the same as the position of the container group with a hash value of 0 in the virtual annular space.
[0088] For example, corresponding to Figure 2 The hash value of the container group shown, such as Figure 3 As shown, if the hash value f2 of the file is between h1 and h2, the file to which f2 belongs is the to-be-processed file of the second container group identified as s2 to which h2 belongs; if the hash value f m Between h2 and h3, then f m The file to which f1 belongs is a to-be-processed file of the second container group identified as s3 to which h3 belongs; if the hash value f1 of the file is between h3 and h1, the file to which f1 belongs is a to-be-processed file of the first container group identified as s1 to which h1 belongs.
[0089] The first container group can execute the file processing file regularly, that is, the above steps S11-S15, to achieve regular file processing.
[0090] In this embodiment, the first container group obtains first information of the first container group and second information of at least one second container group from a database, and the hash value of the first container group in the first information and the second hash value of the second container group in the second information are respectively calculated based on the consistent hash algorithm to obtain the identifier of the first container group and the identifier of the second container group. The first container group determines at least one valid container group from the first container group and the at least one second container group based on the first information and the second information of the at least one second container group. The first container group sorts the hash values of at least one of the valid container groups, and uses the hash value range between the hash values of each two adjacent valid container groups as the target file hash value range, thereby ensuring that each target file The hash value ranges of the files do not conflict with each other. On this basis, the first container group reads at least one file from the to-be-processed file directory, and uses the consistent hash algorithm to calculate the hash value of the file. If the hash value of the file is within the hash value range of the target file, the file is used as the to-be-processed file of the target valid container group in every two adjacent valid container groups, and is searched in a clockwise direction. The position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm, so that the to-be-processed files of each valid container group are different, thereby achieving the purpose of improving the utilization of system resources and improving the file processing speed.
[0091] As another optional embodiment of the present application, refer to Figure 4 , is a flow chart of a file processing method embodiment 2 provided by the present application, the method may include but is not limited to the following steps:
[0092] Step S21: The first container group obtains first information of the first container group and second information of at least one second container group from a database.
[0093] The first information includes at least a hash value of the first container group, and the second information includes at least a hash value of the second container group, the hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application.
[0094] Step S22: The first container group determines at least one valid container group from the first container group and at least one second container group based on the first information and the second information of at least one second container group.
[0095] Step S23: The first container group sorts the hash value of at least one of the valid container groups, and uses the hash value range between the hash values of every two adjacent valid container groups as the target file hash value range.
[0096] Step S24: The first container group reads at least one file from the to-be-processed file directory, and calculates a hash value of the file using the consistent hashing algorithm.
[0097] Step S25: If the hash value of the file is within the target file hash value range, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups.
[0098] Among them, searching in a clockwise direction, the position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is located before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
[0099] The detailed process of steps S21-S25 can refer to the relevant introduction of steps S11-S15 in Example 1, which will not be repeated here.
[0100] Step S26: The first container group updates the registration time of the first container group in the database to the current time, and updates the task scheduling number of the first container group in the database to the sum of the task scheduling number of the first container group and 1.
[0101] In the present application, the first container group obtains first information of the first container group and second information of at least one second container group from a database, and the hash value of the first container group in the first information and the second hash value of the second container group in the second information are respectively calculated based on the consistent hashing algorithm to obtain the identifier of the first container group and the identifier of the second container group. The first container group determines at least one valid container group from the first container group and the at least one second container group based on the first information and the second information of the at least one second container group. The first container group sorts the hash values of at least one of the valid container groups, and uses the hash value range between the hash values of each two adjacent valid container groups as the target file hash value range, so as to ensure that each target file The hash value ranges of the files do not conflict with each other. On this basis, the first container group reads at least one file from the to-be-processed file directory, and uses the consistent hash algorithm to calculate the hash value of the file. If the hash value of the file is within the hash value range of the target file, the file is used as the to-be-processed file of the target valid container group in every two adjacent valid container groups, and is searched in a clockwise direction. The position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm, so that the to-be-processed files of each valid container group are different, thereby achieving the purpose of improving the utilization of system resources and improving the file processing speed.
[0102] Furthermore, after obtaining the file to be processed, the first container group may update the first information of the first container group in the database to ensure the accuracy of subsequent file processing.
[0103] As another optional embodiment of the present application, refer to Figure 3 , is a flowchart of Example 3 of a file processing method provided by the present application, and the method may include but is not limited to the following steps:
[0104] Step S31: The first container group obtains first information of the first container group and second information of at least one second container group from a database, where the first information at least includes a hash value of the first container group, and the second information at least includes a hash value of the second container group. The hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application.
[0105] Step S32: The first container group determines at least one valid container group from the first container group and at least one second container group based on the first information and the second information of at least one second container group.
[0106] Step S33: The first container group sorts the hash value of at least one of the valid container groups, and uses the hash value range between the hash values of every two adjacent valid container groups as the target file hash value range.
[0107] Step S34: The first container group reads at least one file from the to-be-processed file directory, and calculates a hash value of the file using the consistent hashing algorithm.
[0108] Step S35: If the hash value of the file is within the target file hash value range, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups.
[0109] Among them, searching in a clockwise direction, the position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is located before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
[0110] The detailed process of steps S31-S35 can refer to the relevant introduction of steps S11-S15 in Example 1, which will not be repeated here.
[0111] Step S36: The scheduling node in the cluster to which the first container group and at least one of the second container groups belong responds to the new deployment request of the application and adds the third container group to the cluster to which the first container group and at least one of the second container groups belong.
[0112] Step S37: The third container group writes its third information into the database, where the third information at least includes: an identifier of the third container group, a hash value, a registration interval, and a task scheduling number, and the hash value of the third container group is calculated based on the consistent hashing algorithm on the identifier of the third container group.
[0113] In this embodiment, a new third container group may be deployed for the application, and the third information of the third container group may be written into the database to ensure the accuracy of subsequent file processing.
[0114] As another optional embodiment of the present application, refer to Figure 4 , is a flow chart of a file processing method embodiment 4 provided in the present application, the method may include but is not limited to the following steps:
[0115] Step S41: The first container group obtains first information of the first container group and second information of at least one second container group from a database.
[0116] The first information includes at least a hash value of the first container group, and the second information includes at least a hash value of the second container group, the hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application.
[0117] Step S42: The first container group determines at least one valid container group from the first container group and at least one second container group based on the first information and the second information of at least one second container group.
[0118] Step S43: The first container group sorts the hash value of at least one of the valid container groups, and uses the hash value range between the hash values of every two adjacent valid container groups as the target file hash value range.
[0119] Step S34: The first container group reads at least one file from the to-be-processed file directory, and calculates a hash value of the file using the consistent hashing algorithm.
[0120] Step S45: If the hash value of the file is within the target file hash value range, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups.
[0121] Among them, searching in a clockwise direction, the position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is located before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
[0122] The detailed process of steps S41-S45 can refer to the relevant introduction of steps S11-S15 in Example 1, which will not be repeated here.
[0123] Step S46: The scheduling node in the cluster to which the first container group and at least one of the second container groups belong, after at least one of the first container group and at least one of the second container groups is deleted, deletes information of the deleted container group from the database.
[0124] In this embodiment, after a container group is deleted, its registration time and task scheduling times are no longer changed. After at least one container group among the first container group and at least one of the second container groups is deleted, the scheduling node in the cluster to which the first container group and at least one of the second container groups belong deletes information of the deleted container group from the database, thereby saving database space and reducing the determination time of valid container groups.
[0125] Next, a file processing cluster system provided by the present application is introduced. The file processing cluster system introduced below and the file processing method introduced above can be referenced to each other.
[0126] The file processing cluster system may include: a first container group, at least one second container group and a scheduling node;
[0127] The first container group is used for:
[0128] Acquire first information of the first container group and second information of at least one second container group from a database, wherein the first information at least includes a hash value of the first container group, and the second information at least includes a hash value of the second container group, the hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application;
[0129] determining at least one valid container group from the first container group and at least one second container group based on the first information and second information of at least one second container group;
[0130] By sorting the hash values of at least one of the valid container groups, a hash value range between the hash values of every two adjacent valid container groups is used as a target file hash value range;
[0131] Read at least one file from the to-be-processed file directory, and calculate the hash value of the file using the consistent hash algorithm;
[0132] If the hash value of the file is within the target file hash value range, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups;
[0133] Among them, searching in a clockwise direction, the position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is located before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
[0134] In this embodiment, the first information further includes: the registration time and task scheduling number of the first container group, and the second information further includes: the registration time and task scheduling number of the second container group;
[0135] The first container group can be specifically used for:
[0136] Searching, from the first container group and at least one of the second container groups, a container group whose difference between the registration time and the current time is within a set threshold range;
[0137] From the container groups whose difference between the registration time and the current time is within a set threshold range, find the container group whose task scheduling times are within an expected value range, and use the found container group as a valid container group.
[0138] In this embodiment, the first container group is further used to update the registration time of the first container group in the database to the current time, and update the task scheduling number of the first container group in the database to the sum of the task scheduling number of the first container group and 1.
[0139] In this embodiment, the scheduling node is used to respond to the new deployment request of the application and add the third container group to the cluster to which the first container group and at least one of the second container groups belong;
[0140] The third container group is used to write its third information into the database, where the third information at least includes: an identifier of the third container group, a hash value, a registration interval, and a task scheduling number, and the hash value of the third container group is calculated based on the consistent hashing algorithm on the identifier of the third container group.
[0141] In this embodiment, the scheduling node is also used for:
[0142] After at least one container group among the first container group and at least one of the second container groups is deleted, information of the deleted container group is deleted from the database.
[0143] It should be noted that each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0144] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including 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, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0145] For the convenience of description, the above device is described in terms of functions divided into various modules. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0146] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0147] The above is a detailed introduction to a file processing method and a cluster system provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A file processing method, characterized in that: include: The first container group obtains first information of the first container group and second information of at least one second container group from a database, wherein the first information at least includes a hash value of the first container group, and the second information at least includes a hash value of the second container group, and the hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application; The first container group determines at least one valid container group from the first container group and at least one second container group based on the first information and the second information of at least one second container group; The first container group sorts the hash value of at least one of the valid container groups, and uses the hash value range between the hash values of every two adjacent valid container groups as the target file hash value range; The first container group reads at least one file from the to-be-processed file directory, and calculates a hash value of the file using the consistent hash algorithm; If the hash value of the file is within the target file hash value range, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups; Among them, searching in a clockwise direction, the position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is located before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
2. The method according to claim 1, characterized in that The first information further includes: the registration time and task scheduling number of the first container group; the second information further includes: the registration time and task scheduling number of the second container group; The first container group determines at least one valid container group from the first container group and at least one second container group based on the first information and the first information of at least one second container group, including: The first container group searches for a container group whose difference between the registration time and the current time is within a set threshold range from the first container group and at least one of the second container groups; From the container groups whose difference between the registration time and the current time is within a set threshold range, find the container group whose task scheduling times are within an expected value range, and use the found container group as a valid container group.
3. The method according to claim 2, characterized in that The method further comprises: The first container group updates the registration time of the first container group in the database to the current time, and updates the task scheduling number of the first container group in the database to the sum of the task scheduling number of the first container group and 1.
4. The method according to claim 1, characterized in that: The method further comprises: The scheduling node in the cluster to which the first container group and at least one of the second container groups belong responds to the new deployment request of the application, and adds the third container group to the cluster to which the first container group and at least one of the second container groups belong; The third container group writes its third information into the database, where the third information at least includes: an identifier of the third container group, a hash value, a registration interval, and a task scheduling frequency, and the hash value of the third container group is calculated based on the consistent hashing algorithm on the identifier of the third container group.
5. The method according to claim 1, characterized in that The method further comprises: A scheduling node in the cluster to which the first container group and at least one of the second container groups belong, after at least one of the first container group and at least one of the second container groups is deleted, deletes information of the deleted container group from the database.
6. A file processing cluster system, characterized in that: include: A first container group, at least one second container group, and a scheduling node; The first container group is used for: Acquire first information of the first container group and second information of at least one second container group from a database, wherein the first information at least includes a hash value of the first container group, and the second information at least includes a hash value of the second container group, the hash value of the first container group and the hash value of the second container group are respectively calculated based on a consistent hashing algorithm for an identifier of the first container group and an identifier of the second container group, and the first container group and at least one of the first container groups correspond to the same application; determining at least one valid container group from the first container group and at least one second container group based on the first information and second information of at least one second container group; By sorting the hash values of at least one of the valid container groups, a hash value range between the hash values of every two adjacent valid container groups is used as a target file hash value range; Read at least one file from the to-be-processed file directory, and calculate the hash value of the file using the consistent hash algorithm; If the hash value of the file is within the target file hash value range, the file is used as a to-be-processed file of the target valid container group in each of the two adjacent valid container groups; Among them, searching in a clockwise direction, the position of the hash value of the target valid container group in the virtual annular space corresponding to the consistent hash algorithm is located before the position of the hash value of the file in the virtual annular space corresponding to the consistent hash algorithm.
7. The system according to claim 6, characterized in that The first information further includes: the registration time and task scheduling number of the first container group; the second information further includes: the registration time and task scheduling number of the second container group; The first container group can be specifically used for: Searching, from the first container group and at least one of the second container groups, a container group whose difference between the registration time and the current time is within a set threshold range; From the container groups whose difference between the registration time and the current time is within a set threshold range, find the container group whose task scheduling times are within an expected value range, and use the found container group as a valid container group.
8. The system according to claim 7, characterized in that The first container group is further used to update the registration time of the first container group in the database to the current time, and update the task scheduling number of the first container group in the database to the sum of the task scheduling number of the first container group and 1.
9. The system according to claim 6, characterized in that The scheduling node is configured to respond to a new deployment request of the application and add a third container group to the cluster to which the first container group and at least one of the second container groups belong; The third container group is used to write its third information into the database, where the third information at least includes: an identifier of the third container group, a hash value, a registration interval, and a task scheduling number, and the hash value of the third container group is calculated based on the consistent hashing algorithm on the identifier of the third container group.
10. The system according to claim 6, characterized in that The scheduling node is further used for: After at least one container group among the first container group and at least one of the second container groups is deleted, information of the deleted container group is deleted from the database.
