A method, apparatus, electronic device, and storage medium for processing a resource
By directly obtaining user resource association records and status information, determining and processing resource allocation failure scenarios, and optimizing resource retry tasks with message queues and streaming computing engines, the real-time and storage problems of resource allocation failures in cloud computing are solved, and system performance and user experience are improved.
Patent Information
- Application Number
- CN202110001681.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-04
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-01-04
AI Technical Summary
The current technology has low real-time and efficiency in the processing of resource allocation failure scenarios in cloud computing, resulting in degradation of system performance and poor user experience, and the dependence on logging leads to large storage space.
By obtaining user resource association records and resource allocation status information, the resource processing failure scenario is directly determined, and the association records are processed according to the failure type, and the resource retry task is performed using message queues and streaming computing engines to reduce log read, write and store dependencies.
It improves the real-time resource processing and system performance, reduces storage space usage, avoids system paralysis and economic disputes, and improves user experience.
Smart Images

Figure CN114722261B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computers, and in particular, to a method, apparatus, electronic device, and storage medium for processing resources. Background Art
[0002] With the development of Internet technology, Internet technology is used in more and more application scenarios or application fields, and at the same time, more and more users have joined the Internet applications. Due to the continuous expansion of users' application requirements, higher requirements are also put forward for Internet technology. For various resources in Internet technology, the resources in Internet technology play a very important role in the application of Internet technology, but the number of various resources in Internet technology is huge and the usage environment is complex. Summary of the Invention
[0003] Embodiments of the present invention provide a method, apparatus, electronic device, and storage medium for processing resources.
[0004] A first aspect of the embodiments of the present disclosure provides a method for processing resources, including: obtaining a user resource association record and resource allocation status information; wherein, the user resource association record includes: a resource identifier associated with a user identifier; the resource allocation status information includes a resource identifier of an already allocated resource; determining, according to the user resource association record and the resource allocation status information, whether there is a resource processing failure scenario during the resource allocation process; if there is the resource processing failure scenario during the resource allocation process, processing the user resource association record according to the type of the resource processing failure scenario.
[0005] In one embodiment, the determining, according to the user resource association record and the resource allocation status information, whether there is a resource processing failure scenario during the resource allocation process includes: if the resource identifier of the already allocated resource includes a resource identifier other than the resource identifier associated with the user identifier, determining that there is a resource deletion failure scenario; and / or, if the resource identifier associated with the user identifier includes a resource identifier other than the resource identifier of the already allocated resource, determining that there is a resource addition failure scenario.
[0006] In one embodiment, if there is a resource processing failure scenario during the resource allocation process, the user resource association record is processed according to the type of the resource processing failure scenario, including: if the resource processing failure scenario is a resource addition failure scenario, the user resource association record corresponding to the resource with the addition failure is deleted; the resource with the addition failure includes: the resource corresponding to the resource identifier other than the resource identifier of the allocated resources among the resource identifiers associated with the user identifier; if the resource processing failure scenario is a resource deletion failure scenario, the user resource association record corresponding to the resource with the deletion failure is regenerated according to the resource allocation status information; the resource with the deletion failure includes: the resource corresponding to the resource identifier other than the resource identifier associated with the user identifier among the resource identifiers of the allocated resources.
[0007] In one embodiment, before processing the user resource association record according to the type of the resource processing failure scenario, the method further includes: generating a task message of a resource processing task according to the resource processing failure scenario; adding the task message of the resource processing task to a message queue; if there is a resource processing failure scenario during the resource allocation process, processing the user resource association record according to the type of the resource processing failure scenario includes: reading the task message from the message queue, and deleting the user association record in the resource addition failure scenario and / or regenerating the user resource association record corresponding to the resource with the deletion failure according to the task indicated by the task message.
[0008] In one embodiment, after processing the user resource association record, the method further includes: re-storing the updated user resource association record.
[0009] A second aspect of the embodiments of the present disclosure provides a resource processing apparatus, including: an acquisition module, configured to acquire a user resource association record and resource allocation status information; wherein, the user resource association record includes: a resource identifier associated with a user identifier; the resource allocation status information includes the resource identifier of the allocated resources; a determination module, configured to determine whether there is a resource processing failure scenario during the resource allocation process according to the user resource association record and the resource allocation status information; a processing module, configured to, if there is a resource processing failure scenario during the resource allocation process, process the user resource association record according to the type of the resource processing failure scenario.
[0010] In one embodiment, the determining module includes: a first determining sub-module, configured to determine that there is a resource deletion failure scenario if the resource identifier of the allocated resource includes a resource identifier other than the resource identifier associated with the user identifier; and / or, a second determining sub-module, configured to determine that there is a resource addition failure scenario if the resource identifier associated with the user identifier includes a resource identifier other than the resource identifier of the allocated resource.
[0011] In one embodiment, the processing module includes: a deletion sub-module, configured to delete the user resource association record corresponding to the resource with addition failure if the resource processing failure scenario is a resource addition failure scenario; the resource with addition failure includes: the resource corresponding to the resource identifier other than the resource identifier of the allocated resource in the resource identifier associated with the user identifier; a generation sub-module, configured to regenerate the user resource association record corresponding to the resource with deletion failure according to the resource allocation status information if the resource processing failure scenario is a resource deletion failure scenario; the resource with deletion failure includes: the resource corresponding to the resource identifier other than the resource identifier associated with the user identifier in the resource identifier of the allocated resource.
[0012] In one embodiment, it further includes: a task message generation module, configured to generate a task message of a resource processing task according to the resource processing failure scenario before processing the user resource association record according to the type of the resource processing failure scenario; an addition module, configured to add the task message of the resource processing task to a message queue; a task processing module, configured to read the task message from the message queue and delete the user association record of the resource addition failure scenario and / or regenerate the user resource association record corresponding to the resource with deletion failure according to the task indicated by the task message.
[0013] In one embodiment, it further includes: an update module, configured to re-warehouse the updated user resource association record after processing the user resource association record.
[0014] A third aspect of the embodiments of the present disclosure provides an electronic device, including:
[0015] A processor;
[0016] A memory storing program instructions, which, when executed by the processor, cause the electronic device to execute the method described in any one of the above.
[0017] A fourth aspect of the embodiments of the present disclosure provides a storage medium storing a program, which, when run by a processor, executes the method described in any one of the above.
[0018] The technical solution of the embodiments of the present disclosure determines a resource processing failure scenario by obtaining user resource association records and resource allocation status information, and then matching the user resource association records and the resource allocation status information. The user resource association records include resource identifiers associated with user identifiers, and the resource allocation status information includes the resource identifiers of the allocated resources. If there is a resource processing failure scenario, the user resource association records are processed according to the type of the resource processing failure scenario.
[0019] On the one hand, according to the actual business requirements, this solution can directly obtain user resource association records and resource allocation status information without relying on log records, and can perform resource processing operations at any time. This reduces the large performance overhead caused by resource processing during a certain period, the large number of resource processing tasks, and the resulting system paralysis, thus affecting the user experience. Since it can perform resource processing at any time according to business requirements, the waiting time for resource processing is reduced, thereby reducing the length of time for resource processing. Resources can be processed when they need to be processed without waiting for a fixed period, improving the real-time performance of resource processing.
[0020] On the other hand, by directly obtaining user resource association records and resource allocation status information instead of obtaining resource information based on log records, and then determining the resource processing method for the resource processing failure scenario, the dependence on logs is reduced, and the entire resource processing process does not require reading and writing logs. This solution can perform resource processing at any time, while saving the storage space occupied by logs in the storage medium and saving storage resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a schematic flowchart of a resource processing method provided by an embodiment of the present disclosure;
[0022] Figure 2 It is a schematic flowchart of another resource processing method provided by an embodiment of the present disclosure;
[0023] Figure 3 It is a schematic structural diagram of a resource processing device provided by an embodiment of the present disclosure;
[0024] Figure 4 It is a schematic flowchart of another resource processing method provided by an embodiment of the present disclosure;
[0025] Figure 5 It is a schematic interface diagram for processing resources selected in a specific application scenario provided by an embodiment of the present disclosure;
[0026] Figure 6A schematic diagram of the code corresponding to the user resource association record provided by an embodiment of the present disclosure;
[0027] Figure 7 A schematic diagram of obtaining the intersection of resource identifiers provided by an embodiment of the present disclosure;
[0028] Figure 8 A schematic diagram of determining a resource processing failure scenario provided by an embodiment of the present disclosure;
[0029] Figure 9 A schematic diagram of the resource processing result provided by an embodiment of the present disclosure. Detailed implementation manners
[0030] The technical solutions of the present invention will be further elaborated in detail below in conjunction with the accompanying drawings of the specification and specific embodiments.
[0031] With the development of Internet technology and the growth of the number of Internet users, higher requirements are put forward for the resource processing ability. In this context, cloud computing has become one of the future development trends of Internet technology due to its characteristics such as large scale, distributed characteristics, high availability, high scalability, security, economy, and environmental protection.
[0032] When using cloud computing services, the user selects the corresponding configuration according to the demand through a terminal (such as a browser) and makes a purchase. Then the system uses virtualization technology to generate the corresponding resources, allocates the resources to the corresponding user, and also generates an association record between the user and the resources. Since these purchased resources are time-limited and have the right to use within a certain period, after the resources expire, if the user does not intend to renew the subscription and does not want to continue using, and the user cancels the resource service, the system will recycle the corresponding resources and delete the association record between the user and the resources.
[0033] Due to the use of virtualization technology, it takes a long time to activate and allocate the corresponding resources or recycle the corresponding resources. Therefore, an asynchronous notification mechanism is adopted in the actual application environment. After the user purchases the service, an association record between the user and the resources can be generated and returned to the corresponding terminal to notify the user, and at the same time, the corresponding resource system is notified to activate and allocate the resources. After the user cancels the service, the association record between the user and the resources can be deleted and the deletion result of the association record is returned to the corresponding terminal to notify the user, and at the same time, the corresponding resource system is notified to recycle (delete) the resources.
[0034] Due to the large number of resources (such as computing resources, network resources, and storage resources, etc.) faced by cloud computing technology and the complex operating environment, there is a certain probability of failure when allocating, deleting resources through virtualization technology, or generating or deleting the association records between users and resources. Based on the asynchronous notification mechanism, there may be errors between the association records of users and resources recorded in the system and the allocated resources. That is, the resource allocation fails, but the association records of users and resources have been generated, and / or the resource deletion (recovery) fails, but the association records of users and resources have been deleted.
[0035] For the above situation, the current common solutions are as follows:
[0036] The system filters out the log records of the above-mentioned faulty resources according to the log records, and processes the resources in batches during the time period with the lowest user activity and the least system pressure, that is, performs resource retry tasks, and re-allocates or deletes the resources according to the corresponding resource operation records. However, the time period with the lowest user activity is generally from 3 am to 6 am, which means that this solution has a poor real-time performance problem. After the resource allocation or deletion fails, the resource cannot be retried immediately, which may cause the resource to be in a billing state and lead to economic disputes and other problems.
[0037] At the same time, the time-consuming of batch resource retry tasks within a certain time period is also relatively long. If all resource retry tasks cannot be completed within this time period, with the increase in user access volume and other tasks, it will inevitably affect the system performance, resulting in a reduction in the system processing capacity and affecting the user experience.
[0038] In addition, due to the short duration of the above-mentioned time period with the lowest user activity, if the resource retry tasks cannot be completed within this time period, it will inevitably affect the core business of the system, resulting in problems such as a decline in system performance and slow service response. Moreover, the resource allocation and deletion tasks will bring certain performance overheads. A large number of resource allocation and deletion tasks densely distributed within a very short time period may cause the system to crash, posing a risk that the system cannot provide services to the outside world.
[0039] There is also a problem with the above solution: the above solution needs to generate resource retry tasks according to the operation log records. This method only supports sequential reading and writing of operation log records, and cannot read operation records and execute resource retry tasks at any time according to actual needs. At the same time, by reading and writing log records, a large number of log records will inevitably be generated, and these log records will occupy a certain amount of storage space.
[0040] Reference Figure 1 , a resource processing method provided for the technical solution of this application, the method includes the following steps:
[0041] Step S100, obtain the user resource association record and the resource allocation status information. Among them, the user resource association record includes the resource identifier associated with the user identifier, and the resource allocation status information includes the resource identifier of the allocated resource.
[0042] Step S200, determine whether there is a resource processing failure scenario during the resource allocation process according to the user resource association record and the resource allocation status information.
[0043] Step S300, if there is the resource processing failure scenario during the resource allocation process, process the user resource association record according to the type of the resource processing failure scenario.
[0044] Among them,
[0045] Step S100, obtain the user resource association record and the resource allocation status information. Among them, the user resource association record includes the resource identifier associated with the user identifier, and the resource allocation status information includes the resource identifier of the allocated resource.
[0046] The user resource association record includes the stored user identifier and the resource identifier. The user resource association record represents the association relationship between the stored user identifier and the resource identifier, and reflects the association relationship between the stored user identifier and the resource identifier in the form of a user resource association record, thereby reflecting the relationship between the user and the resource. The resource identifier associated with the user identifier here can be the resource identifier that already has an association relationship with the user identifier, that is, the resource identifier that generates the user resource association record with the user identifier.
[0047] The resource identifier associated with the user identifier and the resource identifier of the allocated resource can both include computing resources, network resources, storage resources, etc. The computing resources can be CPU resources, the network resources can be bandwidth resources, and can be the communication resources of the communication network. Of course, it can also be other resources, which are not limited here and are all within the protection scope of this embodiment.
[0048] The resource allocation status information can be information other than the log record, and can be the resource allocation status information generated by a resource manager, etc., rather than the resource allocation status information obtained according to the log record. The management of resources by the resource manager can include the generation, allocation, and deletion (recovery) of resources, etc., and can also include invalid management, such as distinguishing normal resources and abnormal resources, etc.
[0049] The resource identifier of the allocated resource may be the resource identifier of the already allocated resource, and the resource identifier of the already allocated resource includes the resource identifier associated with the user identifier and / or the resource identifier not associated with the user identifier. That is, the resource identifier of the allocated resource may or may not be associated with the user identifier.
[0050] Step S200, determine whether there is a resource processing failure scenario during the resource allocation process according to the user resource association record and the resource allocation status information.
[0051] After obtaining the user resource association record and the resource allocation status information, match the user resource association record and the resource allocation status information to determine whether there is a resource processing failure scenario during the resource allocation process. Specifically, it may be determined whether the resource identifier associated with the user identifier and the resource identifier of the allocated resource are exactly the same according to the resource identifier associated with the user identifier included in the user resource association record and the resource identifier of the allocated resource included in the resource allocation status information, so as to determine whether there is a resource processing failure scenario. When the resource identifier associated with the user identifier and the resource identifier of the allocated resource are not all the same, it is determined that there is a resource processing failure scenario. When the resource identifier associated with the user identifier and the resource identifier of the allocated resource are all the same, it is determined that there is no resource processing failure scenario.
[0052] Among them, the resource processing failure scenario includes a resource addition failure scenario and a resource deletion failure scenario. The resource addition failure scenario includes: the resource identifier included in the user resource association record includes a resource identifier other than the resource identifier included in the resource status information. In this case, the resource processing failure scenario is determined as the resource addition failure scenario.
[0053] The resource addition failure scenario indicates that there already exists a resource identifier of a certain resource in the user resource association record associated with the user identifier of the corresponding user, that is, the resource identifier of this certain resource is already associated with the user identifier, and the user resource association record includes the resource identifier of this resource associated with the user identifier. However, the resource identifier in the allocated resources included in the resource status information does not include the resource identifier of this resource, and the resource identifier of this resource does not exist in the resource identifier of the allocated resources, indicating that the system has not generated and allocated this resource. That is, the resource activation and allocation fails, but the association record between the user and the resource has been generated.
[0054] The resource deletion failure scenario in the resource processing failure scenario includes: the resource identifier included in the resource status information includes a resource identifier other than the resource identifier included in the user resource association record. In this case, the resource processing failure scenario is determined as the resource deletion failure scenario.
[0055] The resource deletion failure scenario characterizes that the resource identifier of a certain resource has been deleted from the user resource association record, that is, the resource identifier of this resource associated with the user identifier in the user resource association record has been deleted, and there is no longer an association relationship between the resource identifier of this resource and the user identifier. However, the resource identifier corresponding to this resource has not been deleted (recycled) among the resource identifiers of the allocated resources included in the resource status information, and the resource identifier of this resource is still included in the resource identifiers of the allocated resources, indicating that the system has not deleted this resource. That is, the resource deletion (recycling) fails, but the association record between the user and the resource has been deleted.
[0056] Specifically, the resource processing failure scenario can be determined according to an algorithm. The process of this algorithm can include:
[0057] By determining the common resource identifiers between the resource identifiers associated with the user identifier in the user resource association record and the resource identifiers of the allocated resources in the resource allocation status information, that is, selecting the intersection of the resource identifiers associated with the user identifier and the resource identifiers of the allocated resources. This step can be carried out according to the resource ID of the resource corresponding to the resource identifier. The resource identifier intersection represents the resources that exist in both the user resource record information and the resource allocation status information, and the corresponding resources in the resource identifier intersection are the resources that have been successfully allocated.
[0058] Then select the first difference set between the resource identifiers associated with the user identifier in the user resource association record and the resource identifier intersection. Specifically, it can be selected through the resource ID corresponding to the resource identifier associated with the user identifier and the resource ID corresponding to the resource identifier intersection. If this first difference set exists and is not empty, this first difference set represents that the resource activation and allocation fails, but the association record between the user and the resource has been generated, that is, the resource addition failure scenario.
[0059] Select the second difference set between the resource identifiers of the allocated resources and the resource identifier intersection. Specifically, it can be selected through the resource ID corresponding to the resource identifier of the allocated resources and the resource ID corresponding to the resource identifier intersection. If this second difference set exists and is not empty, this second difference set represents that the resource deletion (recycling) fails, but the association record between the user and the resource has been deleted, that is, the resource deletion failure scenario.
[0060] Through this step, it can be determined whether the user resource association record is consistent with the resource allocation status information and whether there is a resource processing failure scenario, so as to process the resources when the two are inconsistent and there is a resource processing failure scenario.
[0061] Step S300, if there is the resource processing failure scenario during the resource allocation process, process the user resource association record according to the type of the resource processing failure scenario.
[0062] When it is determined that there is a resource processing failure scenario, the user resource association records are processed according to whether it is a resource addition failure scenario or a resource deletion failure scenario. Different resource processing failure scenarios correspond to different processing methods. The resource addition failure scenario corresponds to the processing method of the user resource association records for the resource addition failure scenario, and the resource deletion failure scenario corresponds to the processing method of the user resource association records for the resource deletion failure scenario.
[0063] This solution uses the resource identifier of the allocated resources as a reference benchmark. According to the resource identifier of the allocated resources, the resource identifiers associated with the user identifier are processed, so as to synchronize the resource identifier of the allocated resources and the resource identifier associated with the user identifier, make the two consistent, and reduce the errors existing in the process of resource use.
[0064] Through different processing methods for user resource association records in different resource processing failure scenarios, the processing of user resource association records is completed, so that the resource identifier associated with the user identifier in the user resource association records is the same as the resource identifier of the allocated resources in the resource allocation status information. It reduces the errors existing in the process of resource use and reduces the problem that the inconsistency between the allocated resources and the user resource association records leads to errors in the user resource records.
[0065] On the one hand, according to the actual business requirements, this solution can directly obtain the user resource association records and the resource allocation status information without logging, and can perform resource processing operations at any time. Thus, it reduces the large performance overhead caused by resource processing within a certain period of time, the large number of resource processing tasks, resulting in system paralysis, and thus affecting the user experience. Since it can perform resource processing at any time according to the business requirements, it reduces the waiting time for resource processing, thereby reducing the length of time for resource processing. It can process the resources when the resources need to be processed without waiting in a fixed time period, improving the real-time performance of resource processing.
[0066] On the other hand, by directly obtaining the user resource association records and the resource allocation status information instead of obtaining resource information according to logging, and then determining the resource processing method for the resource processing failure scenario, it reduces the dependence on logging. The entire resource processing process does not require reading and writing logs. This solution can perform resource processing at any time, and at the same time saves the occupied space of logs in the storage medium and saves storage resources.
[0067] In another embodiment, in step S200, according to the user resource association records and the resource allocation status information, it is determined whether there is a resource processing failure scenario in the resource allocation process.
[0068] Among them, if the resource identifier of the allocated resource contains a resource identifier other than the resource identifier associated with the user identifier, it is determined that there is a resource deletion failure scenario. When the resource identifier of the allocated resource includes a resource identifier that is not included in the resource identifier associated with the user identifier (for the sake of convenience, this resource identifier is referred to as the first resource identifier), it indicates that the user association record of the first resource identifier and the user identifier has been deleted, and the association record information of the first resource identifier and the user identifier no longer exists in the user association record. This first resource is the resource for which the deletion fails. However, the first resource identifier still exists in the resource identifier of the allocated resource, and the system does not delete (recycle) the first resource corresponding to the first resource identifier in the allocated resource, so the first resource identifier is not deleted in the resource identifier of the allocated resource.
[0069] In this case, it indicates that the deletion of the first resource fails, the first resource still exists, but the association record between the user and the first resource has been deleted, and this situation is determined as a resource deletion failure scenario.
[0070] If the resource identifier associated with the user identifier contains a resource identifier other than the resource identifier of the allocated resource, it is determined that there is a resource addition failure scenario. When the resource identifier associated with the user identifier contains a resource identifier that does not exist in the resource identifier of the allocated resource (for the sake of convenience, this resource identifier is referred to as the second resource identifier), it indicates that the system has not generated and allocated the second resource corresponding to the second resource identifier, so the second resource identifier does not exist in the resource identifier of the allocated resource. This second resource is the resource for which the addition fails. However, the second resource identifier already exists in the resource identifier associated with the user identifier, and the second resource identifier already has an association relationship with the user identifier, that is, the association record of the second resource identifier and the user identifier already exists in the user resource association record.
[0071] In this case, it indicates that the addition of the second resource fails, the second resource has not been successfully generated and allocated, but the association record between the user and the second resource already exists, and this situation is determined as a resource addition failure scenario.
[0072] In another embodiment, in step S300, if there is the resource processing failure scenario during the resource allocation process, according to the type of the resource processing failure scenario, processing the user resource association record includes:
[0073] If the resource processing failure scenario is the resource addition failure scenario, delete the user resource association records corresponding to the resources that failed to be added. To keep the resource identifiers of the allocated resources consistent with the resource identifiers associated with the user identifiers, based on the resource identifiers of the allocated resources, process the resource identifiers associated with the user identifiers and delete the user resource association records corresponding to the resources that failed to be added among the resource identifiers associated with the user identifiers. The resources that failed to be added include: the resources corresponding to the resource identifiers other than the resource identifiers of the allocated resources among the resource identifiers associated with the user identifiers. For example, the second resource.
[0074] Taking the second resource in the above embodiment as an example of the resource that failed to be added, the second resource is the resource corresponding to the resource identifier other than the allocated resource identifier included in the resource identifier associated with the user identifier. Delete the user resource association record associated with the user identifier corresponding to the second resource identifier of the second resource that failed to be added. In this way, the second resource identifier does not exist in the user resource association record, so that the resource identifiers associated with the user identifier in the user resource association record are consistent with the resource identifiers of the allocated resources, reducing the problem that the inconsistency between the allocated resources and the user resource association records leads to errors in the user resource records.
[0075] If the resource processing failure scenario is the resource deletion failure scenario, regenerate the user resource association records corresponding to the resources that failed to be deleted according to the resource allocation status information. Similarly, to keep the resource identifiers of the allocated resources consistent with the resource identifiers associated with the user identifiers, based on the resource identifiers of the allocated resources, process the resource identifiers associated with the user identifiers and regenerate the user resource association records corresponding to the resources that failed to be deleted in the user resource association records. The resources that failed to be deleted include: the resources corresponding to the resource identifiers other than the resource identifiers associated with the user identifiers among the resource identifiers of the allocated resources. For example, the first resource.
[0076] Taking the first resource in the above embodiment as an example of the resource that failed to be deleted, the first resource is the resource corresponding to the resource identifier other than the resource identifier associated with the user identifier included in the allocated resource identifier. Regenerate the association between the first resource identifier corresponding to the first resource that failed to be deleted and the user identifier. In this way, the resource identifiers associated with the user identifier included in the user resource association record are consistent with the resource identifiers of the allocated resources, reducing the problem that the inconsistency between the allocated resources and the user resource association records leads to errors in the user resource records.
[0077] It should be noted that the resource deletion failure scenario and the resource addition failure scenario may exist simultaneously or only one of them may exist. When both scenarios exist simultaneously, execute the resource processing methods corresponding to the two scenarios respectively.
[0078] ReferenceFigure 2 , in another embodiment, another method for processing resources is further provided. The processing method includes steps S100 and S200 in the above embodiment, which will not be described herein again. In addition to steps S100 and S200, it further includes:
[0079] Step S400: Generate a task message for the resource processing task according to the scenario where the resource processing fails.
[0080] After determining that there is a resource processing failure scenario, generate a corresponding task message for the resource processing task according to the type of the resource processing failure scenario. When the resource processing failure scenario is a resource addition failure scenario, generate a task message corresponding to the resource addition failure. When the resource processing failure scenario is a resource deletion failure scenario, generate a task message corresponding to the resource deletion failure.
[0081] Different task messages can carry different tags or flag bits, and the tags or flag bits can indicate what kind of task message the task message is, which is convenient for the execution of the task message.
[0082] Step S500: Add the task message of the resource processing task to the message queue.
[0083] Step S600: Read the task message from the message queue, and delete the user association record in the resource addition failure scenario and / or regenerate the user resource association record corresponding to the deleted failed resource according to the task indicated by the task message.
[0084] After adding the task message to the message queue, it is necessary to read the task message from the message queue according to the different message tasks indicated by the task message. When the task message is the task message corresponding to the resource deletion failure, regenerate the user resource association record corresponding to the deleted failed resource. When the task message is the task message corresponding to the resource addition failure, delete the user association record in the resource addition failure scenario.
[0085] By adding the task message to the message queue, the processing performance of the system can be improved. At the same time, since log records are required, a large amount of disk storage space does not need to be occupied, saving storage space. The task message can also be persistently processed through the message queue until the task message is processed, reducing the risk of data loss. The message queue can be a distributed message queue (such as Kafka, etc.).
[0086] In another embodiment, the above method may further include: after processing the user resource association record, re-storing the updated user resource association record into the database.
[0087] After processing the user resource association records according to the type of resource processing failure scenarios, the updated user resource association information is obtained, and the updated user resource association information is stored back in the database, etc.
[0088] In another embodiment, the above method for resource processing can be executed in a streaming computing engine (such as Flink, etc.). The streaming computing engine has the characteristics of streaming computing, which improves the timeliness of processing and can process resources in a timely manner.
[0089] Reference Figure 3 , which is a schematic structural diagram of a resource processing device provided by the technical solution of the present application. The processing device includes:
[0090] An obtaining module 1, configured to obtain user resource association records and resource allocation status information; wherein, the user resource association records include: resource identifiers associated with user identifiers; the resource allocation status information includes resource identifiers of the allocated resources.
[0091] A determining module 2, configured to determine whether there is a resource processing failure scenario during the resource allocation process according to the user resource association records and the resource allocation status information.
[0092] A processing module 3, configured to, if there is the resource processing failure scenario during the resource allocation process, process the user resource association records according to the type of the resource processing failure scenario.
[0093] Figure 3 Only the above three module structures are shown in [[ID=]], and other structures are not shown.
[0094] In another embodiment, the determining module includes:
[0095] A first determining sub-module, configured to determine that there is a resource deletion failure scenario if the resource identifier of the allocated resource includes a resource identifier other than the resource identifier associated with the user identifier;
[0096] And / or,
[0097] A second determining sub-module, configured to determine that there is a resource addition failure scenario if the resource identifier associated with the user identifier includes a resource identifier other than the resource identifier of the allocated resource.
[0098] In another embodiment, the processing module includes:
[0099] A deletion sub-module, configured to, if the resource processing failure scenario is a resource addition failure scenario, delete the user resource association records corresponding to the resources with addition failures; the resources with addition failures include: resources corresponding to the resource identifiers other than the resource identifiers of the allocated resources among the resource identifiers associated with the user identifier;
[0100] A generation sub-module, configured to, if the resource processing failure scenario is a resource deletion failure scenario, regenerate the user resource association record corresponding to the resource with deletion failure according to the resource allocation status information; the resources with deletion failure include: resources corresponding to the resource identifiers other than the resource identifiers associated with the user identifier in the resource identifiers of the allocated resources.
[0101] In another embodiment, the processing device further includes:
[0102] A task message generation module, configured to generate a task message for a resource processing task according to the resource processing failure scenario before processing the user resource association record according to the type of the resource processing failure scenario;
[0103] An addition module, configured to add the task message of the resource processing task to a message queue;
[0104] A task processing module, configured to read the task message from the message queue, and delete the user association record in the resource addition failure scenario and / or regenerate the user resource association record corresponding to the resource with deletion failure according to the task indicated by the task message.
[0105] In another embodiment, the device further includes:
[0106] An update module, configured to re-enter and update the updated user resource association record after processing the user resource association record.
[0107] The technical solution of the present application further provides an electronic device, including:
[0108] A processor;
[0109] A memory storing program instructions, which when executed by the processor, cause the electronic device to execute the method in any one of the above embodiments.
[0110] The technical solution of the present application further provides a storage medium storing a program, which when run by a processor, executes the method in any one of the above embodiments. The storage medium includes a non-transitory storage medium.
[0111] In another embodiment, the present invention provides a resource processing method, including a cloud computing resource processing method based on a streaming computing engine (Flink). The main idea of the method includes:
[0112] 1. Submit a resource retry job task to a Flink cluster of a streaming computing engine, and the Flink cluster of the streaming computing engine notifies a working node to obtain the user resource association record and the resource allocation status information.
[0113] 2. Match the user resource association records and resource allocation status information, and determine the resource processing failure scenarios, including determining the intersection and difference set between the resource identifiers of the user resource association records and the resource allocation status information.
[0114] 3. If there are resource processing failure scenarios, according to the types of the resource processing failure scenarios, process the user resource association records, including generating task messages for resource activation and / or deletion tasks, and persist them into the message queue (such as kafka), and the consumer consumes the task messages in the message queue kafka.
[0115] Reference Figure 4 , a resource processing method provided for another embodiment, the processing method includes steps A, B, and C. Among them:
[0116] A: The step of obtaining the user resource association records and resource allocation status information, this step includes:
[0117] Step 1: The client in the streaming computing engine flink sends a resource retry job request to the JobManager in the streaming computing engine flink. After receiving the request, the JobManager notifies each thread manager TaskManger in the streaming computing engine to run the task through the network. The TaskManger starts to run the task and feeds back the task running status and heartbeat information to the JobManager.
[0118] Reference Figure 5 , a schematic diagram of the interface for processing the resources selected in the specific application scenario.
[0119] Submit a business request to the flink cluster. This embodiment is to perform a resource processing task on the block storage resources of the POD2-KVM test resource pool under the East China regional center, creating the resources that failed to be added before or deleting the resources that failed to be cleared before.
[0120] Step 2: Each TaskManager accesses the system through the application programming interface (restful API) to obtain the set S1 corresponding to the user resource association records and the set S2 corresponding to the user resource association records.
[0121] Reference Figure 6 , an explanation of the relevant information in the set corresponding to the user resource association records and the resource allocation status information. The TaskManager of the flink cluster calls the application programming interface (restful API) to obtain the set S1 and the set S2 according to the conditions of POD2-KVM under the East China regional center.
[0122] B: Steps to match user resource association records and resource allocation status information to determine scenarios of failed resource processing. Among them, the types of scenarios of failed resource processing include: scenarios of failed resource addition and / or scenarios of failed resource deletion. These steps include:
[0123] Step 3: By comparing the unique ID identifiers of the elements in set S1 and set S2 one by one. If the ID identifier exists in both set S1 and set S2, it means that the resource corresponding to this ID identifier has been successfully activated, there is no error in the user resource association record, and no processing of the resource is required. Determine set Sall based on this ID identifier. Set Sall represents the set of resource identifiers that are common to the user resource association record and the user resource association record.
[0124] Step 4: Determine the difference set Sdel between set S1 and set Sall. This set corresponds to the user resource association records generated in the user resource association record in the scenario of failed resource addition, and there is no resource identifier in this set in the resource allocation status information. Determine the difference set Sadd between set S2 and set Sall. This set corresponds to the scenario of failed resource deletion where the resource identifier in this set has been allocated in the resource allocation status information, but there is no corresponding association record information in the user resource association record for this set.
[0125] Reference Figure 7 , determine the intersection Sall of set S1 and set S2. As Figure 7 shown, both set S1 and set S2 contain the resource identifier with the ID of 00251ace-dfde-4a30-99c4-966084269e96. Therefore, the number of elements (resource identifiers) in the generated set Sall is 1, and the ID of this element (resource identifier) is 00251ace-dfde-4a30-99c4-966084269e96.
[0126] C: If there is a scenario of failed resource processing, steps to process the user resource association record according to the type of the scenario of failed resource processing. These steps include:
[0127] It Step 5: Based on the sets Sdel and Sadd obtained in Step 4, generate corresponding resource operation tasks, determine whether the task is a creation task or a deletion task by setting the flag bit of the task, and serialize the task and write it into the message queue kafka.
[0128] Reference Figure 8 , determine the difference set between set S1 and set Sall, and the difference set between set S2 and set Sall, respectively obtaining the corresponding sets Sdel and Sadd. From Figure 8As can be seen, the elements (resource identifiers) in the set Sdel all satisfy that the ID only exists in the set S1 and does not exist in the set S2. The set Sdel represents the user resource association records corresponding to the resources that failed to be newly added in the scenario of resource addition failure. The elements (resource identifiers) in the set Sadd all satisfy that the ID only exists in the set S2 and does not exist in the set S1. The set Sadd represents the relevant information of the resource identifiers of the resources that failed to be deleted in the scenario of resource deletion failure.
[0129] Step 6: Multiple kafka consumers consume the data in the message queue and call the api to create and delete resources according to the task flag.
[0130] The TaskManager process generates specific task messages for the set Sadd and / or the set Sdel, serializes the task messages, and adds them to the message queue kafka. The consumer consumes the task messages in the message queue and calls the API interface according to the attributes of the task messages to execute the deletion or addition of the user resource association records.
[0131] Step 7: After the resource retry task is executed, the task status is updated and stored in the database.
[0132] Taking the deletion of resources as an example, observing the task monitoring platform of the system, it is found that the resource deletion tasks corresponding to the first two records are successfully executed and the resources have been normally deleted. Refer to Figure 9 .
[0133] Using the flink streaming computing engine, the batch resource retry tasks are evenly distributed to each time point according to the time sequence of resource operations, splitting the large task into multiple small tasks, and continuously operating on the small batch of resource retry tasks, so as to ensure data consistency and integrity and achieve a small system performance overhead. It solves the problems of poor real-time performance, large performance overhead, and long task time of the resource retry task.
[0134] By comparing the user resource association records and the resource allocation status information through the auditing algorithm, rather than generating resource creation and deletion tasks in the way of reading logs in the original solution, and serializing the tasks and persisting them to the message middleware kafka. It solves the problem that the resource retry task only supports the way of sequentially reading and writing operation logs, and at the same time, the resource retry task can be completed without the resource operation logs during operation, saving a large amount of storage costs and precious disk resources.
[0135] In the existing solution, to ensure resource retry tasks, it is necessary to read operation logs and generate resource retry tasks based on resource operation results, which causes the following problems: (1) Multiple operations may be performed on the same resource. For example, a certain resource is first created and then deleted, but from the result, no operation is required on this resource. This leads to a meaningless creation and deletion resource overhead of the system for this resource. (2) If a task fails during the execution of the resource retry batch task, then when the task is executed next time, it cannot start from the time point where the previous task failed and can only be executed sequentially from the starting position of the log, resulting in poor performance. (3) In an actual production environment, the log files generated by resource operation records are large, usually in the order of Gb, and these log files cannot be deleted, which leads to a large number of log files in the system occupying storage space. However, the solution of the present invention uses an auditing algorithm to generate deletion and generation tasks in real time, and resource retry tasks can be performed without operating on a large amount of logs, ensuring that there is only one operation on the resource and the situation of first creating and then deleting will not occur. At the same time, the tasks are persisted to the kafka message middleware, taking advantage of the compact structure of the kafka's own persistent files and the ability to freely select the file storage period, ensuring that a small amount of system storage space is occupied.
[0136] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical, or other forms.
[0137] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0138] In addition, in each embodiment of the present invention, the various functional units can all be integrated in a processing module, or each unit can be separately used as a unit, or two or more units can be integrated in one unit; the above integrated units can be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.
[0139] In some cases, when any two of the above technical features do not conflict, they can be combined into a new method technical solution.
[0140] In some cases, when any two of the above technical features do not conflict, they can be combined into a new device technical solution.
[0141] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including the above method embodiments; and the foregoing storage medium includes: various media that can store program codes, such as removable storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.
[0142] The above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for processing a resource, characterized in that, Including: Obtain user resource association records and resource allocation status information; wherein, the user resource association records include: resource identifiers associated with user identifiers, and the user resource association records are generated according to resources being allocated to users; the resource allocation status information includes the resource identifiers of the allocated resources; Determine whether there is a resource processing failure scenario during the resource allocation process according to the user resource association records and the resource allocation status information; If there is the resource processing failure scenario during the resource allocation process, process the user resource association records according to the type of the resource processing failure scenario.
2. The processing method according to claim 1, characterized in that The determining whether there is a resource processing failure scenario during the resource allocation process according to the user resource association records and the resource allocation status information includes: If the resource identifiers of the allocated resources include resource identifiers other than the resource identifiers associated with the user identifiers, determine that there is a resource deletion failure scenario; And / or If the resource identifiers associated with the user identifiers include resource identifiers other than the resource identifiers of the allocated resources, determine that there is a resource addition failure scenario.
3. The method according to claim 2, wherein The processing the user resource association records according to the type of the resource processing failure scenario if there is the resource processing failure scenario during the resource allocation process includes: If the resource processing failure scenario is a resource addition failure scenario, delete the user resource association records corresponding to the resources with addition failures; the resources with addition failures include: the resources corresponding to the resource identifiers other than the resource identifiers of the allocated resources in the resource identifiers associated with the user identifiers; If the resource processing failure scenario is a resource deletion failure scenario, regenerate the user resource association records corresponding to the resources with deletion failures according to the resource allocation status information; the resources with deletion failures include: the resources corresponding to the resource identifiers other than the resource identifiers associated with the user identifiers in the resource identifiers of the allocated resources.
4. The processing method according to any one of claims 1 to 3, characterized in that Before the processing the user resource association records according to the type of the resource processing failure scenario, the method further includes: Generate a task message of a resource processing task according to the resource processing failure scenario; Add the task message of the resource processing task to a message queue; The processing the user resource association records according to the type of the resource processing failure scenario if there is the resource processing failure scenario during the resource allocation process includes: Read the task message from the message queue, and delete the user association records in the resource addition failure scenario and / or regenerate the user resource association records corresponding to the resources with deletion failures according to the task indicated by the task message.
5. The processing method according to claim 1, wherein After the processing the user resource association records, the method further includes: Re-archive the updated user resource association records.
6. A processing device for a resource, characterized in that, Including: An obtaining module, configured to obtain user resource association records and resource allocation status information; wherein, the user resource association records include: resource identifiers associated with user identifiers, and the user resource association records are generated according to resources being allocated to users; the resource allocation status information includes the resource identifiers of the allocated resources; A determination module, configured to determine whether there is a resource processing failure scenario during the resource allocation process according to the user resource association record and the resource allocation status information; A processing module, configured to, if there is the resource processing failure scenario during the resource allocation process, process the user resource association record according to the type of the resource processing failure scenario.
7. The processing device according to claim 6, wherein The determination module includes: A first determination sub-module, configured to determine that there is a resource deletion failure scenario if the resource identifier of the allocated resource includes a resource identifier other than the resource identifier associated with the user identifier; And / or A second determination sub-module, configured to determine that there is a resource addition failure scenario if the resource identifier associated with the user identifier includes a resource identifier other than the resource identifier of the allocated resource.
8. The processing device according to claim 7, characterized in that, The processing module includes: A deletion sub-module, configured to, if the resource processing failure scenario is a resource addition failure scenario, delete the user resource association record corresponding to the resource with the addition failure; the resource with the addition failure includes: the resource corresponding to the resource identifier other than the resource identifier of the allocated resource in the resource identifier associated with the user identifier; A generation sub-module, configured to, if the resource processing failure scenario is a resource deletion failure scenario, regenerate the user resource association record corresponding to the resource with the deletion failure according to the resource allocation status information; the resource with the deletion failure includes: the resource corresponding to the resource identifier other than the resource identifier associated with the user identifier in the resource identifier of the allocated resource.
9. The processing device according to any one of claims 6 to 8, characterized in that, It further includes: A task message generation module, configured to generate a task message of a resource processing task according to the resource processing failure scenario before processing the user resource association record according to the type of the resource processing failure scenario; An addition module, configured to add the task message of the resource processing task to a message queue; A task processing module, configured to read the task message from the message queue, and delete the user association record of the resource addition failure scenario and / or regenerate the user resource association record corresponding to the resource with the deletion failure according to the task indicated by the task message.
10. The processing device according to claim 6, characterized in that, It further includes: An update module, configured to re-enter and update the updated user resource association record after processing the user resource association record.
11. An electronic device, including: A processor; A memory, which stores program instructions, and when the program instructions are executed by the processor, enables the electronic device to execute the method according to any one of claims 1 to 5.
12. A storage medium, which stores a program, and when the program runs on a processor, executes the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Detection method and device for invalid resources, electronic equipment and storage medium
CN109787862A