Method and apparatus for invoking services

By generating service instance identifiers in a distributed cluster and using the current timestamp and auto-incrementing sequence number to generate unique prefixes and suffixes, the problem of inconsistent service instance identifiers in a distributed cluster is solved, and accurate service instance invocation is achieved.

CN110263565BActive Publication Date: 2025-12-30BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN201910577325.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-28
Publication Date
2025-12-30
Estimated Expiration
2039-06-28

AI Technical Summary

Technical Problem

In a distributed cluster, the different configuration methods for service instance identity identification of each product lead to inconsistent and inaccurate service calls.

Method used

By generating an identity identifier for service instances, a unique prefix and suffix are generated using the current timestamp and auto-incrementing sequence number, and these are combined to form a unified identity identifier, ensuring the uniqueness of service instances and automated configuration in the distributed cluster.

Benefits of technology

It achieves automated and unified configuration of unique identifiers for service instances in a distributed cluster, improving call accuracy and ensuring accurate service instance invocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110263565B_ABST
    Figure CN110263565B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure disclose a method and device for calling a service, and relate to the field of cloud computing. A specific implementation of the method comprises: in response to receiving a calling request for a target service sent by a user, determining a target service instance for providing the target service in a distributed cluster; configuring an identity for the target service instance, so that the user calls the target service instance by using the identity, wherein the identity of the target service instance is generated by the following steps: obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance; generating a suffix of the target service instance based on a current timestamp and a self-incrementing serial number; and combining the prefix of the target service instance and the suffix of the target service instance to generate the identity of the target service instance. The embodiment realizes automatic and unified configuration of the unique identity of the service instance in the distributed cluster, and improves the accuracy of calling the target service instance.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present disclosure relate to the technical field of computer, and in particular, to a method and apparatus for invoking a service. BACKGROUND

[0002] A plurality of products can be distributed in a distributed cluster, and each product can provide at least one service. For example, a distributed cluster where an intelligent cloud product is located can include cloud disk storage, cloud servers and other cloud products, wherein the cloud servers can provide multiple services such as images and snapshots. In the distributed cluster of the related technology, different ways are usually used to configure identity for service instances providing services for different products. For example, the cloud servers and the cloud disk storage have different ways of configuring the identity of service instances. SUMMARY

[0003] Embodiments of the present disclosure provide a method and apparatus for invoking a service.

[0004] In a first aspect, embodiments of the present disclosure provide a method for invoking a service, the method comprising: in response to receiving a user-sent invocation request of a target service, determining a target service instance for providing the target service in a distributed cluster; configuring an identity for the target service instance, so that the user invokes the target service instance by using the identity, wherein the identity of the target service instance is generated by the following steps: obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance, wherein the prefix list includes services in the distributed cluster and corresponding unique prefixes; generating a suffix of the target service instance based on a current timestamp and an auto-incrementing serial number that increases with the number of generated suffixes in a unit time; and combining the prefix of the target service instance and the suffix of the target service instance to generate the identity of the target service instance.

[0005] In some embodiments, generating the suffix of the target service instance based on the current timestamp and the auto-incrementing serial number that increases with the number of generated suffixes in a unit time comprises: obtaining the current timestamp, and calculating a relative timestamp by difference between the current timestamp and a reference time; generating the auto-incrementing serial number based on the number of generated suffixes in the current unit time; and generating the suffix of the target service instance according to a preset suffix generation format from the relative timestamp and the auto-incrementing serial number.

[0006] In some embodiments, generating the suffix of the target service instance according to the preset suffix generation format from the relative timestamp and the auto-incrementing serial number comprises: combining the relative timestamp and the auto-incrementing serial number to generate a numerical sequence of a preset number of bits; exchanging a numerical value at a first preset position and a numerical value at a second preset position in the generated numerical sequence; and converting the exchanged numerical sequence into an N-base character sequence to generate the suffix of the target service instance.

[0007] In some embodiments, after converting the exchanged numerical sequence into the N-ary character sequence, the relative timestamp and the self-incrementing sequence number are generated into the suffix of the target service instance according to a preset suffix generation format, further comprising: transposing at least one character in the N-ary character sequence; and / or obtaining the machine identification of the server generating the identity of the target service instance, and inserting the obtained machine identification at any position in the N-ary character sequence.

