CN107704462B - Resource metadata maintenance method, equipment and storage device - Google Patents

Resource metadata maintenance method, equipment and storage device Download PDF

Info

Publication number
CN107704462B
CN107704462B CN201610642192.5A CN201610642192A CN107704462B CN 107704462 B CN107704462 B CN 107704462B CN 201610642192 A CN201610642192 A CN 201610642192A CN 107704462 B CN107704462 B CN 107704462B
Authority
CN
China
Prior art keywords
resource
log
same
attribute
routing information
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
CN201610642192.5A
Other languages
Chinese (zh)
Other versions
CN107704462A (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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201610642192.5A priority Critical patent/CN107704462B/en
Publication of CN107704462A publication Critical patent/CN107704462A/en
Application granted granted Critical
Publication of CN107704462B publication Critical patent/CN107704462B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases

Abstract

The method is suitable for a distributed storage system which provides storage service by using a cluster, and not only can the resource naming be ensured to be globally unique, but also the metadata of the resource can be ensured to be highly available in multiple regions of the resource. In addition, when the resource is created or deleted, the timestamp of the created or deleted resource of the main node is updated, a log is persisted, the log comprises the same resource name and timestamp as the routing information of the resource, and the residual routing information generated under the abnormal scene on the residual main node can be deleted according to the log.

Description

Resource metadata maintenance method, equipment and storage device
Technical Field
The present application relates to the field of computers, and in particular, to a method, an apparatus, and a storage device for maintaining metadata of a resource.
Background
In a cloud storage system, it is generally required to ensure global uniqueness of resource naming, which is generally realized by storing metadata of resources on a common node, and ensuring the metadata on the common node through transactions. However, if the common node cannot be normally served under the structure, all requests for accessing the metadata are affected, and the availability of the system is seriously affected. In addition, the communication quality of different regions cannot be guaranteed, and even the public node cannot be served at all, and the public node can only be deployed in one region, at this time, the access request of other regions to the public node cannot be guaranteed, and the availability is poor. A common approach at this time is to partition the metadata of the resource geographically.
At present, the metadata is divided into regions by removing global nodes, each region is taken as a completely independent system, each region stores respective metadata, and the regions are completely isolated. The global uniqueness of the resource name is generally ensured by attaching region information to the resource name or represented by a globally unique character string. The resource naming in this way can only ensure uniqueness in a certain region, and if the resource is accessed in the whole region, the region information needs to be added or a long alias needs to be used. At this time, one resource has two names, which is easy for users to confuse, and is easy to make mistakes and poor in usability.
Disclosure of Invention
An object of the present application is to provide a method, a device, and a storage apparatus for maintaining metadata of a resource, which can solve the problem of poor availability of metadata of the resource or global non-uniqueness of resource naming.
According to an aspect of the present application, there is provided a method for maintaining metadata of a resource, the metadata of the resource including routing information and resource attributes of the resource, the method including:
the method comprises the steps that routing information of resources is maintained in a master node, resource attributes are maintained in slave nodes corresponding to position information of the resource attributes, and the routing information of the resources comprises globally unique resource names and position information of the resource attributes.
Further, in the above method, the routing information of the resource further includes a timestamp for creating or deleting the resource;
the method for maintaining the routing information of the resources at the master node and maintaining the resource attributes at the slave nodes corresponding to the position information of the resource attributes comprises the following steps:
and according to the timestamp of the resource creation or deletion, deleting the routing information remained when the resource is created or deleted at the main node, and maintaining the resource attribute at the slave node corresponding to the position information of the resource attribute. Further, in the above method, according to the timestamp of creating or deleting a resource, route information remaining when the master node deletes the creating or deleting the resource, and a resource attribute is maintained at a slave node corresponding to the location information of the resource attribute, the method includes:
when a resource is created or deleted, updating the timestamp of the created or deleted resource at a main node, and meanwhile persisting a log, wherein the log comprises a resource name and a timestamp which are the same as the routing information of the resource, and the resource attribute is maintained at a slave node corresponding to the position information of the resource attribute;
and according to the time stamp of the created or deleted resource and the log, deleting the routing information remained when the resource is created or deleted by the main node.
Further, in the above method, when creating a resource, the master node updates a timestamp of the creation or deletion of the resource, and persists a log, and the resource attribute is maintained at a slave node corresponding to the location information of the resource attribute, including:
when the route information of the resource is requested to be created, the main node inquires whether the route information of the resource exists or not,
if the resource does not exist, creating the routing information of the resource in the main node, and meanwhile persisting a log, wherein the routing information of the resource comprises the name of the resource, the position information of the resource attribute and the timestamp of the created or deleted resource;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log.
Further, in the above method, when the master node requests to create the routing information of the resource, after querying whether the routing information of the resource exists, the method further includes:
if the resource attribute exists, judging whether the position information of the resource attribute in the routing information of the resource is different from the position information of the request for creating the resource attribute,
if not, returning the resource creation failure.
Further, in the foregoing method, after the routing information of the resource further includes a user, and whether the location information of the resource attribute in the routing information of the resource is different from the location information of the request for creating the resource attribute is determined, the method further includes:
if the two requests are the same, judging whether the requests are initiated by the same user or not,
if so, updating the time stamp of the creation or deletion of the resource at the main node, and meanwhile persisting a log;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log.
Further, in the above method, when deleting a resource, the master node updates a timestamp of the resource creation or deletion, and persists a log, and the resource attribute is maintained at a slave node corresponding to the location information of the resource attribute, including:
when requesting to delete the routing information of the resource, the main node inquires whether the routing information of the resource exists or not,
if the resource exists, the time stamp of the creation or deletion of the resource is updated at the main node, and a log is persisted at the same time;
deleting the resource attribute from the slave node according to the routing information of the resource, and if the deletion of the resource attribute fails, returning the failure of the deletion of the resource; if the deletion is successful, returning the resource deletion success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log.
Further, in the above method, according to the timestamp and the log of creating or deleting the resource, the route information remaining when the master node deletes the creating or deleting the resource includes:
scanning logs which still exist after the preset time is exceeded;
and deleting the residual routing information when the resources are created and deleted according to the scanned log.
Further, in the above method, deleting the routing information remaining when the resource is created and deleted according to the scanned log includes:
querying at the master node whether routing information having the same resource name as the scanned log exists,
if not, the log is deleted.
Further, in the above method, after the master node queries whether the routing information of the same resource name exists, the method further includes:
if yes, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name,
if not, deleting the log.
Further, in the above method, after determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name, the method further includes:
if the resource attributes are the same, inquiring whether the resource attributes with the same resource name exist on the corresponding slave nodes,
if so, deleting the log.
Further, in the above method, after querying whether the resource attribute with the same resource name exists on the corresponding slave node, the method further includes:
if not, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name or not again;
if the log and the routing information are the same, deleting the log and the routing information.
Further, in the above method, after determining again whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name, the method further includes:
if not, deleting the log.
Further, in the method, the maintaining the resource attribute at the slave node further includes:
when the creation or deletion of the resource attribute of the slave node is successful, saving the time stamp of the creation or deletion of the resource in the resource attribute on the slave node;
when the slave node receives a request for the attribute of creation or deletion of the same resource again, whether the time stamp of the creation or deletion of the resource of the current request is larger than the time stamp in the resource attribute saved on the slave node is judged,
if so, processing the request at the slave node;
if not, the request is ignored at the slave node.
According to another aspect of the present application, there is also provided a method for maintaining metadata of a resource, where the metadata of the resource includes routing information and resource attributes of the resource, the method including:
the method comprises the steps that a main node acquires a request for creating routing information of resources, and queries whether the routing information of the resources exists in the main node or not, wherein the routing information of the resources comprises globally unique resource names, position information of resource attributes and timestamps for creating or deleting the resources;
if the resource does not exist, the master node creates the routing information of the resource, and after a log is persisted at the same time, a request for creating the resource attribute is sent to the slave node according to the resource name and the position information of the resource, and the log comprises the resource name and the timestamp which are the same as the routing information of the resource;
and the slave node creates the resource attribute according to the received request for creating the resource attribute, and if the creation of the resource attribute fails, the slave node returns the failure of the creation of the resource to the master node.
Further, in the above method, after the slave node creates the resource attribute according to the received request for creating the resource attribute, the method further includes:
if the creation is successful, returning feedback of successful resource creation to the main node;
and the master node compares the time stamp of the created or deleted resource in the routing information of the resource with the time stamp in the log with the same resource name according to the feedback of the successful creation of the resource, and deletes the log if the time stamps are the same.
Further, in the above method, after the master node queries whether the routing information of the resource exists in the master node, the method further includes:
if the resource attribute exists, the main node judges whether the position information of the resource attribute in the routing information of the resource is different from the position information of the resource attribute required to be created,
and if the two nodes are different, the master node returns a resource creating failure to the slave node.
Further, in the above method, the routing information of the resource further includes a user,
after the master node determines whether the location information of the resource attribute in the routing information of the resource is different from the location information of the request for creating the resource attribute, the method further includes:
if the resource attributes are the same, the main node judges whether the request for creating the resource attributes is initiated by the same user or not,
if so, the master node updates the timestamp of the created or deleted resource, and initiates a request for creating the resource attribute to the slave node according to the resource name and the position information of the resource after simultaneously persisting a log;
and the slave node creates the resource attribute according to the request for creating the resource attribute, and if the resource attribute is failed to be created, the slave node returns the resource creation failure to the master node.
Further, in the above method, after the slave node creates the resource attribute according to the request for creating a resource attribute, the method further includes:
if the creation is successful, after the resource creation is returned to the main node, the main node compares the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, the log is deleted.
Further, in the foregoing method, if the two logs are the same, after deleting the log, the method includes:
the main node scans logs which still exist after the preset time is exceeded;
and the main node deletes the residual routing information when the resources are created and deleted according to the scanned log.
Further, in the above method, the deleting, by the master node, the routing information remaining when the resource is created and deleted according to the scanned log includes:
the master node inquires whether routing information having the same resource name as the scanned log exists,
and if the log does not exist, the master node deletes the log.
Further, in the above method, after the master node queries whether the routing information having the same resource name as the scanned log exists, the method further includes:
if so, the master node judges whether the timestamp of the log is the same as the timestamp of the inquired creation or deletion resource with the same resource name,
and if not, the master node deletes the log.
Further, in the above method, after the master node determines whether the timestamp of the log is the same as the timestamp of the queried resource creation or deletion of the same resource name, the method further includes:
if the resource attributes are the same, the master node initiates a request for inquiring whether the resource attributes with the same resource name exist to the corresponding slave node according to the position information of the resource attributes, the slave node inquires according to the request for inquiring whether the resource attributes with the same resource name exist,
and if the log exists, the slave node sends feedback of the existence of the resource attribute to the master node, and the master node deletes the log according to the feedback of the existence of the resource attribute.
Further, in the above method, after the slave node performs the query according to the request for querying whether the resource attribute having the same resource name exists, the method further includes:
if the resource name does not exist, the slave node sends feedback that the resource attribute does not exist to the master node, and the master node judges whether the timestamp of the log is the same as the timestamp of the inquired created or deleted resource with the same resource name again according to the feedback that the resource attribute does not exist;
and if the log and the routing information are the same, the master node deletes the log and the routing information.
Further, in the foregoing method, after the master node determines again whether the timestamp of the log is the same as the timestamp of the queried resource creation or deletion of the same resource name, the method further includes:
and if not, the master node deletes the log.
According to another aspect of the present application, there is also provided a method for maintaining metadata of a resource, where the metadata of the resource includes routing information and resource attributes of the resource, the method including:
the main node acquires a request for deleting the routing information of the resource, inquires whether the routing information of the resource exists according to the request for deleting the routing information of the resource, wherein the routing information of the resource comprises a globally unique resource name, position information of resource attributes and a time stamp for creating or deleting the resource,
if the resource attribute exists, the master node updates the timestamp of the created or deleted resource and initiates a request for deleting the resource attribute to the slave node after persisting a log;
and the slave node deletes the resource attribute according to the received request for deleting the resource attribute, and if the deletion of the resource attribute fails, the slave node returns the failure of deleting the resource to the master node.
Further, in the foregoing method, after the slave node deletes the resource attribute according to the received request for deleting the resource attribute, the method further includes:
if the deletion is successful, returning the resource deletion success to the main node, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log.
Further, in the foregoing method, if the two logs are the same, after deleting the log, the method includes:
the main node scans logs which still exist after the preset time is exceeded;
and the main node deletes the residual routing information when the resources are created and deleted according to the scanned log.
Further, in the above method, the deleting, by the master node, the routing information remaining when the resource is created and deleted according to the scanned log includes:
the master node inquires whether routing information having the same resource name as the scanned log exists,
and if the log does not exist, the master node deletes the log.
Further, in the above method, after the master node queries whether the routing information having the same resource name as the scanned log exists, the method further includes:
if so, the master node judges whether the timestamp of the log is the same as the timestamp of the inquired creation or deletion resource with the same resource name,
and if not, the master node deletes the log.
Further, in the above method, after the master node determines whether the timestamp of the log is the same as the timestamp of the queried resource creation or deletion of the same resource name, the method further includes:
if the resource attributes are the same, the master node initiates a request for inquiring whether the resource attributes with the same resource name exist to the corresponding slave node according to the position information of the resource attributes, the slave node inquires according to the request for inquiring whether the resource attributes with the same resource name exist,
and if the log exists, the slave node sends feedback of the existence of the resource attribute to the master node, and the master node deletes the log according to the feedback of the existence of the resource attribute.
Further, in the above method, after the slave node performs the query according to the request for querying whether the resource attribute having the same resource name exists, the method further includes:
if the resource name does not exist, the slave node sends feedback that the resource attribute does not exist to the master node, and the master node judges whether the timestamp of the log is the same as the timestamp of the inquired created or deleted resource with the same resource name again according to the feedback that the resource attribute does not exist;
and if the log and the routing information are the same, the master node deletes the log and the routing information.
Further, in the foregoing method, after the master node determines again whether the timestamp of the log is the same as the timestamp of the queried resource creation or deletion of the same resource name, the method further includes:
and if not, the master node deletes the log.
According to another aspect of the present application, there is also provided a metadata maintenance apparatus for a resource, the metadata of the resource including routing information and resource attributes of the resource, the apparatus including:
the maintenance device is used for maintaining the routing information of the resource in the main node, wherein the routing information of the resource comprises a globally unique resource name and the position information of the resource attribute; and maintaining the resource attribute at the slave node corresponding to the position information of the resource attribute.
Further, in the above device, the routing information of the resource further includes a timestamp for creating or deleting the resource, and the maintenance device is configured to delete, according to the timestamp for creating or deleting the resource, the routing information remaining when the master node deletes creating or deleting the resource, and maintain the resource attribute at the slave node corresponding to the location information of the resource attribute.
Further, in the above apparatus, the maintenance device includes:
the creating and maintaining device is used for updating the time stamp of the creating or deleting resource at the main node when the resource is created, and meanwhile persisting a log, wherein the log comprises the resource name and the time stamp which are the same as the routing information of the resource, and the resource attribute is maintained at the slave node corresponding to the position information of the resource attribute;
the deleting maintenance device is used for updating the time stamp of the resource creation or deletion at the main node when the resource is deleted, and meanwhile persisting a log, wherein the log comprises a resource name and the time stamp which are the same as the routing information of the resource, and the resource attribute is maintained at the slave node corresponding to the position information of the resource attribute;
and the scanning device is used for deleting the residual routing information when the main node deletes the resources according to the time stamp of the resources and the log.
Further, in the above device, the creation and maintenance means is configured to, when requesting to create the routing information of the resource, query, at the master node, whether the routing information of the resource exists,
if not, the routing information of the resource is established in the main node, and a log is persisted at the same time;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log.
Further, in the above device, the creation maintenance means is further configured to, when the master node requests to create the routing information of the resource, after the master node queries whether the routing information of the resource exists,
if the resource attribute exists, judging whether the position information of the resource attribute in the routing information of the resource is different from the position information of the request for creating the resource attribute,
if not, returning the resource creation failure.
Further, in the above device, the routing information of the resource further includes a user, a creation and maintenance device, and is further configured to, after determining whether the location information of the resource attribute in the routing information of the resource is different from the location information of the request for creating the resource attribute, if the location information of the resource attribute is the same as the location information of the request for creating the resource attribute, determine whether the request is initiated by the same user,
if so, updating the time stamp of the creation or deletion of the resource at the main node, and meanwhile persisting a log;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log.
Further, in the above device, the deletion maintaining means is configured to, when requesting to delete the routing information of the resource, query, at the master node, whether the routing information of the resource exists,
if the resource exists, the time stamp of the creation or deletion of the resource is updated at the main node, and a log is persisted at the same time;
deleting the resource attribute from the slave node according to the routing information of the resource, and if the deletion of the resource attribute fails, returning the failure of the deletion of the resource; if the deletion is successful, returning the resource deletion success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log.
Further, in the above device, the scanning device is configured to scan a log that still exists after a preset time is exceeded;
and deleting the residual routing information when the resources are created and deleted according to the scanned log.
Further, in the above device, the scanning means is configured to query whether routing information having the same resource name as the scanned log exists in the master node,
if not, the log is deleted.
Further, in the above device, the scanning means is further configured to, after the master node queries whether the routing information of the same resource name exists,
if yes, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name,
if not, deleting the log.
Further, in the above device, the scanning means is further configured to determine whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name,
if the resource attributes are the same, inquiring whether the resource attributes with the same resource name exist on the corresponding slave nodes,
if so, deleting the log.
Further, in the above device, the scanning means is further configured to, after querying whether the resource attribute with the same resource name exists on the corresponding slave node,
if not, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name or not again;
if the log and the routing information are the same, deleting the log and the routing information.
Further, in the above device, the scanning means is further configured to, after determining again whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name,
if not, deleting the log.
Further, in the above device, the maintaining means is further configured to, after the creation or deletion of the resource attribute at the slave node is successful, store a timestamp of the creation or deletion of the resource at the slave node into the resource attribute;
when the slave node receives a request for the attribute of creation or deletion of the same resource again, whether the time stamp of the creation or deletion of the resource of the current request is larger than the time stamp in the resource attribute saved on the slave node is judged,
if so, processing the request at the slave node;
if not, the request is ignored at the slave node.
According to another aspect of the present application, there is also provided a metadata maintenance device for a resource, where the metadata of the resource includes routing information and resource attributes of the resource, the device including:
the system comprises a main node, a resource management server and a resource management server, wherein the main node is used for acquiring a request for creating routing information of resources and inquiring whether the routing information of the resources exists in the main node or not, and the routing information of the resources comprises globally unique resource names, position information of resource attributes and timestamps for creating or deleting the resources; if the resource does not exist, creating the routing information of the resource, and after a log is persisted, initiating a request for creating the resource attribute to a slave node according to the resource name and the position information of the resource, wherein the log comprises the same resource name and timestamp as the routing information of the resource;
and the slave node is used for creating the resource attribute according to the received request for creating the resource attribute, and returning the resource creation failure to the master node if the resource attribute is failed to be created.
Preferably, in the above device, the slave node is further configured to, after the resource attribute is created according to the received request for creating the resource attribute, if the creation is successful, return a feedback that the creation of the resource is successful to the master node;
and the master node is further configured to compare the timestamp of the created or deleted resource in the routing information of the resource with the timestamp in the log with the same resource name according to the feedback of the successful creation of the resource, and if the timestamps are the same, delete the log.
Preferably, in the above device, the master node is further configured to, after querying whether the routing information of the resource exists in the master node, if so, the master node determines whether the location information of the resource attribute in the routing information of the resource is different from the location information of the resource attribute requested to be created, and if not, returns a resource creation failure to the slave node.
Preferably, in the above device, the routing information of the resource further includes a user,
the master node is further configured to determine whether location information of a resource attribute in the routing information of the resource is different from location information of a request for creating the resource attribute, and if the location information of the resource attribute is the same as the location information of the request for creating the resource attribute, determine whether the request for creating the resource attribute is initiated by the same user, if the request for creating the resource attribute is initiated by the same user, update the timestamp of creating or deleting the resource, and after a log is persisted at the same time, initiate a request for creating the resource attribute to a slave node according to the resource name and the location information of the resource;
the slave node is further configured to create the resource attribute according to the request for creating the resource attribute, and if the creation of the resource attribute fails, return a resource creation failure to the master node.
Preferably, in the above device, the slave node is further configured to, after creating the resource attribute according to the request for creating the resource attribute, if the creation is successful, return the resource creation success to the master node,
and the master node is also used for comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log.
Preferably, in the above device, the master node is further configured to, if the two logs are the same, delete the log and then scan a log that still exists after a preset time is exceeded; and deleting the residual routing information when the resources are created and deleted according to the scanned log.
Preferably, in the above device, the master node is further configured to query whether routing information having the same resource name as the scanned log exists, and if not, the master node deletes the log.
Preferably, in the above device, the master node is further configured to, after querying whether routing information having the same resource name as the scanned log exists, determine whether a timestamp of the log is the same as a timestamp of the queried creation or deletion resource having the same resource name, and if not, delete the log.
Preferably, in the above device, the master node is further configured to, after determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name, if so, initiate a request for querying whether a resource attribute with the same resource name exists to the corresponding slave node according to the location information of the resource attribute;
the slave node is further configured to query according to whether the request for querying the resource attribute with the same resource name exists, and if the request for querying the resource attribute with the same resource name exists, send a feedback that the resource attribute exists to the master node;
and the main node is also used for deleting the log according to the feedback existing in the resource attribute.
Preferably, in the above device, the slave node is further configured to send a feedback that the resource attribute does not exist to the master node if the request for querying whether the resource attribute with the same resource name exists is not sent;
the master node is further configured to judge again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name according to the feedback that the resource attribute does not exist; if the log and the routing information are the same, deleting the log and the routing information.
Preferably, in the above device, the master node is further configured to, after determining again whether the timestamp of the log is the same as the timestamp of the queried resource creation or deletion with the same resource name, if not, delete the log.
According to another aspect of the present application, there is also provided a metadata maintenance apparatus for a resource, the metadata of the resource including routing information and resource attributes of the resource, the apparatus including:
the master node is used for acquiring a request for deleting the routing information of the resource, inquiring whether the routing information of the resource exists according to the request for deleting the routing information of the resource, wherein the routing information of the resource comprises a globally unique resource name, position information of a resource attribute and a time stamp for creating or deleting the resource, if so, updating the time stamp for creating or deleting the resource, and after a log is persisted, initiating a request for deleting the resource attribute to the slave node;
and the slave node is used for deleting the resource attribute according to the received request for deleting the resource attribute, and if the resource attribute is failed to be deleted, returning the resource deletion failure to the master node.
Preferably, in the above device, the slave node is further configured to, after deleting the resource attribute according to the received request for deleting the resource attribute, if the deletion is successful, return a resource deletion success to the master node, compare the timestamp of creating or deleting the resource with the timestamp in the log with the same resource name, and if the timestamps are the same, delete the log.
Preferably, in the above device, the master node is further configured to, if the two logs are the same, delete the log and then scan a log that still exists after a preset time is exceeded; and deleting the residual routing information when the resources are created and deleted according to the scanned log.
Preferably, in the above device, the master node is further configured to delete, according to the scanned log, the routing information remaining when the resource is created and deleted, query whether the routing information having the same resource name as the scanned log exists, and delete the log if the routing information does not exist.
Preferably, in the above device, the master node is further configured to, after querying whether routing information having the same resource name as the scanned log exists, if so, the master node determines whether a timestamp of the log is the same as a timestamp of the queried created or deleted resource having the same resource name, and if not, deletes the log.
Preferably, in the above device, the master node is further configured to, after determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name, if so, initiate a request for querying whether a resource attribute with the same resource name exists to the corresponding slave node according to the location information of the resource attribute;
the slave node is further configured to query according to whether the request for querying the resource attribute with the same resource name exists, and if the request exists, the slave node sends a feedback that the resource attribute exists to the master node;
and the main node is also used for deleting the log according to the feedback existing in the resource attribute.
Preferably, in the above device, the slave node is further configured to send a feedback that the resource attribute does not exist to the master node if the request for querying whether the resource attribute with the same resource name exists is not sent;
the master node is further configured to judge again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name according to the feedback that the resource attribute does not exist; if the log and the routing information are the same, deleting the log and the routing information.
Preferably, in the above device, the master node is further configured to, after determining again whether the timestamp of the log is the same as the timestamp of the queried resource creation or deletion with the same resource name, if not, delete the log.
According to another aspect of the present application, there is also provided a metadata storage apparatus for a resource, the metadata of the resource including routing information and resource attributes of the resource, wherein the apparatus includes:
the main node is used for storing the routing information of the resources, and the routing information of the resources comprises globally unique resource names and position information of resource attributes; a slave node for storing the resource attributes.
Preferably, in the above apparatus, the routing information of the resource further includes a timestamp for creating or deleting the resource.
Preferably, in the above apparatus, the master node further includes a log, and the log includes a resource name and a timestamp that are the same as the routing information of the resource.
Compared with the prior art, the resource naming global uniqueness is realized by segmenting the metadata of the resource into the master node and the slave node, the routing information of the resource is recorded and maintained at the master node, the resource naming global uniqueness is realized, the resource attribute is maintained at the slave node, and the metadata high availability of the resource is realized. In addition, when the resource is created or deleted, the timestamp of the created or deleted resource of the main node is updated, a log is persisted, the log comprises the same resource name and timestamp as the routing information of the resource, and the residual routing information generated under the abnormal scene on the residual main node can be deleted according to the log.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 illustrates a metadata structure diagram of a resource in a preferred embodiment of the present application;
FIG. 2 is a flow diagram of a preferred embodiment of a method for metadata maintenance of resources in the present application;
FIG. 3 illustrates a flow diagram of another preferred embodiment of a method for metadata maintenance of resources in the present application;
FIG. 4 shows a flow chart of yet another preferred embodiment of a method for metadata maintenance of resources in the present application.
The same or similar reference numbers in the drawings identify the same or similar elements.
Detailed Description
The present application is described in further detail below with reference to the attached figures.
In a typical configuration of the present application, the terminal, the device serving the network, and the trusted party each include one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
According to an aspect of the present application, there is provided a method for maintaining metadata of a resource, the metadata of the resource including routing information and resource attributes of the resource, the method including:
step S1, maintaining the routing information of the resource at the master node, and maintaining the resource attribute at the slave node corresponding to the location information of the resource attribute, where the routing information of the resource includes a slave node where a resource name (bucket) and a resource attribute (bucket meta) are located, and the metadata of the resource includes the routing information and the attribute of the resource. Specifically, the slave nodes are regions/regions (regions) divided according to geographic locations, each region node is called a slave node, the master node (common node) is a common node of all regions and is used for storing the region to which the resource belongs, namely, the slave node where the resource is located, the routing information is used for recording the region to which the resource belongs and is used for the master node to query the corresponding slave node, and the routing information (bucket route) of the resource includes the slave node where the resource name (bucket) and the resource attribute (meta) are located. The read-write resource attribute (bucket meta) only needs to access the slave node, and the request for creating and deleting the resource needs to access the master node and the slave node simultaneously. The resource naming global uniqueness is realized by segmenting the metadata of the resource into the master node and the slave node, the routing information of the resource is recorded and maintained in the master node, the resource naming global uniqueness is realized, the slave node maintains the resource attribute, and the metadata high availability of the resource is realized.
In a preferred embodiment of the method for maintaining metadata of a resource according to the present application, the routing information of the resource further includes a timestamp for creating or deleting the resource, the routing information of the resource is maintained at the master node, and the resource attribute is maintained at a slave node corresponding to the location information of the resource attribute, including:
according to the time stamp of creating or deleting the resource, the route information remained when the main node deletes the creating or deleting the resource, and the resource attribute is maintained at the slave node corresponding to the position information of the resource attribute, so that the abnormal route information can be deleted according to the time stamp in the follow-up process, and the global uniqueness of the resource naming is further ensured.
In a preferred embodiment of the method for maintaining metadata of resources of the present application, in step S1, according to the timestamp of creating or deleting a resource, the method for maintaining metadata of resources includes:
step S11, when creating the resource, the master node updates the time stamp (mtime) of the creation or deletion of the resource, and meanwhile persists a log, wherein the log comprises the same resource name and time stamp as the routing information of the resource, and the resource attribute is maintained at the slave node corresponding to the position information of the resource attribute;
step S12, when deleting the resource, the master node updates the time stamp of the resource creation or deletion, and meanwhile persists a log, wherein the log comprises the same resource name and time stamp as the routing information of the resource, and the resource attribute is maintained at the slave node corresponding to the position information of the resource attribute. In each creating and deleting operation, the master node updates the time stamp (mtime) of the created or deleted resource, and meanwhile persists an operation log (oplog) corresponding to the same time stamp for deleting the residual routing information generated under the abnormal scene on the residual master node according to log check, wherein the time stamp in the log is consistent with the time stamp of the log updated when the resource is created or deleted. For example, as shown in fig. 1, the format of the routing information may be set to (bucket, region, mtime), and the format of the corresponding log may be set to (bucket, region, mtime).
The resource creation is divided into three steps, and a request for creating the resource is sent to the main node:
the first step is as follows:
in order to ensure that the resource naming is globally unique, whether the routing information of the resource created by the query exists or not is queried, and the method is divided into three conditions according to the result: in the first case, the routing information (packet route) exists, but the area/region (region) in the routing information is different from the area/region (region) requested this time, or the user (user) in the routing information is different from the user (user) requested this time; in the second case, the bucket route exists, the region in the bucket route is the same as the region requested this time, and the user recorded in the existing bucket route is the same user as the user requested this time; in the third case, bucket route is not present. And for the first case, directly returning failure, for the second case, updating the timestamp in the bucket route information to be latest, and for the third case, adding a new bucket route information. When a packet route is updated and newly added, an oplog needs to be persisted at the same time, and the timestamp stored in the oplog is the same as the timestamp in the updated or newly added packet route. In addition, the newly added or updated bucket route and the persisted oplog need to be in the same transaction, so that the atomicity of the newly added or updated bucket route and the persisted oplog at the same time is ensured, namely, the newly added or updated and the persisted oplog are successful or unsuccessful.
The second step is that:
for the second and third cases, a create operation request needs to be initiated to the corresponding slave node.
The third step:
for the second and third cases, if the corresponding slave node returns a failure, the user failure is returned. If the corresponding slave node returns success, the user success is returned, then whether the timestamp in the bucket route is the same as the timestamp in the persistent oplog in the first step is compared, and if so, the oplog is deleted.
As shown in fig. 2, in a preferred embodiment of the method for maintaining metadata of a resource according to the present application, in step S11, when creating a resource, the master node updates a timestamp of the creation or deletion of the resource and persists a log, including:
step S111, when the route information of the resource is requested to be created, the main node inquires whether the route information of the resource exists or not,
if not, step S112, creating the routing information of the resource in the master node, and persisting a log at the same time;
step S113, the resource attribute is created in the slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, step S114, the failure of the creation of the resource is returned; if the creation is successful, step S115 returns the resource creation success, and compares the timestamp of the created or deleted resource with the timestamp in the log with the same resource name, and if the timestamps are the same, step S116 deletes the log. Here, in the present embodiment, for the third case of creating a resource, if a packet route does not exist, a new packet route information is added. If the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, it indicates that both the master node and the slave node are successfully created, the bucket route is not an abnormal bucket route, and the corresponding oplog does not need to be retained, and the corresponding oplog should be deleted. In this embodiment, since the resource does not exist, the timestamp for updating the resource at the master node is the timestamp in the master node creation path information, and is a special timestamp update.
As shown in fig. 2, in a preferred embodiment of the method for maintaining metadata of a resource according to the present application, in step S111, when requesting to create routing information of a resource, after the master node queries whether the routing information of the resource exists, the method further includes:
if yes, step S117 determines whether the location information of the resource attribute in the routing information of the resource is different from the location information of the request for creating the resource attribute,
if not, step S118 returns a resource creation failure. Here, in this embodiment, for the first case of creating a resource, the routing information (bucket route) exists, but the area/region (region) in the routing information is different from the area/region (region) of the request, which indicates that the bucket route already exists, and if the region/region (region) of the already-existing bucket route is beijing and the region/region (region) of the request is shanghai, it indicates that the bucket route is already occupied and cannot be used as a bucket route in shanghai, and the already-existing bucket route may be a bucket route that has already been created successfully by a slave node in beijing, or a bucket route that is being used, or a bucket route that has not been created successfully by a slave node in beijing and is not in use, and it is necessary to delete the already-existing bucket route before the existing route can be used by another slave node.
In a preferred embodiment of the metadata maintenance method for resources of the present application, the routing information of the resources further includes a user. Here, the routing information of the resource further includes a user (user) to which the resource belongs, that is, a user that indicates which user requests to create the resource, so that it is convenient to subsequently check whether the creation request is initiated by the same user, and global uniqueness of the resource is further ensured. Here, the routing information may be formatted as (packet, region, mtime, user).
As shown in fig. 2, in a preferred embodiment of the method for maintaining metadata of a resource according to the present application, after determining whether location information of a resource attribute in routing information of the resource is different from location information of a request for creating a resource attribute in step S117, the method further includes:
if the two requests are the same, step S119, determining whether the requests are initiated by the same user,
if yes, step S1191, the time stamp of the creation or deletion of the resource is updated at the master node, and a log is persisted at the same time;
step 1192, create the said resource attribute in the slave node according to the said resource name and said positional information of the resource, if the creation of the said resource attribute fails, step 1193, return to the resource and create and fail; if the creation is successful, step S1194 returns the resource creation success, and compares the timestamp of the created or deleted resource with the timestamp in the log with the same resource name, and if the two timestamps are the same, step S1195 deletes the log. Specifically, in the present embodiment, for the second case in the created resources, a bucket route exists, a region in the bucket route is the same as a region requested this time, and a user recorded in the existing bucket route is the same user as the user requested this time, so that the same user performs repeated creation processing on the same resource; in addition, if the user is a different user, the same processing method as that in the first case is used, and the creation failure is directly returned.
The same as creating a bucket, and sending a bucket deleting request to the main node, wherein the method basically comprises the following three steps:
the first step is as follows:
the main node judges whether the packet route exists or not, if the packet route exists, the timestamp of the packet route is updated to be the latest time, and an oplog is persisted at the same time, wherein the format of the oplog is the same as that of the created packet;
the second step is that:
initiating a request for deleting the bucket meta to the corresponding slave node;
the third step:
after receiving the processing result of the slave node, the master node returns the failure of the user if the request fails; if the request is successful, returning the success of the user, and then deleting the packet route and the oplog of the first step of persistence.
As shown in fig. 3, in a preferred embodiment of the method for maintaining metadata of a resource according to the present application, in step S12, when deleting a resource, the master node updates a timestamp of creating or deleting the resource and persists a log, where the resource attribute is maintained at a slave node corresponding to the location information of the resource attribute, and the method includes:
step S121, when the route information of the resource is requested to be deleted, the main node inquires whether the route information of the resource exists or not,
if so, step S122, updating the timestamp of creating or deleting the resource at the master node, and meanwhile persisting a log;
step S123, deleting the resource attribute from the slave node according to the routing information of the resource, and if the deletion of the resource attribute fails, returning the failure of the resource deletion in step S124; if the deletion is successful, step S125, the resource deletion is returned, and the timestamp of the created or deleted resource is compared with the timestamp in the log with the same resource name, and if the timestamps are the same, step S126, the log is deleted. Here, after the resource deletion is successful, since the packet meta has been successfully deleted, and the corresponding packet route and oplog have not been used yet, the deletion is performed, so that the corresponding packet route is prevented from being unnecessarily occupied after the packet meta is deleted. In addition, in order to judge whether the bucket route is updated, if the bucket route is not updated, the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, and the bucket route and the oplog are deleted, and if the bucket route is updated, the time stamp of the created or deleted resource is not the same as the time stamp in the log with the same resource name, only the oplog is deleted.
The record oplog is used to delete the residual packet route when creating and deleting the packet, for example, when creating the packet route successfully but creating the corresponding meta does not succeed, or when deleting the meta successfully but deleting the corresponding packet route does not succeed. And regularly releasing the unnecessarily occupied packet routes by scanning the oplog which still exists after the set time is exceeded through the background thread, namely recovering the occupied packet routes. oplog treatment:
firstly, whether a corresponding bucket route exists is checked, and the method is divided into two conditions: the packet route does not exist or exists, the timestamp in the packet route is different from the timestamp stored by the oplog, and the oplog is directly deleted; if the packet route exists and the timestamp is the same as the timestamp stored in the oplog, the corresponding slave node queries whether the packet meta exists:
if the packet meta exists on the slave node, deleting oplog; if the packet meta does not exist on the slave node, whether the time stamp in the oplog is the same as that in the packet route is compared, if so, the packet route and the oplog are deleted, and if not, only the oplog is deleted.
In a preferred embodiment of the method for maintaining metadata of resources of the present application, when creating or deleting resources in step S11 and step S12, after the master node updates the timestamp of creating or deleting resources of resources and persists a log, the method further includes:
step S13, scanning the logs which still exist after the preset time is exceeded;
and step S14, deleting the residual routing information when creating and deleting the resources according to the scanned logs, thereby ensuring the final consistency of the master node resources and the slave node resources. Here, all logs (Oplog) only record the routing information at the time of creation and deletion, that is, only record the incremental content in all routing information, and here, only scanning the logs can improve the scanning speed and quickly find abnormal routing information.
As shown in fig. 4, in a preferred embodiment of the method for maintaining metadata of a resource according to the present application, in step S14, according to the scanned log, deleting the routing information remaining when the resource is created and deleted includes:
step S141, inquiring whether the routing information with the same resource name as the scanned log exists in the main node,
if not, step S142 deletes the log. Here, when the packet route does not exist, it is not necessary to check the slave node, and it is only necessary to delete oplog directly.
In a preferred embodiment of the method for maintaining metadata of resources of the present application, in step S141, after the master node queries whether routing information of the same resource name exists, the method further includes:
if yes, step S143, determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name,
if not, step S144 deletes the log. Here, since the timestamp stored by the oplog is different from the current timestamp in the packet route, the oplog of the different timestamp does not need to be retained, because there exists an oplog with the same current timestamp in the packet route, and only the oplog with the same timestamp can be used to check the packet route from which the corresponding phase timestamp is deleted.
As shown in fig. 4, in a preferred embodiment of the method for maintaining metadata of a resource according to the present application, after determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource of the same resource name in step S143, the method further includes:
if they are the same, step S145, queries whether there is a resource attribute with the same resource name in the corresponding slave node,
if so, step S146 deletes the log. Here, if a packet meta exists on the slave node, it indicates that the corresponding packet route is not an abnormal packet route, and the corresponding oplog is not necessarily retained any more, and the oplog should be deleted.
As shown in fig. 4, in a preferred embodiment of the method for maintaining metadata of a resource according to the present application, after querying whether a resource attribute with the same resource name exists on a corresponding slave node, the method further includes:
if not, step S147, determining again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name;
if the log and the routing information are the same, step S148 deletes the log and the routing information. Here, since there is a possibility that the timestamp of the packet route is modified between the two comparisons, it is necessary to determine again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name, so as to ensure accurate deletion of the log and the routing information. When the corresponding slave node does not have the resource attribute with the same resource name, judging that the time stamp of the log is the same as the time stamp of the inquired created or deleted resource with the same resource name again, indicating that the bucket route is an abnormal bucket route, and deleting the bucket route and the oplog simultaneously.
As shown in fig. 4, in a preferred embodiment of the method for maintaining metadata of a resource according to the present application, after step S147, determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name, the method further includes:
if not, in step S149, the log is deleted. Here, because the timestamp stored by the oplog is different from the timestamp in the packet route, the oplog with the different timestamp does not need to be retained, because there exists an oplog with the same timestamp in the packet route, only the oplog with the same timestamp can be used for checking and deleting the packet route corresponding to the time-of-phase timestamp, and only the timestamp is the same, it can be ensured that the time-of-phase timestamp cannot be deleted by mistake.
In a preferred embodiment of the method for maintaining metadata of a resource according to the present application, in step S1, the maintaining, by the slave node, the resource attribute further includes:
when the creation or deletion of the resource attribute of the slave node is successful, saving the time stamp of the creation or deletion of the resource in the resource attribute on the slave node;
when the slave node receives a request for the attribute of creation or deletion of the same resource again, whether the time stamp of the creation or deletion of the resource of the current request is larger than the time stamp in the resource attribute saved on the slave node is judged,
if so, processing the request at the slave node;
if not, the request is ignored at the slave node. Here, in this embodiment, for the concurrent processing requirement of creating and deleting a packet, the request for creating or deleting a resource may carry a corresponding timestamp of the resource being created or deleted at that time to perform an operation on the slave node, and the timestamp is compared with a timestamp stored in an attribute on the slave node, and only when the timestamp of the request is greater than the timestamp stored in the slave node, the request may be processed, otherwise, the request is ignored. And after the request processing is completed, updating and storing the time stamp of the processed request on the resource attribute of the slave node. The order execution of the concurrent requests is ensured through timestamp information of the bucket route stored in the slave node, the timestamp of the later received request on the master node is the larger value of the timestamp of the last recorded bucket route plus 1 or the current timestamp, so as to ensure that the timestamp of the later received request is larger, for example, the timestamp of the earlier received request is 10:00, the timestamp of the later received request is 10:01, or the timestamp of the later received request is a value larger than 10:00, in addition, the request execution order of the master node is executed according to the received request order, for example, the master node receives a request for creating the bucket route at 10:00, the timestamp of the master node corresponding to the bucket route is 10:00, the master node receives a request for deleting the bucket at 10:01, the timestamp of the corresponding updated bucket route is 10:01, if the slave node receives the request for deleting the meter of the bucket route at 10:01 first, then, since the timestamp 10:01 of the delete create request is greater than the timestamp of the packet route saved from the node, the delete meta operation is executed, since the corresponding meta is not found, the delete success is returned, the timestamp of the resource packet route saved at the slave node is updated to 10:01, then the slave node receives the request for creating the meta of the 10:00 packet route again, since the timestamp 10:00 of the create delete request is less than the timestamp 10:01 of the packet route saved from the slave node, if the create meta is wrong after the delete meta, the slave node determines whether the request for creating or deleting the meta is executed by judging the size of the timestamp, ignores the request less than the timestamp 10:01 of the packet route saved, and the rule of the judgment is that if the timestamp of the request received from the node is greater than the timestamp of the packet route saved from the node, and executing the request, and if the time stamp of the request received from the node is less than the time stamp of the packet route stored in the node, not executing the request.
In addition, when reading and writing the resource attribute (bucket meta), updating and reading the bucket meta only need to update or read the corresponding slave node, if the read-write request which can be directly sent to the slave node is wrongly sent to the master node, the master node obtains the slave node to which the bucket belongs from the bucket route table, and then directly forwards the read-write request to the corresponding slave node for processing.
According to another aspect of the present application, there is also provided a metadata maintenance apparatus for a resource, the apparatus including:
the maintenance device 100 is configured to maintain routing information of a resource at a master node, maintain routing information of the resource at a slave node corresponding to location information of a resource attribute, where the routing information of the resource includes a resource name and location information of the resource attribute, and the metadata of the resource includes routing information and an attribute of the resource. Specifically, the slave nodes are regions/regions (regions) divided according to geographic locations, each region node is called a slave node, the master node (common node) is a common node of all regions and is used for storing the region to which the resource belongs, namely, the slave node where the resource is located, the routing information is used for recording the region to which the resource belongs and is used for the master node to query the corresponding slave node, and the routing information (bucket route) of the resource includes the slave node where the resource name (bucket) and the resource attribute (meta) are located. The read-write resource attribute (bucket meta) only needs to access the slave node, and the request for creating and deleting the resource needs to access the master node and the slave node simultaneously. The resource naming global uniqueness is realized by segmenting the metadata of the resource into the master node and the slave node, the routing information of the resource is recorded and maintained in the master node, the resource naming global uniqueness is realized, the slave node maintains the resource attribute, and the metadata high availability of the resource is realized.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the routing information of the resources further includes a timestamp for creating or deleting the resources, which is convenient for deleting abnormal routing information according to the timestamp in the following, and further ensures global uniqueness of resource naming.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the maintenance apparatus 100 includes:
the creating and maintaining device 1 is used for updating the time stamp of creating or deleting the resource at the main node when the resource is created, and meanwhile persisting a log, wherein the log comprises the same resource name and time stamp as the routing information of the resource;
and the deletion maintenance device 2 is used for updating the time stamp of the creation or deletion of the resource at the main node when the resource is deleted, and meanwhile persisting a log, wherein the log comprises the same resource name and time stamp as the routing information of the resource. In each creating and deleting operation, the master node updates the time stamp (mtime) of the created or deleted resource, and meanwhile persists an operation log (oplog) corresponding to the same time stamp for deleting the residual routing information generated under the abnormal scene on the residual master node according to log check, wherein the time stamp in the log is consistent with the time stamp of the log updated when the resource is created or deleted. For example, as shown in fig. 1, the format of the routing information may be set to (bucket, region, mtime), and the format of the corresponding log may be set to (bucket, region, mtime).
The resource creation is divided into three steps, and a request for creating the resource is sent to the main node:
the first step is as follows:
in order to ensure that the resource naming is globally unique, whether the routing information of the resource created by the query exists or not is queried, and the method is divided into three conditions according to the result: in the first case, the routing information (packet route) exists, but the area/region (region) in the routing information is different from the area/region (region) requested this time, or the user (user) in the routing information is different from the user (user) requested this time; in the second case, the bucket route exists, the region in the bucket route is the same as the region requested this time, and the user recorded in the existing bucket route is the same user as the user requested this time; in the third case, bucket route is not present. And for the first case, directly returning failure, for the second case, updating the timestamp in the bucket route information to be latest, and for the third case, adding a new bucket route information. When a packet route is updated and newly added, an oplog needs to be persisted at the same time, and the timestamp stored in the oplog is the same as the timestamp in the updated or newly added packet route. In addition, the newly added or updated bucket route and the persisted oplog need to be in the same transaction, so that the atomicity of the newly added or updated bucket route and the persisted oplog at the same time is ensured, namely, the newly added or updated and the persisted oplog are successful or unsuccessful.
The second step is that:
for the second and third cases, a create operation request needs to be initiated to the corresponding slave node.
The third step:
for the second and third cases, if the corresponding slave node returns a failure, the user failure is returned. If the corresponding slave node returns success, the user success is returned, then whether the timestamp in the bucket route is the same as the timestamp in the persistent oplog in the first step is compared, and if so, the oplog is deleted.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the creation and maintenance apparatus 1 is configured to, when requesting to create the routing information of a resource, query the master node whether the routing information of the resource exists,
if not, the routing information of the resource is established in the main node, and a log is persisted at the same time;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log. Here, in the present embodiment, for the third case of creating a resource, if a packet route does not exist, a new packet route information is added. If the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, it indicates that both the master node and the slave node are successfully created, the bucket route is not an abnormal bucket route, and the corresponding oplog does not need to be retained, and the corresponding oplog should be deleted. In this embodiment, since the resource does not exist, the timestamp for updating the resource at the master node is the timestamp in the master node creation path information, and is a special timestamp update.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the creation and maintenance apparatus 1 is further configured to, when the master node queries whether the routing information of the resource exists or not,
if the resource attribute exists, judging whether the position information of the resource attribute in the routing information of the resource is different from the position information of the request for creating the resource attribute,
if not, returning the resource creation failure. Here, in this embodiment, for the first case of creating a resource, the routing information (bucket route) exists, but the area/region (region) in the routing information is different from the area/region (region) of the request, which indicates that the bucket route already exists, and if the region/region (region) of the already-existing bucket route is beijing and the region/region (region) of the request is shanghai, it indicates that the bucket route is already occupied and cannot be used as a bucket route in shanghai, and the already-existing bucket route may be a bucket route that has already been created successfully by a slave node in beijing, or a bucket route that is being used, or a bucket route that has not been created successfully by a slave node in beijing and is not in use, and it is necessary to delete the already-existing bucket route before the existing route can be used by another slave node.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the routing information of the resources further includes a user. Here, the routing information of the resource further includes a user (user) to which the resource belongs, that is, a user that indicates which user requests to create the resource, so that it is convenient to subsequently check whether the creation request is initiated by the same user, and global uniqueness of the resource is further ensured. Here, the routing information may be formatted as (packet, region, mtime, user).
In a preferred embodiment of the metadata maintenance device for resources of the present application, the creation and maintenance apparatus 1 is further configured to determine whether the location information of the resource attribute in the routing information of the resource is different from the location information of the resource attribute requested to be created, and if the location information of the resource attribute is the same as the location information of the resource attribute requested to be created, determine whether the request is initiated by the same user,
if so, updating the time stamp of the creation or deletion of the resource at the main node, and meanwhile persisting a log;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log. Specifically, in the present embodiment, for the second case in the created resources, a bucket route exists, a region in the bucket route is the same as a region requested this time, and a user recorded in the existing bucket route is the same user as the user requested this time, so that the same user performs repeated creation processing on the same resource; in addition, if the user is a different user, the same processing method as that in the first case is used, and the creation failure is directly returned.
The same as creating a bucket, and sending a bucket deleting request to the main node, wherein the method basically comprises the following three steps:
the first step is as follows:
the main node judges whether the packet route exists or not, if the packet route exists, the timestamp of the packet route is updated to be the latest time, and an oplog is persisted at the same time, wherein the format of the oplog is the same as that of the created packet;
the second step is that:
initiating a request for deleting the bucket meta to the corresponding slave node;
the third step:
after receiving the processing result of the slave node, the master node returns the failure of the user if the request fails; if the request is successful, returning the success of the user, and then deleting the packet route and the oplog of the first step of persistence.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the deletion maintenance apparatus 2 is configured to, when requesting to delete the routing information of a resource, query, at the master node, whether the routing information of the resource exists,
if the resource exists, the time stamp of the creation or deletion of the resource is updated at the main node, and a log is persisted at the same time;
deleting the resource attribute from the slave node according to the routing information of the resource, and if the deletion of the resource attribute fails, returning the failure of the deletion of the resource; if the deletion is successful, returning the resource deletion success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log. Here, after the resource deletion is successful, since the packet meta has been successfully deleted, and the corresponding packet route and oplog have not been used yet, the deletion is performed, so that the corresponding packet route is prevented from being unnecessarily occupied after the packet meta is deleted. In addition, in order to judge whether the bucket route is updated, if the bucket route is not updated, the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, and the bucket route and the oplog are deleted, and if the bucket route is updated, the time stamp of the created or deleted resource is not the same as the time stamp in the log with the same resource name, only the oplog is deleted.
The record oplog is used to delete the residual packet route when creating and deleting the packet, for example, when creating the packet route successfully but creating the corresponding meta does not succeed, or when deleting the meta successfully but deleting the corresponding packet route does not succeed. And regularly releasing the unnecessarily occupied packet routes by scanning the oplog which still exists after the set time is exceeded through the background thread, namely recovering the occupied packet routes. oplog treatment:
firstly, whether a corresponding bucket route exists is checked, and the method is divided into two conditions: the packet route does not exist or exists, the timestamp in the packet route is different from the timestamp stored by the oplog, and the oplog is directly deleted; if the packet route exists and the timestamp is the same as the timestamp stored in the oplog, the corresponding slave node queries whether the packet meta exists:
if the packet meta exists on the slave node, deleting oplog; if the packet meta does not exist on the slave node, whether the time stamp in the oplog is the same as that in the packet route is compared, if so, the packet route and the oplog are deleted, and if not, only the oplog is deleted.
As shown, in a preferred embodiment of the metadata maintenance device for resources of the present application, the scanning device 3 is further configured to, when a resource is created or deleted, after the master node updates the timestamp of the creation or deletion of the resource and persists a log,
scanning logs which still exist after the preset time is exceeded;
and deleting the residual routing information when the resources are created and deleted according to the scanned log. Here, all logs (Oplog) only record the routing information at the time of creation and deletion, that is, only record the incremental content in all routing information, and here, only scanning the logs can improve the scanning speed and quickly find abnormal routing information.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the scanning unit 3 is configured to query the master node whether routing information having the same resource name as the scanned log exists,
if not, the log is deleted. Here, when the packet route does not exist, it is not necessary to check the slave node, and it is only necessary to delete oplog directly.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the scanning device 3 is further configured to, after the master node queries whether routing information of the same resource name exists,
if yes, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name,
if not, deleting the log. Here, since the timestamp stored by the oplog is different from the current timestamp in the packet route, the oplog of the different timestamp does not need to be retained, because there exists an oplog with the same current timestamp in the packet route, and only the oplog with the same timestamp can be used to check the packet route from which the corresponding phase timestamp is deleted.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the scanning device 3 is further configured to determine whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource of the same resource name,
if the resource attributes are the same, inquiring whether the resource attributes with the same resource name exist on the corresponding slave nodes,
if so, deleting the log. Here, if a packet meta exists on the slave node, it indicates that the corresponding packet route is not an abnormal packet route, and the corresponding oplog is not necessarily retained any more, and the oplog should be deleted.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the scanning unit 3 is further configured to, after querying the corresponding slave node whether there is a resource attribute with the same resource name,
if not, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name or not again;
if the log and the routing information are the same, deleting the log and the routing information. Here, since there is a possibility that the timestamp of the packet route is modified between the two comparisons, it is necessary to determine again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name, so as to ensure accurate deletion of the log and the routing information. When the corresponding slave node does not have the resource attribute with the same resource name, judging that the time stamp of the log is the same as the time stamp of the inquired created or deleted resource with the same resource name again, indicating that the bucket route is an abnormal bucket route, and deleting the bucket route and the oplog simultaneously.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the scanning device 3 is further configured to determine whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name,
if not, deleting the log. Here, because the timestamp stored by the oplog is different from the timestamp in the packet route, the oplog with the different timestamp does not need to be retained, because there exists an oplog with the same timestamp in the packet route, only the oplog with the same timestamp can be used for checking and deleting the packet route corresponding to the time-of-phase timestamp, and only the timestamp is the same, it can be ensured that the time-of-phase timestamp cannot be deleted by mistake.
In a preferred embodiment of the metadata maintenance device for resources of the present application, the maintenance apparatus 100 is further configured to, after the creation or deletion of the resource attribute of the slave node is successful, store a timestamp of the creation or deletion of the resource into the resource attribute on the slave node;
when the slave node receives a request for the attribute of creation or deletion of the same resource again, whether the time stamp of the creation or deletion of the resource of the current request is larger than the time stamp in the resource attribute saved on the slave node is judged,
if so, processing the request at the slave node;
if not, the request is ignored at the slave node. Here, in this embodiment, for the concurrent processing requirement of creating and deleting a packet, the request for creating or deleting a resource may carry a corresponding timestamp of the resource being created or deleted at that time to perform an operation on the slave node, and the timestamp is compared with a timestamp stored in an attribute on the slave node, and only when the timestamp of the request is greater than the timestamp stored in the slave node, the request may be processed, otherwise, the request is ignored. And after the request processing is completed, updating and storing the time stamp of the processed request on the resource attribute of the slave node. The order execution of the concurrent requests is ensured through timestamp information of the bucket route stored in the slave node, the timestamp of the later received request on the master node is the larger value of the timestamp of the last recorded bucket route plus 1 or the current timestamp, so as to ensure that the timestamp of the later received request is larger, for example, the timestamp of the earlier received request is 10:00, the timestamp of the later received request is 10:01, or the timestamp of the later received request is a value larger than 10:00, in addition, the request execution order of the master node is executed according to the received request order, for example, the master node receives a request for creating the bucket route at 10:00, the timestamp of the master node corresponding to the bucket route is 10:00, the master node receives a request for deleting the bucket at 10:01, the timestamp of the corresponding updated bucket route is 10:01, if the slave node receives the request for deleting the meter of the bucket route at 10:01 first, then, since the timestamp 10:01 of the delete create request is greater than the timestamp of the packet route saved from the node, the delete meta operation is executed, since the corresponding meta is not found, the delete success is returned, the timestamp of the resource packet route saved at the slave node is updated to 10:01, then the slave node receives the request for creating the meta of the 10:00 packet route again, since the timestamp 10:00 of the create delete request is less than the timestamp 10:01 of the packet route saved from the slave node, if the create meta is wrong after the delete meta, the slave node determines whether the request for creating or deleting the meta is executed by judging the size of the timestamp, ignores the request less than the timestamp 10:01 of the packet route saved, and the rule of the judgment is that if the timestamp of the request received from the node is greater than the timestamp of the packet route saved from the node, and executing the request, and if the time stamp of the request received from the node is less than the time stamp of the packet route stored in the node, not executing the request.
In addition, when reading and writing the resource attribute (bucket meta), updating and reading the bucket meta only need to update or read the corresponding slave node, if the read-write request which can be directly sent to the slave node is wrongly sent to the master node, the master node obtains the slave node to which the bucket belongs from the bucket route table, and then directly forwards the read-write request to the corresponding slave node for processing.
In a specific application example of the present application, the resource is a folder, the metadata of the file includes the routing information and the folder attributes of the folder, and the folder attributes include the maximum number of files of the folder, the creation time of the folder, the authority management rule of the folder, and the like. Specifically, a method for maintaining metadata of a folder is provided, where the metadata of the folder includes routing information and folder attributes of the folder, and the method includes:
the method comprises the steps that a main node acquires a request for creating routing information of a folder, and inquires whether the routing information of the folder exists in the main node or not, wherein the routing information of the folder comprises a globally unique folder name, position information of folder attributes and a time stamp for creating or deleting the folder;
if the log does not exist, the master node creates the routing information of the folder, and after a log is persisted, a request for creating the attribute of the folder is sent to a slave node according to the name of the folder and the position information of the folder, wherein the log comprises the name of the folder and a timestamp which are the same as the routing information of the folder;
and the slave node creates the folder attribute according to the received request for creating the folder attribute, and if the folder attribute is failed to be created, the slave node returns the folder creation failure to the master node.
Further, in the above method, after the slave node creates the folder attribute according to the received request for creating the folder attribute, the method further includes:
if the creation is successful, returning feedback of successful creation of the folder to the main node;
and the master node compares the time stamp of the created or deleted folder in the routing information of the folder with the time stamp in the log with the same folder name according to the feedback of the successful creation of the folder, and deletes the log if the time stamps are the same.
Further, in the above method, after the master node queries whether the routing information of the folder exists in the master node, the method further includes:
if so, the master node judges whether the position information of the folder attribute in the routing information of the folder is different from the position information of the folder attribute requested to be created,
and if the two files are different, the master node returns a folder creation failure to the slave node.
Further, in the above method, the routing information of the folder further includes a user,
after the master node determines whether the location information of the folder attribute in the routing information of the folder is different from the location information of the folder attribute requested to be created, the method further includes:
if the two are the same, the main node judges whether the request for creating the folder attribute is initiated by the same user or not,
if so, the master node updates the time stamp of the created or deleted folder, and initiates a request for creating the attribute of the folder to the slave node according to the name of the folder and the position information of the folder after persisting a log;
and the slave node creates the folder attribute according to the request for creating the folder attribute, and if the creation of the folder attribute fails, the slave node returns the creation failure of the folder to the master node.
Further, in the above method, after the slave node creates the folder attribute according to the request for creating the folder attribute, the method further includes:
if the creation is successful, after the folder creation is returned to the master node, the master node compares the time stamp of the created or deleted folder with the time stamp in the log with the same folder name, and if the time stamps are the same, the log is deleted.
Further, in the foregoing method, if the two logs are the same, after deleting the log, the method includes:
the main node scans logs which still exist after the preset time is exceeded;
and the main node deletes the residual routing information when the folder is created and deleted according to the scanned log.
Further, in the above method, the deleting, by the master node, the routing information remaining when the folder is created and deleted according to the scanned log includes:
the master node inquires whether routing information having the same folder name as the scanned log exists,
and if the log does not exist, the master node deletes the log.
Further, in the above method, after the master node queries whether the routing information having the same folder name as the scanned log exists, the method further includes:
if so, the master node judges whether the time stamp of the log is the same as the time stamp of the created or deleted folder with the same inquired folder name or not,
and if not, the master node deletes the log.
Further, in the above method, after the master node determines whether the timestamp of the log is the same as the timestamp of the queried creation or deletion folder with the same folder name, the method further includes:
if the file names are the same, the master node initiates a request for inquiring whether the file attributes with the same folder name exist to the corresponding slave node according to the position information of the file attributes, the slave node inquires according to the request for inquiring whether the file attributes with the same folder name exist,
if the log exists, the slave node sends the feedback of the existence of the folder attribute to the master node, and the master node deletes the log according to the feedback of the existence of the folder attribute.
Further, in the above method, after the slave node performs the query according to the request for querying whether there are folder attributes with the same folder name, the method further includes:
if the log does not exist, the slave node sends feedback that the folder attribute does not exist to the master node, and the master node judges whether the timestamp of the log is the same as the timestamp of the inquired creation or deletion folder with the same folder name or not again according to the feedback that the folder attribute does not exist;
and if the log and the routing information are the same, the master node deletes the log and the routing information.
Further, in the above method, after the master node determines again whether the timestamp of the log is the same as the timestamp of the queried creation or deletion folder with the same folder name, the method further includes:
and if not, the master node deletes the log.
In another specific application scenario of the present application, a method for maintaining metadata of a folder is further provided, where the metadata of the folder includes routing information and folder attributes of the folder, and the method includes:
the main node acquires a request for deleting the routing information of the folder, inquires whether the routing information of the folder exists according to the request for deleting the routing information of the folder, wherein the routing information of the folder comprises a globally unique folder name, position information of folder attributes and a time stamp for creating or deleting the folder,
if the file folder attribute exists, the master node updates the time stamp of the created or deleted file folder and simultaneously initiates a request for deleting the file folder attribute to the slave node after persisting a log;
and the slave node deletes the folder attribute according to the received request for deleting the folder attribute, and if the deletion of the folder attribute fails, returns the deletion failure of the folder to the master node.
Further, in the above method, after the slave node deletes the folder attribute according to the received request for deleting the folder attribute, the method further includes:
if the deletion is successful, returning the successful deletion of the folder to the main node, comparing the time stamp of the created or deleted folder with the time stamp in the log with the same folder name, and if the time stamps are the same, deleting the log.
Further, in the foregoing method, if the two logs are the same, after deleting the log, the method includes:
the main node scans logs which still exist after the preset time is exceeded;
and the main node deletes the residual routing information when the folder is created and deleted according to the scanned log.
Further, in the above method, the deleting, by the master node, the routing information remaining when the folder is created and deleted according to the scanned log includes:
the master node inquires whether routing information having the same folder name as the scanned log exists,
and if the log does not exist, the master node deletes the log.
Further, in the above method, after the master node queries whether the routing information having the same folder name as the scanned log exists, the method further includes:
if so, the master node judges whether the time stamp of the log is the same as the time stamp of the created or deleted folder with the same inquired folder name or not,
and if not, the master node deletes the log.
Further, in the above method, after the master node determines whether the timestamp of the log is the same as the timestamp of the queried creation or deletion folder with the same folder name, the method further includes:
if the file names are the same, the master node initiates a request for inquiring whether the file attributes with the same folder name exist to the corresponding slave node according to the position information of the file attributes, the slave node inquires according to the request for inquiring whether the file attributes with the same folder name exist,
if the log exists, the slave node sends the feedback of the existence of the folder attribute to the master node, and the master node deletes the log according to the feedback of the existence of the folder attribute.
Further, in the above method, after the slave node performs the query according to the request for querying whether there are folder attributes with the same folder name, the method further includes:
if the log does not exist, the slave node sends feedback that the folder attribute does not exist to the master node, and the master node judges whether the timestamp of the log is the same as the timestamp of the inquired creation or deletion folder with the same folder name or not again according to the feedback that the folder attribute does not exist;
and if the log and the routing information are the same, the master node deletes the log and the routing information.
Further, in the above method, after the master node determines again whether the timestamp of the log is the same as the timestamp of the queried creation or deletion folder with the same folder name, the method further includes:
and if not, the master node deletes the log.
In another specific application scenario of the present application, there is further provided a device for maintaining metadata of a folder, where the metadata of the folder includes routing information and folder attributes of the folder, and the device includes:
the main node is used for acquiring a request for creating the routing information of the folder and inquiring whether the routing information of the folder exists in the main node or not, wherein the routing information of the folder comprises a globally unique folder name, position information of folder attributes and a time stamp for creating or deleting the folder; if the log does not exist, creating the routing information of the folder, and after a log is persisted, initiating a request for creating the attribute of the folder to a slave node according to the name of the folder and the position information of the folder, wherein the log comprises the name of the folder and a timestamp which are the same as the routing information of the folder;
and the slave node is used for creating the folder attribute according to the received request for creating the folder attribute, and if the folder attribute is failed to be created, returning the folder creation failure to the master node.
Preferably, in the above device, the slave node is further configured to, after creating the folder attribute according to the received request for creating the folder attribute, if the creation is successful, return a feedback that the creation of the folder is successful to the master node;
and the master node is further used for comparing the time stamp of the created or deleted folder in the routing information of the folder with the time stamp in the log with the same folder name according to the feedback of the successful creation of the folder, and deleting the log if the time stamps are the same.
Preferably, in the above device, the master node is further configured to, after querying whether the routing information of the folder exists in the master node, if so, the master node determines whether the location information of the folder attribute in the routing information of the folder is different from the location information of the folder attribute requested to be created, and if not, returns a folder creation failure to the slave node.
Preferably, in the above device, the routing information of the folder further includes a user,
the master node is further configured to determine whether location information of a folder attribute in the routing information of the folder is different from location information of a folder attribute requested to be created, and if the location information of the folder attribute is the same as the location information of the folder attribute requested to be created, determine whether the request for creating the folder attribute is initiated by the same user, if the request for creating the folder attribute is initiated by the same user, update the timestamp of creating or deleting the folder, and after a log is persisted at the same time, initiate a request for creating the folder attribute to a slave node according to the name of the folder and the location information of the folder;
the slave node is further configured to create the folder attribute according to the request for creating the folder attribute, and if the folder attribute is failed to be created, return a folder creation failure to the master node.
Preferably, in the above device, the slave node is further configured to, after creating the folder attribute according to the request for creating the folder attribute, if the creation is successful, return the folder creation success to the master node,
and the master node is also used for comparing the time stamp of the created or deleted folder with the time stamp in the log with the same folder name, and if the time stamps are the same, deleting the log.
Preferably, in the above device, the master node is further configured to, if the two logs are the same, delete the log and then scan a log that still exists after a preset time is exceeded; and deleting the residual routing information when the folder is created and deleted according to the scanned log.
Preferably, in the above device, the master node is further configured to query whether routing information having the same folder name as the scanned log exists, and if not, the master node deletes the log.
Preferably, in the above device, the master node is further configured to, after querying whether routing information having the same folder name as the scanned log exists, determine whether a timestamp of the log is the same as a timestamp of a created or deleted folder having the same folder name that is queried, and if not, delete the log.
Preferably, in the above device, the master node is further configured to, after determining whether the timestamp of the log is the same as the timestamp of the created or deleted folder with the same queried folder name, if so, initiate a request for querying whether a folder attribute with the same queried folder name exists to the corresponding slave node according to the location information of the folder attribute;
the slave node is also used for inquiring according to the request of inquiring whether the folder attributes with the same folder name exist, and if yes, sending the feedback of the existence of the folder attributes to the master node;
and the main node is also used for deleting the log according to the feedback of the existence of the folder attribute.
Preferably, in the above device, the slave node is further configured to send a feedback that the folder attribute does not exist to the master node if the request for inquiring whether the folder attribute with the same folder name exists is not sent;
the main node is further configured to judge again whether the timestamp of the log is the same as the timestamp of the queried created or deleted folder with the same folder name according to the feedback that the folder attribute does not exist; if the log and the routing information are the same, deleting the log and the routing information.
Preferably, in the above device, the master node is further configured to, after determining again whether the timestamp of the log is the same as the timestamp of the queried created or deleted folder with the same folder name, delete the log if the timestamp of the log is not the same as the timestamp of the queried created or deleted folder with the same folder name.
In another specific application scenario of the present application, there is further provided a device for maintaining metadata of a folder, where the metadata of the folder includes routing information and folder attributes of the folder, and the device includes:
the master node is used for acquiring a request for deleting the routing information of the folder, inquiring whether the routing information of the folder exists according to the request for deleting the routing information of the folder, wherein the routing information of the folder comprises a globally unique folder name, position information of folder attributes and a timestamp for creating or deleting the folder, if so, updating the timestamp for creating or deleting the folder, and after a log is persisted, initiating a request for deleting the folder attributes to the slave node;
and the slave node is used for deleting the folder attribute according to the received request for deleting the folder attribute, and if the deletion of the folder attribute fails, returning the deletion failure of the folder to the master node.
Preferably, in the above device, the slave node is further configured to, after deleting the folder attribute according to the received request for deleting the folder attribute, if the deletion is successful, return a folder deletion success to the master node, compare the time stamp of creating or deleting the folder with the time stamp in the log with the same folder name, and if the two time stamps are the same, delete the log.
Preferably, in the above device, the master node is further configured to, if the two logs are the same, delete the log and then scan a log that still exists after a preset time is exceeded; and deleting the residual routing information when the folder is created and deleted according to the scanned log.
Preferably, in the above device, the master node is further configured to delete, according to the scanned log, the routing information remaining when the folder is created and deleted, query whether routing information having the same folder name as the scanned log exists, and delete the log if the routing information does not exist.
Preferably, in the above device, the master node is further configured to, after querying whether routing information having the same folder name as the scanned log exists, if so, the master node determines whether a timestamp of the log is the same as a timestamp of the queried creation or deletion folder having the same folder name, and if not, deletes the log.
Preferably, in the above device, the master node is further configured to, after determining whether the timestamp of the log is the same as the timestamp of the created or deleted folder with the same queried folder name, if so, initiate a request for querying whether a folder attribute with the same queried folder name exists to the corresponding slave node according to the location information of the folder attribute;
the slave node is further configured to query whether a request for the folder attribute with the same folder name exists according to the query, and if yes, the slave node sends a feedback that the folder attribute exists to the master node;
and the main node is also used for deleting the log according to the feedback of the existence of the folder attribute.
Preferably, in the above device, the slave node is further configured to send a feedback that the folder attribute does not exist to the master node if the request for inquiring whether the folder attribute with the same folder name exists is not sent;
the main node is further configured to judge again whether the timestamp of the log is the same as the timestamp of the queried created or deleted folder with the same folder name according to the feedback that the folder attribute does not exist; if the log and the routing information are the same, deleting the log and the routing information.
Preferably, in the above device, the master node is further configured to, after determining again whether the timestamp of the log is the same as the timestamp of the queried created or deleted folder with the same folder name, delete the log if the timestamp of the log is not the same as the timestamp of the queried created or deleted folder with the same folder name.
In another specific application scenario of the present application, there is further provided a metadata storage apparatus for a folder, where the metadata of the folder includes routing information and folder attributes of the folder, and the apparatus includes:
the main node is used for storing the routing information of the folder, and the routing information of the folder comprises a globally unique folder name and position information of folder attributes; and the slave node is used for storing the folder attributes.
Preferably, in the above apparatus, the routing information of the folder further includes a timestamp for creating or deleting the folder.
Preferably, in the above apparatus, the master node further includes a log, and the log includes a folder name and a timestamp that are the same as the routing information of the folder.
In summary, the metadata of the resource is segmented into the master node and the slave node, the routing information of the resource is recorded and maintained at the master node, the global uniqueness of the resource naming is realized, the attribute of the resource is maintained at the slave node, and the high availability of the metadata of the resource is realized. In addition, when the resource is created or deleted, the time stamp (mtime) of the created or deleted resource of the main node is updated, a log is persisted, the log comprises the same resource name and the same time stamp as the routing information of the resource, and the residual routing information generated under the abnormal scene on the main node of the deleted residual can be checked according to the log.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions described above. Likewise, the software programs (including associated data structures) of the present application may be stored in a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the present application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or a solution according to the aforementioned embodiments of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.

Claims (69)

1. A method for maintaining metadata of a resource, wherein the metadata of the resource comprises routing information and resource attributes of the resource, the method comprising:
the method comprises the steps that routing information of resources is maintained in a main node, and the routing information of the resources comprises globally unique resource names, position information of resource attributes and timestamps for creating or deleting the resources;
maintaining the resource attribute at the slave node corresponding to the position information of the resource attribute;
when creating or deleting resources, the main node updates the time stamp of the created or deleted resources and persists an operation log corresponding to the same time stamp, wherein the operation log is used for checking residual routing information generated under an abnormal scene on the deleted residual main node.
2. The method of claim 1, wherein the maintaining of the routing information of the resource at the master node and the maintaining of the resource attribute at the slave node corresponding to the location information of the resource attribute comprise:
and according to the timestamp of the resource creation or deletion, deleting the routing information remained when the resource is created or deleted at the main node, and maintaining the resource attribute at the slave node corresponding to the position information of the resource attribute.
3. The method of claim 2, wherein according to the timestamp of creating or deleting the resource, route information remaining when the master node deletes the creating or deleting the resource, and the resource attribute is maintained at the slave node corresponding to the location information of the resource attribute, comprises:
when a resource is created or deleted, updating the timestamp of the created or deleted resource at a main node, and meanwhile persisting a log, wherein the log comprises a resource name and a timestamp which are the same as the routing information of the resource, and the resource attribute is maintained at a slave node corresponding to the position information of the resource attribute;
and according to the time stamp of the created or deleted resource and the log, deleting the routing information remained when the resource is created or deleted by the main node.
4. The method of claim 3, wherein when creating the resource, updating the timestamp of creating or deleting the resource at the master node, and persisting a log, and the resource attribute is maintained at the slave node corresponding to the location information of the resource attribute, comprising:
when the route information of the resource is requested to be created, the main node inquires whether the route information of the resource exists or not,
if the resource does not exist, creating the routing information of the resource in the main node, and meanwhile persisting a log, wherein the routing information of the resource comprises the name of the resource, the position information of the resource attribute and the timestamp of the created or deleted resource;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log.
5. The method of claim 4, wherein when requesting to create the routing information of the resource, after the master node querying whether the routing information of the resource exists, further comprising:
if the resource attribute exists, judging whether the position information of the resource attribute in the routing information of the resource is different from the position information of the resource attribute required to be created,
if not, returning the resource creation failure.
6. The method of claim 5, wherein the routing information of the resource further includes a user, and after determining whether the location information of the resource attribute in the routing information of the resource is different from the location information of the request for creating the resource attribute, the method further includes:
if the two requests are the same, judging whether the requests are initiated by the same user or not,
if so, updating the time stamp of the creation or deletion of the resource at the main node, and meanwhile persisting a log;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log.
7. The method of claim 3, wherein when deleting the resource, updating the timestamp of creating or deleting the resource at the master node, and persisting a log, and the resource attribute is maintained at the slave node corresponding to the location information of the resource attribute, comprising:
when requesting to delete the routing information of the resource, the main node inquires whether the routing information of the resource exists or not,
if the resource exists, the time stamp of the created or deleted resource in the routing information of the resource is updated at the main node, and a log is persisted at the same time;
deleting the resource attribute from the slave node according to the routing information of the resource, and if the deletion of the resource attribute fails, returning the failure of the deletion of the resource; if the deletion is successful, returning the resource deletion success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log.
8. The method of claim 3, wherein the routing information remaining when the master node deletes the create and delete resource based on the log and the timestamp of the create or delete resource comprises:
scanning logs which still exist after the preset time is exceeded;
and deleting the residual routing information when the resources are created and deleted according to the scanned log.
9. The method of claim 8, wherein deleting the routing information remaining from creating and deleting resources based on the scanned log comprises:
querying at the master node whether routing information having the same resource name as the scanned log exists,
if not, the log is deleted.
10. The method of claim 9, wherein after the master node queries whether routing information for the same resource name exists, further comprising:
if yes, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name,
if not, deleting the log.
11. The method of claim 10, wherein after determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource of the same resource name, further comprising:
if the resource attributes are the same, inquiring whether the resource attributes with the same resource name exist on the corresponding slave nodes,
if so, deleting the log.
12. The method of claim 11, wherein after querying the corresponding slave node whether the resource attribute of the same resource name exists, further comprising:
if not, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name or not again;
if the log and the routing information are the same, deleting the log and the routing information.
13. The method of claim 12, wherein after determining again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource of the same resource name, further comprising:
if not, deleting the log.
14. The method of any of claims 1 to 13, wherein maintaining the resource attributes at the slave node further comprises:
when the creation or deletion of the resource attribute of the slave node is successful, saving the time stamp of the creation or deletion of the resource in the resource attribute on the slave node;
when the slave node receives a request for the attribute of creation or deletion of the same resource again, whether the time stamp of the creation or deletion of the resource of the current request is larger than the time stamp in the resource attribute saved on the slave node is judged,
if so, processing the request at the slave node;
if not, the request is ignored at the slave node.
15. A method for maintaining metadata of a resource, wherein the metadata of the resource comprises routing information and resource attributes of the resource, the method comprising:
the method comprises the steps that a main node acquires a request for creating routing information of resources, and queries whether the routing information of the resources exists in the main node or not, wherein the routing information of the resources comprises globally unique resource names, position information of resource attributes and timestamps for creating or deleting the resources;
if the resource does not exist, the master node creates the routing information of the resource, and after a log is persisted, a request for creating the resource attribute is sent to the slave node according to the resource name and the position information of the resource, wherein the log comprises the resource name and the timestamp which are the same as the routing information of the resource and is used for checking and deleting the residual routing information generated under the abnormal scene on the residual master node;
and the slave node creates the resource attribute according to the received request for creating the resource attribute, and if the creation of the resource attribute fails, the slave node returns the failure of the creation of the resource to the master node.
16. The method of claim 15, wherein after the slave node creates the resource attribute in accordance with the received request to create the resource attribute, further comprising:
if the creation is successful, returning feedback of successful resource creation to the main node;
and the master node compares the time stamp of the created or deleted resource in the routing information of the resource with the time stamp in the log with the same resource name according to the feedback of the successful creation of the resource, and deletes the log if the time stamps are the same.
17. The method of claim 15, wherein the master node querying the routing information of the resource after the master node is present, further comprising:
if the resource attribute exists, the main node judges whether the position information of the resource attribute in the routing information of the resource is different from the position information of the resource attribute required to be created,
and if the two nodes are different, the master node returns a resource creating failure to the slave node.
18. The method of claim 17, wherein the routing information for the resource further comprises a user,
after the master node determines whether the location information of the resource attribute in the routing information of the resource is different from the location information of the request for creating the resource attribute, the method further includes:
if the resource attributes are the same, the main node judges whether the request for creating the resource attributes is initiated by the same user or not,
if so, the master node updates the timestamp of the created or deleted resource, and initiates a request for creating the resource attribute to the slave node according to the resource name and the position information of the resource after simultaneously persisting a log;
and the slave node creates the resource attribute according to the request for creating the resource attribute, and if the resource attribute is failed to be created, the slave node returns the resource creation failure to the master node.
19. The method of claim 18, wherein after the slave node creates the resource attribute in accordance with the request to create the resource attribute, further comprising:
if the creation is successful, after the resource creation is returned to the main node, the main node compares the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, the log is deleted.
20. The method of claim 19, wherein if the same, deleting the log comprises:
the main node scans logs which still exist after the preset time is exceeded;
and the main node deletes the residual routing information when the resources are created and deleted according to the scanned log.
21. The method of claim 20, wherein the master node deleting the routing information remaining from the creating and deleting resources according to the scanned log comprises:
the master node inquires whether routing information having the same resource name as the scanned log exists,
and if the log does not exist, the master node deletes the log.
22. The method of claim 21, wherein after the master node queries whether routing information having the same resource name as the scanned log exists, further comprising:
if so, the master node judges whether the timestamp of the log is the same as the timestamp of the inquired creation or deletion resource with the same resource name,
and if not, the master node deletes the log.
23. The method of claim 22, wherein after the master node determines whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource of the same resource name, the method further comprises:
if the resource attributes are the same, the master node initiates a request for inquiring whether the resource attributes with the same resource name exist to the corresponding slave node according to the position information of the resource attributes, the slave node inquires according to the request for inquiring whether the resource attributes with the same resource name exist,
and if the log exists, the slave node sends feedback of the existence of the resource attribute to the master node, and the master node deletes the log according to the feedback of the existence of the resource attribute.
24. The method of claim 23, wherein after the slave node performs the query according to the request for querying whether the resource attribute of the same resource name exists, the method further comprises:
if the resource name does not exist, the slave node sends feedback that the resource attribute does not exist to the master node, and the master node judges whether the timestamp of the log is the same as the timestamp of the inquired created or deleted resource with the same resource name again according to the feedback that the resource attribute does not exist;
and if the log and the routing information are the same, the master node deletes the log and the routing information.
25. The method of claim 24, wherein the master node, after determining again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource of the same resource name, further comprises:
and if not, the master node deletes the log.
26. A method for maintaining metadata of a resource, wherein the metadata of the resource comprises routing information and resource attributes of the resource, the method comprising:
the main node acquires a request for deleting the routing information of the resource, inquires whether the routing information of the resource exists according to the request for deleting the routing information of the resource, wherein the routing information of the resource comprises a globally unique resource name, position information of resource attributes and a time stamp for creating or deleting the resource,
if the route information exists, the main node updates the timestamp of the created or deleted resource, and simultaneously persists a log, then a request for deleting the resource attribute is sent to the slave node, and the operation log is used for checking the residual route information generated under the abnormal scene on the deleted main node;
and the slave node deletes the resource attribute according to the received request for deleting the resource attribute, and if the deletion of the resource attribute fails, the slave node returns the failure of deleting the resource to the master node.
27. The method of claim 26, wherein after the slave node deletes the resource attribute in accordance with the received request to delete the resource attribute, further comprising:
if the deletion is successful, returning the resource deletion success to the main node, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log.
28. The method of claim 27, wherein if the same, deleting the log comprises:
the main node scans logs which still exist after the preset time is exceeded;
and the main node deletes the residual routing information when the resources are created and deleted according to the scanned log.
29. The method of claim 28, wherein the master node deleting the routing information remaining from the creating and deleting resources based on the scanned log comprises:
the master node inquires whether routing information having the same resource name as the scanned log exists,
and if the log does not exist, the master node deletes the log.
30. The method of claim 29, wherein after the master node queries whether routing information having the same resource name as the scanned log exists, further comprising:
if so, the master node judges whether the timestamp of the log is the same as the timestamp of the inquired creation or deletion resource with the same resource name,
and if not, the master node deletes the log.
31. The method of claim 30, wherein after the master node determines whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource of the same resource name, the method further comprises:
if the resource attributes are the same, the master node initiates a request for inquiring whether the resource attributes with the same resource name exist to the corresponding slave node according to the position information of the resource attributes, the slave node inquires according to the request for inquiring whether the resource attributes with the same resource name exist,
and if the log exists, the slave node sends feedback of the existence of the resource attribute to the master node, and the master node deletes the log according to the feedback of the existence of the resource attribute.
32. The method of claim 31, wherein after the slave node performs the query according to the request for querying whether the resource attribute of the same resource name exists, the method further comprises:
if the resource name does not exist, the slave node sends feedback that the resource attribute does not exist to the master node, and the master node judges whether the timestamp of the log is the same as the timestamp of the inquired created or deleted resource with the same resource name again according to the feedback that the resource attribute does not exist;
and if the log and the routing information are the same, the master node deletes the log and the routing information.
33. The method of claim 32, wherein the master node, after determining again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource of the same resource name, further comprises:
and if not, the master node deletes the log.
34. A metadata maintenance device for a resource, wherein the metadata for the resource includes routing information and resource attributes for the resource, the device comprising:
the maintenance device is used for maintaining the routing information of the resources in the main node, wherein the routing information of the resources comprises globally unique resource names, position information of resource attributes and timestamps for creating or deleting the resources; maintaining the resource attribute at the slave node corresponding to the position information of the resource attribute; when creating or deleting resources, the main node updates the time stamp of the created or deleted resources and persists an operation log corresponding to the same time stamp, wherein the operation log is used for checking residual routing information generated under an abnormal scene on the deleted residual main node.
35. The apparatus of claim 34, wherein the maintaining device is configured to delete, according to the timestamp of creating or deleting the resource, routing information remaining when the master node deletes the creating or deleting the resource, and maintain the resource attribute at the slave node corresponding to the location information of the resource attribute.
36. The apparatus of claim 35, wherein the maintenance device comprises:
the creating and maintaining device is used for updating the time stamp of the creating or deleting resource at the main node when the resource is created, and meanwhile persisting a log, wherein the log comprises the resource name and the time stamp which are the same as the routing information of the resource, and the resource attribute is maintained at the slave node corresponding to the position information of the resource attribute;
the deleting maintenance device is used for updating the time stamp of the resource creation or deletion at the main node when the resource is deleted, and meanwhile persisting a log, wherein the log comprises a resource name and the time stamp which are the same as the routing information of the resource, and the resource attribute is maintained at the slave node corresponding to the position information of the resource attribute;
and the scanning device is used for deleting the residual routing information when the main node deletes the resources according to the time stamp of the resources and the log.
37. The apparatus of claim 36, wherein the creation maintenance means, when requesting to create the routing information of the resource, queries the master node whether the routing information of the resource exists,
if not, the routing information of the resource is established in the main node, and a log is persisted at the same time;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log.
38. The apparatus of claim 36, wherein the creation maintenance means is further configured to, when requesting to create the routing information of the resource, after the master node inquires whether the routing information of the resource exists,
if the resource attribute exists, judging whether the position information of the resource attribute in the routing information of the resource is different from the position information of the request for creating the resource attribute,
if not, returning the resource creation failure.
39. The apparatus according to claim 38, wherein the routing information of the resource further includes a user, the creation and maintenance device is further configured to, after determining whether the location information of the resource attribute in the routing information of the resource is different from the location information of the request for creating the resource attribute, if the location information of the resource attribute is the same, determine whether the request is initiated by the same user,
if so, updating the time stamp of the creation or deletion of the resource at the main node, and meanwhile persisting a log;
creating the resource attribute at a slave node according to the resource name and the position information of the resource, and if the creation of the resource attribute fails, returning the failure of the creation of the resource; if the creation is successful, returning the resource creation success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamp of the created or deleted resource is the same as the time stamp in the log with the same resource name, deleting the log.
40. The apparatus of claim 36, wherein the deletion maintenance means is configured to query the master node whether the routing information of the resource exists when requesting to delete the routing information of the resource,
if the resource exists, the time stamp of the creation or deletion of the resource is updated at the main node, and a log is persisted at the same time;
deleting the resource attribute from the slave node according to the routing information of the resource, and if the deletion of the resource attribute fails, returning the failure of the deletion of the resource; if the deletion is successful, returning the resource deletion success, comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log.
41. Apparatus according to claim 36, wherein the scanning means is for
Scanning logs which still exist after the preset time is exceeded;
and deleting the residual routing information when the resources are created and deleted according to the scanned log.
42. The apparatus of claim 41, wherein the scanning means is configured to query the master node whether routing information having the same resource name as the scanned log exists,
if not, the log is deleted.
43. The apparatus of claim 42, wherein the scanning means is further for, after the master node queries whether routing information for the same resource name exists,
if yes, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name,
if not, deleting the log.
44. The device of claim 43, wherein the scanning device is further configured to determine whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource of the same resource name,
if the resource attributes are the same, whether the resource attributes with the same resource name exist is inquired on the corresponding slave node, and if the resource attributes exist, the log is deleted.
45. The apparatus of claim 44, wherein the scanning means is further configured to, after querying the corresponding slave node whether the resource attribute of the same resource name exists,
if not, judging whether the time stamp of the log is the same as the time stamp of the inquired creation or deletion resource with the same resource name or not again;
if the log and the routing information are the same, deleting the log and the routing information.
46. The apparatus of claim 45, wherein the scanning device is further configured to determine again whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource of the same resource name,
if not, deleting the log.
47. The apparatus according to any of claims 34 to 46, wherein the maintaining means is further configured to save a timestamp of creating or deleting a resource on the slave node into the resource attribute after the creating or deleting of the resource attribute on the slave node is successful;
when the slave node receives a request for the attribute of creation or deletion of the same resource again, whether the time stamp of the creation or deletion of the resource of the current request is larger than the time stamp in the resource attribute saved on the slave node is judged,
if so, processing the request at the slave node;
if not, the request is ignored at the slave node.
48. A metadata maintenance device for a resource, wherein the metadata for the resource includes routing information and resource attributes for the resource, the device comprising:
the system comprises a main node, a resource management server and a resource management server, wherein the main node is used for acquiring a request for creating routing information of resources and inquiring whether the routing information of the resources exists in the main node or not, and the routing information of the resources comprises globally unique resource names, position information of resource attributes and timestamps for creating or deleting the resources; if the resource attribute does not exist, creating the routing information of the resource, and after a log is persisted, initiating a request for creating the resource attribute to a slave node according to the name of the resource and the position information of the resource, wherein the log comprises the name of the resource and a timestamp which are the same as the routing information of the resource and is used for checking and deleting the residual routing information generated under the abnormal scene on the residual master node;
and the slave node is used for creating the resource attribute according to the received request for creating the resource attribute, and returning the resource creation failure to the master node if the resource attribute is failed to be created.
49. The apparatus of claim 48, wherein the slave node is further configured to, after creating the resource attribute according to the received request for creating the resource attribute, if the creation is successful, return a feedback that the creation of the resource is successful to the master node;
and the master node is further configured to compare the timestamp of the created or deleted resource in the routing information of the resource with the timestamp in the log with the same resource name according to the feedback of the successful creation of the resource, and if the timestamps are the same, delete the log.
50. The apparatus of claim 49, wherein the master node is further configured to, after querying whether the routing information of the resource exists in the master node, if so, the master node determines whether the location information of the resource attribute in the routing information of the resource is different from the location information of the resource attribute requested to be created, and if not, returns a resource creation failure to the slave node.
51. The apparatus of claim 50, wherein the routing information for the resource further comprises a user,
the master node is further configured to determine whether location information of a resource attribute in the routing information of the resource is different from location information of a request for creating the resource attribute, and if the location information of the resource attribute is the same as the location information of the request for creating the resource attribute, determine whether the request for creating the resource attribute is initiated by the same user, if the request for creating the resource attribute is initiated by the same user, update the timestamp of creating or deleting the resource, and after a log is persisted at the same time, initiate a request for creating the resource attribute to a slave node according to the resource name and the location information of the resource;
the slave node is further configured to create the resource attribute according to the request for creating the resource attribute, and if the creation of the resource attribute fails, return a resource creation failure to the master node.
52. The device of claim 51, wherein said slave node is further configured to, after creating said resource attribute according to said request for creating a resource attribute, if the creation is successful, return a resource creation success to said master node,
and the master node is also used for comparing the time stamp of the created or deleted resource with the time stamp in the log with the same resource name, and if the time stamps are the same, deleting the log.
53. The device of claim 52, wherein the master node is further configured to scan logs that still exist after a preset time is exceeded after deleting the log if the logs are the same; and deleting the residual routing information when the resources are created and deleted according to the scanned log.
54. The apparatus of claim 53, wherein the master node is further configured to query whether routing information having the same resource name as the scanned log exists, and if not, delete the log.
55. The device of claim 54, wherein the master node is further configured to, after querying whether routing information having the same resource name as the scanned log exists, determine whether a timestamp of the log is the same as a timestamp of the queried created or deleted resource having the same resource name, and if not, delete the log.
56. The device of claim 55, wherein the master node is further configured to, after determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name, if so, initiate a request to the corresponding slave node according to the location information of the resource attribute to query whether the resource attribute with the same resource name exists;
the slave node is further configured to query according to whether the request for querying the resource attribute with the same resource name exists, and if the request for querying the resource attribute with the same resource name exists, send a feedback that the resource attribute exists to the master node;
and the main node is also used for deleting the log according to the feedback existing in the resource attribute.
57. The device of claim 56, wherein the slave node is further configured to send a feedback that the resource attribute does not exist to the master node if the request for querying whether the resource attribute with the same resource name exists is not sent;
the master node is further configured to judge again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name according to the feedback that the resource attribute does not exist; if the log and the routing information are the same, deleting the log and the routing information.
58. The device of claim 57, wherein the master node is further configured to delete the log if the timestamp of the log is not the same as the timestamp of the queried created or deleted resource with the same resource name after determining again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name.
59. A metadata maintenance device for a resource, wherein the metadata for the resource includes routing information and resource attributes for the resource, the device comprising:
the master node is used for acquiring a request for deleting the routing information of the resource, inquiring whether the routing information of the resource exists according to the request for deleting the routing information of the resource, wherein the routing information of the resource comprises a globally unique resource name, position information of a resource attribute and a time stamp for creating or deleting the resource, if so, updating the time stamp for creating or deleting the resource, and meanwhile, after a log is persisted, initiating a request for deleting the resource attribute to the slave node, and the operation log is used for checking and deleting residual routing information generated under an abnormal scene on the residual master node;
and the slave node is used for deleting the resource attribute according to the received request for deleting the resource attribute, and if the resource attribute is failed to be deleted, returning the resource deletion failure to the master node.
60. The device of claim 59, wherein the slave node is further configured to, after deleting the resource attribute according to the received request for deleting the resource attribute, if the deletion is successful, return a resource deletion success to the master node, compare the timestamp of creating or deleting the resource with the timestamp in the log with the same resource name, and if the timestamps are the same, delete the log.
61. The device of claim 60, wherein the master node is further configured to scan logs that still exist after a preset time is exceeded after deleting the log if the log is the same as the log; and deleting the residual routing information when the resources are created and deleted according to the scanned log.
62. The device of claim 61, wherein the master node is further configured to delete the route information remaining when the resource is created and deleted according to the scanned log, query whether the route information having the same resource name as the scanned log exists, and delete the log if the route information does not exist.
63. The apparatus of claim 62, wherein the master node is further configured to, after querying whether routing information having the same resource name as the scanned log exists, if so, the master node determines whether a timestamp of the log is the same as a timestamp of the queried created or deleted resource having the same resource name, and if not, deletes the log.
64. The device of claim 63, wherein the master node is further configured to, after determining whether the timestamp of the log is the same as the timestamp of the queried creation or deletion resource with the same resource name, if so, initiate a request to the corresponding slave node according to the location information of the resource attribute to query whether the resource attribute with the same resource name exists;
the slave node is further configured to query according to whether the request for querying the resource attribute with the same resource name exists, and if the request exists, the slave node sends a feedback that the resource attribute exists to the master node;
and the main node is also used for deleting the log according to the feedback existing in the resource attribute.
65. The device of claim 64, wherein the slave node is further configured to send a feedback that the resource attribute does not exist to the master node if the request for querying whether the resource attribute with the same resource name exists is not sent;
the master node is further configured to judge again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name according to the feedback that the resource attribute does not exist; if the log and the routing information are the same, deleting the log and the routing information.
66. The device of claim 65, wherein the master node is further configured to delete the log if the timestamp of the log is not the same as the timestamp of the queried created or deleted resource with the same resource name after determining again whether the timestamp of the log is the same as the timestamp of the queried created or deleted resource with the same resource name.
67. A metadata storage of a resource, the metadata of the resource comprising routing information and resource attributes of the resource, wherein the apparatus comprises:
the master node is used for storing the routing information of the resources, the routing information of the resources comprises globally unique resource names, position information of resource attributes and timestamps of creating or deleting the resources, when the resources are created or deleted, the master node updates the timestamps of creating or deleting the resources and persists an operation log corresponding to the same timestamp, and the operation log is used for checking and deleting residual routing information generated under abnormal scenes on the residual master node; a slave node for storing the resource attributes.
68. The storage device of claim 67, wherein the routing information for the resource further comprises a timestamp for creating or deleting the resource.
69. The storage device of claim 68, wherein the master node further comprises a log comprising a same resource name and timestamp as the routing information for the resource.
CN201610642192.5A 2016-08-08 2016-08-08 Resource metadata maintenance method, equipment and storage device Active CN107704462B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610642192.5A CN107704462B (en) 2016-08-08 2016-08-08 Resource metadata maintenance method, equipment and storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610642192.5A CN107704462B (en) 2016-08-08 2016-08-08 Resource metadata maintenance method, equipment and storage device

Publications (2)

Publication Number Publication Date
CN107704462A CN107704462A (en) 2018-02-16
CN107704462B true CN107704462B (en) 2021-07-06

Family

ID=61169170

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610642192.5A Active CN107704462B (en) 2016-08-08 2016-08-08 Resource metadata maintenance method, equipment and storage device

Country Status (1)

Country Link
CN (1) CN107704462B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111400255B (en) * 2019-09-26 2023-04-28 杭州海康威视系统技术有限公司 Data cleaning method, device and equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101187930A (en) * 2007-12-04 2008-05-28 浙江大学 Distribution type file system dummy directory and name space implementing method
CN102929789A (en) * 2012-09-21 2013-02-13 曙光信息产业(北京)有限公司 Record organizational method and record organizational structure
CN102937964A (en) * 2012-09-28 2013-02-20 无锡江南计算技术研究所 Intelligent data service method based on distributed system
CN103246716A (en) * 2013-04-26 2013-08-14 中国传媒大学 Object copy efficient management method based on object cluster file system and object copy efficient management system based on object cluster file system
CN103310000A (en) * 2013-06-25 2013-09-18 曙光信息产业(北京)有限公司 Metadata management method
CN103577123A (en) * 2013-11-12 2014-02-12 河海大学 Small file optimization storage method based on HDFS

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7730012B2 (en) * 2004-06-25 2010-06-01 Apple Inc. Methods and systems for managing data
CN100337218C (en) * 2005-02-23 2007-09-12 北京邦诺存储科技有限公司 Data managing method for network storage system and network storage system constituted thereby
CN102546749B (en) * 2010-12-08 2015-07-29 中国电信股份有限公司 For accessing method and the IP bearer network of mobile IP network
US9842128B2 (en) * 2013-08-01 2017-12-12 Sandisk Technologies Llc Systems and methods for atomic storage operations
US9986029B2 (en) * 2014-03-19 2018-05-29 Red Hat, Inc. File replication using file content location identifiers
CN103986655A (en) * 2014-05-20 2014-08-13 东南大学 Network routing service construction method
CN104281506B (en) * 2014-07-10 2017-02-15 中国科学院计算技术研究所 Data maintenance method and system for file system
CN105718217B (en) * 2016-01-18 2018-10-30 浪潮(北京)电子信息产业有限公司 A kind of method and device of simplify configuration storage pool data sign processing

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101187930A (en) * 2007-12-04 2008-05-28 浙江大学 Distribution type file system dummy directory and name space implementing method
CN102929789A (en) * 2012-09-21 2013-02-13 曙光信息产业(北京)有限公司 Record organizational method and record organizational structure
CN102937964A (en) * 2012-09-28 2013-02-20 无锡江南计算技术研究所 Intelligent data service method based on distributed system
CN103246716A (en) * 2013-04-26 2013-08-14 中国传媒大学 Object copy efficient management method based on object cluster file system and object copy efficient management system based on object cluster file system
CN103310000A (en) * 2013-06-25 2013-09-18 曙光信息产业(北京)有限公司 Metadata management method
CN103577123A (en) * 2013-11-12 2014-02-12 河海大学 Small file optimization storage method based on HDFS

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
【Hadoop】HDFS笔记(二):HDFS的HA机制和Federation机制;DianaCody;《https://blog.csdn.net/DianaCody/article/details/39480971?utm_source=blogxgwz7&utm_medium=distribute.pc_relevant.none-task-blog-title-2&spm=1001.2101.3001.4242》;20140922;全文 *
分布式文件系统元数据服务器高可用性设计;战科宇 等;《小型微型计算机系统》;20130415(第2013年04期);第801-805页 *
大数据场景下的云存储技术与应用;陈杰;《中兴通讯技术》;20121210(第2012年第6期);第47-51页 *

Also Published As

Publication number Publication date
CN107704462A (en) 2018-02-16

Similar Documents

Publication Publication Date Title
CN108093094B (en) Database instance access method, device, system, storage medium and equipment
US8069224B2 (en) Method, equipment and system for resource acquisition
WO2017167171A1 (en) Data operation method, server, and storage system
US20130073691A1 (en) File Processing Method, System and Server-clustered System for Cloud Storage
US20160364407A1 (en) Method and Device for Responding to Request, and Distributed File System
US10831612B2 (en) Primary node-standby node data transmission method, control node, and database system
CN107562757B (en) Query and access method, device and system based on distributed file system
EP3862883B1 (en) Data backup method and apparatus, and system
CN107153644B (en) Data synchronization method and device
CN108614837B (en) File storage and retrieval method and device
US20170060941A1 (en) Systems and Methods for Searching Heterogeneous Indexes of Metadata and Tags in File Systems
US20070143286A1 (en) File management method in file system and metadata server therefor
EP2710477B1 (en) Distributed caching and cache analysis
CN109600410B (en) Data storage system and method
CN106933550B (en) Global information obtaining, processing and updating method, device and system
US10069941B2 (en) Scalable event-based notifications
CN102708165A (en) Method and device for processing files in distributed file system
US20220318095A1 (en) Using a storage log to generate an incremental backup
GB2520361A (en) Method and system for a safe archiving of data
CN111327651A (en) Resource downloading method, device, edge node and storage medium
EP3786802A1 (en) Method and device for failover in hbase system
WO2015192213A1 (en) System and method for retrieving data
CN111240892A (en) Data backup method and device
CN111324665A (en) Log playback method and device
US20160012070A1 (en) Methods for managing a request to list previous versions of an object and devices thereof

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