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.
Parameters: |
|
---|
Check if the account DB is empty.
Returns: | True if the database has no active containers. |
---|
Get the put_timestamp of a container.
Parameters: |
|
---|---|
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.
Parameters: |
|
---|---|
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 |
---|
Only returns true if the status field is set to DELETED.
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.
Parameters: |
|
---|
Timeout for trying to connect to a DB
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.
Parameters: |
|
---|
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.
Parameters: |
|
---|---|
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.
Parameters: |
|
---|
Bases: object
Encapsulates working with a database.
Mark the DB as deleted
Parameters: |
|
---|
Use with the “with” statement; returns a database connection.
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.
Parameters: |
|
---|---|
Returns: | list of {‘remote_id’, ‘sync_point’} |
Create the DB
Parameters: |
|
---|
Use with the “with” statement; locks a database.
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.
Parameters: |
|
---|
Bases: sqlite3.DatabaseError
More friendly error messages for DB Errors.
Bases: sqlite3.Connection
SQLite DB Connection handler that plays well with eventlet.
Max number of pending entries
Pickle protocol to use
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 |
This should only be used when you need a real dict, i.e. when you’re going to serialize the results.
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
Parameters: |
|
---|---|
Returns: | httplib response object |
Bases: object
Implements the logic for directing db replication.
Replicate dbs under the given root in an infinite loop.
Run a replication pass once.
Generator to walk the data dirs in a round robin manner, evenly hitting each device on the system.
Parameters: |
|
---|
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: |
|
---|