[0008] In some embodiments, after configuring the identity of the target service instance, the method further comprises: sending the identity of the target service instance to the user; and in response to receiving the user inputting the identity of the target service instance, invoking the target service instance.

[0009] In some embodiments, after configuring the identity of the target service instance, the method further comprises: generating a password corresponding to the identity of the target service instance; sending the identity of the target service instance and the corresponding password to the user; and in response to receiving the user inputting the password, invoking the target service instance.

[0010] In a second aspect, embodiments of the present disclosure provide a device for invoking a service, the device comprising: a determination unit configured to determine a target service instance for providing a target service in a distributed cluster in response to receiving a user sending an invocation request of the target service; and a configuration unit configured to configure an identity of the target service instance for the user to invoke the target service instance by using the identity, wherein the identity of the target service instance is generated by: obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance, wherein the prefix list comprises services in the distributed cluster and corresponding unique prefixes; generating a suffix of the target service instance based on a current timestamp and a self-incrementing sequence number that is incremented with the number of generated suffixes in a unit time; and combining the prefix of the target service instance and the suffix of the target instance to generate the identity of the target service instance.

[0011] In some embodiments, the identity of the target service instance is further generated by: obtaining a current timestamp, and calculating a relative timestamp by subtracting a reference time from the current timestamp; generating a self-incrementing sequence number based on the number of generated suffixes in the current unit time; and generating the suffix of the target service instance according to the relative timestamp and the self-incrementing sequence number according to a preset suffix generation format.

[0012] In some embodiments, the identity of the target service instance is further generated by the following steps: combining the relative timestamp and the self-incrementing serial number to generate a numerical sequence with a preset number of digits; swapping the numerical value at a first preset position and the numerical value at a second preset position in the generated numerical sequence; converting the swapped numerical sequence into a sequence of N-base characters to generate a suffix of the target service instance.

[0013] In some embodiments, the identity of the target service instance is further generated by the following steps: transposing at least one character in the sequence of N-base characters; and / or obtaining a machine identity of a server that generates the identity of the target service instance, and inserting the obtained machine identity at any position in the sequence of N-base characters.

[0014] In some embodiments, the apparatus further comprises: an identity sending unit configured to send the identity of the target service instance to the user; and a target service instance calling unit configured to call the target service instance in response to receiving the identity of the target service instance input by the user.

[0015] In some embodiments, the apparatus further comprises: a generating unit configured to generate a password corresponding to the identity of the target service instance; a password sending unit configured to send the identity of the target service instance and the corresponding password to the user; and a calling unit configured to call the target service instance in response to receiving the password input by the user.

[0016] Embodiments of the present disclosure provide a method and apparatus for calling a service, in response to receiving a calling request of a target service sent by a user, determining a target service instance for providing the target service in a distributed cluster, then obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance, and then generating a suffix of the target service instance based on a current timestamp and a self-incrementing serial number, and then combining the prefix of the target service instance and the suffix of the target service instance to generate an identity of the target service instance, and finally configuring the identity of the target service instance, so that the user can call the target service instance by using the identity, realizing automatic and unified configuration of unique identities of service instances in the distributed cluster, and ensuring that the identities of the service instances are not duplicated and the user can accurately call the target service instance. BRIEF DESCRIPTION OF DRAWINGS

[0017] Other features, objects, and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments made with reference to the accompanying drawings:

[0018] Figure 1 is an exemplary system architecture diagram in which some embodiments of the present disclosure can be applied;

[0019] Figure 2 This is a flowchart of one embodiment of a method for invoking a service according to the present disclosure;

[0020] Figure 3 This is a schematic diagram illustrating one implementation of the method for generating the identity identifier of a target service instance according to this embodiment;

[0021] Figure 4 This is a schematic diagram of another implementation of the method for generating the identity of the target service instance according to this embodiment;

[0022] Figure 5 This is a schematic diagram of one embodiment of an apparatus for invoking services according to the present disclosure;

