Domain name access method, terminal and storage medium
The correspondence between the server's location area and domain name is obtained through the terminal device, and the target domain name is automatically determined using the consistent hashing algorithm. This solves the problem of inflexible terminal device domain name settings in traditional device management systems and achieves efficient and flexible domain name access.
Patent Information
- Application Number
- CN202110796179.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-14
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2041-07-14
AI Technical Summary
In traditional device management systems, the external access address setting for terminal devices pointing to the Web server is inflexible, resulting in the need to manually modify each terminal device when the Web server address changes. This is labor-intensive and inefficient, especially when the load pressure is high, resulting in poor system scalability.
The terminal device obtains the correspondence between different location areas and domain names from the server, uses the consistent hashing algorithm and regional identification information to determine the target domain name, and automatically adjusts domain name access, thereby improving the efficiency and flexibility of terminal domain name access.
By automatically acquiring and updating domain name correspondences, terminal devices can quickly adapt to server configuration changes without manual settings, reducing the impact of modifications and improving domain name setting efficiency and system flexibility.
Smart Images

Figure CN115701066B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a domain name access method, a terminal, and a storage medium. Background Art
[0002] Traditional device management systems generally consist of several terminal devices and a World Wide Web (Web) server. The Web server acts as a site to provide an external access address. Device terminals perform data exchange and device management by setting a point to the external access address provided by the Web server.
[0003] At present, the setting of the external access address of the device terminal pointing to the Web server is generally preset at the factory, or set through a page when the device is registered, which causes the access address on the Web server to change. The pointing address of each terminal device needs to be modified and set separately, otherwise the device may not be used normally. In addition, when the number of devices connected to the current Web server is large and the load pressure is high and other Web servers need to be added, it is also necessary to reset some of the existing terminal devices in the system so that the pointing addresses of these devices point to the newly added Web servers, resulting in a large workload, poor flexibility and extremely low efficiency. Summary of the Invention
[0004] In order to solve the above technical problems, the present invention hopes to provide a domain name access method, terminal and storage medium, so that the terminal can obtain the correspondence between different location areas and different domain names from the server, and then use the correspondence to determine the target domain name for initiating access, thereby improving the efficiency and flexibility of terminal domain name access.
[0005] The technical solution of the present invention is achieved as follows:
[0006] The present invention provides a domain name access method, which is applied to a terminal. The method includes:
[0007] Obtain the correspondence between different location areas and different domain names from the server;
[0008] Obtaining a current location area of the terminal, and searching for a domain name corresponding to the current location area from the corresponding relationship to obtain at least one optional domain name;
[0009] A target domain name is determined from the at least one optional domain name, and an access is initiated to the target domain name.
[0010] In the above method, determining the target domain name from the at least one optional domain name includes:
[0011] Obtaining area identification information of the current location area from the server;
[0012] According to the at least one optional domain name, searching for each area corresponding to the at least one optional domain name from the corresponding relationship to obtain at least one area; the at least one area includes the current location area;
[0013] The target domain name is determined from the at least one optional domain name according to the at least one region and the region identification information by using a consistent hashing algorithm.
[0014] In the above method, the using a consistent hashing algorithm to determine the target domain name from the at least one optional domain name according to the at least one region and the region identification information includes:
[0015] For each domain name in the at least one optional domain name, using the corresponding domain name identification information, determine a corresponding hash value on a preset hash integer ring, and use each determined hash value as a domain name hash value to obtain at least one domain name hash value corresponding one-to-one to the at least one optional domain name;
[0016] Allocate a corresponding hash value on the preset hash integer ring for each area in the at least one area to obtain at least one hash value corresponding to the at least one area;
[0017] Determining, using a preset loop method, a zone corresponding to each domain name in the at least one optional domain name according to the at least one hash value and the at least one domain name hash value;
[0018] Performing a hash calculation using the region identification information to obtain a target hash value;
[0019] Searching for a hash value closest to the target hash value from the at least one hash value, and determining a region corresponding to the found hash value in the at least one region as a target region;
[0020] The domain name corresponding to the target area among the at least one optional domain name is determined as the target domain name.
[0021] In the above method, allocating a corresponding hash value on the preset hash integer ring for each area in the at least one area to obtain at least one hash value corresponding to the at least one area in a one-to-one manner includes:
[0022] Obtaining at least one current weight value corresponding one-to-one to the at least one optional domain name;
[0023] On the preset hash integer ring, using the at least one domain name hash value corresponding to the at least one optional domain name as a boundary, determining a numerical interval corresponding to each domain name in the at least one optional domain name, to obtain at least one numerical interval;
[0024] For each area in the at least one area, based on the current weight value corresponding to the at least one current weight value, an area is selected from the at least one area, and a hash value is assigned to the selected area within the corresponding numerical range to obtain the at least one hash value.
[0025] In the above method, before obtaining at least one current weight value corresponding to the at least one optional domain name, the method further includes:
[0026] For each domain name in the at least one optional domain name, obtain a plurality of corresponding access response durations, and determine an average duration of the obtained durations as a first average duration, to obtain at least one first average duration;
[0027] Between the current moment and the preset moment, for each domain name in the at least one optional domain name, periodically obtain a corresponding access response duration, and determine an average duration of the obtained durations as a second average duration, to obtain at least one second average duration;
[0028] For each domain name in the at least one optional domain name, determining a corresponding weight adjustment value based on a corresponding duration in the at least one first average duration and the at least one second average duration, to obtain at least one weight adjustment value;
[0029] For each domain name in the at least one optional domain name, a corresponding historical weight value is adjusted using a corresponding adjustment value in the at least one weight adjustment value to obtain the at least one current weight value.
[0030] The present invention provides a terminal, comprising:
[0031] A first acquisition module is used to obtain the correspondence between different location areas and different domain names from the server;
[0032] A second acquisition module is configured to acquire a current location area of the terminal and search for a domain name corresponding to the current location area from the corresponding relationship to obtain at least one optional domain name;
[0033] The processing module is configured to determine a target domain name from the at least one optional domain name and initiate access to the target domain name.
[0034] In the above-mentioned terminal, the processing module is specifically used to obtain the area identification information of the current location area from the server; according to the at least one optional domain name, search for each area corresponding to the at least one optional domain name from the corresponding relationship to obtain at least one area; the at least one area includes the current location area; and use a consistent hashing algorithm to determine the target domain name from the at least one optional domain name based on the at least one area and the area identification information.
[0035] In the above-mentioned terminal, the processing module is specifically configured to determine, for each domain name in the at least one optional domain name, a corresponding hash value on a preset hash integer ring using corresponding domain name identification information, and use each determined hash value as a domain name hash value to obtain at least one domain name hash value corresponding one-to-one to the at least one optional domain name; for each area in the at least one area, allocate a corresponding hash value on the preset hash integer ring to obtain at least one hash value corresponding one-to-one to the at least one area; determine, using a preset loop method, the area corresponding to each domain name in the at least one optional domain name in the at least one area based on the at least one hash value and the at least one domain name hash value; perform a hash calculation using the area identification information to obtain a target hash value; search for a hash value closest to the target hash value from the at least one hash value, and determine the area in the at least one area corresponding to the found hash value as the target area; and determine the domain name in the at least one optional domain name corresponding to the target area as the target domain name.
[0036] In the above-mentioned terminal, the processing module is specifically used to obtain at least one current weight value corresponding to the at least one optional domain name; on the preset hash integer ring, with the at least one domain name hash value corresponding to the at least one optional domain name as the boundary, determine the numerical interval corresponding to each domain name in the at least one optional domain name, and obtain at least one numerical interval; for each area in the at least one area, based on the current weight value corresponding to the at least one current weight value, select an area from the at least one area, and assign a hash value to the selected area within the corresponding numerical interval to obtain the at least one hash value.
[0037] In the above-mentioned terminal, the processing module is specifically used to obtain, for each domain name in the at least one optional domain name, corresponding multiple access response durations, and determine the average duration of the obtained durations as a first average duration, thereby obtaining at least one first average duration; between the current moment and the preset moment, for each domain name in the at least one optional domain name, periodically obtain the corresponding access response duration, and determine the average duration of the obtained durations as a second average duration, thereby obtaining at least one second average duration; for each domain name in the at least one optional domain name, determine the corresponding weight adjustment value based on the corresponding durations in the at least one first average duration and the at least one second average duration, thereby obtaining at least one weight adjustment value; for each domain name in the at least one optional domain name, use the corresponding adjustment value in the at least one weight adjustment value to adjust the corresponding historical weight value, thereby obtaining the at least one current weight value.
[0038] The present invention provides a terminal, comprising: a processor, a memory and a communication bus;
[0039] The communication bus is used to realize the communication connection between the processor and the memory;
[0040] The processor is configured to execute the domain name access program stored in the memory to implement the domain name access method.
[0041] The present invention provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the above-mentioned domain name access method.
[0042] The present invention provides a domain name access method, terminal, and storage medium. The method includes: obtaining, from a server, a correspondence between different location areas and different domain names; obtaining the terminal's current location area, and searching the corresponding relationship for a domain name corresponding to the current location area to obtain at least one optional domain name; determining a target domain name from the at least one optional domain name, and initiating access to the target domain name. The technical solution provided by the present invention enables the terminal to obtain the correspondence between different location areas and different domain names from the server, and then use this correspondence to determine the target domain name to initiate access, thereby improving the efficiency and flexibility of terminal domain name access. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A flowchart of a domain name access method provided by an embodiment of the present invention;
[0044] Figure 2 A schematic diagram of an exemplary process for determining a target domain name provided by an embodiment of the present invention;
[0045] Figure 3 A schematic diagram of an exemplary process of performing domain name access by a terminal according to an embodiment of the present invention;
[0046] Figure 4 A schematic diagram of the structure of a terminal provided in an embodiment of the present invention Figure 1 ;
[0047] Figure 5 A schematic diagram of the structure of a terminal provided in an embodiment of the present invention Figure 2 . DETAILED DESCRIPTION
[0048] The following will be combined with the accompanying drawings to clearly and completely describe the technical solutions in the embodiments of the present invention. It should be understood that the specific embodiments described herein are only used to illustrate the relevant invention and are not intended to limit the invention. It should also be noted that for ease of description, only the parts relevant to the relevant invention are shown in the drawings.
[0049] The present invention provides a domain name access method, which is applied to a terminal. Figure 1 A flowchart of a domain name access method provided by an embodiment of the present invention. Figure 1 As shown, it mainly includes the following steps:
[0050] S101. Obtaining, from a server, correspondences between different location areas and different domain names.
[0051] In the embodiment of the present invention, the terminal can directly obtain the correspondence between different location areas and different domain names from the server.
[0052] It should be noted that, in the embodiments of the present invention, the location areas may be divided based on different dimensions such as provinces, cities, counties, districts, and schools. The specific dimensions of the location area division may be selected and set according to actual needs and application scenarios; the domain name is the external access address provided by the server as a site, and the terminal may access data through the domain name.
[0053] It should be noted that in an embodiment of the present invention, different location areas may correspond to one or more domain names. For example, all schools in Beijing, Tianjin and Hebei Province may point to the same domain name, or all schools in Shandong Province, Henan Province, and Nanjing City, Jiangsu Province may simultaneously point to at least one optional domain name, where the at least one optional domain name may be: domain name 1, domain name 2, and domain name 3.
[0054] It should be noted that, in the embodiments of the present invention, since the terminal can directly obtain the correspondence between different location areas and different domain names, and then can determine the access domain name based on the correspondence, when the domain name configured on the server changes, the changed correspondence will be updated on the server in a timely manner, and the terminal obtains the updated correspondence from the server, and modifies and resets the existing domain name of the terminal according to the updated correspondence. Compared with the existing technology, the terminal can directly modify and reset the domain name using the obtained correspondence without manually setting the domain name, thereby improving the efficiency of the terminal in setting the domain name and reducing the impact of the server modifying the configured domain name.
[0055] S102: Acquire the current location area of the terminal, and search for a domain name corresponding to the current location area from the corresponding relationship to obtain at least one optional domain name.
[0056] In the embodiment of the present invention, the terminal can directly obtain its current location area, and search for a domain name corresponding to the current location area from the corresponding relationship to obtain at least one optional domain name.
[0057] It should be noted that in an embodiment of the present invention, the terminal can first obtain the actual location information of the terminal, which can be a specific longitude and latitude, and then determine the current location area where the actual location information is located based on the actual location information, and then, based on the current location area, search for the domain name corresponding to the current location information from the corresponding relationship, thereby obtaining at least one optional domain name.
[0058] For example, in an embodiment of the present invention, if the actual location obtained by the terminal is a specific teaching building or a specific street, based on the current location area to which the actual location belongs, the optional domain name corresponding to the school can be found from the corresponding relationship to obtain at least one optional domain name.
[0059] For example, if in the corresponding relationship, the domain names corresponding to a school in Nanjing where the terminal is located are domain name 1, domain name 2 and domain name 3, then domain name 1, domain name 2 and domain name 3 are all optional domain names of the terminal, thereby obtaining at least one optional domain name.
[0060] S103: Determine a target domain name from at least one optional domain name, and initiate access to the target domain name.
[0061] In the embodiment of the present invention, after the terminal determines the target domain name from at least one optional domain name, it may directly initiate access to the target domain name.
[0062] Specifically, in an embodiment of the present invention, the terminal determines the target domain name from at least one optional domain name, including: obtaining the area identification information of the current location area from the server; according to the at least one optional domain name, searching for each area corresponding to the at least one optional domain name from the corresponding relationship to obtain at least one area; at least one area includes the current location area; using a consistent hashing algorithm, according to the at least one area and the area identification information, determining the target domain name from the at least one optional domain name.
[0063] It should be noted that, in an embodiment of the present invention, the terminal needs to obtain the regional identification information of the current location area from the server, and the current location area can be divided into regions according to different dimensions. If the regional division dimension of the current location area is selected according to the school dimension, then the current location area obtained by the terminal is specific to a certain school, such as: a certain school in Nanjing City, Jiangsu Province, and then, the regional identification information obtained by the terminal is the identification information of the school; of course, if the dimension of the current location area is selected as a city, correspondingly, the current location area obtained by the terminal is specific to a certain city, such as: Nanjing City, Jiangsu Province. At this time, the regional identification information obtained by the terminal is the identification information of Nanjing City. The specific dimension of the current location area obtained by the terminal can also select other dimensions such as province, county, district, etc., and the present invention does not limit this.
[0064] It should be noted that in an embodiment of the present invention, if the current location area obtained by the terminal is a school in Nanjing City, Jiangsu Province, then the terminal can determine at least one area with the same domain name as the school from the corresponding relationship based on the optional domain name of the school.
[0065] For example, if the current location area of the terminal is a school in Nanjing, then the terminal can find out from the corresponding relationship that the optional domain names corresponding to the school are domain name 1, domain name 2, and domain name 3, and then according to the optional domain names: domain name 1, domain name 2, and domain name 3, find each area corresponding to the optional domain name from the corresponding relationship to obtain at least one area. At this time, at least one area refers to at least one school; for example, domain name 1, domain name 2, and domain name 3 correspond to all schools in Shandong Province, Henan Province, and Nanjing City, Jiangsu Province, then at least one area refers to all schools in Shandong Province, Henan Province, and Nanjing City, Jiangsu Province.
[0066] Figure 2 The following is a flow chart of an exemplary process for determining a target domain name provided by an embodiment of the present invention. Figure 2 As shown, the terminal uses a consistent hashing algorithm to determine a target domain name from at least one optional domain name according to at least one region and region identification information, mainly including the following steps:
[0067] S201. For each domain name in at least one optional domain name, use the corresponding domain name identification information to determine the corresponding hash value on a preset hash integer ring, and use each determined hash value as a domain name hash value to obtain at least one domain name hash value that corresponds one-to-one to the at least one optional domain name.
[0068] In an embodiment of the present invention, the terminal uses the corresponding domain name identification information to determine the corresponding hash value on a preset hash integer ring for each domain name in at least one optional domain name, and uses each determined hash value as a domain name hash value to obtain at least one domain name hash value that corresponds one-to-one to the at least one optional domain name.
[0069] It should be noted that, in the embodiment of the present invention, before performing the consistent hashing algorithm, the terminal needs to preset a hash integer ring. The length of the preset hash integer ring can be 2 to the power of 32, and then construct a large prime number so that the hash calculation can be performed using the hash formula. The formula is as follows:
[0070] H=hash ^ ANSI*p (1)
[0071] Among them, H is the hash value corresponding to the ANSI code, and the large prime number p can be any value, such as: 16777619, or any other arbitrary value. The ANSI code refers to the identification information. If the hash value of the domain name is calculated using this formula, then the ANSI code in the formula refers to the identification information of the domain name. If the hash value of the school is calculated using this formula, then the ANSI code in the formula refers to the identification information of the school.
[0072] It should be noted that, in an embodiment of the present invention, the terminal uses the domain name identification information of each domain name in at least one optional domain name to calculate the hash value of the corresponding domain name according to formula (1), and obtains the hash value of each domain name in the optional domain name. Then, based on the hash value, the position of each domain name in the optional domain name on the preset hash integer ring is determined, thereby determining the domain name hash value corresponding to each domain name.
[0073] S202 . Allocate a corresponding hash value on a preset hash integer ring for each area in the at least one area, and obtain at least one hash value corresponding to the at least one area in a one-to-one manner.
[0074] In an embodiment of the present invention, the terminal allocates a corresponding hash value on a preset hash integer ring for each area in the at least one area, and obtains at least one hash value corresponding to the at least one area in a one-to-one manner.
[0075] It should be noted that, in the embodiment of the present invention, the terminal may allocate at least one area to a preset hash integer ring to obtain a corresponding hash value, that is, each area in the at least one area has a corresponding position on the hash integer ring.
[0076] Specifically, in an embodiment of the present invention, the terminal allocates a corresponding hash value on a preset hash integer ring for each area in at least one area, and obtains at least one hash value corresponding one-to-one to the at least one area, including: obtaining at least one current weight value corresponding one-to-one to at least one optional domain name; on the preset hash integer ring, using at least one domain name hash value corresponding to at least one optional domain name as a boundary, determining a numerical interval corresponding to each domain name in at least one optional domain name, and obtaining at least one numerical interval; for each area in at least one area, based on the corresponding current weight value in at least one current weight value, selecting an area from at least one area, and performing hash value allocation for the selected area within the corresponding numerical interval, and obtaining at least one hash value.
[0077] It should be noted that, in the embodiments of the present invention, taking into account the different business needs of each terminal accessing the server, correspondingly, the loads generated by different business needs are also different. If the same number of regions is simply allocated to each domain name, it may cause a certain domain name to be overloaded, while other domain names are idle. At this time, the terminal can obtain at least one current weight value corresponding to the optional domain name in the server, and then adjust the weight of the corresponding domain name in at least one optional domain name according to the at least one current weight value, and then adjust the number of regions allocated to the domain name to achieve load balance between the domain names.
[0078] It should be noted that in an embodiment of the present invention, if the current weight value corresponding to each domain name in the optional domain names is not taken into account, then the number of areas allocated to each domain name is equal. For example, the number of areas corresponding to domain names 1 to 3 is 3,000, then domain name 1, domain name 2 and domain name 3 can all be allocated 1,000 areas. If the domain name weight value is taken into account according to the load situation of each domain name, then the number of areas allocated to each domain name is uneven, but the load is balanced, thereby achieving load balancing between the domain names. For example, when the current weight value of domain name 1 is 0.1, the current weight value of domain name 2 is 0.6, and the current weight value of domain name 3 is 0.3, domain name 1 can be allocated 300 areas, domain name 2 can be allocated 1,800 areas, and domain name 3 can be allocated 900 areas.
[0079] It should be noted that, in an embodiment of the present invention, the terminal can determine the numerical interval corresponding to each domain name in at least one domain name based on the limit of at least one domain name hash value corresponding to at least one domain name, that is, divide the preset hash integer ring into at least one numerical interval according to at least one domain name hash value, that is, each domain name in the optional domain name corresponds to a numerical interval, and then, for each domain name, according to the current weight value corresponding to at least one current weight value obtained, select an area from at least one area, and then assign a hash value to the selected area in the numerical interval corresponding to the domain name to obtain at least one hash value.
[0080] It should be noted that in an embodiment of the present invention, during the operation of the terminal, the terminal will dynamically adjust the current weight value according to the actual access time of each domain name, so that each domain name in the optional domain name maintains load balancing during the operation of the terminal.
[0081] Specifically, in an embodiment of the present invention, before obtaining at least one current weight value corresponding to at least one optional domain name, the terminal also includes: for each domain name in the at least one optional domain name, obtaining corresponding multiple access response time lengths, and determining the average time length of the obtained time lengths as a first average time length, to obtain at least one first average time length; between the current moment and the preset moment, for each domain name in the at least one optional domain name, periodically obtaining the corresponding access response time length, and determining the average time length of the obtained time lengths as a second average time length, to obtain at least one second average time length; for each domain name in the at least one optional domain name, based on the corresponding time lengths in the at least one first average time length and the at least one second average time length, determining the corresponding weight adjustment value, to obtain at least one weight adjustment value; for each domain name in the at least one optional domain name, using the corresponding adjustment value in the at least one weight adjustment value, adjusting the corresponding historical weight value, to obtain at least one current weight value.
[0082] It should be noted that in an embodiment of the present invention, the terminal obtains multiple corresponding access response time lengths for each domain name in at least one optional domain name, which can be 1000 or 500. The specific number of times can be set according to actual needs and application scenarios, and the present invention does not limit this.
[0083] Specifically, if the terminal can obtain the latest 1000 access response times corresponding to each domain name in at least one optional domain name, the average duration of 1000 visits is calculated based on these 1000 access times and determined as the first average duration, and at least one first average duration T1 is obtained.
[0084] It should be noted that, in an embodiment of the present invention, the duration between the current moment and the preset moment can be 5 minutes or 10 minutes. The specific duration between the current moment and the preset moment can be set according to actual needs and application scenarios, and the present invention does not limit this.
[0085] It should be noted that, in an embodiment of the present invention, for each domain name in at least one optional domain name, the terminal periodically obtains the access response duration. For example, the duration between the current moment and the preset moment is 5 minutes, and 300 access response durations are obtained in 5 minutes. Then, the terminal uses the 300 access response durations obtained to calculate the average duration, and determines the average duration as the second average duration, thereby obtaining at least one second average duration T0.
[0086] It should be noted that, in the embodiment of the present invention, the terminal can set a difference rate and use the difference rate to judge the load corresponding to the domain name. If the access response time is long, it means that the current load of the domain name is heavy, and the current weight value of the corresponding domain name can be appropriately lowered to achieve load balancing between the domain names; if the access response time is short, it means that the current load of the domain name is light, and the current weight value of the domain name can be appropriately increased to achieve load balancing; wherein, the difference rate includes a positive difference rate S + and negative difference rate S - Then, the difference between the first average duration T1 and the second average duration T0 is calculated. The difference formula is shown in formula (2):
[0087]
[0088] Wherein, S is the difference between the first average duration and the second average duration, T1 is the first average duration, and T0 is the second average duration.
[0089] For example, the terminal calculates the difference S between the first average duration T1 and the second average duration T0 using formula (2), and compares the difference S with the positive difference rate and the negative difference rate. If the difference S is greater than the positive difference rate S + , indicating that the access response time is too long, determine the corresponding domain name weight adjustment value, if the difference S is less than the negative difference rate S - , indicating that the access response time is shortened, and the weight adjustment value of the corresponding domain name is determined to be increased by the current weight value.
[0090] It should be noted that, in an embodiment of the present invention, when the current weight value of a domain name among the optional domain names is adjusted, if the current weight value of the domain name is less than the historical weight value, then the area allocated to the domain name will also be reduced accordingly, thereby reducing the load of the domain name and improving the access response efficiency of the domain name.
[0091] S203: Determine, using a preset loop method, a zone corresponding to each domain name in at least one zone in at least one optional domain name according to at least one hash value and at least one domain name hash value.
[0092] In an embodiment of the present invention, the terminal determines the zone corresponding to each domain name in at least one zone in at least one optional domain name according to at least one hash value and at least one domain name hash value using a preset loop method.
[0093] It should be noted that, in the embodiment of the present invention, the preset circulation mode can be a clockwise circulation or a counterclockwise circulation, and the specific circulation mode can be set according to the actual scenario and actual needs.
[0094] It should be noted that, in an embodiment of the present invention, the terminal cycles through each area in at least one area in a preset cycle mode, and the first domain name encountered is used as the domain name selected for the area, thereby establishing a relationship between each domain name in the optional domain names and at least one area.
[0095] S204: Perform hash calculation using the region identification information to obtain a target hash value.
[0096] In an embodiment of the present invention, the terminal performs a hash calculation using the area identification information to obtain a target hash value.
[0097] It should be noted that, in the embodiment of the present invention, the terminal can calculate the hash value corresponding to the terminal using formula (2) according to the area identification information where the terminal is located, and determine the hash value as the target hash value.
[0098] S205 . Search for a hash value closest to the target hash value from the at least one hash value, and determine the region corresponding to the found hash value in the at least one region as the target region.
[0099] In an embodiment of the present invention, the terminal searches for a hash value closest to a target hash value from at least one hash value, and determines a region corresponding to the found hash value in the at least one region as the target region.
[0100] It should be noted that in an embodiment of the present invention, each area in at least one area corresponds one-to-one to a hash value. After the terminal determines the hash value closest to the target hash value from at least one hash value through the target hash value, the corresponding area can be determined based on the hash value, and the area can be determined as the target area.
[0101] S206: Determine the domain name corresponding to the target area among the at least one optional domain name as the target domain name.
[0102] In an embodiment of the present invention, the terminal selects a domain name corresponding to the target area from among the at least one optional domain name.
[0103] It should be noted that in the embodiment of the present invention, if a domain name in the optional domain names fails, the terminal will re-determine the target domain name based on the existing normal domain names in the optional domain names, thereby ensuring that the terminal can normally access the domain name.
[0104] Figure 3 The following is a flow chart of an exemplary terminal performing domain name access according to an embodiment of the present invention. Figure 3 As shown, the server sends the correspondence between different location areas and different domain names to the terminal. The terminal uses the area identification information of its own location to calculate the hash value and obtain the target hash value. Then, according to the location area of the terminal, the optional domain name is determined from the correspondence, and the domain name hash value corresponding to each domain name in the optional domain name is determined according to at least one optional domain name. Then, according to the optional domain name, at least one area and the area hash value (hash value) of at least one area are determined. The area hash value of at least one area and the domain name hash value of the domain name are used to establish a relationship between at least one area and the optional domain name. The target area is determined from the area hash value of at least one area according to the target hash value, and the corresponding target domain name is determined according to the target area. Then, the target domain name is used to initiate access to the corresponding server in the server cluster.
[0105] The present invention provides a domain name access method, comprising: obtaining, from a server, a correspondence between different location areas and different domain names; obtaining a terminal's current location area, and searching the correspondence for a domain name corresponding to the current location area to obtain at least one optional domain name; determining a target domain name from the at least one optional domain name, and initiating access to the target domain name. The method provided by the present invention enables a terminal to obtain, from a server, the correspondence between different location areas and different domain names, and thereby utilize the correspondence to determine a target domain name for initiating access, thereby improving the efficiency and flexibility of terminal domain name access.
[0106] The present invention provides a terminal. Figure 4 A schematic diagram of the structure of a terminal provided in an embodiment of the present invention Figure 1 .like Figure 4 Shown, including:
[0107] The first acquisition module 401 is used to obtain the correspondence between different location areas and different domain names from the server;
[0108] A second obtaining module 402 is configured to obtain a current location area of the terminal and search for a domain name corresponding to the current location area from the corresponding relationship to obtain at least one optional domain name;
[0109] The processing module 403 is configured to determine a target domain name from the at least one optional domain name and initiate access to the target domain name.
[0110] Optionally, the processing module 403 is specifically used to obtain the area identification information of the current location area from the server; according to the at least one optional domain name, search for each area corresponding to the at least one optional domain name from the corresponding relationship to obtain at least one area; the at least one area includes the current location area; and use a consistent hashing algorithm to determine the target domain name from the at least one optional domain name according to the at least one area and the area identification information.
[0111] Optionally, the processing module 403 is specifically configured to determine, for each domain name in the at least one optional domain name, a corresponding hash value on a preset hash integer ring using corresponding domain name identification information, and use each determined hash value as a domain name hash value to obtain at least one domain name hash value corresponding one-to-one to the at least one optional domain name; for each area in the at least one area, allocate a corresponding hash value on the preset hash integer ring to obtain at least one hash value corresponding one-to-one to the at least one area; determine, using a preset loop method, the area corresponding to each domain name in the at least one optional domain name in the at least one area according to the at least one hash value and the at least one domain name hash value; perform hash calculation using the area identification information to obtain a target hash value; search for a hash value closest to the target hash value from the at least one hash value, and determine the area corresponding to the found hash value in the at least one area as the target area; and determine the domain name corresponding to the target area in the at least one optional domain name as the target domain name.
[0112] Optionally, the processing module 403 is specifically used to obtain at least one current weight value corresponding one-to-one to the at least one optional domain name; on the preset hash integer ring, with the at least one domain name hash value corresponding to the at least one optional domain name as the boundary, determine the numerical interval corresponding to each domain name in the at least one optional domain name, and obtain at least one numerical interval; for each area in the at least one area, based on the current weight value corresponding to the at least one current weight value, select an area from the at least one area, and assign a hash value to the selected area within the corresponding numerical interval to obtain the at least one hash value.
[0113] Optionally, the processing module 403 is specifically used to obtain corresponding multiple access response time lengths for each domain name in the at least one optional domain name, and determine the average time length of the obtained time lengths as a first average time length to obtain at least one first average time length; between the current moment and the preset moment, for each domain name in the at least one optional domain name, periodically obtain the corresponding access response time length, and determine the average time length of the obtained time lengths as a second average time length to obtain at least one second average time length; for each domain name in the at least one optional domain name, based on the corresponding time lengths in the at least one first average time length and the at least one second average time length, determine the corresponding weight adjustment value to obtain at least one weight adjustment value; for each domain name in the at least one optional domain name, use the corresponding adjustment value in the at least one weight adjustment value to adjust the corresponding historical weight value to obtain the at least one current weight value.
[0114] Figure 5 A schematic diagram of the structure of a terminal provided in an embodiment of the present invention Figure 2 .like Figure 5 As shown, the terminal includes a processor 501, a memory 502 and a communication bus 503;
[0115] The communication bus 503 is used to realize the communication connection between the processor 501 and the memory 502;
[0116] The processor 501 is configured to execute the domain name access program stored in the memory 502 to implement the above domain name access method.
[0117] The present invention provides a terminal that obtains, from a server, the correspondence between different location areas and different domain names; obtains the terminal's current location area, searches for a domain name corresponding to the current location area from the correspondence, and obtains at least one optional domain name; determines a target domain name from the at least one optional domain name, and initiates access to the target domain name. The terminal provided by the present invention can obtain the correspondence between different location areas and different domain names from a server, and then use the correspondence to determine the target domain name to initiate access, thereby improving the efficiency and flexibility of terminal domain name access.
[0118] The present invention provides a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to implement the above-mentioned domain name access method. The computer-readable storage medium can be a volatile memory (volatile memory), such as a random-access memory (RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); or a device including one or any combination of the above-mentioned memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, etc.
[0119] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage and optical storage, etc.) containing computer-usable program code.
[0120] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0121] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0122] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0123] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this utility model should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A domain name access method, characterized in that: Applied to a terminal, the method includes: Obtain the correspondence between different location areas and different domain names from the server; Obtaining a current location area of the terminal, and searching for a domain name corresponding to the current location area from the corresponding relationship to obtain at least one optional domain name; Obtaining area identification information of the current location area, and performing a hash calculation using the area identification information to obtain a target hash value; Determine a domain name hash value corresponding to each optional domain name in the at least one optional domain name to obtain at least one domain name hash value, and determine at least one region and at least one hash value of the region based on the at least one optional domain name; Establishing a relationship between the at least one region and the optional domain name using the at least one domain name hash value and the at least one region hash value; determining a target region from the hash value of the at least one region according to the target hash value, and determining a target domain name according to the target region; Initiate access to the target domain name.
2. The method according to claim 1, characterized in that The acquiring the area identification information of the current location area includes: Obtaining area identification information of the current location area from the server; Accordingly, determining at least one region according to the at least one optional domain name includes: According to the at least one optional domain name, each area corresponding to the at least one optional domain name is searched from the corresponding relationship to obtain the at least one area; the at least one area includes the current location area.
3. The method according to claim 2, characterized in that Determining a domain name hash value corresponding to each optional domain name in the at least one optional domain name to obtain at least one domain name hash value, and determining a hash value of the at least one zone based on the at least one optional domain name includes: For each domain name in the at least one optional domain name, using the corresponding domain name identification information, determine a corresponding hash value on a preset hash integer ring, and use each determined hash value as a domain name hash value to obtain at least one domain name hash value corresponding one-to-one to the at least one optional domain name; Allocate a corresponding hash value on the preset hash integer ring for each area in the at least one area to obtain at least one hash value corresponding to the at least one area; The establishing a relationship between the at least one region and the optional domain name by using the at least one domain name hash value and the at least one region hash value includes: Determining, using a preset loop method, a zone corresponding to each domain name in the at least one optional domain name according to the at least one hash value and the at least one domain name hash value; The determining a target region from the hash value of the at least one region according to the target hash value, and determining a target domain name according to the target region, includes: Searching for a hash value closest to the target hash value from the at least one hash value, and determining a region corresponding to the found hash value in the at least one region as a target region; The domain name corresponding to the target area among the at least one optional domain name is determined as the target domain name.
4. The method according to claim 3, characterized in that Allocating a corresponding hash value on the preset hash integer ring for each of the at least one area to obtain at least one hash value corresponding to the at least one area in a one-to-one manner includes: Obtain at least one current weight value corresponding to the at least one optional domain name; determine, on the preset hash integer ring, a numerical interval corresponding to each domain name in the at least one optional domain name, using the at least one domain name hash value corresponding to the at least one optional domain name as a boundary, to obtain at least one numerical interval; For each area in the at least one area, based on the current weight value corresponding to the at least one current weight value, an area is selected from the at least one area, and a hash value is assigned to the selected area within the corresponding numerical range to obtain the at least one hash value.
5. The method according to claim 4, characterized in that Before acquiring at least one current weight value corresponding to the at least one optional domain name, the method further includes: For each domain name in the at least one optional domain name, obtain a plurality of corresponding access response durations, and determine an average duration of the obtained durations as a first average duration, to obtain at least one first average duration; Between the current moment and the preset moment, for each domain name in the at least one optional domain name, periodically obtain a corresponding access response duration, and determine an average duration of the obtained durations as a second average duration, to obtain at least one second average duration; For each domain name in the at least one optional domain name, determining a corresponding weight adjustment value based on a corresponding duration in the at least one first average duration and the at least one second average duration, to obtain at least one weight adjustment value; For each domain name in the at least one optional domain name, a corresponding historical weight value is adjusted using a corresponding adjustment value in the at least one weight adjustment value to obtain the at least one current weight value.
6. A terminal, characterized in that: The terminal includes: A first acquisition module is used to obtain the correspondence between different location areas and different domain names from the server; A second acquisition module is configured to acquire a current location area of the terminal and search for a domain name corresponding to the current location area from the corresponding relationship to obtain at least one optional domain name; The processing module is configured to obtain area identification information of the current location area, perform a hash calculation using the area identification information to obtain a target hash value, determine a domain name hash value corresponding to each optional domain name in the at least one optional domain name to obtain at least one domain name hash value, and determine at least one area and at least one hash value of the area based on the at least one optional domain name; establish a relationship between the at least one area and the optional domain name using the at least one domain name hash value and the hash value of the at least one area; determine a target area from the hash value of the at least one area based on the target hash value, and determine a target domain name based on the target area; and initiate an access to the target domain name.
7. The terminal according to claim 6, characterized in that The processing module is specifically configured to obtain, from the server, area identification information of the current location area; and, based on the at least one optional domain name, search the corresponding relationship for each area corresponding to the at least one optional domain name to obtain at least one area; the at least one area includes the current location area; The target domain name is determined from the at least one optional domain name according to the at least one region and the region identification information by using a consistent hashing algorithm. The terminal according to claim 7 , wherein: The processing module is specifically configured to determine, for each domain name in the at least one optional domain name, a corresponding hash value on a preset hash integer ring using the corresponding domain name identification information, and use each determined hash value as a domain name hash value to obtain at least one domain name hash value corresponding one-to-one to the at least one optional domain name; Allocate a corresponding hash value on the preset hash integer ring for each area in the at least one area to obtain at least one hash value corresponding to the at least one area; Determining, using a preset loop method, a zone corresponding to each domain name in the at least one optional domain name according to the at least one hash value and the at least one domain name hash value; Performing a hash calculation using the region identification information to obtain a target hash value; Searching for a hash value closest to the target hash value from the at least one hash value, and determining a region corresponding to the found hash value in the at least one region as a target region; The domain name corresponding to the target area among the at least one optional domain name is determined as the target domain name.
9. A terminal, characterized in that: include: processor, memory, and communication bus; The communication bus is used to realize the communication connection between the processor and the memory; The processor is configured to execute the domain name access program stored in the memory to implement the domain name access method according to any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the domain name access method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Distribution network control method, distribution network control device, household appliance and storage medium
CN112305926A