Database code for Swift
Timeout for trying to connect to a DB
Whether calls will be made to preallocate disk space for database files.
Bases: sqlite3.DatabaseError
More friendly error messages for DB Errors.
Bases: object
Encapsulates working with a database.
Mark the DB as deleted
Parameters: | timestamp – delete timestamp |
---|
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: | dict containing keys: hash, id, created_at, put_timestamp, delete_timestamp, count, max_row, and metadata |
---|
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: | incoming – if True, get the last incoming sync, otherwise get the last outgoing sync |
---|---|
Returns: | list of {‘remote_id’, ‘sync_point’} |
Create the DB
Parameters: | put_timestamp – timestamp of initial PUT request |
---|
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: |
|
---|
Returns the metadata dict for the database. The metadata dict values are tuples of (value, timestamp) where the timestamp indicates when that key was set to that value.
Re-id the database. This should be called after an rsync.
Parameters: | remote_id – the ID of the remote database being rsynced in |
---|
Checks the exception info to see if it indicates a quarantine situation (malformed or corrupted database). If not, the original exception will be reraised. If so, the database will be quarantined and a new sqlite3.DatabaseError will be raised indicating the action taken.
Delete rows from the db_contains_type table that are marked deleted and whose created_at timestamp is < age_timestamp. Also deletes rows from incoming_sync and outgoing_sync where the updated_at timestamp is < sync_timestamp.
In addition, this calls the DatabaseBroker’s _reclaim() method.
Parameters: |
|
---|
Updates the metadata dict for the database. The metadata dict values are tuples of (value, timestamp) where the timestamp indicates when that key was set to that value. Key/values will only be overwritten if the timestamp is newer. To delete a key, set its value to (‘’, timestamp). These empty keys will eventually be removed by reclaim()
Update the put_timestamp. Only modifies it if it is greater than the current timestamp.
Parameters: | timestamp – put timestamp |
---|
Bases: sqlite3.DatabaseError
More friendly error messages for DB Errors.
Bases: sqlite3.Connection
SQLite DB Connection handler that plays well with eventlet.
Bases: sqlite3.Cursor
SQLite Cursor 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 REPLICATEing to a remote server.
Make an HTTP REPLICATE request
Parameters: | args – list of json-encodable objects |
---|---|
Returns: | bufferedhttp response object |
Bases: swift.common.daemon.Daemon
Implements the logic for directing db replication.
Extract the device name from an object path. Returns “UNKNOWN” if the path could not be extracted successfully for some reason.
Parameters: | object_file – the path to a database file. |
---|
Replicate dbs under the given root in an infinite loop.
Run a replication pass once.
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: |
|
---|
Generator to walk the data dirs in a round robin manner, evenly hitting each device on the system, and yielding any .db files found (in their proper places). The partitions within each data dir are walked randomly, however.
Parameters: | datadirs – a list of (path, node_id) to walk |
---|---|
Returns: | A generator of (partition, path_to_db_file, node_id) |