MediaWiki  REL1_19
SwiftFileBackend Class Reference

Class for an OpenStack Swift based file backend. More...

Inheritance diagram for SwiftFileBackend:
Collaboration diagram for SwiftFileBackend:

List of all members.

Public Member Functions

 __construct (array $config)
 doGetFileSha1base36 (array $params)
 getFileContents (array $params)
 getFileListInternal ($fullCont, $dir, array $params)
 getFileListPageInternal ($fullCont, $dir, $after, $limit)
 Do not call this function outside of SwiftFileBackendFileList.
 getLocalCopy (array $params)
 isPathUsableInternal ($storagePath)

Protected Member Functions

 addMissingMetadata (CF_Object $obj, $path)
 Fill in any missing object metadata and save it to Swift.
 createContainer ($container)
 Create a Swift container.
 deleteContainer ($container)
 Delete a Swift container.
 doCleanInternal ($fullCont, $dir, array $params)
 doClearCache (array $paths=null)
 doCopyInternal (array $params)
 doCreateInternal (array $params)
 doDeleteInternal (array $params)
 doGetFileStat (array $params)
 doPrepareInternal ($fullCont, $dir, array $params)
 doSecureInternal ($fullCont, $dir, array $params)
 doStoreInternal (array $params)
 doStreamFile (array $params)
 getConnection ()
 Get a connection to the Swift proxy.
 getContainer ($container, $reCache=false)
 Get a Swift container object, possibly from process cache.
 headersFromParams (array $params)
 Get headers to send to Swift when reading a file based on a FileBackend params array, e.g.
 logException (Exception $e, $func, array $params)
 Log an unexpected exception for this backend.
 resolveContainerPath ($container, $relStoragePath)
 setContainerAccess (CF_Container $contObj, array $readGrps, array $writeGrps)
 Set read/write permissions for a Swift container.

Protected Attributes

 $auth
 $authTTL
 $conn
 $connContainers = array()
 $connStarted = 0
 $maxContCacheSize = 100
 $swiftAnonUser

Detailed Description

Class for an OpenStack Swift based file backend.

