Index data configuration method and device
By optimizing the index data configuration in the distributed search system and dynamically determining the regional configuration of the primary and secondary replicas, the problem of inconvenient write operations in the same region is solved, thus achieving both convenience for user write operations and data security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
- Filing Date
- 2024-11-06
- Publication Date
- 2026-05-08
AI Technical Summary
Existing distributed search systems cannot perform all write operations in the same region, making write operations inconvenient for users.
By traversing and querying the configuration information of each region, the configuration information of the primary and secondary replicas is determined. The primary replica is configured in regions with priority configuration information for primary replicas, and the secondary replicas are configured in regions with priority configuration information for all replicas. The number of replicas is dynamically balanced to enable write operations in the same region.
It improves the convenience of user write operations, ensures that write operations can be performed in the same region, and enhances data security and resource balance.
Smart Images

Figure CN121996653A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of distributed search technology, and in particular to an index data configuration method and apparatus. Background Technology
[0002] Currently, distributed search can provide basic region-aware capabilities, automatically distributing data shards across cluster nodes based on configured region information. By default, region-aware capabilities mean that all replicas of the same shard for an index will not be deployed to nodes in the same rack, but this does not allow for the execution of all write operations within the same region.
[0003] Therefore, there is an urgent need for an index data configuration method that can perform write operations in the same region, thereby improving the convenience of user write operations. Summary of the Invention
[0004] To solve the above-mentioned technical problems, or at least partially solve them, this disclosure provides an index data configuration method and apparatus.
[0005] A first aspect of this disclosure provides an index data configuration method applied to a master node, the method comprising:
[0006] In response to a request to configure index data, the configuration information for each region is traversed and queried. The index data is divided into multiple shards; one of these shards is a primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one.
[0007] If there exists a region where the configuration information is primary replica priority configuration information, then the region is determined as the first region, a primary replica is obtained, and the primary replica is configured in the first region;
[0008] Obtain a slave replica and configure the slave replica in a second region; wherein the second region is a region excluding the first region; the configuration information of the second region is the full replica priority configuration information.
[0009] In one example, each region includes multiple slave nodes; obtaining the primary replica and configuring the primary replica in the first region includes:
[0010] Get the number of first slave nodes in the first region;
[0011] Obtain the primary replica and its quantity, and configure the primary replica in the first region based on the quantity of the primary replica and the quantity of the first slave nodes; wherein the quantity of the first slave nodes is greater than or equal to the quantity of the primary replica.
[0012] In one example, configuring the primary replica in the first region based on the number of primary replicas and the number of the first secondary nodes includes:
[0013] If the number of primary replicas is the same as the number of first slave nodes, then one primary replica is configured on each of the first slave nodes;
[0014] If the number of primary replicas is less than the number of primary replicas, then select a primary replica from the primary replicas and configure one primary replica on each primary replica; wherein the number of primary replicas is the same as the number of primary replicas.
[0015] In one example, obtaining the replica and configuring the replica in the second region includes:
[0016] Obtain the number of slave replicas and the number of slave replicas, and obtain the number of second slave nodes in the second region;
[0017] Configure the slave replicas on the second slave nodes in the second region according to the number of second slave nodes and the number of slave replicas in the second region.
[0018] In one example, the method further includes:
[0019] If the number of slave replicas configured on the second slave node is greater than the number of primary replicas configured on the first slave node, then some slave replicas are moved from the second slave node to the first slave node until the number of slave replicas on the second slave node and the number of full replicas on the first slave node are dynamically balanced; wherein, the full replicas include the primary replicas and the slave replicas.
[0020] In one example, the method further includes:
[0021] If there is an unconfigured slave replica, then configure the unconfigured slave replica on the first slave node.
[0022] In one example, after iterating through and querying the configuration information for each region, the method further includes:
[0023] If the configuration information for the region does not exist, the primary replica priority configuration information is obtained, and the primary replica and the secondary replica are dynamically configured in the first region and the second region until the number of full replicas in the first region and the number of full replicas in the second region are dynamically balanced.
[0024] A second aspect of this disclosure provides an index data configuration apparatus for a master node, the apparatus comprising:
[0025] The query module is used to respond to requests for index data configuration and traverse and query the configuration information of each region; wherein, the index data is divided into multiple shards; one of the shards is a primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one.
[0026] The determination module is used to determine the region as the first region if there is a region where the configuration information is primary replica priority configuration information, obtain the primary replica, and configure the primary replica in the first region;
[0027] The first configuration module is used to obtain a slave replica and configure the slave replica in a second region; wherein the second region is a region excluding the first region; and the configuration information of the second region is the full replica priority configuration information.
[0028] In one example, each region includes multiple slave nodes; the determining module is specifically used for:
[0029] Get the number of first slave nodes in the first region;
[0030] Obtain the primary replica and its quantity, and configure the primary replica in the first region based on the quantity of the primary replica and the quantity of the first slave nodes; wherein the quantity of the first slave nodes is greater than or equal to the quantity of the primary replica.
[0031] In one example, the determining module is specifically used for:
[0032] If the number of primary replicas is the same as the number of first slave nodes, then one primary replica is configured on each of the first slave nodes;
[0033] If the number of primary replicas is less than the number of primary replicas, then select a primary replica from the primary replicas and configure one primary replica on each primary replica; wherein the number of primary replicas is the same as the number of primary replicas.
[0034] In one example, the first configuration module is specifically used for:
[0035] Obtain the number of slave replicas and the number of slave replicas, and obtain the number of second slave nodes in the second region;
[0036] Configure the slave replicas on the second slave nodes in the second region according to the number of second slave nodes and the number of slave replicas in the second region.
[0037] In one example, the device further includes:
[0038] The moving module is configured to move a portion of the slave replicas from the second slave node to the first slave node if the number of slave replicas configured on the second slave node is greater than the number of master replicas configured on the first slave node, until the number of slave replicas on the second slave node and the total number of replicas on the first slave node are dynamically balanced; wherein the total number of replicas includes the master replicas and the slave replicas.
[0039] In one example, the device further includes:
[0040] The second configuration module is used to configure the unconfigured slave replica on the first slave node if there is an unconfigured slave replica.
[0041] In one example, after traversing and querying the configuration information for each region, the device further includes:
[0042] The third configuration module is used to obtain the primary replica and the secondary replica if the configuration information for the region does not exist, and to dynamically configure the primary replica and the secondary replica in the first region and the second region until the number of full replicas in the first region and the number of full replicas in the second region are dynamically balanced.
[0043] A third aspect of this disclosure provides an electronic device, the server comprising: a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the method of the first aspect described above.
[0044] A fourth aspect of this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the method of the first aspect described above.
[0045] This disclosure provides an index data configuration method and apparatus. The method is applied to a master node and includes: responding to an index data configuration request operation, traversing and querying configuration information for each region; wherein the index data is divided into multiple shards; one of the shards is a primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one; if the configuration information for a region is primary replica priority configuration information, then the region is determined as a first region, a primary replica is obtained, and the primary replica is configured in the first region; a secondary replica is obtained, and the secondary replica is configured in a second region; wherein the second region is the region excluding the first region; the configuration information for the second region is the full replica priority configuration information. This technical solution enables write operations to be performed in the same region, improving the convenience of user write operations. Attached Figure Description
[0046] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0047] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a flowchart illustrating an index data configuration method provided in an embodiment of this disclosure;
[0049] Figure 2 This is a schematic diagram of a regional configuration provided in an embodiment of this disclosure;
[0050] Figure 3 This is a schematic diagram illustrating the configuration of index data in different regions according to an embodiment of this disclosure;
[0051] Figure 4 This is a flowchart illustrating an index data configuration method provided in an embodiment of this disclosure;
[0052] Figure 5 This is a schematic diagram illustrating the configuration of index data in different regions according to an embodiment of this disclosure;
[0053] Figure 6 This is a schematic diagram of the structure of an index data configuration device provided in an embodiment of this disclosure;
[0054] Figure 7This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. Detailed Implementation
[0055] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0056] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0057] Figure 1 This is a flowchart illustrating an index data configuration method provided in an embodiment of this disclosure. The method is applied to a master node, and the electronic device can be exemplarily understood as a device such as a mobile phone, tablet computer, laptop computer, desktop computer, or smart TV. Figure 1 As shown, the method provided in this embodiment includes the following steps:
[0058] S101. In response to the request operation for index data configuration, traverse and query the configuration information of each region; wherein, the index data is divided into multiple shards; one of the shards is the primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one.
[0059] In one example, the index data is created on a distributed cluster. The index data is divided into multiple shards, each configured on a slave node by the master node of the distributed cluster. One shard is the primary replica, and the others are slave replicas. For clarity, let's name the index data A. Index data A is then divided into shards A1, A2, A3, and A4. Shard A1 can create primary replica A11, slave replica A12, and slave replica A13.
[0060] In this embodiment, primary replica priority configuration information means that all primary replicas are preferentially configured in one region. Full replica priority configuration information means that all primary replicas and secondary replicas are configured together in multiple regions.
[0061] In this embodiment, after the request operation for index data configuration is triggered, the configuration information for each region is traversed and queried. For details, please refer to... Figure 2 This diagram illustrates a possible regional configuration. For example, each shard of index data A is configured on a slave node in region A, a slave node in region B, and a slave node in region C. Figure 2 As can be seen, if region A's configuration prioritizes primary replicas, then region B and region C both prioritize full replicas. This is because there can only be one region with primary replica priority configuration; that is, only one region can have primary replica priority configuration. Specifically, since region A is configured with all primary replicas, write operations can be performed in region A. Then, data synchronization can be performed between regions A, B, and C within the distributed cluster, and users can then read from regions B and C.
[0062] S102. If there is a region whose configuration information prioritizes the primary replica, then the region is determined as the first region, the primary replica is obtained, and the primary replica is configured in the first region.
[0063] In one example, if a region's configuration prioritizes primary replicas—for example, region A's configuration prioritizes primary replicas—then region A is designated as the first region. After being designated as the first region, the primary replicas of all shards are retrieved, and these primary replicas are configured in region A.
[0064] S103. Obtain the slave replica and configure the slave replica in the second region; wherein, the second region is the region excluding the first region; the configuration information of the second region is the full replica priority configuration information.
[0065] In one example, after configuring the primary replica in the first region, all secondary replicas are retrieved, and then all secondary replicas are configured in the second region. For example, the second region could be regions B and C. The configuration information for the second region prioritizes all replicas. For a clearer explanation, please refer to [link to relevant documentation]. Figure 3 This diagram illustrates a structure for configuring index data in different regions.
[0066] This disclosure provides an index data configuration method applied to a master node. The method includes: responding to an index data configuration request, traversing and querying the configuration information for each region; wherein the index data is divided into multiple shards; one shard is a primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one; if a region's configuration information is primary replica priority configuration information, then the region is determined as the first region, and a primary replica is obtained and configured in the first region; secondary replicas are obtained and configured in a second region; wherein the second region is the region excluding the first region; the configuration information in the second region is full replica priority configuration information. Using this technical solution, write operations can be performed in the same region, improving the convenience of user write operations.
[0067] Figure 4 This illustration shows a flowchart of an index data configuration method provided by an embodiment of the present disclosure, applied to a master node. This embodiment of the present disclosure is an optimization based on the above embodiments, and can be combined with various optional solutions in one or more of the above embodiments.
[0068] like Figure 4 As shown, the index data configuration method may include the following steps:
[0069] S401. In response to the request operation for index data configuration, traverse and query the configuration information of each region; wherein, the index data is divided into multiple shards; one of the shards is the primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one.
[0070] In one example, after iterating through and querying the configuration information for each region, the method also includes:
[0071] If no configuration information for a region is available, and the primary and secondary replicas are prioritized, then the primary and secondary replicas are obtained, and the primary and secondary replicas are dynamically configured in the first and second regions until the number of full replicas in the first region and the number of full replicas in the second region are dynamically balanced.
[0072] In one example, if no region configuration information prioritizes primary replicas (meaning all regions are configured with full replicas first), then primary and secondary replicas are obtained and allocated sequentially between the first and second regions. This dynamically balances the number of full replicas in the first and second regions, and ensures that secondary replicas of different shards are configured in different regions as much as possible. For details, please refer to [link to relevant documentation]. Figure 5 This diagram illustrates a structure for configuring index data in different regions.
[0073] S402. If there is a region whose configuration information prioritizes the primary replica, then that region will be designated as the first region.
[0074] In one example, this step can be found in step S102.
[0075] S403, Get the number of first slave nodes in the first region.
[0076] In one example, the number of primary slave nodes in the first region is typically multiple. This configuration increases the redundancy of the primary / replica configuration, improving data security. Specifically, if primary slave node A in the first region fails, primary slave node B in the first region can replace the functionality of primary slave node A. For example, the number of primary slave nodes in the first region might be four.
[0077] S404. Obtain the primary replica and its quantity. Based on the quantity of primary replicas and the quantity of first slave nodes, configure the primary replica in the first region; wherein the quantity of first slave nodes is greater than or equal to the quantity of primary replicas.
[0078] In this embodiment, the number of primary replicas is generally multiple. For example, shard A1 can create primary replica A11, secondary replica A12, and secondary replica A13. Shard A2 can create primary replica A21, secondary replica A22, and secondary replica A23. Shard A3 can create primary replica A31, secondary replica A32, and secondary replica A33. Therefore, primary replicas A11, A21, and A31 can be obtained, and the total number of primary replicas is 3. For clarity, we assume the number of primary secondary nodes in the first region is 4. Specifically, primary replicas can be configured in the first region based on 4 primary secondary nodes and 3 primary replicas.
[0079] In one example, the primary replicas are configured in the first region based on the number of primary replicas and the number of first slave nodes, including:
[0080] If the number of primary replicas is the same as the number of first slave nodes, then configure one primary replica on each first slave node;
[0081] If the number of primary replicas is less than the number of primary replicas, then select replicas to be configured from the primary replicas, and configure one primary replica on each replica to be configured; wherein the number of replicas to be configured is the same as the number of primary replicas.
[0082] In one example, if the number of primary replicas is the same as the number of primary slave nodes—for instance, if there are three primary replicas, designated A11, A21, and A31, and three primary slave nodes, designated A, B, and C—then primary replica A11 can be configured on primary slave node A, primary replica A21 on primary slave node B, and primary replica A31 on primary slave node C.
[0083] In one example, if the number of primary replicas is less than the number of primary slave nodes—for instance, if there are three primary replicas (A11, A21, and A31) and four primary slave nodes (A, B, C, and D)—then three primary slave nodes can be selected. Specifically, this could be primary slave nodes A, B, and C. Then, primary replica A11 can be configured on primary slave node A, primary replica A21 on primary slave node B, and primary replica A31 on primary slave node C.
[0084] S405, Get the number of slave replicas and the number of slave replicas, and get the number of second slave nodes in the second region.
[0085] In one example, the replicas can be replica A12, replica A13, replica A22, replica A23, replica A32, and replica A33. The number of replicas is 6. For example, the number of second regions can be 3: region B, region C, and region D. Each second region has 2 second slave nodes. For example, second slave nodes E and F in region B, second slave nodes G and H in region C, and second slave nodes I and Z in region D.
[0086] S406. Configure slave replicas on the second slave nodes in the second region according to the number of slave nodes and the number of slave replicas in the second region.
[0087] In one example, the second region is the region excluding the first region; the configuration information for the second region is the full replica priority configuration information.
[0088] In one example, replica A12 can be configured on the second slave node E, replica A13 on the second slave node F, replica A22 on the second slave node G, replica A23 on the second slave node H, replica A32 on the second slave node I, and replica A33 on the second slave node Z.
[0089] S407. If the number of slave replicas configured on the second slave node is greater than the number of master replicas configured on the first slave node, then some slave replicas are moved from the second slave node to the first slave node until the number of slave replicas on the second slave node and the number of full replicas on the first slave node are dynamically balanced; wherein, full replicas include master replicas and slave replicas.
[0090] In this embodiment, the number of slave replicas configured on the second slave node is greater than the number of master replicas configured on the first slave node, allowing slave replicas on the second slave node to be moved. This configuration ensures a more balanced resource distribution between the first and second slave nodes.
[0091] S408. If there are unconfigured slave replicas, configure the unconfigured slave replicas on the first slave node.
[0092] In this embodiment, if there are unconfigured slave replicas, they can be preferentially configured on the first slave node, ensuring that the first slave node has both a primary replica and a corresponding slave replica. The advantage of this setup is that if the primary replica of the first slave node, or one of the first slave nodes, fails, the corresponding slave replica can be promoted to primary, and a new slave replica can be generated by selecting a surviving primary slave node within the local area. If there are no slave replicas within the local area suitable for promotion to primary, the strategy reverts to a normal replica recovery strategy, selecting a suitable slave replica from another region to be promoted to primary, and gradually transferring the newly promoted primary replica to the region where the primary replica priority configuration information is located. However, this operation may result in additional network bandwidth consumption between different regions. Therefore, to minimize additional network bandwidth consumption, the number of full replicas, the number of first slave nodes, and the number of second slave nodes in different regions can be limited by the following three conditions: the number of slave nodes in different regions should be as equal as possible; the number of primary replicas should be as equal as possible to the number of first slave nodes; and the number of slave replicas should be as equal as possible to the number of second slave nodes.
[0093] Furthermore, in order to avoid selecting suitable replicas from other regions to promote to primary replicas as much as possible, the number of primary replica nodes can be increased, thereby increasing redundancy.
[0094] This disclosure provides an index data configuration method applied to a master node. The method includes: if the number of master replicas is the same as the number of first slave nodes, then configuring one master replica on each first slave node; if the number of master replicas is less than the number of first slave nodes, then selecting slave nodes to be configured from the first slave nodes, and configuring one master replica on each slave node to be configured; wherein the number of slave nodes to be configured is the same as the number of master replicas. Using this technical solution, master replicas can be distributed across different slave nodes, thereby improving data security.
[0095] Figure 6 This is a schematic diagram of an index data configuration device provided in an embodiment of this disclosure, applied to a master node. This index data configuration device can be understood as the aforementioned electronic device or a functional module within the aforementioned electronic device. For example... Figure 6 As shown, the index data configuration device 60 includes:
[0096] The query module 601 is used to respond to the request operation of index data configuration and traverse and query the configuration information of each region. The index data is divided into multiple shards, one of which is a primary replica. Each primary replica has at least one secondary replica. The configuration information includes primary replica priority configuration information or full replica priority configuration information. The number of primary replica priority configuration information is at most one.
[0097] The determination module 602 is used to determine the region as the first region if there is configuration information for a region that prioritizes the primary replica, and to obtain the primary replica and configure the primary replica in the first region.
[0098] The first configuration module 603 is used to obtain the slave replica and configure the slave replica in the second region; wherein the second region is the region excluding the first region; the configuration information of the second region is the full replica priority configuration information.
[0099] In one example, each region includes multiple slave nodes; module 602 is specifically used for:
[0100] Get the number of first slave nodes in the first region;
[0101] Obtain the primary replica and its quantity. Based on the quantity of primary replicas and the quantity of first slave nodes, configure the primary replica in the first region; wherein the quantity of first slave nodes is greater than or equal to the quantity of primary replicas.
[0102] In one example, module 602 is identified as being used specifically for:
[0103] If the number of primary replicas is the same as the number of first slave nodes, then configure one primary replica on each first slave node;
[0104] If the number of primary replicas is less than the number of primary replicas, then select replicas to be configured from the primary replicas, and configure one primary replica on each replica to be configured; wherein the number of replicas to be configured is the same as the number of primary replicas.
[0105] In one example, the first configuration module 603 is specifically used for:
[0106] Get the number of slave nodes and the number of slave nodes in the second region;
[0107] Configure slave replicas on the second slave nodes in the second region based on the number of slave nodes and slave replicas in the second region.
[0108] In one example, device 60 also includes:
[0109] The moving module 604 is used to move some slave replicas from the second slave node to the first slave node if the number of slave replicas configured on the second slave node is greater than the number of master replicas configured on the first slave node, until the number of slave replicas on the second slave node and the number of full replicas on the first slave node are dynamically balanced; wherein, the full replicas include master replicas and slave replicas.
[0110] In one example, device 60 also includes:
[0111] The second configuration module 605 is used to configure the unconfigured slave replica on the first slave node if there is an unconfigured slave replica.
[0112] In one example, after iterating through and querying the configuration information for each region, device 60 also includes:
[0113] The third configuration module 606 is used to obtain the primary and secondary replicas if the configuration information for a region does not exist and the primary replica is prioritized, and to dynamically configure the primary and secondary replicas in the first and second regions until the number of full replicas in the first region and the number of full replicas in the second region are dynamically balanced.
[0114] The apparatus provided in this embodiment can execute the methods of any of the above embodiments, and its execution method and beneficial effects are similar, so they will not be described again here.
[0115] This disclosure also provides an electronic device, which includes: a memory storing a computer program; and a processor for executing the computer program, wherein when the computer program is executed by the processor, it can implement the methods of any of the above embodiments.
[0116] Example, Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. See below for details. Figure 7 The diagram illustrates a structural schematic suitable for implementing the electronic device 1000 in the embodiments of this disclosure. The electronic device 1000 in the embodiments of this disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0117] like Figure 7As shown, the electronic device 1000 may include a processing unit (e.g., a central processing unit, a graphics processor, etc.) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1008 into a random access memory (RAM) 1003. The RAM 1003 also stores various programs and data required for the operation of the electronic device 1000. The processing unit 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0118] Typically, the following devices can be connected to the I / O interface 1005: input devices 1006 including, for example, a touchscreen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 1007 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1008 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows electronic device 1000 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 1000 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0119] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 1009, or installed from storage device 1008, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of embodiments of this disclosure.
[0120] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0121] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0122] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0123] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: respond to a request operation for configuring index data, traverse and query the configuration information of each region; wherein the index data is divided into multiple shards; one shard is a primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one; if there is a region whose configuration information is primary replica priority configuration information, then the region is determined as the first region, and the primary replica is obtained and configured in the first region; secondary replicas are obtained and configured in the second region; wherein the second region is the region excluding the first region; the configuration information of the second region is full replica priority configuration information.
[0124] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltank, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0125] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0126] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.
[0127] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application-Specific Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0128] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0129] This disclosure also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the methods of any of the above embodiments. The execution method and beneficial effects are similar, and will not be described again here.
[0130] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0131] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for configuring index data, characterized in that, Applied to the master node, the method includes: In response to a request to configure index data, the configuration information for each region is traversed and queried. The index data is divided into multiple shards; one of these shards is a primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one. If there exists a region where the configuration information is primary replica priority configuration information, then the region is determined as the first region, a primary replica is obtained, and the primary replica is configured in the first region; Obtain a slave replica and configure the slave replica in a second region; wherein the second region is a region excluding the first region; the configuration information of the second region is the full replica priority configuration information.
2. The method according to claim 1, characterized in that, Each of the regions includes multiple slave nodes; The step of obtaining the primary replica and configuring the primary replica in the first region includes: Get the number of first slave nodes in the first region; Obtain the primary replica and its quantity, and configure the primary replica in the first region based on the quantity of the primary replica and the quantity of the first slave nodes; wherein the quantity of the first slave nodes is greater than or equal to the quantity of the primary replica.
3. The method according to claim 2, characterized in that, The step of configuring the primary replica in the first region based on the number of primary replicas and the number of the first secondary nodes includes: If the number of primary replicas is the same as the number of first slave nodes, then one primary replica is configured on each of the first slave nodes; If the number of primary replicas is less than the number of primary replicas, then select a primary replica from the primary replicas and configure one primary replica on each primary replica; wherein the number of primary replicas is the same as the number of primary replicas.
4. The method according to claim 1, characterized in that, The step of obtaining the slave copy and configuring the slave copy in the second region includes: Obtain the number of slave replicas and the number of slave replicas, and obtain the number of second slave nodes in the second region; Configure the slave replicas on the second slave nodes in the second region according to the number of second slave nodes and the number of slave replicas in the second region.
5. The method according to claim 4, characterized in that, The method further includes: If the number of slave replicas configured on the second slave node is greater than the number of primary replicas configured on the first slave node, then some slave replicas are moved from the second slave node to the first slave node until the number of slave replicas on the second slave node and the number of full replicas on the first slave node are dynamically balanced; wherein, the full replicas include the primary replicas and the slave replicas.
6. The method according to claim 1 or 4, characterized in that, The method further includes: If there is an unconfigured slave replica, then configure the unconfigured slave replica on the first slave node.
7. The method according to claim 1, characterized in that, After traversing and querying the configuration information for each region, the method further includes: If the configuration information for the region does not exist, the primary replica priority configuration information is obtained, and the primary replica and the secondary replica are dynamically configured in the first region and the second region until the number of full replicas in the first region and the number of full replicas in the second region are dynamically balanced.
8. An index data configuration device, characterized in that, Applied to a master node, the device includes: The query module is used to respond to requests for index data configuration and traverse and query the configuration information of each region; wherein, the index data is divided into multiple shards; one of the shards is a primary replica; each primary replica has at least one secondary replica; the configuration information includes primary replica priority configuration information or full replica priority configuration information; the number of primary replica priority configuration information is at most one. The determination module is used to determine the region as the first region if there is a region where the configuration information is primary replica priority configuration information, obtain the primary replica, and configure the primary replica in the first region; The first configuration module is used to obtain a slave replica and configure the slave replica in a second region; wherein the second region is a region excluding the first region; and the configuration information of the second region is the full replica priority configuration information.
9. An electronic device, characterized in that, include: A processor and a memory, wherein the memory stores a computer program that, when executed by the processor, performs the method of any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1-7.