Data processing method and device, electronic equipment, storage medium and program product
By locally maintaining the token queue in the business system and obtaining tokens from the local queue when needed, the problem of low efficiency and poor stability of token acquisition in centralized services is solved, and more efficient and reliable token acquisition is achieved, improving the The stability and availability of business systems.
Patent Information
- Application Number
- CN202410996846.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-12-20
AI Technical Summary
In the prior art, the token acquisition provided by centralized services has problems with network instability and frequent calls, which affects the availability and stability of the business system.
The business system maintains the local queue uniformly locally, stores tokens obtained from the central system, reduces network dependence when directly obtaining tokens in the local queue, and sends requests to the central system to update and expand the local queue when the number of tokens is less than a certain value. .
It improves the efficiency of token acquisition, reduces the impact of network instability and central system problems on the business system, and improves the stability and availability of the business system.
Smart Images

Figure CN119166380A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data processing method, device, electronic device, storage medium and program product. Background Art
[0002] At present, services such as tokens and global identifiers are mostly provided in the form of centralized services. In related technologies, when a business system needs a token, it calls a centralized service to request it. However, centralized services may have problems such as network instability and frequent calls, which may lead to availability and time consumption, thus affecting the business needs and stability of the business system. Summary of the invention
[0003] The present application provides a data processing method, device, electronic device, storage medium and program product, which improve the efficiency and performance of token acquisition, thereby improving the stability and availability of the business system.
[0004] In a first aspect, the present application provides a data processing method, the data processing method comprising:
[0005] In response to a first token acquisition request for a business system, determining a first number of tokens stored in a local queue of the business system;
[0006] When the first number is greater than a first preset value, obtaining the number of tokens requested by the first token acquisition request from the local queue and sending it to the business system, and updating the first number;
[0007] When the updated first number is less than the second preset value, sending a second token acquisition request to the central system;
[0008] The token returned by the central system in response to the second token acquisition request is updated to the local queue.
[0009] In a second aspect, the present application provides a data processing device, the data processing device comprising:
[0010] A determination module, configured to determine, in response to a first token acquisition request for a business system, a first number of tokens stored in a local queue of the business system;
[0011] A first acquisition module, configured to acquire the number of tokens requested by the first token acquisition request from the local queue and send the tokens to the business system to update the first number when the first number is greater than a first preset value;
[0012] A first processing module, configured to send a second token acquisition request to the central system when the updated first number is less than a second preset value;
[0013] An updating module is used to update the token returned by the central system in response to the second token acquisition request to the local queue.
[0014] In a third aspect, the present application provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can perform the above-mentioned data processing method.
[0015] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned data processing method when executed by a processor.
[0016] In a fifth aspect, the present application provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned data processing method.
[0017] In an embodiment of the present application, the business system uniformly maintains a local queue locally, and tokens are stored in the local queue. When a business in the business system has a token demand, a first token acquisition request is sent, and the number of tokens requested by the first token acquisition request can be directly obtained from the local queue, thereby improving acquisition efficiency and reducing the impact on the business system caused by network instability or problems in the central system. When acquiring from the local queue, if the number of tokens in the local queue is less than a certain value, a second token acquisition request can be sent to the central system in time to update and expand the token returned by the central system to the local queue, so that there can always be a certain number of tokens in the local queue as much as possible, thereby improving the stability and availability of the business system.
[0018] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings are used to provide a further understanding of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the present application and do not constitute a limitation of the present application. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings. In the accompanying drawings:
[0020] Figure 1A flowchart of a data processing method provided in an embodiment of the present application;
[0021] Figure 2 This is an overall architecture diagram of the data processing method in the embodiment of the present application;
[0022] Figure 3 This is an example diagram of obtaining a token from a local queue in an embodiment of the present application;
[0023] Figure 4 This is a flowchart of another data processing method in an embodiment of the present application;
[0024] Figure 5 A block diagram of a data processing device provided in an embodiment of the present application;
[0025] Figure 6 A block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the technical solution of the present application, the exemplary embodiments of the present application are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0027] In the absence of conflict, the embodiments of the present application and the features therein may be combined with each other.
[0028] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0029] The terms used herein are only used to describe specific embodiments and are not intended to limit the present application. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect.
[0030] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this application, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined herein.
[0031] At present, services such as tokens and global identification are mostly provided in the form of centralized services. Taking tokens as an example, in related technologies, centralized services generate tokens, and when the business system needs tokens, it calls centralized services to obtain them. Since services that require tokens are usually highly dependent on the generation of tokens, and tokens are obtained from centralized services when they are needed, if the network is unstable or the centralized service is unstable, the business system will be unavailable, and if the central system is called frequently, it will take a long time and reduce performance.
[0032] Therefore, a data processing method is provided in an embodiment of the present application, in which the business system uniformly maintains a local queue locally, and the local queue is used to store tokens obtained from the central system. Then, when the business system needs a token, it responds to a first token acquisition request for the business system and determines a first number of tokens stored in the local queue of the business system. When the first number is greater than a first preset value, the number of tokens requested by the first token acquisition request is obtained from the local queue and sent to the business system. The first number is updated and can be directly read from the local queue. When the updated first number is less than a second preset value, a second token acquisition request is sent to the central system, so as to timely pull, update and expand the local queue from the central system, rather than pulling from the central system when the business system needs it, thereby improving the efficiency of token acquisition, reducing the impact on the business system caused by network instability or problems in the central system, and improving the stability and availability of the business system.
[0033] To facilitate understanding of the embodiments of the present application, a data processing method disclosed in the embodiments of the present application is first introduced in detail. The execution subject of the data processing method provided in the embodiments of the present application is generally an electronic device with certain computing capabilities. The electronic device includes, for example: a terminal device, a server or other processing device. The terminal device can be a vehicle-mounted device, a user equipment (User Equipment, UE), a mobile device, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a wearable device, etc. The server can be an independent physical server, a server cluster composed of multiple physical servers, or a cloud server capable of cloud computing. In some possible implementations, the data processing method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0034] It should be noted that the data processing method provided in the embodiment of the present application can be applied to centralized service scenarios, where services are provided by a central system. A central system can manage multiple business systems, and usually a business system can include multiple businesses or services. In the embodiment of the present application, the business system obtains tokens from the central system and caches them in a local queue. In a business system, the cached tokens are managed uniformly, and the local queues are uniformly maintained in the business system, rather than different businesses in the business system pulling tokens on demand and maintaining their own local queues. Since the cached local queues will be cleared after restart, if multiple businesses in the business system maintain local queues separately, it will lead to waste of token resources. In the embodiment of the present application, the tokens are uniformly maintained and managed, which improves efficiency and reduces resource waste.
[0035] See also Figure 1 FIG. 1 is a flowchart of a data processing method provided in an embodiment of the present application, the method comprising:
[0036] S101: In response to a first token acquisition request for a business system, determine a first number of tokens stored in a local queue of the business system.
[0037] In the embodiments of the present application, it is mainly aimed at centralized service scenarios, which include a central system and multiple business systems. The central system provides services for multiple business systems. For example, in the embodiments of the present application, a token is generated by the central system to be provided to each business system for use, wherein the token can represent unique identification information such as an identity identifier or a global identifier. For example, the token is an order number. In the embodiments of the present application, the business system uniformly maintains a local queue locally for the multiple businesses included. The local queue is used to store the tokens obtained by the business system from the central system, rather than each business maintaining a local queue. In this way, the usage of the local queue in the business system can be reduced, and the resource waste of tokens in the local queue can also be reduced.
[0038] In addition, in the embodiment of the present application, a token may be obtained from the central system in advance and stored in a local queue. Specifically, the present application provides several possible implementation methods:
[0039] In a possible implementation, in response to the business system being started, a second number of tokens is obtained from the central system, and the second number of tokens is stored in a local queue.
[0040] The second number may be preset according to the needs of the business system and other performance requirements, and is not limited in the embodiments of the present application.
[0041] In this way, token pulling is performed when the business system is started, so that when the business needs to use the token, the token can be obtained from the local queue, which improves availability, is simple to implement, and improves efficiency.
[0042] In a possible implementation, a second number of tokens are obtained from the central system according to a preset pulling cycle, and the second number of tokens are stored in a local queue.
[0043] In an embodiment of the present application, tokens can also be pulled from the central system regularly according to a preset pulling cycle, which can further improve availability. Furthermore, in an embodiment of the present application, the length of the local queue is usually related to the memory space. When pulling according to the preset pulling cycle, the tokens in the local queue may be consumed slowly, resulting in a large number of tokens remaining, which may cause the tokens pulled regularly to exceed the memory capacity of the local queue. Therefore, in an embodiment of the present application, the current remaining number of the local queue can be judged when pulling regularly, and it will be pulled when it is less than a certain number, which can further reduce resource waste.
[0044] In addition, in the embodiments of the present application, the local queue can be stored in the memory, so that the speed and efficiency of obtaining the token are also high. When the business system is started, the token is obtained from the central system, and a local queue is established in the local memory, and the obtained token is stored in the local queue. Of course, the local queue can also be stored in a persistent space such as a database. This is not limited in the embodiments of the present application and can be determined according to actual needs.
[0045] S102: When the first number is greater than a first preset value, the number of tokens requested by the first token acquisition request is obtained from the local queue and sent to the business system, and the first number is updated.
[0046] In an embodiment of the present application, when reading the local queue, the first number of tokens stored in the local queue can be determined. When the first number is greater than a first preset value, the token is returned from the local queue to the business system, wherein the setting of the first preset value may be related to the number of tokens requested by the business system each time. For example, if the business system only needs to request one token each time to perform business processing, the first preset value may be set to 0. At this time, after the business system sends the first token acquisition request, as long as there is a token in the local queue, it can be returned to the business system for use.
[0047] In this way, in an embodiment of the present application, when any business in the business system needs to use a token, a first token acquisition request is triggered, and it can be read from the local queue. As long as the first number of tokens in the local queue is greater than the first preset value, the token can be obtained, thereby reducing the time consumption of token acquisition and improving the efficiency and performance of token acquisition.
[0048] S103: When the updated first number is less than the second preset value, send a second token acquisition request to the central system.
[0049] Among them, the second preset value can be set according to demand and actual conditions, for example, according to the maximum length of the local queue, the frequency of token use of the business system, the usage consumption speed and other usage information. For example, the second preset value is set to the first proportion of the maximum length of the local queue, and there is no specific restriction. This can better meet the needs of the business system and reduce the performance and resource consumption of frequently pulling tokens from the central system.
[0050] For example, the maximum length of the local queue is 100, and the second preset value is 60. If it is determined that the first number of the local queue after the current update is 70, 70>60, it means that the token consumption in the local queue is small, and the current remaining number of tokens can still meet subsequent use. At this time, there is no need to pull it from the central system again.
[0051] For another example, the maximum length of the local queue is 100, and the second preset value is 60. If it is determined that the first number of the local queue after the current update is 30, and 30>60, it means that the token consumption in the local queue is large. At this time, it is necessary to pull it from the central system again to update and expand the number of tokens in the local queue, so that the tokens in the local queue can meet the use of subsequent business.
[0052] S104: Update the token returned by the central system in response to the second token acquisition request to the local queue.
[0053] In addition, it should be noted that in an embodiment of the present application, after sending a first token acquisition request for the number of tokens requested from the local queue to the business system, when it is determined that the updated first number is less than the second preset value, a second token acquisition request is sent to the central system to pull tokens; or, in response to the first token acquisition request from the business system, the first number of tokens stored in the local queue is smaller. If the first number is less than the second preset value, tokens can be pulled from the central system at this time. The execution order is not restricted in the embodiment of the present application.
[0054] In an embodiment of the present application, in response to a first token acquisition request for a business system, a first number of tokens stored in a local queue of the business system is determined, and when the first number is greater than a first preset value, the number of tokens requested by the first token acquisition request is obtained from the local queue and sent to the business system, and the first number is updated. In this way, tokens can be obtained from the local queue, which reduces the time for acquiring tokens and improves the performance of acquiring tokens. When the updated first number is less than a second preset value, a second token acquisition request is sent to the central system, and the token returned by the central system for the second token acquisition request is updated to the local queue, so that when the number of tokens in the local queue is small, it can be acquired from the central system again, so that the tokens in the local queue can meet the business needs, reducing the dependence on the central system, and reducing the impact of network problems or temporary unavailability of the central system on the business system, thereby improving the stability and availability of the business system.
[0055] The data processing method in the embodiment of the present application is described below.
[0056] In a possible embodiment, as described above, for the above step S103, when the updated first number is less than the second preset value, a second token acquisition request is sent to the central system, including: when the updated first number is a third preset value, based on the asynchronous lock mode, a second token acquisition request is sent to the central system; when the token returned by the central system is not received within the preset time period, the central system is called to make the central system return the token.
[0057] In an embodiment of the present application, when it is determined that the updated first number is less than the second preset value, for example, the updated first number is the third preset value, and the third preset value is less than the second preset value, it is necessary to pull the token from the central system again. In a centralized service scenario, there may be multiple businesses that need to obtain tokens. Therefore, in order to prevent multiple businesses in the business system from requesting to obtain tokens at the same time and causing uncontrollable expansion of the local queue, in an embodiment of the present application, a second token acquisition request can be sent to the central system based on the asynchronous lock mode.
[0058] Among them, the asynchronous lock mode represents the lock waiting mode. If multiple second token acquisition requests are triggered in the business system, if one second token acquisition request is locked, then other second token acquisition requests will not call the central system, but wait for the second token acquisition request that already holds the lock to be completed and unlocked before executing other second token acquisition requests. In this way, it can be ensured that only one asynchronous request calls the central system at the same time, thereby improving performance and controllability.
[0059] Furthermore, in an embodiment of the present application, the second token acquisition request sent by the business system may include a third number. Specifically for the above step 104, the present application provides a possible implementation method, including: receiving the third number of tokens returned by the receiving center system based on the second token acquisition request, and storing the third number of tokens in a local queue.
[0060] In one possible embodiment, the third number may be a preset fixed value, and the third number may be the same as or different from the second number requested to be obtained when the business system is started, and there is no restriction on this. In this way, a fixed number of tokens are pulled each time, which is more controllable and can also improve processing efficiency.
[0061] In another possible embodiment, the third number can be determined based on the updated first number and the current token usage information. For example, if the current token usage information indicates that the current token is consumed quickly or is used frequently, then a request can be made to the central system to obtain more tokens. In addition, the third number can be determined based on information such as the current system load. In this way, a more appropriate third number can be dynamically determined to improve accuracy.
[0062] In another possible embodiment, the third number is greater than or equal to the difference between the second preset value and the updated first number. For example, the second preset value is 50, and the updated first number is 30, then the third number is 20, that is, a second token acquisition request for 20 tokens can be sent to the central system, and the 20 tokens returned by the central system are stored in the local queue, so that a sufficient number of tokens can be stored in the local queue.
[0063] Further, in an embodiment of the present application, when the business system sends a first token acquisition request, if the first number of tokens stored in the local queue of the business system is less than or equal to a first preset value, a possible implementation method is also provided, including:
[0064] When the first number is less than or equal to the first preset value, a third token acquisition request is sent to the central system; the token returned by the central system for the third token acquisition request is updated to the local queue; the number of tokens requested by the first token acquisition request is obtained from the local queue and sent to the business system to update the first number.
[0065] In an embodiment of the present application, when the first number of tokens stored in the local queue is less than or equal to a first preset value, it means that the tokens in the local queue may not be sufficient to be provided to the business system at present, and the need to obtain tokens from the central system is stronger. At this time, a request can be made directly to the central system to obtain tokens.
[0066] Specifically, for sending a third token acquisition request to the central system when the first number is less than or equal to the first preset value, the present application also provides several possible implementations:
[0067] 1) In a possible implementation, the central system is directly called and a request for obtaining a third token is sent to the central system.
[0068] In the embodiment of the present application, in this method, there is no need to wait for an asynchronous lock, and the central system can be directly called to obtain a token. In this way, the acquisition time can be reduced and the token can be provided to the business system more quickly.
[0069] 2) In a possible implementation, based on the asynchronous lock mode, a third token acquisition request is sent to the central system, and if the token returned by the central system is not received within a preset time, the central system is directly called to obtain the token.
[0070] That is, in this method, the central system can be called asynchronously to wait. If the waiting period exceeds the preset time, it will affect the service of the business system and may cause the business system to be unavailable. The preset time can be configured according to experience and needs. For example, the preset time is set to M milliseconds. The specific embodiment of the present application does not limit this. Therefore, after the preset time exceeds the preset time, if the token in the local queue is still less than the first preset value, the central system can be directly called to obtain the token to improve the stability and availability of the business system.
[0071] 3) In a possible implementation, based on the asynchronous lock mode, a third token acquisition request is sent to the central system, and the system waits until a token returned by the central system is received.
[0072] In this method, the token is obtained from the central system based on the asynchronous lock mode. The implementation method can also combine factors such as the importance level of the business system and the response time requirements to determine whether to wait until the token is obtained. For example, if the service response time of the business system requesting the token is relatively long and no immediate response is required, the asynchronous lock mode can be used for waiting.
[0073] Of course, the embodiments of the present application may also support configuration of other implementation methods based on actual needs and experience, and are not limited to this.
[0074] In addition, in an embodiment of the present application, the token stored in the local queue in the business system can be an indifferent token, and a corresponding local queue can be maintained in the business system. Of course, the embodiment of the present application can also be applied to scenarios with a variety of different token types. In this scenario, a local queue can be maintained for each token type. Specifically, the present application provides a possible implementation method, and the second token acquisition request includes a token type, and the token type corresponds to the type of the business system. The token returned by the central system for the second token acquisition request is updated to the local queue, including: receiving a token of the token type returned by the central system for the second token acquisition request; storing the received token in the local queue corresponding to the token type, wherein each token type corresponds to a local queue.
[0075] In this way, a local queue is maintained for each token type. When the business system triggers the first token acquisition request, the token type required by the business system can be acquired from the local queue corresponding to the token type, thereby improving efficiency and business stability.
[0076] The following uses a specific application scenario to illustrate, taking the example of pulling the second number of tokens to the local queue when the business system starts, see Figure 2 , which is an overall architecture diagram of the data processing method in an embodiment of the present application.
[0077] like Figure 2 As shown, when the business system is started, a second number of tokens are obtained in batches from the central system, and the second number of tokens are stored in the local queue.
[0078] After the business system is started, each time a business in the business system needs to obtain a token, a first token acquisition request is triggered, and the first number of tokens stored in the local queue is determined. When the first number is greater than a first preset value, the number of tokens requested by the first token acquisition request is obtained from the local queue and sent to the business system, and the first number is updated to be provided to the business for use.
[0079] And when the updated first number is less than the second preset value, a second token acquisition request is sent to the central system, and the token returned by the central system for the second token acquisition request is updated to the local queue.
[0080] For example, see Figure 3 As shown, this is an example diagram of obtaining a token from a local queue in an embodiment of the present application, where the second number is 100, the first preset value is 0, and the second preset value is 50.
[0081] When the business system starts, it pulls 100 tokens from the central system and stores them in the local queue. After startup, multiple businesses in the business system continuously use and consume tokens in the local queue. For example, after reading the 50th token, it is determined that the updated first number in the local queue is 50, which is less than the second preset value. Then it is necessary to request a token from the central system again. For example, Figure 3 As shown, the third number requested is still 100. After obtaining the token returned by the central system, the 100 tokens obtained are stored in the local queue. When the subsequent business system requests the token again, the first number in the local queue is greater than the first preset value. For example, if the number of tokens read is 1, then after reading, the updated first number in the local queue is also greater than 50. At this time, there is no need to pull it from the central system.
[0082] In this way, in an embodiment of the present application, tokens can be pulled from the central system and stored in a local queue before being used by the business system. When the business system requires a token after startup, it can be obtained directly from the local queue, thereby improving the acquisition efficiency, reducing the impact on the business system, and improving the stability of the business system.
[0083] See also Figure 4 As shown, it is a flowchart of another data processing method in an embodiment of the present application. Figure 4 As shown, the centralized service scenario includes a central system and multiple business systems. Taking a business system as an example, the central system provides centralized services. For example, in the embodiment of the present application, the central system can provide centralized token services, specifically including:
[0084] S401: When the business system is started, token acquisition is triggered.
[0085] S402: Acquire a second number of tokens from the central system.
[0086] S403: Store the second number of tokens into the local queue.
[0087] In this way, in the embodiment of the present application, when the business system is started, the token is obtained and stored in the local queue, so that the token can be stored in the local queue before the business system uses it, thereby improving the availability of the business system requirements.
[0088] S404: The business system triggers a first token acquisition request.
[0089] S405: Read the local queue of the business system.
[0090] S406: Determine the first number of tokens stored in the local queue.
[0091] S407: Determine that the first number is greater than a first preset value, and execute step S410.
[0092] S408: Determine whether the updated first number is less than the second preset value, and execute step S409 and step S412 respectively.
[0093] Furthermore, in the embodiment of the present application, when it is determined that the first number is less than or equal to the first preset value, it is also necessary to request a token from the central system to store it in the queue of the current team.
[0094] It should be noted that in this step, after the number of tokens requested by the business system is sent from the local queue, the first number is updated, and then it is determined whether the updated first number is less than the second preset value. The purpose is to determine whether it is necessary to request a token from the central system at this time.
[0095] S409: Synchronously determine whether the updated first number is greater than the first preset value. If it is less than or equal to the first preset value, execute step S411. If it is greater than the first preset value, it means that the token requirement of the next business system can be met, and execute step S410.
[0096] S410: Return the token from the local queue to the business system.
[0097] S411: Request a token from the central system.
[0098] In this step, the updated first number currently remaining in the local queue is less than or equal to the first preset value, and may not meet the token demand of the next business system. At this time, the central system can be directly called to pull.
[0099] S412: Request a token from the central system.
[0100] S413: Store the acquired token into the local queue.
[0101] In addition, in an embodiment of the present application, other methods are also provided. For example, when a first token acquisition request is received from a business system, it can be determined whether the first number is less than the second preset value. If the first number is greater than or equal to the second preset value, it means that the first number is also greater than the first preset value. The token can be returned only to the business system, and there is no need to request a token from the central system. If the first number is less than the second preset value, on the one hand, a token is requested from the central system, and on the other hand, it is determined whether the first number is greater than the first preset value. If the first number is greater than the first preset value, the token can be returned to the business system. That is to say, in an embodiment of the present application, when the business system requests a token, it can also be determined whether it can be returned to the business system and whether it is necessary to request a token from the central system. This is not limited in the embodiment of the present application.
[0102] In an embodiment of the present application, tokens are obtained from the central system in batches at startup and stored in a local queue. When business needs arise in the business system after startup, tokens are obtained from the local queue, which reduces dependence on the central system. Directly obtaining tokens from the local queue also reduces the time spent in obtaining tokens, improves efficiency and performance, and when obtaining tokens from the local queue, if the number of tokens in the local queue is small, they can be pulled from the central system again in a timely manner, thereby improving the availability and stability of the business system.
[0103] It can be understood that the above-mentioned various method embodiments mentioned in this application can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, this application will not go into details. Those skilled in the art can understand that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined by its function and possible internal logic.
[0104] In addition, the present application also provides a data processing device, an electronic device, and a computer-readable storage medium, all of which can be used to implement any data processing method provided by the present application. The corresponding technical solutions and descriptions are referred to in the corresponding records of the method part and will not be repeated here.
[0105] Figure 5 A block diagram of a data processing device provided in an embodiment of the present application.
[0106] Reference Figure 5 , an embodiment of the present application provides a data processing device, the data processing device comprising:
[0107] A determination module 51, configured to determine, in response to a first token acquisition request for a business system, a first number of tokens stored in a local queue of the business system;
[0108] A first acquisition module 52, configured to acquire the number of tokens requested by the first token acquisition request from the local queue and send the tokens to the business system to update the first number when the first number is greater than a first preset value;
[0109] A first processing module 53, configured to send a second token acquisition request to the central system when the updated first number is less than a second preset value;
[0110] The updating module 54 is used to update the token returned by the central system in response to the second token acquisition request to the local queue.
[0111] In an optional embodiment, a second acquisition module 55 is further included, which is used to:
[0112] In response to the business system being started, obtaining a second number of tokens from the central system, and storing the second number of tokens in the local queue; or,
[0113] According to a preset pulling cycle, the second number of tokens is obtained from the central system, and the second number of tokens is stored in the local queue.
[0114] In an optional embodiment, the second token acquisition request includes a third number, and when the token returned by the central system for the second token acquisition request is updated to the local queue, the updating module 54 is used to:
[0115] Receive the third number of tokens returned by the central system according to the second token acquisition request, and store the third number of tokens in the local queue.
[0116] In an optional embodiment, the third number is greater than or equal to the difference between the second preset value and the updated first number.
[0117] In an optional embodiment, when the updated first number is less than the second preset value, when sending the second token acquisition request to the central system, the processing module 53 is used to:
[0118] When the updated first number is a third preset value, based on the asynchronous lock mode, sending a second token acquisition request to the central system;
[0119] In the case where the token returned by the central system is not received within a preset time period, the central system is called to make the central system return a token.
[0120] In an optional embodiment, the second token acquisition request includes a token type, and the token type corresponds to the type of the business system. When the token returned by the central system for the second token acquisition request is updated to the local queue, the update module 54 is used to:
[0121] Receiving a token of the token type returned by the central system in response to the second token acquisition request;
[0122] The received tokens are stored in a local queue corresponding to the token type, wherein each token type corresponds to one local queue.
[0123] In an optional embodiment, the second processing module 56 is further included to:
[0124] When the first number is less than or equal to the first preset value, sending a third token acquisition request to the central system;
[0125] Update the token returned by the central system in response to the third token acquisition request to the local queue;
[0126] The number of tokens requested by the first token acquisition request is obtained from the local queue and sent to the business system to update the first number.
[0127] Figure 6 A block diagram of an electronic device provided in an embodiment of the present application.
[0128] Reference Figure 6 An embodiment of the present application provides an electronic device, which includes: at least one processor 601; at least one memory 602, and one or more I / O interfaces 603, connected between the processor 601 and the memory 602; wherein the memory 602 stores one or more computer programs that can be executed by at least one processor 601, and the one or more computer programs are executed by at least one processor 601 so that the at least one processor 601 can execute the above-mentioned data processing method.
[0129] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned data processing method when executed by a processor. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0130] An embodiment of the present application also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned data processing method.
[0131] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0132] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0133] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0134] The computer program instructions for performing the operation of the present application can be assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions can be executed completely on a user's computer, partially on a user's computer, executed as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, 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 can be connected to an external computer (for example, using an Internet service provider to connect through the Internet). In some embodiments, by using the state information of a computer-readable program instruction to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA), the electronic circuit can execute a computer-readable program instruction, thereby realizing various aspects of the present application.
[0135] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0136] Various aspects of the present application are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0137] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0138] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0139] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the logical function of the specification. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can also be executed in the opposite order sometimes, depending on the function involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be realized by a dedicated hardware-based system that performs the function or action of the specification, or can be realized by a combination of special-purpose hardware and computer instructions.
[0140] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present application as set forth in the appended claims.
Claims
1. A data processing method, characterized in that: include: In response to a first token acquisition request for a business system, determining a first number of tokens stored in a local queue of the business system; When the first number is greater than a first preset value, obtaining the number of tokens requested by the first token acquisition request from the local queue and sending it to the business system, and updating the first number; When the updated first number is less than the second preset value, sending a second token acquisition request to the central system; The token returned by the central system in response to the second token acquisition request is updated to the local queue.
2. The data processing method according to claim 1, characterized in that: The method further comprises: In response to the business system being started, obtaining a second number of tokens from the central system, and storing the second number of tokens in the local queue; or, According to a preset pulling cycle, the second number of tokens is obtained from the central system, and the second number of tokens is stored in the local queue.
3. The data processing method according to claim 1, characterized in that: The second token acquisition request includes a third number, and updating the token returned by the central system in response to the second token acquisition request to the local queue includes: Receive the third number of tokens returned by the central system according to the second token acquisition request, and store the third number of tokens in the local queue.
4. The data processing method according to claim 3, characterized in that: The third number is greater than or equal to a difference between the second preset value and the updated first number.
5. The data processing method according to claim 1, characterized in that: When the updated first number is less than the second preset value, sending a second token acquisition request to the central system includes: When the updated first number is a third preset value, based on the asynchronous lock mode, sending a second token acquisition request to the central system; In the case where the token returned by the central system is not received within a preset time period, the central system is called to make the central system return a token.
6. The data processing method according to claim 1, characterized in that: The second token acquisition request includes a token type, and the token type corresponds to the type of the business system. The updating of the token returned by the central system in response to the second token acquisition request to the local queue includes: Receiving a token of the token type returned by the central system in response to the second token acquisition request; The received tokens are stored in a local queue corresponding to the token type, wherein each token type corresponds to one local queue.
7. The data processing method according to claim 1, characterized in that: The method further comprises: When the first number is less than or equal to the first preset value, sending a third token acquisition request to the central system; Update the token returned by the central system in response to the third token acquisition request to the local queue; The number of tokens requested by the first token acquisition request is obtained from the local queue and sent to the business system to update the first number.
8. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the data processing method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the data processing method according to any one of claims 1 to 7.
10. A computer program product, characterized in that The invention comprises a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the data processing method as described in any one of claims 1 to 7.