This requires the SwiftCloudFiles MediaWiki extension, which includes the php-cloudfiles library (https://github.com/rackspace/php-cloudfiles). php-cloudfiles requires the curl, fileinfo, and mb_string PHP extensions.

Status messages should avoid mentioning the Swift account name. Likewise, error suppression should be used to avoid path disclosure.

Since:
1.19

Definition at line 22 of file SwiftFileBackend.php.


Constructor & Destructor Documentation

SwiftFileBackend::__construct ( array $  config)
See also:
FileBackendStore::__construct() Additional $config params include: swiftAuthUrl : Swift authentication server URL swiftUser : Swift user used by MediaWiki (account:username) swiftKey : Swift authentication key for the above user swiftAuthTTL : Swift authentication TTL (seconds) swiftAnonUser : Swift user used for end-user requests (account:username) shardViaHashLevels : Map of container names to sharding config with: 'base' : base of hash characters, 16 or 36 'levels' : the number of hash levels (and digits) 'repeat' : hash subdirectories are prefixed with all the parent hash directory names (e.g. "a/ab/abc")

Reimplemented from FileBackend.

Definition at line 48 of file SwiftFileBackend.php.


Member Function Documentation

SwiftFileBackend::addMissingMetadata ( CF_Object $  obj,
path 
) [protected]

Fill in any missing object metadata and save it to Swift.

Parameters:
$objCF_Object
$pathstring Storage path to object
Returns:
bool Success
Exceptions:
Exceptioncloudfiles exceptions

Definition at line 479 of file SwiftFileBackend.php.

References $path, getLocalCopy(), FileBackend\getScopedFileLocks(), LockManager\LOCK_UW, and Status\newGood().

Referenced by doGetFileStat().

Here is the call graph for this function:

Here is the caller graph for this function:

SwiftFileBackend::createContainer ( container) [protected]

Create a Swift container.

Parameters:
$containerstring Container name
Returns:
CF_Container

Definition at line 766 of file SwiftFileBackend.php.

References $conn, and getConnection().

Referenced by doPrepareInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

SwiftFileBackend::deleteContainer ( container) [protected]

Delete a Swift container.

Parameters:
$containerstring Container name
Returns:
void

Definition at line 779 of file SwiftFileBackend.php.

References $conn, and getConnection().

Referenced by doCleanInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

SwiftFileBackend::doCleanInternal ( fullCont,
dir,
array $  params 
) [protected]
See also:
FileBackendStore::doCleanInternal()

Reimplemented from FileBackendStore.

Definition at line 398 of file SwiftFileBackend.php.

References $dir, deleteContainer(), getContainer(), logException(), and Status\newGood().

Here is the call graph for this function:

SwiftFileBackend::doClearCache ( array $  paths = null) [protected]
See also:
FileBackendStore::doClearCache()

Reimplemented from FileBackendStore.

Definition at line 730 of file SwiftFileBackend.php.

SwiftFileBackend::doCopyInternal ( array $  params) [protected]
See also:
FileBackendStore::doCopyInternal()

Reimplemented from FileBackendStore.

Definition at line 233 of file SwiftFileBackend.php.

References FileBackendStore\fileExists(), getContainer(), logException(), Status\newGood(), and FileBackendStore\resolveStoragePathReal().

Here is the call graph for this function:

SwiftFileBackend::doDeleteInternal ( array $  params) [protected]
See also:
FileBackendStore::doDeleteInternal()

Reimplemented from FileBackendStore.

Definition at line 288 of file SwiftFileBackend.php.

References getContainer(), logException(), Status\newGood(), and FileBackendStore\resolveStoragePathReal().

Here is the call graph for this function:

See also:
FileBackendStore::doGetFileSha1base36()

Definition at line 563 of file SwiftFileBackend.php.

References FileBackendStore\getFileStat().

Here is the call graph for this function:

SwiftFileBackend::doGetFileStat ( array $  params) [protected]
See also:
FileBackendStore::doFileExists()

Reimplemented from FileBackendStore.

Definition at line 442 of file SwiftFileBackend.php.

References addMissingMetadata(), getContainer(), headersFromParams(), logException(), FileBackendStore\resolveStoragePathReal(), and wfTimestamp().

Here is the call graph for this function:

SwiftFileBackend::doPrepareInternal ( fullCont,
dir,
array $  params 
) [protected]
See also:
FileBackendStore::doPrepareInternal()

Reimplemented from FileBackendStore.

Definition at line 319 of file SwiftFileBackend.php.

References createContainer(), getContainer(), logException(), Status\newGood(), and setContainerAccess().

Here is the call graph for this function:

SwiftFileBackend::doSecureInternal ( fullCont,
dir,
array $  params 
) [protected]
See also:
FileBackendStore::doSecureInternal()

Reimplemented from FileBackendStore.

Definition at line 364 of file SwiftFileBackend.php.

References getContainer(), logException(), Status\newGood(), and setContainerAccess().

Here is the call graph for this function:

SwiftFileBackend::doStreamFile ( array $  params) [protected]
See also:
FileBackendStore::doStreamFile()

Reimplemented from FileBackendStore.

Definition at line 575 of file SwiftFileBackend.php.

References $output, getContainer(), headersFromParams(), logException(), Status\newGood(), and FileBackendStore\resolveStoragePathReal().

Here is the call graph for this function:

Get a connection to the Swift proxy.

Returns:
CF_Connection|false
Exceptions:
InvalidResponseException

Definition at line 699 of file SwiftFileBackend.php.

Referenced by createContainer(), deleteContainer(), and getContainer().

Here is the caller graph for this function:

SwiftFileBackend::getContainer ( container,
reCache = false 
) [protected]

Get a Swift container object, possibly from process cache.

Use $reCache if the file count or byte count is needed.

Parameters:
$containerstring Container name
$reCachebool Refresh the process cache
Returns:
CF_Container

Definition at line 742 of file SwiftFileBackend.php.

References $conn, and getConnection().

Referenced by doCleanInternal(), doCopyInternal(), doCreateInternal(), doDeleteInternal(), doGetFileStat(), doPrepareInternal(), doSecureInternal(), doStoreInternal(), doStreamFile(), getFileContents(), getFileListPageInternal(), getLocalCopy(), and isPathUsableInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

SwiftFileBackend::getFileContents ( array $  params)
See also:
FileBackend::getFileContents()

Reimplemented from FileBackendStore.

Definition at line 503 of file SwiftFileBackend.php.

References FileBackendStore\fileExists(), getContainer(), headersFromParams(), logException(), and FileBackendStore\resolveStoragePathReal().

Here is the call graph for this function:

SwiftFileBackend::getFileListInternal ( fullCont,
dir,
array $  params 
)
See also:
FileBackendStore::getFileListInternal()

Reimplemented from FileBackendStore.

Definition at line 530 of file SwiftFileBackend.php.

References $dir.

SwiftFileBackend::getFileListPageInternal ( fullCont,
dir,
after,
limit 
)

Do not call this function outside of SwiftFileBackendFileList.

Parameters:
$fullContstring Resolved container name
$dirstring Resolved storage directory with no trailing slash
$afterstring Storage path of file to list items after
$limitinteger Max number of items to list
Returns:
Array

Definition at line 543 of file SwiftFileBackend.php.

References $dir, $files, $limit, getContainer(), and logException().

Here is the call graph for this function:

SwiftFileBackend::getLocalCopy ( array $  params)
See also:
FileBackendStore::getLocalCopy()

Reimplemented from FileBackend.

Definition at line 614 of file SwiftFileBackend.php.

References $ext, FileBackend\extensionFromPath(), TempFSFile\factory(), FileBackendStore\fileExists(), getContainer(), headersFromParams(), logException(), FileBackendStore\resolveStoragePathReal(), and wfBaseName().

Referenced by addMissingMetadata().

Here is the call graph for this function:

Here is the caller graph for this function:

SwiftFileBackend::headersFromParams ( array $  params) [protected]

Get headers to send to Swift when reading a file based on a FileBackend params array, e.g.

that of getLocalCopy(). $params is currently only checked for a 'latest' flag.

Parameters:
$paramsArray
Returns:
Array

Definition at line 661 of file SwiftFileBackend.php.

Referenced by doGetFileStat(), doStreamFile(), getFileContents(), and getLocalCopy().

Here is the caller graph for this function:

See also:
FileBackendStore::isPathUsableInternal()

Reimplemented from FileBackendStore.

Definition at line 82 of file SwiftFileBackend.php.

References getContainer(), logException(), and FileBackendStore\resolveStoragePathReal().

Here is the call graph for this function:

SwiftFileBackend::logException ( Exception $  e,
func,
array $  params 
) [protected]

Log an unexpected exception for this backend.

Parameters:
$eException
$funcstring
$paramsArray
Returns:
void

Definition at line 793 of file SwiftFileBackend.php.

References wfDebugLog().

Referenced by doCleanInternal(), doCopyInternal(), doCreateInternal(), doDeleteInternal(), doGetFileStat(), doPrepareInternal(), doSecureInternal(), doStoreInternal(), doStreamFile(), getFileContents(), getFileListPageInternal(), getLocalCopy(), and isPathUsableInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

SwiftFileBackend::resolveContainerPath ( container,
relStoragePath 
) [protected]
See also:
FileBackendStore::resolveContainerPath()

Reimplemented from FileBackendStore.

Definition at line 72 of file SwiftFileBackend.php.

SwiftFileBackend::setContainerAccess ( CF_Container $  contObj,
array $  readGrps,
array $  writeGrps 
) [protected]

Set read/write permissions for a Swift container.

Parameters:
$contObjCF_Container Swift container
$readGrpsArray Swift users who can read (account:user)
$writeGrpsArray Swift users who can write (account:user)
Returns:
Status

Definition at line 677 of file SwiftFileBackend.php.

References $url.

Referenced by doPrepareInternal(), and doSecureInternal().

Here is the caller graph for this function:


Member Data Documentation

SwiftFileBackend::$auth [protected]

Definition at line 24 of file SwiftFileBackend.php.

SwiftFileBackend::$authTTL [protected]

Definition at line 25 of file SwiftFileBackend.php.

SwiftFileBackend::$conn [protected]

Definition at line 30 of file SwiftFileBackend.php.

Referenced by createContainer(), deleteContainer(), and getContainer().

SwiftFileBackend::$connContainers = array() [protected]

Definition at line 32 of file SwiftFileBackend.php.

SwiftFileBackend::$connStarted = 0 [protected]

Definition at line 31 of file SwiftFileBackend.php.

SwiftFileBackend::$maxContCacheSize = 100 [protected]

Definition at line 27 of file SwiftFileBackend.php.

SwiftFileBackend::$swiftAnonUser [protected]

Definition at line 26 of file SwiftFileBackend.php.


The documentation for this class was generated from the following file: