Database code for Swift
Bases: swift.common.db.DatabaseBroker
Encapsulates working with a account database.
Check if the accont DB can be deleted.
Returns: | True if the account can be deleted, False otherwise |
---|
Create account_stat table which is specific to the account DB.
Parameters: |
|
---|
Create container table which is specific to the account DB.
Parameter: | conn – DB connection object |
---|
Check if the account DB is empty.
Returns: | True if the database has no active containers. |
---|
Get the put_timestamp of a container.
Parameter: | container_name – container name |
---|---|
Returns: | put_timestamp of the container |
Get global data for the account.
Returns: | a tuple of (account, created_at, put_timestamp, delete_timestamp, container_count, object_count, bytes_used, hash, id) |
---|
Get random containers from the DB. This is used by the account_auditor when testing random containerss for existence.
Parameter: | max_count – maximum number of containers to get |
---|---|
Returns: | list of container names |
Check if the account DB is considered to be deleted.
Returns: | True if the account DB is considered to be deleted, False otherwise |
---|
Get a list of containerss 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: |
|
---|
Delete rows from the container table that are marked deleted and whose created_at timestamp is < object_timestamp. Also deletes rows from incoming_sync and outgoing_sync where the updated_at timestamp is < sync_timestamp.
Parameters: |
|
---|
Update the put_timestamp. Only modifies it if it is greater than the current timestamp.
Parameter: | timestamp – put timestamp |
---|
Bases: swift.common.db.DatabaseBroker
Encapsulates working with a container database.
Create the container_stat table which is specifc to the container DB.
Parameters: |
|
---|
Create the object table which is specifc to the container DB.
Parameter: | conn – DB connection object |
---|
Mark an object deleted.
Parameters: |
|
---|
Check if the DB is empty.
Returns: | True if the database has no active objects, False otherwise |
---|
Get global data for the container.
Returns: | a tuple of (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) |
---|
Get random objects from the DB. This is used by the container_auditor when testing random objects for existence.
Parameter: | max_count – maximum number of objects to get |
---|---|
Returns: | list of object names |
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: |
|
---|
Delete rows from the object table that are marked deleted and whose created_at timestamp is < object_timestamp. Also deletes rows from incoming_sync and outgoing_sync where the updated_at timestamp is < sync_timestamp.
Parameters: |
|
---|
Update reported stats.
Parameters: |
|
---|
Update the put_timestamp. Only modifies it if it is greater than the current timestamp.
Parameter: | timestamp – put timestamp |
---|
Bases: object
Encapsulates working with a database.
Mark the DB as deleted
Parameter: | timestamp – delete timestamp |
---|
Get a list of objects in the database between start and end.
Parameters: |
|
---|---|
Returns: | list of objects between start and end |
Get information about the DB required for replication.
Returns: | tuple of (hash, id, created_at, put_timestamp, delete_timestamp) from the DB |
---|
Gets the most recent sync point for a server from the sync table.
Parameters: |
|
---|---|
Returns: | the sync point, or -1 if the id doesn’t exist. |
Get a serialized copy of the sync table.
Parameter: | incoming – if True, get the last incoming sync, otherwise get the last outgoing sync |
---|---|
Returns: | list of {‘remote_id’, ‘sync_point’} |
Create the DB
Parameter: | put_timestamp – timestamp of initial PUT request |
---|
Merge a list of sync points with the incoming sync table.
Parameters: |
|
---|
Used in replication to handle updating timestamps.
Parameters: |
|
---|
Re-id the database. This should be called after an rsync.
Parameter: | remote_id – the ID of the remote database being rsynced in |
---|
Bases: sqlite3.DatabaseError
More friendly error messages for DB Errors.
Bases: sqlite3.Connection
SQLite DB Connection handler that plays well with eventlet.
Each entry in the account and container databases is XORed by the 128-bit hash on insert or delete. This serves as a rolling, order-independent hash of the contents. (check + XOR)
Parameters: |
|
---|---|
Returns: | a hex representation of the new hash value |
Returns a properly configured SQLite database connection.
Parameters: |
|
---|---|
Returns: | DB connection object |
Bases: swift.common.bufferedhttp.BufferedHTTPConnection
Helper to simplify POSTing to a remote server.
Make an HTTP POST request
Parameter: | args – list of json-encodable objects |
---|---|
Returns: | httplib response object |
Bases: object
Implements the logic for directing db replication.
Generator to walk the data dirs in a round robin manner, evenly hitting each device on the system.
Parameter: | datadirs – a list of paths to walk |
---|
Bases: object
Handle Replication RPC calls. TODO: redbo document please :)
In the case that a corrupt file is found, move it to a quarantined area to allow replication to fix it.
Parameters: |
|
---|