[0023] Figure 6 This is a schematic diagram of the structure of an electronic device suitable for implementing embodiments of the present disclosure. Detailed Implementation

[0024] The present disclosure will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0025] It should be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0026] Figure 1 An exemplary system architecture 100 for invoking a service or an apparatus for invoking a service, to which embodiments of the present disclosure may be applied, is shown.

[0027] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server cluster 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server cluster 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0028] The user can use the terminal device 101, 102, 103 to interact with the server cluster 105 through the network 104 to receive or send messages, etc. The user interacts with the server cluster 105 through the terminal device 101, 102, 103, and obtains the identity of the target service instance for providing the target service in the server cluster 105 through an account payment, etc. Then the user can call the target service instance by inputting the identity or related information, etc. in the terminal device 101, 102, 103.

[0029] The terminal device 101, 102, 103 can be hardware or software. When the terminal device 101, 102, 103 is hardware, it can be various electronic devices with a display screen and supporting functions such as information display, including but not limited to smart phones, tablet computers, e-book readers, laptop computers, desktop computers, etc. When the terminal device 101, 102, 103 is software, it can be installed in the above-mentioned electronic devices. It can be implemented as multiple software or software modules for providing distributed services, or as a single software or software module. No specific limitation is made herein.

[0030] The server cluster 105 can be composed of multiple servers providing various services, such as a background cloud server supporting storage, computing, etc. in the terminal device 101, 102, 103. The background cloud server can analyze and process the received calling request of the target service, etc. data, and return the processing result (such as the determined target service instance for providing the target service) to the user, so that the user can process storage, computing, etc. tasks through the terminal.

[0031] It should be noted that the method for calling a service provided by the embodiments of the present disclosure can be executed by a server in the server cluster 105. Accordingly, the apparatus for calling a service can be arranged in the server in the server cluster 105.

[0032] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster composed of multiple servers. When the server is software, it can be implemented as multiple software or software modules for providing distributed services. No specific limitation is made herein.

[0033] It should be understood that Figure 1 The number of terminal devices, networks and servers in the above-mentioned embodiments is only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.

[0034] Continuing to refer to Figure 2Fig. 200 shows one embodiment of a method for invoking a service according to the present disclosure. The method for invoking a service comprises the following steps:

[0035] At step 201, in response to receiving a user- sent invocation request of a target service, a target service instance for providing the target service is determined in a distributed cluster.

[0036] In this embodiment, the terminal device where the user is located can send an invocation request of a target service to an execution subject (e.g. Figure 1 The server in the server cluster 105) of the method for invoking a service when performing storage, calculation, etc. After the execution subject determines that the invocation request of the target service sent by the user is received, the target service instance for providing the target service can be determined in the distributed cluster by random allocation, etc.

[0037] Generally, various cloud products such as cloud disk storage, cloud servers, etc. can be distributed in the distributed cluster. And various services can be included under each cloud product, for example, services such as image, snapshot, etc. can be included under the cloud server. At least one service instance for providing the image, snapshot, etc. can be set in the distributed cluster. Therefore, when the user needs to perform an image operation on a file, the execution subject can receive the invocation request of the image service sent by the user, and randomly determine a service instance for providing the image service as the target service instance in the distributed cluster.

[0038] At step 202, an identity is configured for the target service instance, so that the user can invoke the target service instance by using the identity.

[0039] In this embodiment, based on the target service instance determined at step 201, the execution subject can configure an identity for the target service instance. Then, the user can invoke the target service instance from the distributed cluster by using the generated identity in various ways.

[0040] In some optional implementations of this embodiment, after the execution subject configures the identity for the target service instance, the execution subject can send the identity of the target service instance to the user. In response to receiving the identity of the target service instance input by the user, the execution subject invokes the target service instance.

[0041] In some optional implementations of this embodiment, after the execution subject configures the identity for the target service instance, the execution subject can also generate identification information such as a password corresponding to the identity, and send the generated identity information and the corresponding identification information such as the password to the user. When invoking the target service instance, in response to receiving the identification such as the password corresponding to the identity input by the user, the execution subject invokes the target service instance.

