[go: up one dir, main page]

CN109471729B - Resource cleaning method and device based on recursion - Google Patents

Resource cleaning method and device based on recursion Download PDF

Info

Publication number
CN109471729B
CN109471729B CN201811358548.8A CN201811358548A CN109471729B CN 109471729 B CN109471729 B CN 109471729B CN 201811358548 A CN201811358548 A CN 201811358548A CN 109471729 B CN109471729 B CN 109471729B
Authority
CN
China
Prior art keywords
resource
resources
basic data
dependent
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811358548.8A
Other languages
Chinese (zh)
Other versions
CN109471729A (en
Inventor
向文宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811358548.8A priority Critical patent/CN109471729B/en
Publication of CN109471729A publication Critical patent/CN109471729A/en
Application granted granted Critical
Publication of CN109471729B publication Critical patent/CN109471729B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3698Environments for analysis, debugging or testing of software

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention relates to the field of data processing, and particularly discloses a resource cleaning method and device based on recursion, wherein the method comprises the following steps: determining a basic data resource which is not set to be reserved as a first resource, and searching a dependent resource of the first resource in a system where the first resource is located according to a resource identifier of the first resource; if the dependent resource of the first resource is not found in the system where the first resource is located, deleting the first resource; otherwise, respectively taking the dependent resources of the first resource as first resources to execute the step of searching the dependent resources of the first resource in the system where the first resource is located according to the resource identification of the first resource; and deleting the first resource after all the dependent resources of the first resource are deleted. By adopting the invention, the time and the labor for cleaning the resources can be saved, and sufficient resources can be provided.

Description

基于递归的资源清理方法及装置Resource cleaning method and device based on recursion

技术领域Technical Field

本发明涉及计算机技术领域,尤其涉及一种基于递归的资源清理方法及装置。The present invention relates to the field of computer technology, and in particular to a recursive resource cleaning method and device.

背景技术Background technique

随着计算机技术的不断发展,软件测试也越来越重要,在如今,基本上每个进行产品研发的单位都会有专门的软件测试人员,对研发出的产品的性能、正确性、完整性、安全性、代码或框架的严谨性等进行测试,包括白盒测试和黑盒测试等,以发现程序错误,衡量软件质量,并对其是否能满足设计要求进行评估,从而不断优化产品,保障投放到市场上的产品质量。With the continuous development of computer technology, software testing is becoming more and more important. Nowadays, basically every unit engaged in product research and development will have dedicated software testers to test the performance, correctness, integrity, security, code or framework rigor of the developed products, including white box testing and black box testing, etc., to discover program errors, measure software quality, and evaluate whether it can meet the design requirements, so as to continuously optimize products and ensure the quality of products put on the market.

而在软件测试行业内,为了验证产品的功能,测试人员会在测试环境、生产环境下不断创建产品进行测试,从而会消耗很多资源。验证完成后,测试人员通常会手动删除这些测试时候创建的资源,或者暂时不予处理,待资源不足时再按需清理一部分。然而,对于“手动清理”的方式,会在一定程度上消耗测试人员或管理人员的时间和人力;对于“暂不处理,待资源不足时再按需清理一部分”的方式,可能会影响测试进度,尤其在需要紧急获取资源时,会带来不便,影响工作进程。In the software testing industry, in order to verify the functions of the product, testers will continuously create products for testing in the test environment and production environment, which will consume a lot of resources. After the verification is completed, testers usually manually delete the resources created during the test, or temporarily ignore them and clean up some of them as needed when resources are insufficient. However, the "manual cleanup" method will consume the time and manpower of testers or managers to a certain extent; the "not processing for the time being, and clean up some of them as needed when resources are insufficient" method may affect the progress of the test, especially when resources need to be urgently obtained, which will cause inconvenience and affect the work process.

发明内容Summary of the invention

基于此,为解决上述提到的资源清理浪费人力和时间,还可能造成在急需使用时资源不足影响工作进程的问题,特提供了一种基于递归的资源清理方法和装置。Based on this, in order to solve the above-mentioned problem that resource cleaning wastes manpower and time, and may also cause insufficient resources when urgently needed, affecting the work progress, a recursive resource cleaning method and device are specially provided.

本发明实施例一方面提供了一种基于递归的资源清理方法,包括:An embodiment of the present invention provides a recursive resource cleaning method, comprising:

判断基础数据资源是否被设置为保留,若所述基础数据资源未被设置为保留,则确定所述基础数据资源为第一资源;Determining whether the basic data resource is set to be reserved, and if the basic data resource is not set to be reserved, determining that the basic data resource is the first resource;

根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源,所述第一资源的依赖资源为在生成时引用所述第一资源的数据资源;Searching for a dependent resource of the first resource in a system where the first resource is located according to the resource identifier of the first resource, where the dependent resource of the first resource is a data resource that references the first resource when it is generated;

若在所述第一资源的所处系统中查找到所述第一资源的至少一个依赖资源,则分别将所述第一资源的至少一个依赖资源作为第一资源执行所述根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源的步骤;If at least one dependent resource of the first resource is found in the system where the first resource is located, the step of searching for the dependent resource of the first resource in the system where the first resource is located according to the resource identifier of the first resource is performed using the at least one dependent resource of the first resource as the first resource;

若在所述第一资源的所处系统中未查找到所述第一资源的依赖资源,则删除所述第一资源,并将所述第一资源的被依赖资源作为第一资源执行所述根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源的步骤。If the dependent resources of the first resource are not found in the system where the first resource is located, the first resource is deleted, and the dependent resources of the first resource are used as the first resource to execute the step of searching for the dependent resources of the first resource in the system where the first resource is located according to the resource identifier of the first resource.

其中,所述第一资源的资源标识包括所述第一资源的引用标识,所述根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源包括:The resource identifier of the first resource includes a reference identifier of the first resource, and searching for a dependent resource of the first resource in a system where the first resource is located according to the resource identifier of the first resource includes:

根据所述第一资源的引用标识在所述第一资源的所处系统中查找资源名称包括所述第一资源的引用标识的其他数据资源,作为所述第一资源的依赖资源;According to the reference identifier of the first resource, searching in the system where the first resource is located for other data resources whose resource names include the reference identifier of the first resource as dependent resources of the first resource;

或者,根据所述第一资源的引用标识在所述第一资源的所处系统中查找资源内容包括所述第一资源的引用标识的其他数据资源,作为所述第一资源的依赖资源。Alternatively, other data resources whose resource contents include the reference identifier of the first resource are searched in the system where the first resource is located according to the reference identifier of the first resource as dependent resources of the first resource.

其中,所述判断基础数据资源是否被设置为保留包括:The step of determining whether the basic data resource is set to be reserved includes:

判断所述基础数据资源是否携带预设的保留标签,若是则确定所述基础数据资源被设置为保留,否则确定所述基础数据资源未被设置为保留;或Determine whether the basic data resource carries a preset retention tag, and if so, determine that the basic data resource is set to be retained, otherwise, determine that the basic data resource is not set to be retained; or

读取所述基础数据资源的布尔标记,若所述基础数据资源的布尔标记为true值则确定所述基础数据资源被设置为保留,否则确定所述基础数据资源未被设置为保留。The Boolean flag of the basic data resource is read, and if the Boolean flag of the basic data resource is a true value, it is determined that the basic data resource is set to be reserved, otherwise it is determined that the basic data resource is not set to be reserved.

其中,所述判断基础数据资源是否被设置为保留之前还包括:Wherein, the determining whether the basic data resource is set to be reserved also includes:

若确定到达预设的资源清理时间或接收到资源清理指令,则触发所述判断基础数据资源是否被设置为保留的步骤。If it is determined that the preset resource cleanup time has arrived or a resource cleanup instruction has been received, the step of determining whether the basic data resource is set to be retained is triggered.

其中,所述删除所述第一资源包括:The deleting the first resource includes:

提取所述第一资源的资源信息,所述第一资源的资源信息包括所述第一资源的id,所述第一资源的id用于指示所述第一资源的存放地址;Extracting resource information of the first resource, where the resource information of the first resource includes an ID of the first resource, where the ID of the first resource is used to indicate a storage address of the first resource;

根据所述第一资源的资源类型调用对应的资源删除方法,并将所述第一资源的id作为所述资源删除方法的调用参数,对所述第一资源进行删除。The corresponding resource deletion method is called according to the resource type of the first resource, and the id of the first resource is used as a calling parameter of the resource deletion method to delete the first resource.

其中,所述第一资源的信息还包括所述第一资源的创建用户账号;The information of the first resource also includes a user account for creating the first resource;

所述根据所述第一资源的资源类型调用对应的资源删除方法,并将所述第一资源的id作为所述资源删除方法的调用参数,对所述第一资源进行删除之后还包括:The method further includes calling a corresponding resource deletion method according to the resource type of the first resource, and using the ID of the first resource as a calling parameter of the resource deletion method, and after deleting the first resource, the method further includes:

根据所述第一资源的创建用户账号将所述第一资源的删除结果反馈给所述第一资源的创建用户,所述删除结果包括删除失败信息或删除成功信息。Feedback a deletion result of the first resource to the user who created the first resource according to the user account who created the first resource, wherein the deletion result includes deletion failure information or deletion success information.

其中,所述基础数据资源为虚拟私有云。Wherein, the basic data resource is a virtual private cloud.

其中,所述方法还包括:Wherein, the method further comprises:

在确定到达预设的资源清理时间或接收到资源清理指令后,提取所述基础数据资源的资源信息,将提取的所述基础数据资源的资源信息存入集合中,按序遍历,当所述基础数据资源的资源信息全部遍历结束,则结束资源清理。After determining that the preset resource cleaning time has arrived or receiving a resource cleaning instruction, the resource information of the basic data resource is extracted, the extracted resource information of the basic data resource is stored in a collection, and traversed in order. When all the resource information of the basic data resource is traversed, the resource cleaning is ended.

其中,在进行所述资源清理时,查找到所述第一资源的依赖资源之后,调用所述第一资源的依赖资源的资源信息,若所述第一资源的依赖资源有依赖资源,则自动将所述第一资源的依赖资源的资源信息存入缓存,将所述第一资源的依赖资源的依赖资源作为第一资源继续进行资源清理,否则删除所述第一资源的依赖资源,返回所述第一资源继续进行所述资源清理。Among them, when performing the resource cleanup, after finding the dependent resources of the first resource, the resource information of the dependent resources of the first resource is called. If the dependent resources of the first resource have dependent resources, the resource information of the dependent resources of the first resource is automatically stored in the cache, and the dependent resources of the dependent resources of the first resource are used as the first resources to continue resource cleanup. Otherwise, the dependent resources of the first resource are deleted, and the first resource is returned to continue the resource cleanup.

本发明实施例另一方面提供了一种图像处理装置,包括:Another aspect of the present invention provides an image processing device, including:

遍历处理模块,用于遍历资源,查找未被标记保留的基础数据资源,并将所述基础数据资源的资源信息存储到存储模块;A traversal processing module, used to traverse resources, search for basic data resources that are not marked as reserved, and store resource information of the basic data resources in a storage module;

存储模块,用于存储所述基础数据资源的信息及资源清理结果;A storage module, used to store the information of the basic data resources and resource cleaning results;

删除模块,用于若在第一资源的所处系统中未查找到所述第一资源的依赖资源,则删除所述第一资源,若在所述第一资源的所处系统中查找到所述第一资源的至少一个依赖资源,则分别将所述第一资源的至少一个依赖资源作为第一资源执行所述根据所述第一资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源的步骤;a deletion module, configured to delete the first resource if no dependent resource of the first resource is found in the system where the first resource is located, and to use the at least one dependent resource of the first resource as the first resource to perform the step of searching for the dependent resource of the first resource in the system where the first resource is located according to the first resource identifier if at least one dependent resource of the first resource is found in the system where the first resource is located;

判断模块,用于判断所述基础数据资源是否被设置保留,判断当前资源是否有依赖资源,及判断资源是否全部清理。The judgment module is used to judge whether the basic data resources are set to be retained, whether the current resources have dependent resources, and whether all resources are cleared.

设置模块,用于获取用户设置的删除资源的指定时间及所述基础数据资源是否保留;A setting module, used to obtain the specified time for deleting resources set by the user and whether the basic data resources are to be retained;

反馈模块,用于在资源清理结束后向用户反馈所述资源清理结果,所述资源清理结果包括资源删除结果。The feedback module is used to feed back the resource cleaning result to the user after the resource cleaning is completed, and the resource cleaning result includes the resource deletion result.

其中,所述判断模块包括:Wherein, the judgment module includes:

判断所述基础数据资源是否携带预设的保留标签,若是则确定所述基础数据资源被设置为保留,否则确定所述基础数据资源未被设置为保留,或者,读取所述基础数据资源的布尔标记,若所述基础数据资源的布尔标记为true值则确定所述基础数据资源被设置为保留,否则确定所述基础数据资源未被设置为保留;Determine whether the basic data resource carries a preset retention tag, if so, determine that the basic data resource is set to be retained, otherwise, determine that the basic data resource is not set to be retained, or read the Boolean tag of the basic data resource, if the Boolean tag of the basic data resource is a true value, determine that the basic data resource is set to be retained, otherwise, determine that the basic data resource is not set to be retained;

根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源,若在所述第一资源的所处系统中查找到包含所述第一资源的资源标识的其他数据资源,则所述第一资源有依赖资源,查找到的所述其他数据资源为所述第一资源的依赖资源;Searching for dependent resources of the first resource in the system where the first resource is located according to the resource identifier of the first resource; if other data resources containing the resource identifier of the first resource are found in the system where the first resource is located, then the first resource has dependent resources, and the other data resources found are dependent resources of the first resource;

通过遍历所述基础数据资源的信息过程中判断下一个基础数据资源信息是否为空得到所述资源清理结果,若为空则资源全部清理,否则继续进行资源清理。The resource cleaning result is obtained by traversing the information of the basic data resources and judging whether the next basic data resource information is empty. If it is empty, all resources are cleaned up, otherwise, resource cleaning continues.

本发明实施例另一方面提供了一种基于递归的资源清理装置,包括:处理器、存储器;Another aspect of the embodiment of the present invention provides a recursive-based resource cleaning device, comprising: a processor, a memory;

所述处理器与所述存储器相连,其中,所述存储器用于存储程序代码,所述处理器用于调用所述程序代码,执行如本发明实施例中一方面所述基于递归的资源清理方法。The processor is connected to the memory, wherein the memory is used to store program codes, and the processor is used to call the program codes to execute the recursive-based resource cleaning method as described in one aspect of an embodiment of the present invention.

本发明实施例另一方面提供了一种计算机存储介质,所述计算机存储介质存储有计算机程序指令,所述计算机程序指令当被处理器执行时用于处理如本发明实施例中一方面所述基于递归的资源清理方法。Another aspect of an embodiment of the present invention provides a computer storage medium storing computer program instructions. When the computer program instructions are executed by a processor, they are used to process the recursive-based resource cleaning method as described in one aspect of an embodiment of the present invention.

实施本发明实施例,将具有如下有益效果:Implementing the embodiments of the present invention will have the following beneficial effects:

本发明实施例通过使用递归删除的方式对资源进行清理,以一个基础数据资源为例,若所述基础数据资源未被设置为保留,则将所述基础数据资源确定为第一资源,根据所述第一资源的资源标识查找所述第一资源的依赖资源,若存在所述第一资源的依赖资源,则将所述第一资源的依赖资源确定为第一资源,执行所述根据第一资源的资源标识查找所述第一资源的依赖资源的步骤,否则删除所述第一资源,通过这种递归方式,最大限度地清理所有资源,同时保留需保留的资源,使资源可以按需清理,避免了资源清理不完全的情况出现,避免删除重要资源,而且定时自动清理节省了时间和人力。The embodiment of the present invention cleans up resources by using a recursive deletion method. Taking a basic data resource as an example, if the basic data resource is not set to be retained, the basic data resource is determined as a first resource, and the dependent resource of the first resource is searched according to the resource identifier of the first resource. If the dependent resource of the first resource exists, the dependent resource of the first resource is determined as the first resource, and the step of searching for the dependent resource of the first resource according to the resource identifier of the first resource is performed. Otherwise, the first resource is deleted. Through this recursive method, all resources are cleaned up to the maximum extent, and the resources that need to be retained are retained at the same time, so that resources can be cleaned up on demand, avoiding the occurrence of incomplete resource cleaning and the deletion of important resources. In addition, regular automatic cleaning saves time and manpower.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

其中:in:

图1为本发明实施例提供的一种基于递归的资源清理方法流程图;FIG1 is a flow chart of a recursive resource cleaning method provided by an embodiment of the present invention;

图2为本发明实施例的一个数据资源的处理结构图;FIG2 is a diagram showing a processing structure of a data resource according to an embodiment of the present invention;

图3为一个基于递归的资源清理实例图;FIG3 is a diagram showing an example of resource cleanup based on recursion;

图4为平安公有云的一个VPC资源依赖图;Figure 4 is a VPC resource dependency diagram of Ping An Public Cloud;

图5为本发明实施例提供的一种基于递归的资源清理装置的结构示意图;FIG5 is a schematic diagram of the structure of a recursive resource cleaning device provided by an embodiment of the present invention;

图6为本发明实施例提供的服务器的结构示意图。FIG. 6 is a schematic diagram of the structure of a server provided in an embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

请参见图1,图1是本发明实施例提供的一种基于递归的资源清理方法的流程图。如图1所示,上述方法包括以下步骤:Please refer to Figure 1, which is a flow chart of a recursive resource cleaning method provided by an embodiment of the present invention. As shown in Figure 1, the method includes the following steps:

步骤S101,判断基础数据资源是否被设置为保留;Step S101, determining whether the basic data resource is set to be reserved;

具体的,在确定到达预设的资源清理时间或接收到资源清理指令后,遍历本系统中所有资源,查找基础数据资源。上述基础数据资源是进行删除操作的起点,例如为虚拟私有云(VPC,VirtualPrivateCloud),为被其他数据资源依赖,但不依赖其他数据资源的数据资源。具体的,所述基础数据资源不包含其他数据资源的资源标识,在生成时不引用其他数据资源,即上述基础数据资源不依赖其他数据资源。查找到基础数据资源后判断上述基础数据资源是否被设置为保留,若上述基础数据资源未被设置为保留,则提取查找到的基础数据资源的资源信息,包括上述基础数据资源的id,上述基础数据资源的创建用户的账号等,将提取的上述基础数据资源的资源信息依次存入列表。Specifically, after determining that the preset resource cleanup time has been reached or receiving a resource cleanup instruction, all resources in the system are traversed to search for basic data resources. The above basic data resources are the starting point for the deletion operation, such as a virtual private cloud (VPC), which is a data resource that is dependent on other data resources but does not depend on other data resources. Specifically, the basic data resources do not contain resource identifiers of other data resources, and do not reference other data resources when generated, that is, the above basic data resources do not depend on other data resources. After finding the basic data resources, it is determined whether the above basic data resources are set to be retained. If the above basic data resources are not set to be retained, the resource information of the basic data resources found is extracted, including the id of the above basic data resources, the account of the user who created the above basic data resources, etc., and the extracted resource information of the above basic data resources is stored in the list in sequence.

具体的,通过判断上述基础数据资源是否携带预设的保留标签或读取上述基础数据资源的布尔标记来判断上述基础数据资源是否被设置为保留,若上述基础数据资源携带预设的保留标签或上述基础数据资源的布尔标记为true,则上述基础数据资源被设置为保留,执行步骤S108,否则未被设置为保留,提取上述基础数据资源的信息,执行步骤S102。Specifically, whether the basic data resource is set to be retained is determined by determining whether the basic data resource carries a preset retention tag or reading the Boolean mark of the basic data resource. If the basic data resource carries the preset retention tag or the Boolean mark of the basic data resource is true, the basic data resource is set to be retained, and step S108 is executed; otherwise, the basic data resource is not set to be retained, the information of the basic data resource is extracted, and step S102 is executed.

步骤S102,将所述基础数据资源确定为第一资源;Step S102, determining the basic data resource as the first resource;

具体的,上述存储的基础数据资源的资源信息以栈、队列或数组等的方式存储在系统中,上述基础数据资源的资源信息包括上述基础数据资源的id,上述基础数据资源的创建用户的账号,其中,上述基础数据资源的id用于指示上述基础数据资源的地址,作为调用删除上述基础数据资源方法的参数,对上述基础数据资源进行删除。Specifically, the resource information of the above-mentioned stored basic data resources is stored in the system in the form of a stack, queue or array, and the resource information of the above-mentioned basic data resources includes the id of the above-mentioned basic data resources and the account of the user who created the above-mentioned basic data resources, wherein the id of the above-mentioned basic data resources is used to indicate the address of the above-mentioned basic data resources, and is used as a parameter for calling a method for deleting the above-mentioned basic data resources to delete the above-mentioned basic data resources.

具体的,上述存储的基础数据资源的资源信息一种方式如下表所示:Specifically, one way of resource information of the basic data resources stored above is shown in the following table:

idid 资源名称Resource Name 创建用户Create User xxxxx1xxxxx1 基础资源ABasic Resources A XXXXXX xxxxx2xxxxx2 基础资源BBasic Resources B XXXXXX xxxxx3xxxxx3 基础资源CBasic Resources C XXXXXX

依次遍历,以基础数据资源的id作为参数调用上述基础数据资源的删除方法,通过上述基础数据资源的id获取上述基础数据资源的地址,访问上述基础数据资源,对上述基础数据资源进行删除操作。这里以一个基础数据资源为例,将该基础数据资源确定为第一资源。其中,第一资源为当前正在处理的数据资源,无具体的含义。Traverse in sequence, call the deletion method of the basic data resource with the id of the basic data resource as a parameter, obtain the address of the basic data resource through the id of the basic data resource, access the basic data resource, and delete the basic data resource. Here, take a basic data resource as an example, and determine the basic data resource as the first resource. The first resource is the data resource currently being processed, which has no specific meaning.

步骤S103,判断所述第一资源是否有依赖资源;Step S103, determining whether the first resource has dependent resources;

具体的,根据上述第一资源的资源标识在上述第一资源的所处系统中查找上述第一资源的依赖资源,若在上述第一资源的所处系统中查找到包含上述第一资源的资源标识的其他数据资源,则上述第一资源有依赖资源,查找到的上述其他数据资源为上述第一资源的依赖资源,执行步骤104,否则上述第一资源不存在依赖资源,执行步骤S105。Specifically, according to the resource identifier of the above-mentioned first resource, the dependent resources of the above-mentioned first resource are searched in the system where the above-mentioned first resource is located. If other data resources containing the resource identifier of the above-mentioned first resource are found in the system where the above-mentioned first resource is located, then the above-mentioned first resource has dependent resources, and the above-mentioned other data resources found are the dependent resources of the above-mentioned first resource. Execute step 104. Otherwise, the above-mentioned first resource has no dependent resources, and execute step S105.

步骤S104,将所述第一资源的依赖资源作为第一资源;Step S104, taking the dependent resource of the first resource as the first resource;

具体的,当查找到第一资源的依赖资源,则将上述第一资源放入缓存,同时将上述第一资源的依赖资源作为第一资源返回执行步骤S103。Specifically, when the dependent resource of the first resource is found, the first resource is put into the cache, and the dependent resource of the first resource is returned as the first resource to execute step S103.

步骤S105,删除所述第一资源;Step S105, deleting the first resource;

具体的,通过上述第一资源的信息中包含的id调用删除上述第一资源的方法,对上述第一资源进行删除。Specifically, the method for deleting the first resource is called through the id included in the information of the first resource to delete the first resource.

可选的,在进行删除操作时,调用删除方法,由于数据资源的类型不同,因此上述删除方法为重载方法,对上述第一资源进行删除,得到删除结果,若删除成功,则继续执行后续删除操作,否则将删除失败的信息上传到空文件中,上述删除失败的信息包括删除失败对应的数据资源id,删除失败对应的数据资源的创建用户账号及删除失败的原因,再继续执行后续删除操作。其中,可以通过数据资源的创建用户账号进行分类存储,在结束资源清理后,根据上述数据资源的创建用户账号将删除结果发送给对应的数据资源的创建用户;还可以直接将删除结果直接存入文件中,在结束资源清理后,逐行读取上述文件的内容,获取删除信息对应的创建用户账号,将该行信息反馈给该行创建用户账号对应的创建用户,由人工分析原因。Optionally, when performing a deletion operation, call the deletion method. Since the types of data resources are different, the above-mentioned deletion method is an overloaded method. Delete the above-mentioned first resource to obtain the deletion result. If the deletion is successful, continue to perform subsequent deletion operations, otherwise upload the deletion failure information to an empty file. The above-mentioned deletion failure information includes the data resource id corresponding to the deletion failure, the creation user account of the data resource corresponding to the deletion failure, and the reason for the deletion failure, and then continue to perform subsequent deletion operations. Among them, the data resource creation user account can be used for classified storage. After the resource cleaning is completed, the deletion result is sent to the corresponding data resource creation user according to the creation user account of the above-mentioned data resource; the deletion result can also be directly stored in the file. After the resource cleaning is completed, the content of the above-mentioned file is read line by line to obtain the creation user account corresponding to the deletion information, and the line of information is fed back to the creation user corresponding to the line of creation user account, and the reason is analyzed manually.

步骤S106,判断所述第一资源是否存在被依赖资源;Step S106, determining whether the first resource has any dependent resources;

具体的,通过缓存后序读取,在第一资源删除后,判断缓存中上述第一资源是否存在前驱数据资源,若存在,则上述第一资源存在被依赖资源,上述前驱数据资源即为上述第一资源的被依赖资源,执行步骤S107,否则执行步骤S108。具体的,上述缓存可以通过栈进行存储,利用栈先进后出的特性,通过处理栈顶所指示数据资源是否为空判断上述第一资源是否存在被依赖资源,若为空,则不存在被依赖资源,执行步骤S108,否则执行步骤S107。Specifically, by post-order reading of the cache, after the first resource is deleted, it is determined whether the first resource in the cache has a predecessor data resource. If so, the first resource has a dependent resource, and the predecessor data resource is the dependent resource of the first resource, and step S107 is executed, otherwise step S108 is executed. Specifically, the cache can be stored through a stack, and the first-in-last-out feature of the stack is used to determine whether the first resource has a dependent resource by processing whether the data resource indicated by the top of the stack is empty. If it is empty, there is no dependent resource, and step S108 is executed, otherwise step S107 is executed.

步骤S107,将所述第一资源的被依赖资源作为第一资源;Step S107, taking the dependent resource of the first resource as the first resource;

当缓存中上述第一资源存在前驱数据资源,则上述前驱数据资源为上述第一资源的被依赖资源,将上述第一资源的被依赖资源作为第一资源执行步骤S103。When there is a predecessor data resource for the first resource in the cache, the predecessor data resource is a dependent resource of the first resource, and step S103 is performed with the dependent resource of the first resource as the first resource.

步骤S108,处理下一基础数据资源;Step S108, processing the next basic data resource;

具体的,根据步骤S101查找的基础数据资源,从提取的基础数据资源信息列表中读取上一删除的基础数据资源的后继数据,所述后继数据为上一删除的基础数据资源的下一基础数据资源,将下一基础数据资源作为第一资源执行上述步骤S101-S107,直至所述基础数据资源信息列表全部遍历,结束此次资源清理。Specifically, according to the basic data resources found in step S101, the successor data of the last deleted basic data resource is read from the extracted basic data resource information list, and the successor data is the next basic data resource of the last deleted basic data resource. The above steps S101-S107 are executed with the next basic data resource as the first resource until the basic data resource information list is completely traversed, thereby ending this resource cleaning.

具体的,参见图2,图2为本发明实施例的一个数据资源的处理结构图。这里假定系统中存在系统数据资源301,包括数据资源A、B、C、D、E、A1、A2、A3、A11、A12、A21、B1,其中,数据资源E为含有“保留”标签的基础数据资源,其他数据资源为未被设置为保留的资源。通过遍历系统中数据资源,根据图1所示的资源清理步骤,进行以下操作:Specifically, see Figure 2, which is a processing structure diagram of a data resource in an embodiment of the present invention. It is assumed that there are system data resources 301 in the system, including data resources A, B, C, D, E, A1, A2, A3, A11, A12, A21, B1, among which data resource E is a basic data resource with a "reserved" tag, and other data resources are resources that are not set as reserved. By traversing the data resources in the system, according to the resource cleaning steps shown in Figure 1, the following operations are performed:

①判断基础数据资源是否被设置为保留,其中,基础数据资源A、B、C、D为未被设置为保留的资源,可以使用队列形式存储,包括基础数据资源A—>C—>B—>D。通过遍历系统中的所有资源,查找未被设置为保留的基础数据资源,提取上述基础数据资源的信息,进行入队操作,其中,基础数据资源的信息至少包括上述基础数据资源的id及创建用户账号,最终得到如下关系:A—>next=C,C—>next=B,B—>next=D。① Determine whether the basic data resources are set to be reserved, where basic data resources A, B, C, and D are resources that are not set to be reserved and can be stored in the form of a queue, including basic data resources A—>C—>B—>D. By traversing all resources in the system, finding basic data resources that are not set to be reserved, extracting the information of the above basic data resources, and performing a queue operation, where the information of the basic data resources at least includes the id of the above basic data resources and the user account that created them, the following relationship is finally obtained: A—>next=C, C—>next=B, B—>next=D.

②依次读取上述基础资源,将基础数据资源A确定为第一资源;② Read the above basic resources in sequence and determine the basic data resource A as the first resource;

③判断上述基础数据资源A是否有依赖资源;③ Determine whether the above basic data resource A has dependent resources;

④上述基础数据资源A存在依赖资源,将基础数据资源A加入缓存,将基础数据资源A的依赖资源A1作为第一资源;④ The above basic data resource A has dependent resources, the basic data resource A is added to the cache, and the dependent resource A1 of the basic data resource A is used as the first resource;

⑤判断数据资源A1是否有依赖资源;⑤ Determine whether data resource A1 has dependent resources;

⑥上述数据资源A1存在依赖资源,将上述数据资源A1加入缓存,此时缓存中包括A—>A1,将查找到的数据资源A1的依赖资源A12作为第一资源;⑥ The data resource A1 has dependent resources, and the data resource A1 is added to the cache. At this time, the cache includes A—>A1, and the dependent resource A12 of the found data resource A1 is used as the first resource;

⑦判断数据资源A12是否存在依赖资源;⑦ Determine whether data resource A12 has dependent resources;

⑧数据资源A12没有依赖资源,删除数据资源A12;⑧Data resource A12 has no dependent resources, so delete data resource A12;

⑨读取缓存,数据资源A12存在前驱数据A1,将数据资源A1取出缓存作为第一资源,返回执行⑤。⑨ Read the cache. If data resource A12 has predecessor data A1, take data resource A1 out of the cache as the first resource and return to execute ⑤.

同理,依次删除数据资源A11—>A1—>A21—>A2—>A3—>A,完成基础数据资源A及其依赖资源的清理,使用同种方法删除基础数据资源C、B、D及其依赖资源。Similarly, delete data resources A11—>A1—>A21—>A2—>A3—>A in sequence to complete the cleanup of basic data resource A and its dependent resources. Use the same method to delete basic data resources C, B, D and their dependent resources.

基础数据资源和依赖资源的关系结构图可看做树形结构,以后序遍历顺序进行删除操作,删除的基本步骤如下所示:The relationship structure diagram between basic data resources and dependent resources can be viewed as a tree structure. The deletion operation is performed in post-order traversal order. The basic steps of deletion are as follows:

可选的,具体的删除过程以图3为例,图3为基于递归的资源清理实例图。具体的,可根据存储地址依次读取系统中的数据资源,使用正则表达式进行标签匹配,判断基础数据资源是否被设置为保留。其中,数据资源A不包含其他数据资源的资源标识,确定为基础数据资源,提取数据资源A的信息加入列表基础数据资源302,这里假定使用队列进行存储,此时数据资源A的信息位于队首front,依次遍历,数据资源A1包含数据资源A的资源标识,确定为依赖资源,提取数据资源A1的信息放入未处理依赖资源303列表中,同理,可得到最终结果数据处理1,基础数据资源302包括A—>C—>B—>D,未处理依赖资源303,包括A1—>A12—>A2—>B1—>A21—>A11—>A3,其中,数据资源E不包含其他数据资源的资源标识,确定为基础数据资源,经过正则表达式匹配到“保留”标签,因此,数据资源E不进行删除,不予处理。其中,未处理依赖资源303用于存放未进行删除处理的数据资源,用于后续的依赖资源查找。Optionally, the specific deletion process is shown in Figure 3, which is a diagram of a resource cleanup example based on recursion. Specifically, the data resources in the system can be read in sequence according to the storage address, and regular expressions can be used for label matching to determine whether the basic data resources are set to be retained. Among them, data resource A does not contain the resource identifier of other data resources, and is determined to be a basic data resource. The information of data resource A is extracted and added to the list of basic data resources 302. It is assumed here that a queue is used for storage. At this time, the information of data resource A is located at the front of the queue. After traversing in sequence, data resource A1 contains the resource identifier of data resource A and is determined to be a dependent resource. The information of data resource A1 is extracted and put into the list of unprocessed dependent resources 303. Similarly, the final result data processing 1 can be obtained. Basic data resources 302 include A—>C—>B—>D, and unprocessed dependent resources 303 include A1—>A12—>A2—>B1—>A21—>A11—>A3. Among them, data resource E does not contain the resource identifier of other data resources and is determined to be a basic data resource. After the regular expression matches the "retain" label, data resource E is not deleted and is not processed. Among them, the unprocessed dependent resources 303 are used to store data resources that have not been deleted for subsequent dependent resource search.

依次遍历基础数据资源302,通过数据资源A的信息包含的id访问数据资源A,对数据资源A进行删除,遍历未处理依赖资源303,查找到数据资源A的依赖资源,因此将数据资源A的信息放入缓存资源304中,这里可以以栈的形式存储,其中,数据资源A为栈底bottom,也为栈顶top,同时,对数据资源A的依赖资源A1进行删除操作,如数据处理2所示,数据资源A1存在依赖资源,加入缓存资源304中,为栈顶top,同理,经过处理,对数据资源A1的依赖资源A12进行删除操作,数据资源A12没有依赖资源,加入缓存资源304后,直接根据数据资源A12的id及数据类型调用删除方法进行删除操作,若删除成功,则得到系统数据资源301.a所示数据,对缓存资源304进行出栈操作,top--,若删除失败,则存储数据资源A12的失败信息。再对此时的栈顶数据资源A1进行操作,此时数据资源A1存在依赖资源A11,将数据资源A11加入缓存资源304中,此时未处理依赖资源303包括数据资源A2—>B1—>A21—>A3,对A11进行删除操作,此时数据资源A1不存在依赖资源,则对数据资源A1进行删除操作,删除成功后对缓存资源304进行出栈操作,此时的处理对象为数据资源A,遍历未处理依赖资源303,查找到数据资源A的依赖资源A2,对数据资源A2进行删除操作,在未处理依赖资源303中查找到数据资源A2的依赖资源A21,如上述操作所示,依次删除数据资源A21、数据资源A2,此时未处理依赖资源303中包括数据资源B1—>A3。同理可删除数据资源A3,此时数据资源A不存在依赖资源,将数据资源A进行删除,得到数据处理4所示结果,未处理依赖资源303包括数据资源B1,缓存资源304为空,基础数据资源302包括基础数据资源信息C—>B—>D,系统中数据资源包括数据资源C、数据资源B、数据资源B1、数据资源D、数据资源E。The basic data resources 302 are traversed in sequence, and the data resource A is accessed through the id contained in the information of the data resource A, and the data resource A is deleted. The unprocessed dependent resources 303 are traversed to find the dependent resources of the data resource A, so the information of the data resource A is put into the cache resource 304, which can be stored in the form of a stack, wherein the data resource A is the bottom of the stack and also the top of the stack. At the same time, the dependent resource A1 of the data resource A is deleted. As shown in data processing 2, the data resource A1 has dependent resources. It is added to the cache resource 304 and is the top of the stack. Similarly, after processing, the dependent resource A12 of the data resource A1 is deleted. The data resource A12 has no dependent resources. After being added to the cache resource 304, the deletion method is directly called according to the id and data type of the data resource A12 to perform the deletion operation. If the deletion is successful, the data shown in the system data resource 301.a is obtained, and the cache resource 304 is popped out of the stack, top--. If the deletion fails, the failure information of the data resource A12 is stored. Then operate on the data resource A1 at the top of the stack. At this time, data resource A1 has a dependent resource A11. Data resource A11 is added to the cache resource 304. At this time, the unprocessed dependent resources 303 include data resources A2->B1->A21->A3. A11 is deleted. At this time, data resource A1 has no dependent resources, so data resource A1 is deleted. After the deletion is successful, the cache resource 304 is popped out of the stack. At this time, the processing object is data resource A. The unprocessed dependent resources 303 are traversed to find the dependent resource A2 of data resource A. The data resource A2 is deleted. The dependent resource A21 of data resource A2 is found in the unprocessed dependent resources 303. As shown in the above operation, data resource A21 and data resource A2 are deleted in turn. At this time, the unprocessed dependent resources 303 include data resources B1->A3. Similarly, data resource A3 can be deleted. At this time, data resource A has no dependent resources. Data resource A is deleted to obtain the result shown in data processing 4. The unprocessed dependent resources 303 include data resource B1, the cache resource 304 is empty, and the basic data resource 302 includes basic data resource information C—>B—>D. The data resources in the system include data resource C, data resource B, data resource B1, data resource D, and data resource E.

重复上述步骤,依次删除数据资源C、数据资源B1、数据资源B、数据资源D,最终得到系统数据资源301.c所示数据,包括数据资源E,数据处理5中基础数据资源302、未处理依赖资源303、缓存资源304均为空,释放基础数据资源302、未处理依赖资源303、缓存资源304所占空间,结束此次资源清理,将上述资源清理的结果反馈給数据资源对应的创建用户。Repeat the above steps, delete data resource C, data resource B1, data resource B, and data resource D in turn, and finally obtain the data shown in system data resource 301.c, including data resource E. The basic data resources 302, unprocessed dependent resources 303, and cache resources 304 in data processing 5 are all empty, releasing the space occupied by the basic data resources 302, unprocessed dependent resources 303, and cache resources 304, ending this resource cleanup, and feeding back the results of the above resource cleanup to the user who created the data resource.

可选的,这里假定数据资源A2、数据资源B删除失败,数据资源A2的创建用户账号为XX1,数据资源B的创建用户账号为XX2。Optionally, it is assumed here that the deletion of data resource A2 and data resource B fails, the user account for creating data resource A2 is XX1, and the user account for creating data resource B is XX2.

其中,当对数据资源A2进行删除时删除失败,则将数据资源A2的删除结果存入删除结果文件中,具体的,若此文件已存在,则将上述数据资源A2的id及其创建用户的账号XX1、上述数据资源A2的删除失败原因存入此文件,否则创建一个新文件,存储上述数据资源A2的删除结果。其中,由于数据资源A2删除失败,则数据资源A也无法删除,同样存入上述文件中,当删除数据资源B时,删除失败,由于数据资源A2删除失败时已经存在/创建了删除结果文件,则直接将数据资源B的id及其创建用户的账号XX2、上述数据资源B删除失败的原因存入上述删除结果文件中。具体的,结束资源清理后,逐行读取文件内容,将本行的数据资源的删除结果反馈给创建用户的账号对应的创建用户。其中,读取第一行为数据资源A2的删除结果,将上述删除结果反馈给创建用户的账号XX1对应的用户,第二行为数据资源A的删除结果,同样反馈给创建用户的账号XX1对应的用户,删除失败原因为依赖资源无法删除,第三行为数据资源B的删除结果,将上述数据资源B的删除结果反馈给创建用户的的账号XX2对应的用户。Wherein, when the deletion of data resource A2 fails, the deletion result of data resource A2 is stored in the deletion result file. Specifically, if this file already exists, the id of the above data resource A2, the account XX1 of the user who created it, and the reason for the failure to delete the above data resource A2 are stored in this file. Otherwise, a new file is created to store the deletion result of the above data resource A2. Wherein, since the deletion of data resource A2 fails, data resource A cannot be deleted either, and is also stored in the above file. When deleting data resource B, the deletion fails. Since the deletion result file already exists/is created when the deletion of data resource A2 fails, the id of data resource B, the account XX2 of the user who created it, and the reason for the failure to delete the above data resource B are directly stored in the above deletion result file. Specifically, after the resource cleanup is completed, the file content is read line by line, and the deletion result of the data resource in this line is fed back to the creating user corresponding to the creating user's account. Among them, the first line is read as the deletion result of data resource A2, and the above deletion result is fed back to the user corresponding to the account XX1 of the user who created the user. The second line is the deletion result of data resource A, which is also fed back to the user corresponding to the account XX1 of the user who created the user. The reason for the deletion failure is that the dependent resources cannot be deleted. The third line is the deletion result of data resource B, and the deletion result of the above data resource B is fed back to the user corresponding to the account XX2 of the user who created the user.

其中,当数据资源A2删除失败时,则将数据资源的删除结果存入以创建用户账号XX1命名的文件中。具体的,若该文件已存在,则将上述数据资源A2的id、上述数据资源A2的创建用户账号、上述数据资源A2的删除失败原因存入此文件中,否则提取上述数据资源A2的创建用户账号XX1,创建以上述创建用户账号XX1命名的文件,存储上述数据资源A2的删除结果。由于数据资源A2删除失败,则数据资源A的依赖资源无法删除,因此也删除失败,将上述数据资源A的删除结果存入文件XX1中。继续删除,当数据资源B删除失败时,创建以XX2命名的文件,将数据资源B的删除结果存入文件XX2中。具体的,结束资源清理后,将得到的资源清理结果存储文件发送给上述资源清理结果存储文件名对应的创建用户,即将以XX1命名的文件发送给XX1对应的用户,将以XX2命名的文件发送给XX2对应的用户。Among them, when the deletion of data resource A2 fails, the deletion result of the data resource is stored in a file named after the creation user account XX1. Specifically, if the file already exists, the id of the above data resource A2, the creation user account of the above data resource A2, and the reason for the failure to delete the above data resource A2 are stored in this file, otherwise the creation user account XX1 of the above data resource A2 is extracted, and a file named after the creation user account XX1 is created to store the deletion result of the above data resource A2. Since the deletion of data resource A2 fails, the dependent resources of data resource A cannot be deleted, so the deletion also fails, and the deletion result of the above data resource A is stored in file XX1. Continue to delete, when the deletion of data resource B fails, create a file named XX2, and store the deletion result of data resource B in file XX2. Specifically, after the resource cleanup is completed, the obtained resource cleanup result storage file is sent to the creation user corresponding to the above resource cleanup result storage file name, that is, the file named XX1 is sent to the user corresponding to XX1, and the file named XX2 is sent to the user corresponding to XX2.

本发明实施例通过根据预设的资源清理时间或收到的资源清理请求对资源进行清理,使用递归方式,查找引用基础数据资源的其他数据资源,进行递归删除。具体的,在本发明的一个实施例中,以平安公有云产品为例,平安公有云多数产品都是基于一个独立的隔离网络进行创建的,其中,上述隔离网络为在平安公有云上进行数据生成时划分的虚拟网络空间,一个隔离网络在公有云上体现为一个VPC,一个VPC为一个基础数据资源,在此VPC里,用户可以按需创建网络域、子网和云主机、弹性文件、负载均衡等计算、存储、网络类的产品,这些产品之间互相依赖或被依赖。具体的,参见图4,图4是平安公有云的一个VPC资源依赖图。这里假定用户A在平安公有云400上使用分配的一个VPC401创建了一个网络4011进行产品测试,在此基础上创建子网4012,下设置云主机4014及关系数据库4013,用于具体的数据处理及存储,在测试过程中,系统生成弹性文件4015、ELB(ElasticLoadBalance)4016等共享文件,用于生成存储测试结果,其中,生成的文件依赖关系如图4所示,ELB4016及弹性文件4015直接依赖于云主机4014和关系数据库4013,云主机4014和关系数据库4013依赖于子网4012,子网依赖于网络4011。具体的,此处的所有生成文件为单次使用,未被设置为保留。The embodiment of the present invention cleans up resources according to a preset resource cleanup time or a received resource cleanup request, uses a recursive method to search for other data resources that reference basic data resources, and performs recursive deletion. Specifically, in one embodiment of the present invention, taking Ping An public cloud products as an example, most of Ping An public cloud products are created based on an independent isolated network, wherein the above-mentioned isolated network is a virtual network space divided when data is generated on Ping An public cloud. An isolated network is reflected as a VPC on the public cloud, and a VPC is a basic data resource. In this VPC, users can create network domains, subnets and cloud hosts, elastic files, load balancing and other computing, storage, and network products on demand, and these products are dependent on or depend on each other. Specifically, see Figure 4, which is a VPC resource dependency diagram of Ping An public cloud. Here, it is assumed that user A uses an allocated VPC 401 on Ping An Public Cloud 400 to create a network 4011 for product testing, and then creates a subnet 4012 on this basis, and sets up a cloud host 4014 and a relational database 4013 for specific data processing and storage. During the test, the system generates shared files such as elastic files 4015 and ELB (ElasticLoadBalance) 4016 to generate storage test results. The generated file dependencies are shown in FIG4 . ELB 4016 and elastic files 4015 directly depend on cloud hosts 4014 and relational databases 4013, which depend on subnet 4012, and subnets depend on network 4011. Specifically, all generated files here are for single use and are not set to be retained.

在本发明的该实施例中,到达预设的资源清理时间或收到资源清理请求后,对平安公有云400上的资源进行遍历,提取基础数据资源VPC401的信息,经过查找,基础数据资源VPC401存在依赖资源网络4011,将VPC401加入缓存,对依赖资源网络4011进行删除处理,网络4011存在依赖资源子网4012,将网络4011加入缓存处理依赖资源子网4012,查找子网4012的依赖资源,遍历数据资源后找到云主机4014依赖于子网4012,将子网4012加入缓存,处理云主机4014,同理,查找到ELB4016依赖于云主机4014,将云主机4014加入缓存中,对ELB4016进行删除处理,ELB4016不存在依赖资源,删除ELB4016,返回上一步操作,继续查找云主机4014的依赖资源,存在依赖资源弹性文件4015,则判断弹性文件4015是否存在依赖资源,由于弹性文件4015不存在依赖资源,因此删除弹性文件4015,返回继续处理云主机4014,此时云主机4014不存在依赖资源,将云主机4014取出缓存,删除云主机4014,再后序读取缓存,判断子网4012是否还存在依赖关系,查找到子网4012还存在依赖资源关系数据库4013,对关系数据库4013进行删除处理,,由于关系数据库4013的依赖资源ELB4016及弹性文件4015已经被删除,此时关系数据库4013无依赖资源,直接进行删除,此时子网4012不存在依赖资源,将子网4012取出缓存,删除子网4012,继续后序读取缓存,对网络4011进行删除处理,此时网络4011不存在依赖资源,可直接取出缓存进行删除,最后释放所在的VPC401,完成此次资源清理。In this embodiment of the present invention, after reaching the preset resource cleanup time or receiving a resource cleanup request, the resources on Ping An public cloud 400 are traversed, and the information of the basic data resource VPC401 is extracted. After searching, the basic data resource VPC401 has a dependent resource network 4011, and VPC401 is added to the cache, and the dependent resource network 4011 is deleted. The network 4011 has a dependent resource subnet 4012, and the network 4011 is added to the cache to process the dependent resource subnet 4012, and the dependent resources of the subnet 4012 are searched. After traversing the data resources, it is found that the cloud host 4014 depends on the subnet 4012, and the subnet 4012 is added to the cache, and the cloud host 4014 is processed. Similarly, it is found that ELB4016 depends on the cloud host 4014, and the cloud host 4014 is added to the cache, and the ELB4016 is deleted. ELB4016 does not have a dependent resource, and ELB4016 is deleted. Return to the previous step, continue to search for the dependent resources of the cloud host 4014, and there is a dependent resource elastic file 401 5. It is determined whether elastic file 4015 has dependent resources. Since elastic file 4015 does not have dependent resources, elastic file 4015 is deleted, and the process returns to continue processing cloud host 4014. At this time, cloud host 4014 does not have dependent resources. Cloud host 4014 is taken out of the cache, cloud host 4014 is deleted, and the cache is read in the subsequent order to determine whether subnet 4012 still has a dependent relationship. It is found that subnet 4012 still has a dependent resource relation database 4013, and relation database 4013 is deleted. Since the dependent resources ELB4016 and elastic file 4015 of relation database 4013 have been deleted, relation database 4013 has no dependent resources at this time and is directly deleted. At this time, subnet 4012 does not have dependent resources. Subnet 4012 is taken out of the cache, subnet 4012 is deleted, and the cache is read in the subsequent order to delete network 4011. At this time, network 4011 does not have dependent resources and can be directly taken out of the cache for deletion. Finally, VPC 401 is released to complete the resource cleanup.

通过预设的资源清理时间或收到的资源清理请求自动进行资源清理,可以及时地释放资源空间,减少因资源不足对测试进度造成的影响。而通过依赖关系进行递归删除,在最大程度上实现了资源的清理,在资源中可能存在的资源利用过程中自动生成的一些数据资源也可以得到清理,避免了人工清理出现遗漏的情况出现,也节省了时间和人力。Automatic resource cleanup based on preset resource cleanup time or received resource cleanup requests can release resource space in a timely manner and reduce the impact of insufficient resources on the test progress. Recursive deletion through dependencies can achieve resource cleanup to the greatest extent possible. Some data resources that may be automatically generated during resource utilization can also be cleaned up, avoiding omissions in manual cleanup and saving time and manpower.

进一步的,请参见图5,是本发明实施例提供的一种基于递归的资源清理装置的结构示意图。如图5所示,该基于递归的资源清理装置1可以应用于上述图1所对应实施例中的服务器,所述基于递归的资源清理装置1可以包括:遍历处理模块10,存储模块20,删除模块30,判断模块40,设置模块50和反馈模块60;Further, please refer to FIG5, which is a schematic diagram of the structure of a recursive resource cleaning device provided by an embodiment of the present invention. As shown in FIG5, the recursive resource cleaning device 1 can be applied to the server in the embodiment corresponding to FIG1 above, and the recursive resource cleaning device 1 can include: a traversal processing module 10, a storage module 20, a deletion module 30, a judgment module 40, a setting module 50 and a feedback module 60;

遍历处理模块10,用于遍历资源,查找未被标记保留的基础数据资源,并将上述基础数据资源的资源信息存储到存储模块20中;The traversal processing module 10 is used to traverse the resources, find the basic data resources that are not marked as reserved, and store the resource information of the basic data resources in the storage module 20;

存储模块20,用于存储上述基础数据资源的资源信息及资源清理结果;The storage module 20 is used to store the resource information and resource cleaning results of the above basic data resources;

删除模块30,用于若在第一资源的所处系统中未查找到上述第一资源的依赖资源,则删除上述第一资源,若在上述第一资源的所处系统中查找到上述第一资源的至少一个依赖资源,则分别将上述第一资源的至少一个依赖资源作为第一资源执行上述根据上述第一资源标识在上述第一资源的所处系统中查找所述第一资源的依赖资源的步骤,并将资源清理结果存入存储模块20中;The deleting module 30 is used to delete the first resource if no dependent resource of the first resource is found in the system where the first resource is located, and if at least one dependent resource of the first resource is found in the system where the first resource is located, respectively use the at least one dependent resource of the first resource as the first resource to perform the above step of searching for the dependent resource of the first resource in the system where the first resource is located according to the first resource identifier, and store the resource cleaning result in the storage module 20;

判断模块40,用于判断上述基础数据资源是否被设置为保留,判断第一资源是否有依赖资源,及判断资源是否全部清理;A determination module 40 is used to determine whether the basic data resource is set to be retained, whether the first resource has dependent resources, and whether all resources are cleared;

设置模块50,用于获取用户设置的删除资源的指定时间及上述基础数据资源是否保留;A setting module 50, used to obtain the specified time for deleting resources set by the user and whether the basic data resources are to be retained;

反馈模块60,用于在资源清理结束后向用户反馈存储模块20中存储的资源清理结果,上述资源清理结果包括资源删除结果。The feedback module 60 is used to feed back the resource cleaning result stored in the storage module 20 to the user after the resource cleaning is completed. The resource cleaning result includes the resource deletion result.

其中,所述遍历处理模块10通过获取设置模块50的数据查找未被设置为保留的基础数据资源,具体功能实现方式可以参见上述图1对应实施例中的步骤S101和S103;所述判断模块40包括根据所述设置模块50的基础数据资源保留设置结果判断所述基础数据资源是否被设置为保留,所述判断模块40和所述删除模块30的具体功能实现方式可以参见上述图1对应实施例中的步骤S103-步骤S107,这里不再进行赘述。Among them, the traversal processing module 10 searches for basic data resources that are not set to be retained by obtaining data from the setting module 50. The specific functional implementation method can refer to steps S101 and S103 in the embodiment corresponding to Figure 1 above; the judgment module 40 includes judging whether the basic data resources are set to be retained according to the basic data resource retention setting result of the setting module 50. The specific functional implementation method of the judgment module 40 and the deletion module 30 can refer to steps S103-S107 in the embodiment corresponding to Figure 1 above, which will not be repeated here.

参见图6,图6是本申请实施例提供的服务器的结构示意图。如图6所示,本实施例中的服务器可以包括:一个或多个处理器601和存储器602。上述处理器601和存储器602通过总线603连接。存储器602用于存储计算机程序,该计算机程序包括程序指令,处理器601用于执行存储器602存储的程序指令,执行如下操作:See Figure 6, which is a schematic diagram of the structure of the server provided in the embodiment of the present application. As shown in Figure 6, the server in this embodiment may include: one or more processors 601 and a memory 602. The processor 601 and the memory 602 are connected via a bus 603. The memory 602 is used to store a computer program, which includes program instructions. The processor 601 is used to execute the program instructions stored in the memory 602 to perform the following operations:

判断基础数据资源是否被设置为保留,若上述基础数据资源未被设置为保留,则确定上述基础数据资源为第一资源;Determining whether the basic data resource is set to be reserved, and if the basic data resource is not set to be reserved, determining the basic data resource to be the first resource;

根据上述第一资源的资源标识在上述第一资源的所处系统中查找上述第一资源的依赖资源,上述第一资源的依赖资源为在生成时引用上述第一资源的数据资源;Searching for a dependent resource of the first resource in the system where the first resource is located according to the resource identifier of the first resource, wherein the dependent resource of the first resource is a data resource that references the first resource when it is generated;

若在上述第一资源的所处系统中查找到上述第一资源的至少一个依赖资源,则分别将上述第一资源的至少一个依赖资源作为第一资源执行上述根据上述第一资源的资源标识在上述第一资源的所处系统中查找上述第一资源的依赖资源的步骤;If at least one dependent resource of the first resource is found in the system where the first resource is located, the step of searching for the dependent resource of the first resource in the system where the first resource is located according to the resource identifier of the first resource is performed using the at least one dependent resource of the first resource as the first resource;

若在上述第一资源的所处系统中未查找到上述第一资源的依赖资源,则删除上述第一资源,并将上述第一资源的被依赖资源作为第一资源执行上述根据上述第一资源的资源标识在上述第一资源的所处系统中查找上述第一资源的依赖资源的步骤。If the dependent resources of the first resource are not found in the system where the first resource is located, the first resource is deleted, and the dependent resources of the first resource are used as the first resource to execute the step of searching for the dependent resources of the first resource in the system where the first resource is located according to the resource identifier of the first resource.

在一些可行的实施方式中,上述第一资源的资源标识包括上述第一资源的引用标识,上述处理器601用于:In some feasible implementations, the resource identifier of the first resource includes a reference identifier of the first resource, and the processor 601 is configured to:

根据上述第一资源的引用标识在上述第一资源的所处系统中查找资源名称包括上述第一资源的引用标识的其他数据资源,作为上述第一资源的依赖资源;According to the reference identifier of the first resource, searching in the system where the first resource is located other data resources whose resource names include the reference identifier of the first resource as dependent resources of the first resource;

或者,根据上述第一资源的引用标识在上述第一资源的所处系统中查找资源内容包括上述第一资源的引用标识的其他数据资源,作为上述第一资源的依赖资源。Alternatively, other data resources whose resource contents include the reference identifier of the first resource are searched in the system where the first resource is located according to the reference identifier of the first resource as dependent resources of the first resource.

在一些可行的实施方式中,上述处理器601用于:In some feasible implementations, the processor 601 is configured to:

判断上述基础数据资源是否携带预设的保留标签,若是则确定上述基础数据资源被设置为保留,否则确定上述基础数据资源未被设置为保留;或Determine whether the basic data resource carries a preset retention tag, and if so, determine that the basic data resource is set to be retained, otherwise, determine that the basic data resource is not set to be retained; or

读取上述基础数据资源的布尔标记,若上述基础数据资源的布尔标记为true值则确定上述基础数据资源被设置为保留,否则确定上述基础数据资源未被设置为保留。The Boolean flag of the basic data resource is read, and if the Boolean flag of the basic data resource is a true value, it is determined that the basic data resource is set to be reserved, otherwise it is determined that the basic data resource is not set to be reserved.

在一些可行的实施方式中,上述处理器601还用于:In some feasible implementations, the processor 601 is further configured to:

若确定到达预设的资源清理时间或接收到资源清理指令,则触发上述判断基础数据资源是否被设置为保留的步骤。If it is determined that the preset resource cleanup time has arrived or a resource cleanup instruction has been received, the above step of determining whether the basic data resource is set to be retained is triggered.

在一些可行的实施方式中,上述处理器601用于:In some feasible implementations, the processor 601 is configured to:

提取上述第一资源的资源信息,上述第一资源的资源信息包括上述第一资源的id,上述第一资源的id用于指示上述第一资源的存放地址;Extracting resource information of the first resource, where the resource information of the first resource includes an ID of the first resource, where the ID of the first resource is used to indicate a storage address of the first resource;

根据上述第一资源的资源类型调用对应的资源删除方法,并将上述第一资源的id作为上述资源删除方法的调用参数,对上述第一资源进行删除。The corresponding resource deletion method is called according to the resource type of the first resource, and the id of the first resource is used as a calling parameter of the resource deletion method to delete the first resource.

在一些可行的实施方式中,上述第一资源的信息还包括上述第一资源的创建用户账号;上述处理器601还用于:In some feasible implementation manners, the information of the first resource further includes a user account for creating the first resource; and the processor 601 is further configured to:

根据上述第一资源的创建用户账号将上述第一资源的删除结果反馈给上述第一资源的创建用户,上述删除结果包括删除失败信息或删除成功信息。The deletion result of the first resource is fed back to the user who created the first resource according to the user account who created the first resource, and the deletion result includes deletion failure information or deletion success information.

在一些可行的实施方式中,上述基础数据资源为虚拟私有云(VPC,VirtualPrivateCloud)。In some feasible implementations, the above basic data resource is a virtual private cloud (VPC, Virtual Private Cloud).

在一些可行的实施方式中,上述处理器601可以是中央处理单元(centralprocessingunit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integratedcircuit,ASID)、现成可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。In some feasible implementations, the processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.

该处理器602可以包括只读存储器和随机存取存储器,并向处理器601提供指令和数据。处理器602的一部分还可以包括非易失性随机存取存储器。例如,存储器602还可以存储服务器类型的信息。The processor 602 may include a read-only memory and a random access memory, and provide instructions and data to the processor 601. A portion of the processor 602 may also include a non-volatile random access memory. For example, the memory 602 may also store information about the server type.

具体实现中,上述服务器可通过其内置的各个功能模块执行如上述图1中各个步骤所提供的实现方式,具体可参见上述各个步骤所提供的实现方式,在此不再赘述。In a specific implementation, the server can execute the implementation methods provided in the steps of FIG. 1 through its built-in functional modules. For details, please refer to the implementation methods provided in the steps, which will not be described again.

在本申请实施例中,服务器可以通过预设的资源清理时间或收到的资源清理请求自动执行资源清理操作,使用全部遍历方式,获取未引用其他数据资源的基础数据资源,以此基础数据资源为基础,查找该基础数据资源的直接或间接的依赖资源,根据上述依赖关系,使用递归访问的方式,从未被其他数据资源引用的依赖资源开始删除,依次清除数据资源,最终在所有依赖资源删除后将基础数据资源进行删除,上述处理过程类似于树形结构,进行后序遍历删除,在最大程度上清理资源,减少资源遗漏的情况出现;同时在查找基础数据资源时,判断上述基础数据资源是否被设置为保留,若被设置为保留则不进行处理,避免了重要资源的误删情况,而且自动清理操作节省了时间和人力,保障资源充足。In an embodiment of the present application, the server can automatically perform resource cleaning operations according to a preset resource cleaning time or a received resource cleaning request, use a full traversal method to obtain basic data resources that do not reference other data resources, and use this basic data resource as a basis to find the direct or indirect dependent resources of the basic data resource. According to the above-mentioned dependency relationship, use a recursive access method to start deleting dependent resources that have not been referenced by other data resources, clear data resources in sequence, and finally delete the basic data resources after all dependent resources have been deleted. The above-mentioned processing process is similar to a tree structure, and post-order traversal deletion is performed to clean up resources to the greatest extent and reduce the occurrence of resource omissions. At the same time, when searching for basic data resources, it is determined whether the above-mentioned basic data resources are set to be retained. If they are set to be retained, no processing is performed, thereby avoiding the accidental deletion of important resources, and the automatic cleaning operation saves time and manpower to ensure sufficient resources.

本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序包括程序指令,该程序指令被处理器执行时实现图1中各个步骤所提供的基于递归的资源清理方法,具体可参见上述各个步骤所提供的实现方式,在此不再赘述。An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the recursive resource cleaning method provided in each step of Figure 1 is implemented. For details, please refer to the implementation methods provided in the above steps, which will not be repeated here.

上述计算机可读存储介质可以是前述任一实施例提供的基于递归的资源清理装置或者上述服务器的内部存储单元或外部存储设备。该计算机可读存储介质用于存储该计算机程序以及该服务器所需的其他程序和数据。该计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。The computer-readable storage medium may be the recursive resource cleaning device or the internal storage unit or external storage device of the server provided in any of the above embodiments. The computer-readable storage medium is used to store the computer program and other programs and data required by the server. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.

本申请的权利要求书和说明书及附图中的术语“第一”是用于指示当前的处理对象,而不具备具体的含义。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置展示该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本文所描述的实施例可以与其它实施例相结合。在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。The term "first" in the claims, specification and drawings of the present application is used to indicate the current processing object, and does not have a specific meaning. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. Mentioning "embodiment" in this article means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. Displaying the phrase at various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments. The term "and/or" used in the specification and the attached claims of the present application refers to any combination of one or more of the items listed in association and all possible combinations, and includes these combinations.

以上所揭露的仅为本发明较佳实施例而已,当然不能以此来限定本发明之权利范围,因此依本发明权利要求所作的等同变化,仍属本发明所涵盖的范围。The above disclosure is only a preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims (9)

1.一种基于递归的资源清理方法,其特征在于,包括:1. A recursive resource cleaning method, comprising: 在确定到达预设的资源清理时间后,查找基础数据资源,所述基础数据资源不包含其他数据资源的资源标识,在生成时不引用其他数据资源,所述基础数据资源不依赖其他数据资源,判断所述基础数据资源是否携带预设的保留标签,若是则确定所述基础数据资源被设置为保留,否则确定所述基础数据资源未被设置为保留;或读取所述基础数据资源的布尔标记,若所述基础数据资源的布尔标记为true值则确定所述基础数据资源被设置为保留,否则确定所述基础数据资源未被设置为保留;若所述基础数据资源未被设置为保留,则确定所述基础数据资源为第一资源;After determining that the preset resource cleanup time has arrived, search for a basic data resource, the basic data resource does not contain resource identifiers of other data resources, does not reference other data resources when generated, and the basic data resource does not depend on other data resources, and judge whether the basic data resource carries a preset retention tag, if so, determine that the basic data resource is set to be retained, otherwise determine that the basic data resource is not set to be retained; or read the Boolean mark of the basic data resource, if the Boolean mark of the basic data resource is a true value, determine that the basic data resource is set to be retained, otherwise determine that the basic data resource is not set to be retained; if the basic data resource is not set to be retained, determine that the basic data resource is the first resource; 根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源,所述第一资源的依赖资源为在生成时引用所述第一资源而包含所述第一资源的资源标识的数据资源;Searching for a dependent resource of the first resource in a system where the first resource is located according to the resource identifier of the first resource, wherein the dependent resource of the first resource is a data resource that references the first resource and contains the resource identifier of the first resource when generated; 若在所述第一资源的所处系统中查找到所述第一资源的至少一个依赖资源,则分别将所述第一资源的至少一个依赖资源作为第一资源执行所述根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源的步骤;If at least one dependent resource of the first resource is found in the system where the first resource is located, the step of searching for the dependent resource of the first resource in the system where the first resource is located according to the resource identifier of the first resource is performed using the at least one dependent resource of the first resource as the first resource; 若在所述第一资源的所处系统中未查找到所述第一资源的依赖资源,则删除所述第一资源,并将所述第一资源的被依赖资源作为第一资源执行所述根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源的步骤。If the dependent resources of the first resource are not found in the system where the first resource is located, the first resource is deleted, and the dependent resources of the first resource are used as the first resource to execute the step of searching for the dependent resources of the first resource in the system where the first resource is located according to the resource identifier of the first resource. 2.如权利要求1所述的方法,其特征在于,所述第一资源的资源标识包括所述第一资源的引用标识,所述根据所述第一资源的资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源包括:2. The method according to claim 1, wherein the resource identifier of the first resource comprises a reference identifier of the first resource, and searching for a dependent resource of the first resource in a system where the first resource is located according to the resource identifier of the first resource comprises: 根据所述第一资源的引用标识在所述第一资源的所处系统中查找资源名称包括所述第一资源的引用标识的其他数据资源,作为所述第一资源的依赖资源;According to the reference identifier of the first resource, searching in the system where the first resource is located for other data resources whose resource names include the reference identifier of the first resource as dependent resources of the first resource; 或者,根据所述第一资源的引用标识在所述第一资源的所处系统中查找资源内容包括所述第一资源的引用标识的其他数据资源,作为所述第一资源的依赖资源。Alternatively, other data resources whose resource contents include the reference identifier of the first resource are searched in the system where the first resource is located according to the reference identifier of the first resource as dependent resources of the first resource. 3.如权利要求1所述的方法,其特征在于,所述判断基础数据资源是否被设置为保留之前还包括:3. The method according to claim 1, characterized in that before the determining whether the basic data resource is set to be reserved, the step further comprises: 若确定到达预设的资源清理时间或接收到资源清理指令,则触发所述判断基础数据资源是否被设置为保留的步骤。If it is determined that the preset resource cleanup time has arrived or a resource cleanup instruction has been received, the step of determining whether the basic data resource is set to be retained is triggered. 4.如权利要求1所述的方法,其特征在于,所述删除所述第一资源包括:4. The method according to claim 1, wherein deleting the first resource comprises: 提取所述第一资源的资源信息,所述第一资源的资源信息包括所述第一资源的id,所述第一资源的id用于指示所述第一资源的存放地址;Extracting resource information of the first resource, where the resource information of the first resource includes an ID of the first resource, where the ID of the first resource is used to indicate a storage address of the first resource; 根据所述第一资源的资源类型调用对应的资源删除方法,并将所述第一资源的id作为所述资源删除方法的调用参数,对所述第一资源进行删除。The corresponding resource deletion method is called according to the resource type of the first resource, and the id of the first resource is used as a calling parameter of the resource deletion method to delete the first resource. 5.如权利要求4所述的方法,其特征在于,所述第一资源的信息还包括所述第一资源的创建用户账号;5. The method according to claim 4, wherein the information of the first resource further includes a user account for creating the first resource; 所述根据所述第一资源的资源类型调用对应的资源删除方法,并将所述第一资源的id作为所述资源删除方法的调用参数,对所述第一资源进行删除之后还包括:The method further includes calling a corresponding resource deletion method according to the resource type of the first resource, and using the ID of the first resource as a calling parameter of the resource deletion method, and after deleting the first resource, the method further includes: 根据所述第一资源的创建用户账号将所述第一资源的删除结果反馈给所述第一资源的创建用户,所述删除结果包括删除失败信息或删除成功信息。A deletion result of the first resource is fed back to the user who created the first resource according to the user account who created the first resource, where the deletion result includes deletion failure information or deletion success information. 6.如权利要求1所述的方法,其特征在于,所述基础数据资源为虚拟私有云。6. The method according to claim 1, characterized in that the basic data resource is a virtual private cloud. 7.一种基于递归的资源清理装置,其特征在于,包括:7. A recursive resource cleaning device, comprising: 遍历处理模块,用于在确定到达预设的资源清理时间后,遍历资源,查找未被标记保留的基础数据资源,所述基础数据资源不包含其他数据资源的资源标识,在生成时不引用其他数据资源,所述基础数据资源不依赖其他数据资源,并将所述基础数据资源的资源信息存储到存储模块;A traversal processing module is used to traverse resources after determining that a preset resource cleanup time has been reached, search for basic data resources that are not marked for retention, the basic data resources do not contain resource identifiers of other data resources, do not reference other data resources when generated, the basic data resources do not depend on other data resources, and store resource information of the basic data resources in a storage module; 存储模块,用于存储所述基础数据资源的信息及资源清理结果;A storage module, used to store the information of the basic data resources and resource cleaning results; 删除模块,用于若在第一资源的所处系统中未查找到所述第一资源的依赖资源,则删除所述第一资源,所述第一资源的依赖资源为在生成时引用所述第一资源而包含所述第一资源的资源标识的数据资源,若在所述第一资源的所处系统中查找到所述第一资源的至少一个依赖资源,则分别将所述第一资源的至少一个依赖资源作为第一资源执行所述根据所述第一资源标识在所述第一资源的所处系统中查找所述第一资源的依赖资源的步骤;a deletion module, configured to delete the first resource if no dependent resource of the first resource is found in the system where the first resource is located, wherein the dependent resource of the first resource is a data resource that references the first resource during generation and contains a resource identifier of the first resource, and if at least one dependent resource of the first resource is found in the system where the first resource is located, respectively use the at least one dependent resource of the first resource as the first resource to execute the step of searching for the dependent resource of the first resource in the system where the first resource is located according to the first resource identifier; 判断模块,用于判断所述基础数据资源是否携带预设的保留标签,若是则确定所述基础数据资源被设置为保留,否则确定所述基础数据资源未被设置为保留,或者,读取所述基础数据资源的布尔标记,若所述基础数据资源的布尔标记为true值则确定所述基础数据资源被设置为保留,否则确定所述基础数据资源未被设置为保留,判断当前资源是否有依赖资源,及判断资源是否全部清理;A judgment module, used to judge whether the basic data resource carries a preset retention tag, and if so, determine that the basic data resource is set to be retained, otherwise determine that the basic data resource is not set to be retained, or read the Boolean tag of the basic data resource, and if the Boolean tag of the basic data resource is a true value, determine that the basic data resource is set to be retained, otherwise determine that the basic data resource is not set to be retained, judge whether the current resource has dependent resources, and judge whether all resources are cleared; 设置模块,用于获取用户设置的删除资源的指定时间及所述基础数据资源是否保留;A setting module, used to obtain the specified time for deleting resources set by the user and whether the basic data resources are to be retained; 反馈模块,用于在资源清理结束后向用户反馈所述资源清理结果,所述资源清理结果包括资源删除结果。The feedback module is used to feed back the resource cleaning result to the user after the resource cleaning is completed, and the resource cleaning result includes the resource deletion result. 8.一种基于递归的资源清理装置,其特征在于,包括:处理器、存储器;8. A recursive resource cleaning device, comprising: a processor and a memory; 所述处理器与所述存储器相连,其中,所述存储器用于存储程序代码,所述处理器用于调用所述程序代码,以执行如权利要求1-6任一所述的方法。The processor is connected to the memory, wherein the memory is used to store program codes, and the processor is used to call the program codes to execute the method according to any one of claims 1-6. 9.一种计算机存储介质,其特征在于,所述计算机存储介质存储有计算机程序指令,所述计算机程序指令当被处理器执行时用于处理如权利要求1-6任一所述的方法。9. A computer storage medium, characterized in that the computer storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, they are used to process the method according to any one of claims 1 to 6.
CN201811358548.8A 2018-11-15 2018-11-15 Resource cleaning method and device based on recursion Active CN109471729B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811358548.8A CN109471729B (en) 2018-11-15 2018-11-15 Resource cleaning method and device based on recursion

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811358548.8A CN109471729B (en) 2018-11-15 2018-11-15 Resource cleaning method and device based on recursion

Publications (2)

Publication Number Publication Date
CN109471729A CN109471729A (en) 2019-03-15
CN109471729B true CN109471729B (en) 2024-05-14

Family

ID=65672900

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811358548.8A Active CN109471729B (en) 2018-11-15 2018-11-15 Resource cleaning method and device based on recursion

Country Status (1)

Country Link
CN (1) CN109471729B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112866306B (en) * 2019-11-12 2024-05-28 阿里巴巴集团控股有限公司 Resource management method and cloud service platform
CN111078276B (en) * 2019-12-20 2022-12-30 抖音视界有限公司 Application redundant resource processing method, device, equipment and storage medium
CN111352831B (en) * 2020-02-22 2022-07-19 苏州浪潮智能科技有限公司 A cloud platform automatic test method and system for automatic environment reset
CN114077595A (en) * 2021-11-25 2022-02-22 中国银行股份有限公司 Log backup cleaning method and device for Web middleware type container

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5832529A (en) * 1996-10-11 1998-11-03 Sun Microsystems, Inc. Methods, apparatus, and product for distributed garbage collection
CN106599151A (en) * 2016-12-07 2017-04-26 Tcl集团股份有限公司 Method and system for parallel cleaning of Android engineering useless resources
CN107526639A (en) * 2017-08-16 2017-12-29 杭州朗和科技有限公司 Method, medium, device and the computing device of resource layout
CN108805527A (en) * 2018-05-29 2018-11-13 郑州云海信息技术有限公司 A kind of project management method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
MX2010012475A (en) * 2008-06-09 2010-12-02 Ericsson Telefon Ab L M A system and method of releasing resources in a telecommunications network.

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5832529A (en) * 1996-10-11 1998-11-03 Sun Microsystems, Inc. Methods, apparatus, and product for distributed garbage collection
CN106599151A (en) * 2016-12-07 2017-04-26 Tcl集团股份有限公司 Method and system for parallel cleaning of Android engineering useless resources
CN107526639A (en) * 2017-08-16 2017-12-29 杭州朗和科技有限公司 Method, medium, device and the computing device of resource layout
CN108805527A (en) * 2018-05-29 2018-11-13 郑州云海信息技术有限公司 A kind of project management method and device

Also Published As

Publication number Publication date
CN109471729A (en) 2019-03-15

Similar Documents

Publication Publication Date Title
CN109471729B (en) Resource cleaning method and device based on recursion
CN109246234B (en) A kind of image file downloading method, device, electronic device and storage medium
CN110134738A (en) Distributed storage system resource estimation method and device
CN106598874A (en) Method and device for automatically testing software
CN114238391B (en) Data paging query method, device, electronic device and storage medium
WO2023272918A1 (en) Cache space management method and apparatus, and electronic device and storage medium
CN111460021A (en) Data export method and device
CN115866017B (en) Message processing method, device, communication device and storage medium
CN118708302A (en) Transaction request processing method, device and storage medium
CN115580530A (en) Log distribution method, device, system, electronic device and storage medium
CN110377422A (en) A kind of method for managing resource, device, equipment and readable storage medium storing program for executing
CN112883246A (en) Business item display method, device, equipment and storage medium
CN118585303A (en) A resource scheduling system, method, device, equipment and medium
CN112559775A (en) Patent information management method and system and computer equipment
CN110941597B (en) Method and device for cleaning decompressed file, computing equipment and computer storage medium
WO2020063769A1 (en) User request processing method and apparatus and server
US20160055168A1 (en) Method and apparatus for scanning files
WO2024159628A1 (en) Ldap-based memory management method and apparatus, device, and storage medium
CN114706657A (en) Multi-platform virtual machine management interface, management method, terminal and storage medium
CN114443595A (en) A method and device for processing documents
CN109960687A (en) A file processing system and method
CN112130828A (en) Software source code modification method, device, equipment and storage medium
CN114398246A (en) Data consistency check method, apparatus, computer equipment and medium
CN112241672B (en) Identity data association method and device, electronic equipment and storage medium
CN110597763B (en) Method and device for generating function index table

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant