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 – internalized 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 from get_info plus 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
The storage_policy_index is passed through to the subclass’s _initialize method. It is ignored by AccountBroker.
Parameters: |
|
---|
Check if the DB is considered to be deleted.
Returns: | True if the DB is considered to be deleted, False otherwise |
---|
Use with the “with” statement; locks a database.
Turn this db record dict into the format this service uses for pending pickles.
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 – internalized put timestamp |
---|
Update the status_changed_at field in the stat table. Only modifies status_changed_at if the timestamp is greater than the current status_changed_at timestamp.
Parameters: | timestamp – internalized timestamp |
---|
Validates that metadata_falls within acceptable limits.
Parameters: | metadata – to be validated |
---|---|
Raises : | HTTPBadRequest if MAX_META_COUNT or MAX_META_OVERALL_SIZE is exceeded |
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 size of .pending file in bytes. When this is exceeded, the pending
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) |