Pluggable Back-end for Account Server
Encapsulates working with an account database.
Create account_stat table which is specific to the account DB. Not a part of Pluggable Back-ends, internal to the baseline code.
Parameters: |
|
---|
Create container table which is specific to the account DB.
Parameters: | conn – DB connection object |
---|
Check if the account DB is empty.
Returns: | True if the database has no active containers. |
---|
Get global data for the account.
Returns: | dict with keys: account, created_at, put_timestamp, delete_timestamp, container_count, object_count, bytes_used, hash, id |
---|
Check if the account DB is considered to be deleted.
Returns: | True if the account DB is considered to be deleted, False otherwise |
---|
Only returns true if the status field is set to DELETED.
Get a list of containers sorted by name starting at marker onward, up to limit entries. Entries will begin with the prefix and will not have the delimiter after the prefix.
Parameters: |
|
---|---|
Returns: | list of tuples of (name, object_count, bytes_used, 0) |
Merge items into the container table.
Parameters: |
|
---|
Create a container with the given attributes.
Parameters: |
|
---|
Pluggable Back-ends for Container Server
Encapsulates working with a container database.
Create the container_stat table which is specific to the container DB. Not a part of Pluggable Back-ends, internal to the baseline code.
Parameters: |
|
---|
Create the object table which is specifc to the container DB. Not a part of Pluggable Back-ends, internal to the baseline code.
Parameters: | conn – DB connection object |
---|
Mark an object deleted.
Parameters: |
|
---|
Check if container DB is empty.
Returns: | True if the database has no active objects, False otherwise |
---|
Get global data for the container.
Returns: | dict with keys: account, container, created_at, put_timestamp, delete_timestamp, object_count, bytes_used, reported_put_timestamp, reported_delete_timestamp, reported_object_count, reported_bytes_used, hash, id, x_container_sync_point1, and x_container_sync_point2. |
---|
Check if the DB is considered to be deleted.
Returns: | True if the DB is considered to be deleted, False otherwise |
---|
Get a list of objects sorted by name starting at marker onward, up to limit entries. Entries will begin with the prefix and will not have the delimiter after the prefix.
Parameters: |
|
---|---|
Returns: | list of tuples of (name, created_at, size, content_type, etag) |
Merge items into the object table.
Parameters: |
|
---|
Creates an object in the DB with its metadata.
Parameters: |
|
---|
Update reported stats, available with container’s get_info.
Parameters: |
|
---|
Disk File Interface for Swift Object Server
Manage object files on disk.
Parameters: |
|
---|
Returns an iterator over the data file for range (start, stop)
Returns an iterator over the data file for a set of ranges
Close the file. Will handle quarantining file if necessary.
Parameters: | verify_file – Defaults to True. If false, will not check file to see if it needs quarantining. |
---|
Context manager to create a file. We create a temporary file first, and then return a DiskWriter object to encapsulate the state.
Parameters: | size – optional initial size of file to explicitly allocate on disk |
---|---|
Raises DiskFileNoSpace: | |
if a size is specified and allocation fails |
Simple short hand for marking an object as deleted. Provides a layer of abstraction.
Parameters: | timestamp – time stamp to mark the object deleted at |
---|
Returns the os.path.getsize for the file. Raises an exception if this file does not match the Content-Length stored in the metadata. Or if self.data_file does not exist.
Returns: | file size as an int |
---|---|
Raises: |
|
Provide the metadata for an object as a dictionary.
Returns: | object’s metadata dictionary |
---|
Check if the file is deleted.
Returns: | True if the file doesn’t exist or has been flagged as deleted. |
---|
Check if the file is expired.
Returns: | True if the file has an X-Delete-At in the past |
---|
Open the file and read the metadata.
This method must populate the _metadata attribute.
Parameters: | verify_close – force implicit close to verify_file, no effect on explicit close. |
---|---|
Raises DiskFileCollision: | |
on md5 collision |
Short hand for putting metadata to .meta and .ts files.
Parameters: |
|
---|
In the case that a file is corrupted, move it to a quarantined area to allow replication to fix it.
Returns: | if quarantine is successful, path to quarantined directory otherwise None |
---|
Encapsulation of the write context for servicing PUT REST API requests. Serves as the context manager object for DiskFile’s create() method.
Finalize writing the file on disk, and renames it from the temp file to the real location. This should be called after the data has been written to the temp file.
Parameters: |
|
---|
Write a chunk of data into the temporary file.
Parameters: | chunk – the chunk of data to write as a string object |
---|
Get a list of hashes for the suffix dir. do_listdir causes it to mistrust the hash cache for suffix existence at the (unexpectedly high) cost of a listdir. reclaim_age is just passed on to hash_suffix.
Parameters: |
|
---|---|
Returns: | tuple of (number of suffix dirs hashed, dictionary of hashes) |
List contents of a hash directory and clean up any old files.
Parameters: |
|
---|---|
Returns: | list of files remaining in the directory, reverse sorted |
Performs reclamation and returns an md5 of all (remaining) files.
Parameters: | reclaim_age – age in seconds at which to remove tombstones |
---|---|
Raises: |
|
Invalidates the hash for a suffix_dir in the partition’s hashes file.
Parameters: | suffix_dir – absolute path to suffix dir whose hash needs invalidating |
---|
In the case that a file is corrupted, move it to a quarantined area to allow replication to fix it.
Params device_path: | |
---|---|
The path to the device the corrupted file is on. | |
Params corrupted_file_path: | |
The path to the file you want quarantined. | |
Returns: | path (str) of directory the file was moved to |
Raises OSError: | re-raises non errno.EEXIST / errno.ENOTEMPTY exceptions from rename |
Helper function to read the pickled metadata from an object file.
Parameters: | fd – file descriptor to load the metadata from |
---|---|
Returns: | dictionary of metadata |
Helper function to write pickled metadata for an object file.
Parameters: |
|
---|