[0042] In some optional implementation manners, the identity configured for the target service instance can also be generated by the following steps: the execution subject for generating the identity of the target service instance can acquire a current timestamp and a self-incrementing serial number, and generate a character sequence by converting the current timestamp and the self-incrementing serial number by means of a certain base; and then, the characters in the generated character sequence are shuffled, so that the identity of the target service instance is generated by using the shuffled character sequence.

[0043] In some optional implementation manners, as shown in FIG. 2, the identity configured for the target service instance in step 202 can be generated by the following steps: Figure 3

[0044] Step 301: acquiring, from a preset prefix list, a unique prefix corresponding to the target service as the prefix of the target service instance.

[0045] In the implementation manner, the execution subject for generating the identity of the target service instance can preset a prefix list. Then, a unique prefix corresponding to the target service is acquired from the preset prefix list, and the acquired prefix is used as the prefix of the identity of the target service instance. Here, the prefix list can include each service in the distributed cluster and the unique prefix corresponding to each service, so that the prefixes of different services in the distributed cluster are ensured to be different. When generating the prefix list, each service contained in each product in the distributed cluster can be determined in advance, and then a unique prefix is set for each determined service, so that the above-mentioned prefix list can be generated.

[0046] Step 302: generating the suffix of the target service instance based on the current timestamp and the self-incrementing serial number which is incremented with the number of generated suffixes in a unit time.

[0047] In the implementation manner, the execution subject for generating the identity of the target service instance can acquire a current timestamp and a self-incrementing serial number. The self-incrementing serial number is increased with the number of generated suffixes in the current unit time. Then, the current timestamp and the self-incrementing serial number are processed by various means to generate the suffix of the target service instance. As an example, the current timestamp and the self-incrementing serial number can be uniformly converted by a certain base, and the converted results are spliced, and the spliced result is used as the suffix of the target service instance.

[0048] Step 303: combining the prefix of the target service instance and the suffix of the target service instance to generate the identity of the target service instance.

[0049] ​In the present embodiment, the prefix of the target service instance is combined with the suffix of the target service instance based on the prefix of the target service instance obtained in step 301 and the suffix of the target service instance obtained in step 302, so as to generate the identity of the target service instance, which is a unique identity in the distributed cluster. A preset symbol can also be added between the prefix and the suffix to distinguish the prefix from the suffix, so that the user can know the service to which the target service instance belongs according to the prefix part in the identity of the target service instance. The identity of the target service instance is in the form of, for example, "prefix+suffix", or "prefix.suffix", or "prefix_suffix".

[0050] It can be understood that any service instance in the distributed cluster can be the target service instance described above, and therefore the generation step of the identity of the target service instance provided in the present embodiment can be used to generate the identity of any service instance in the distributed cluster, that is, all service instances in the distributed cluster can generate corresponding identities by using the same rule, so as to realize the automatic and unified configuration of the unique identities of the service instances in the distributed cluster, and the generated identities are the same in length and style, which facilitates the subsequent verification of the generated identities in the distributed cluster.

[0051] In some optional embodiments, as shown in Figure 4 The identity of the target service instance configured in step 202 can also be generated by the following steps.

[0052] In step 401, a unique prefix corresponding to the target service is obtained from a preset prefix list as the prefix of the target service instance.

[0053] In the present embodiment, the execution subject for generating the identity of the target service instance can preset a prefix list. Then, a unique prefix corresponding to the target service is obtained from the preset prefix list, and the obtained prefix is used as the prefix of the identity of the target service instance. Here, the prefix list can include services in the distributed cluster and unique prefixes corresponding to the services, so as to ensure that the prefixes of different services in the distributed cluster are different.

[0054] In step 402, a current timestamp is obtained, and a relative timestamp is obtained by performing difference calculation on the current timestamp and a reference time.

[0055] In the present embodiment, the execution subject for generating the identity of the target service instance can preset a time relative to the start time, which is the reference time. As an example, the reference time can be set as January 1, 2010, 00:00:00, 000 ms. Then, a current timestamp is obtained, and a relative timestamp is obtained by performing difference calculation on the current timestamp and the reference time.

[0056] Step 403, generating the self-incrementing serial number based on the number of suffixes generated in the current unit time.

[0057] In the present implementation, the number of suffixes generated in the current unit time can be determined first. As an example, taking millisecond as the unit time, the number of suffixes generated in the current millisecond can be obtained. It can be understood that the unit time can also be second, microsecond, etc., which is not uniquely limited here. Then, 1 is added to the number of suffixes generated in the current unit time to obtain the corresponding value. Finally, the obtained value is processed by using the preset conversion of radix, bit conversion, etc. to generate the self-incrementing serial number.

[0058] Step 404, generating the suffix of the target service instance according to the preset suffix generation format based on the relative timestamp and the self-incrementing serial number.

[0059] In the present implementation, the suffix generation format is set in advance, and then the relative timestamp and the self-incrementing serial number are converted according to the requirements of the suffix format. Finally, the converted relative timestamp and the self-incrementing serial number are spliced according to the preset suffix generation format, so that the suffix of the target service instance can be generated. As an example, the generation format of the suffix can be 41-bit relative timestamp + 12-bit self-incrementing serial number. The relative timestamp and the self-incrementing serial number are converted into 41-bit and 12-bit data columns respectively, and the obtained data columns are spliced, so that the suffix of the target service instance can be generated.

[0060] In some optional implementations, the suffix of the target service instance can be generated according to the preset suffix format by the following steps: combining the relative timestamp and the self-incrementing serial number to generate a numerical sequence of a preset number of bits; exchanging the value at the first preset position and the value at the second preset position in the generated numerical sequence; converting the exchanged numerical column into an N-radix character sequence to generate the suffix of the target service instance. Through the above steps, the N-radix character sequence of the target service instance obtained can be greatly different from the adjacent N-radix character sequence obtained in the same unit time, and the finally generated suffix is also easier to be distinguished, where N is a positive integer.

[0061] Specifically, the relative timestamp and the self-incrementing serial number can be converted into formats, and the converted relative timestamp and the self-incrementing serial number can be combined to generate a numerical sequence of a preset bit number. For example, the relative timestamp and the self-incrementing serial number are converted into formats of 41-bit data and 12-bit data respectively, and the converted 41-bit data and 12-bit data are spliced to obtain a numerical sequence of 53 bits. Then, a first preset position and a second preset position are determined in the generated numerical sequence of the preset bit number, and the numerical value at the first preset position and the numerical value at the second preset position are exchanged. It should be noted that the numerical sequence can have one or more first preset positions and second preset positions, which are not uniquely limited here. For example, the numerical values at the 4th to 6th positions and the numerical values at the 39th to 41st positions in the generated numerical sequence of 53 bits are exchanged. Finally, the exchanged numerical sequence is converted into an N-ary, thereby generating the suffix of the target service instance. Wherein, 2 < N ≤ 62, and N is an integer. As an example, N = 58, and the generated suffix of the target service instance can include capital letters, lowercase letters and numbers. N = 58 can also avoid the occurrence of easily confused numbers "0, 1" and letters "O, l" in the converted 58-ary string.

[0062] In some optional implementations, after the exchanged numerical sequence is converted into an N-ary character sequence, the generating of the identity of the target service instance can further include: position-shifting at least one character in the N-ary character sequence; and / or obtaining a machine identity of a server generating the identity of the target service instance, and inserting the obtained machine identity at any position in the N-ary character sequence. Finally, the identity of the target service instance is generated. Here, the N-ary character sequence to which the machine identity is inserted can be a string directly obtained by N-ary conversion, or the N-ary character sequence to which the machine identity is inserted can also be an N-ary string after at least one character is shifted. Inserting the machine identity in the N-ary character sequence can avoid different servers generating the same suffix, further ensuring the uniqueness of the identity of the target service instance.

[0063] As an example, after N-ary conversion, a character sequence containing 10 characters is obtained, the first character in the 10-character sequence can be shifted to the seventh position; and / or the obtained machine identity of the server generating the identity of the target service instance can be inserted between the third character and the fourth character in the N-ary string or the N-ary string after the characters are shifted.

[0064] In some optional implementations, in addition to the interval corresponding to the relative timestamp and the interval corresponding to the self-incrementing sequence number, the generation format of the suffix can further include a backup interval. The backup interval can serve to identify a region, etc. If the suffix is composed of several bits of bit values, the generation format of the suffix can include a relative timestamp bit interval, a self-incrementing sequence number bit interval, and a backup bit interval. As an example, the identity can include a 41-bit relative timestamp interval, a 12-bit self-incrementing sequence number interval, and a 5-bit backup interval before N-ary conversion.

[0065] At step 405, the prefix of the target service instance and the suffix of the target service instance are combined to generate the identity of the target service instance.

[0066] In the present implementation, the prefix of the target service instance obtained based on step 401 and the suffix of the target service instance obtained based on step 404 are combined to generate the identity of the target service instance.

[0067] The identity generation method provided by the implementation described above in the present embodiment calculates the relative timestamp and the self-incrementing sequence number, and then generates the suffix of the target service instance according to the preset suffix generation format. This not only ensures the uniqueness of the identity of the target service instance generated in the distributed cluster, but also enables the identity generation method to meet the long-term development needs of the distributed cluster by reasonably setting the reference time.

[0068] In the related service calling process, the product to which the target service belongs is first determined, and then the identity of the target service instance used to provide the target service is configured by using the configuration identity method specific to the product. It can be understood that if the products to which the target services belong are different, the length and style of the identity configured by the target service instance can be different. Of course, it is not ruled out that the same identity can be generated in different products, thereby causing inaccurate calling of the service instance. However, the method for calling the service provided by the embodiments of the present disclosure can directly determine the target service instance used to provide the target service in the distributed cluster when receiving the calling request of the target service sent by the user, and does not need to distinguish the product to which the target service belongs. The identity of the target service instance is directly generated by using the unified identity generation step, thereby realizing the automatic and unified configuration of the unique identity of the service instance in the distributed cluster and ensuring that the user accurately calls the target service instance.

[0069] Further reference is made to Figure 5 As an implementation of the method shown in the above figures, the present disclosure provides an embodiment of an apparatus for calling a service. The apparatus embodiment is used to implement the method for calling a serviceFigure 2 The method embodiments shown correspondingly, the device can be applied to various electronic devices.

[0070] As Figure 5 The device for calling a service 500 in this embodiment includes a determination unit 501 and a configuration unit 502. The determination unit 501 is configured to determine a target service instance for providing a target service in a distributed cluster in response to receiving a calling request of the target service sent by a user. The configuration unit 502 is configured to configure an identity for the target service instance, so that the user calls the target service instance by using the identity. The identity of the target service instance is generated by the following steps: obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance, wherein the prefix list includes services in the distributed cluster and corresponding unique prefixes; generating a suffix of the target service instance based on a current timestamp and an auto-incrementing serial number that increases with the number of generated suffixes in a unit time; and combining the prefix of the target service instance and the suffix of the target service instance to generate the identity of the target service instance.

[0071] The device for calling a service provided by the above embodiments of the present disclosure includes a determination unit 501 that determines a target service instance for providing a target service in a distributed cluster in response to receiving a calling request of the target service sent by a user, and a configuration unit 502 that configures an identity for the target service instance, so that the user calls the target service instance by using the identity. The identity configured by the configuration unit 502 can be generated by the following steps: first obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance, then generating a suffix of the target service instance based on a current timestamp and an auto-incrementing serial number, and then combining the prefix of the target service instance and the suffix of the target service instance to generate the identity of the target service instance. Thus, a unique identity is configured for a service instance in a distributed cluster in a unified manner, and the accuracy of calling the target service instance is improved.

[0072] In some optional implementations of this embodiment, the identity of the target service instance is further generated by the following steps: obtaining a current timestamp, and calculating a relative timestamp by difference between the current timestamp and a reference time; generating an auto-incrementing serial number based on the number of generated suffixes in a current unit time; and generating the suffix of the target service instance according to a preset suffix generation format from the relative timestamp and the auto-incrementing serial number.

[0073] In some optional implementation forms of the embodiment, the identity of the target service instance is further generated by: combining the relative timestamp and the self-incrementing serial number to generate a numerical sequence of a preset bit number; swapping the numerical value at a first preset position and the numerical value at a second preset position in the generated numerical sequence; and converting the swapped numerical sequence into an N-base character sequence to generate the suffix of the target service instance.

[0074] In some optional implementation forms of the embodiment, the identity of the target service instance is further generated by: performing position transposition on at least one character in the N-base character sequence; and / or obtaining the machine identity of the server that generates the identity of the target service instance, and inserting the obtained machine identity at any position in the N-base character sequence.

[0075] In some optional implementation forms of the embodiment, the apparatus 500 further comprises: an identity sending unit configured to send the identity of the target service instance to the user; and a target service instance calling unit configured to call the target service instance in response to receiving the identity of the target service instance input by the user.

[0076] In some optional implementation forms of the embodiment, the apparatus 500 further comprises: a generating unit configured to generate a password corresponding to the identity of the target service instance; a password sending unit configured to send the identity of the target service instance and the corresponding password to the user; and a calling unit configured to call the target service instance in response to receiving the password input by the user.

[0077] The units described in the apparatus 500 correspond to the respective steps in the method described above. Figure 2 The operations and features described above in relation to the method are equally applicable to the apparatus 500 and the units included therein, and thus are not described here again.

[0078] Reference is made below to Figure 6 which shows a structural schematic diagram of an electronic device (e.g. Figure 1 600, which is suitable for use to implement the server in the server cluster 105 in the electronic device 100. Figure 6 The server shown is merely an example and should not bring any limitation to the functions and use range of the embodiments of the present disclosure.

[0079] As Figure 6As shown, the electronic device 600 can include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601 that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or loaded into a random access memory (RAM) 603 from a storage device 608. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0080] Generally, the following devices can be connected to the I / O interface 605: input devices 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 608 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 609. The communication devices 609 can allow the electronic device 600 to communicate wirelessly or wired with other devices to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that all of the shown devices are not required to be implemented or present. More or fewer devices can alternatively be implemented or present. Figure 6 Each block shown in the middle can represent a device or, as desired, multiple devices.

[0081] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the methods of embodiments of the present disclosure are executed. It should be noted that the computer readable medium of embodiments of the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may, for example, be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In embodiments of the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, the computer readable signal medium can include a data signal carried in a baseband or as part of a carrier wave, in which the computer readable program code is carried. Such a propagated data signal can take any of a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code contained in the computer readable medium can be transmitted by any suitable medium, including but not limited to wire, cable, RF, etc., or any suitable combination of the above.

[0082] The computer readable medium can be included in the electronic device; or can exist independently of the electronic device. The computer readable medium carries one or more programs, when executed by the electronic device, cause the electronic device to: in response to receiving a calling request for a target service sent by a user, determine a target service instance for providing the target service in a distributed cluster; configure an identity for the target service instance, so that the user calls the target service instance by using the identity, wherein the identity of the target service instance is generated by: obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance, wherein the prefix list includes services in the distributed cluster and corresponding unique prefixes; generating a suffix of the target service instance based on a current timestamp and an auto-incrementing serial number that increases with the number of generated suffixes in a unit time; and combining the prefix of the target service instance and the suffix of the target service instance to generate the identity of the target service instance.

[0083] Computer program code for carrying out operations of embodiments of the present disclosure can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0084] The flow and block diagrams in the drawings represent possible architectural, functional, and operational architectures of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block can represent a module, a segment, or a portion of code that comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations of blocks in the block diagrams and / or flowchart illustrations, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.

[0085] The units described in the embodiments of the present disclosure can be implemented by software, or can be implemented by hardware. The described units can also be arranged in a processor, for example, can be described as: a processor includes a determining unit, a configuration unit. Among them, the name of these units does not constitute a limitation to the units themselves in some cases, for example, the determining unit can also be described as: a unit for determining a target service instance for providing a target service in a distributed cluster in response to receiving a call request for the target service sent by a user.

[0086] The above description is merely preferred embodiments of the present disclosure and a description of the principles of the technology used. Those skilled in the art should understand that the scope of the application involved in the embodiments of the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the above features are replaced with the technical features disclosed in the embodiments of the present disclosure (but not limited to) having similar functions to form technical solutions.

Claims

1. A method for invoking a service, comprising: determining a target service instance for providing a target service in a distributed cluster in response to receiving a request for invoking the target service sent by a user; configuring an identity for the target service instance, so that the user invokes the target service instance by using the identity, the identity of the target service instance being generated by the following steps: obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance, the prefix list comprising services and corresponding unique prefixes in the distributed cluster; obtaining a current timestamp, and calculating a relative timestamp by subtracting a reference time from the current timestamp; generating an auto-incrementing serial number based on a number of suffixes generated in a current unit of time; combining the relative timestamp and the auto-incrementing serial number to generate a numerical sequence of a preset number of digits; swapping a value at a first preset position and a value at a second preset position in the generated numerical sequence; converting the swapped numerical sequence into an N-ary character sequence, and performing position exchange on at least one character in the N-ary character sequence; and / or obtaining a machine identity of a server generating the identity of the target service instance, and inserting the obtained machine identity at any position in the N-ary character sequence to generate a suffix of the target service instance, the suffix of the target service instance comprising uppercase letters, lowercase letters and numbers; combining the prefix of the target service instance and the suffix of the target service instance to generate the identity of the target service instance.

2. The method of claim 1, wherein, After configuring the identity for the target service instance, the method further comprises: sending the identity of the target service instance to the user; in response to receiving that the user inputs the identity of the target service instance, invoking the target service instance.

3. The method of claim 1, wherein, After configuring the identity for the target service instance, the method further comprises: generating a password corresponding to the identity of the target service instance; sending the identity of the target service instance and the corresponding password to the user; in response to receiving that the user inputs the password, invoking the target service instance. 4.An apparatus for invoking a service, comprising: a determining unit configured to determine a target service instance for providing a target service in a distributed cluster in response to receiving a request for invoking the target service sent by a user; The configuration unit is configured to configure an identity for the target service instance, so that the user invokes the target service instance by using the identity, wherein the identity of the target service instance is generated by the following steps: obtaining a unique prefix corresponding to the target service from a preset prefix list as a prefix of the target service instance, wherein the prefix list comprises services in the distributed cluster and corresponding unique prefixes; obtaining a current timestamp, and calculating a relative timestamp by subtracting a reference time from the current timestamp; generating an auto-increment sequence number based on a number of suffixes generated in a current unit of time; combining the relative timestamp and the auto-increment sequence number to generate a numerical sequence of a preset number of digits; exchanging a value at a first preset position and a value at a second preset position in the generated numerical sequence; converting the exchanged numerical sequence into an N-ary character sequence, and performing position exchange on at least one character in the N-ary character sequence; and / or obtaining a machine identity of a server generating the identity of the target service instance, inserting the obtained machine identity at any position in the N-ary character sequence to generate a suffix of the target service instance, wherein the suffix of the target service instance comprises uppercase letters, lowercase letters, and numbers; and combining the prefix of the target service instance and the suffix of the target service instance to generate the identity of the target service instance.

5. The apparatus of claim 4, wherein, The apparatus further includes: An identity sending unit configured to send the identity of the target service instance to the user; A target service instance invoking unit configured to invoke the target service instance in response to receiving that the user inputs the identity of the target service instance.

6. The apparatus of claim 4, wherein, The apparatus further includes: A generating unit configured to generate a password corresponding to the identity of the target service instance; A password sending unit configured to send the identity of the target service instance and the corresponding password to the user; An invoking unit configured to invoke the target service instance in response to receiving that the user inputs the password. 7.An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon, when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-3.

8. A computer readable medium having stored thereon a computer program, wherein, The program is executed by the processor to implement the method according to any one of claims 1-3.

Citation Information

Patent Citations

  • Authentication method and system based on Web Service

    CN103812843A

  • ID generating method and device

    CN108089916A

  • Global unique ID generating method and system and storage medium

    CN108108252A