BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
FileBackendMultiWrite Class Reference

Proxy backend that mirrors writes to several internal backends. More...

Inheritance diagram for FileBackendMultiWrite:
Collaboration diagram for FileBackendMultiWrite:

Public Member Functions

 __construct (array $config)
 
 consistencyCheck (array $paths)
 
 accessibilityCheck (array $paths)
 
 resyncFiles (array $paths, $resyncMode=true)
 
 concatenate (array $params)
 
 fileExists (array $params)
 
 getFileTimestamp (array $params)
 
 getFileSize (array $params)
 
 getFileStat (array $params)
 
 getFileXAttributes (array $params)
 
 getFileContentsMulti (array $params)
 
 getFileSha1Base36 (array $params)
 
 getFileProps (array $params)
 
 streamFile (array $params)
 
 getLocalReferenceMulti (array $params)
 
 getLocalCopyMulti (array $params)
 
 getFileHttpUrl (array $params)
 
 directoryExists (array $params)
 
 getDirectoryList (array $params)
 
 getFileList (array $params)
 
 getFeatures ()
 
 clearCache (array $paths=null)
 
 preloadCache (array $paths)
 
 preloadFileStat (array $params)
 
 getScopedLocksForOps (array $ops, Status $status)
 
- Public Member Functions inherited from FileBackend
 __construct (array $config)
 
 getName ()
 
 getWikiId ()
 
 isReadOnly ()
 
 getReadOnlyReason ()
 
 getFeatures ()
 
 hasFeatures ($bitfield)
 
 doOperations (array $ops, array $opts=[])
 
 doOperation (array $op, array $opts=[])
 
 create (array $params, array $opts=[])
 
 store (array $params, array $opts=[])
 
 copy (array $params, array $opts=[])
 
 move (array $params, array $opts=[])
 
 delete (array $params, array $opts=[])
 
 describe (array $params, array $opts=[])
 
 doQuickOperations (array $ops, array $opts=[])
 
 doQuickOperation (array $op)
 
 quickCreate (array $params)
 
 quickStore (array $params)
 
 quickCopy (array $params)
 
 quickMove (array $params)
 
 quickDelete (array $params)
 
 quickDescribe (array $params)
 
 concatenate (array $params)
 
 prepare (array $params)
 
 secure (array $params)
 
 publish (array $params)
 
 clean (array $params)
 
 fileExists (array $params)
 
 getFileTimestamp (array $params)
 
 getFileContents (array $params)
 
 getFileContentsMulti (array $params)
 
 getFileXAttributes (array $params)
 
 getFileSize (array $params)
 
 getFileStat (array $params)
 
 getFileSha1Base36 (array $params)
 
 getFileProps (array $params)
 
 streamFile (array $params)
 
 getLocalReference (array $params)
 
 getLocalReferenceMulti (array $params)
 
 getLocalCopy (array $params)
 
 getLocalCopyMulti (array $params)
 
 getFileHttpUrl (array $params)
 
 directoryExists (array $params)
 
 getDirectoryList (array $params)
 
 getTopDirectoryList (array $params)
 
 getFileList (array $params)
 
 getTopFileList (array $params)
 
 preloadCache (array $paths)
 
 clearCache (array $paths=null)
 
 preloadFileStat (array $params)
 
 lockFiles (array $paths, $type, $timeout=0)
 
 unlockFiles (array $paths, $type)
 
 getScopedFileLocks (array $paths, $type, Status $status, $timeout=0)
 
 getScopedLocksForOps (array $ops, Status $status)
 
 getRootStoragePath ()
 
 getContainerStoragePath ($container)
 
 getJournal ()
 

Public Attributes

const CHECK_SIZE = 1
 
const CHECK_TIME = 2
 
const CHECK_SHA1 = 4
 
- Public Attributes inherited from FileBackend
const ATTR_HEADERS = 1
 
const ATTR_METADATA = 2
 
const ATTR_UNICODE_PATHS = 4
 

Protected Member Functions

 doOperationsInternal (array $ops, array $opts)
 
 fileStoragePathsForOps (array $ops)
 
 substOpBatchPaths (array $ops, FileBackendStore $backend)
 
 substOpPaths (array $ops, FileBackendStore $backend)
 
 substPaths ($paths, FileBackendStore $backend)
 
 unsubstPaths ($paths)
 
 hasVolatileSources (array $ops)
 
 doQuickOperationsInternal (array $ops)
 
 doPrepare (array $params)
 
 doSecure (array $params)
 
 doPublish (array $params)
 
 doClean (array $params)
 
 doDirectoryOp ($method, array $params)
 
 getReadIndexFromParams (array $params)
 
- Protected Member Functions inherited from FileBackend
 doOperationsInternal (array $ops, array $opts)
 
 doQuickOperationsInternal (array $ops)
 
 doPrepare (array $params)
 
 doSecure (array $params)
 
 doPublish (array $params)
 
 doClean (array $params)
 
 getScopedPHPBehaviorForOps ()
 
 resolveFSFileObjects (array $ops)
 

Protected Attributes

 $backends = []
 
 $masterIndex = -1
 
 $readIndex = -1
 
 $syncChecks = 0
 
 $autoResync = false
 
 $asyncWrites = false
 
- Protected Attributes inherited from FileBackend
 $name
 
 $wikiId
 
 $readOnly
 
 $parallelize
 
 $concurrency
 
 $lockManager
 
 $fileJournal
 

Additional Inherited Members

- Static Public Member Functions inherited from FileBackend
static isStoragePath ($path)
 
static splitStoragePath ($storagePath)
 
static normalizeStoragePath ($storagePath)
 
static parentStoragePath ($storagePath)
 
static extensionFromPath ($path, $case= 'lowercase')
 
static isPathTraversalFree ($path)
 
static makeContentDisposition ($type, $filename= '')
 
- Static Protected Member Functions inherited from FileBackend
static normalizeContainerPath ($path)
 

Detailed Description

Proxy backend that mirrors writes to several internal backends.

This class defines a multi-write backend. Multiple backends can be registered to this proxy backend and it will act as a single backend. Use this when all access to those backends is through this proxy backend. At least one of the backends must be declared the "master" backend.

Only use this class when transitioning from one storage system to another.

Read operations are only done on the 'master' backend for consistency. Write operations are performed on all backends, starting with the master. This makes a best-effort to have transactional semantics, but since requests may sometimes fail, the use of "autoResync" or background scripts to fix inconsistencies is important.

Since
1.19

Constructor & Destructor Documentation

FileBackendMultiWrite::__construct ( array  $config)

Construct a proxy backend that consists of several internal backends. Locking, journaling, and read-only checks are handled by the proxy backend.

Additional $config params include:

  • backends : Array of backend config and multi-backend settings. Each value is the config used in the constructor of a FileBackendStore class, but with these additional settings:
    • class : The name of the backend class
    • isMultiMaster : This must be set for one backend.
    • readAffinity : Use this for reads without 'latest' set.
    • template: : If given a backend name, this will use the config of that backend as a template. Values specified here take precedence.
  • syncChecks : Integer bitfield of internal backend sync checks to perform. Possible bits include the FileBackendMultiWrite::CHECK_* constants. There are constants for SIZE, TIME, and SHA1. The checks are done before allowing any file operations.
  • autoResync : Automatically resync the clone backends to the master backend when pre-operation sync checks fail. This should only be used if the master backend is stable and not missing any files. Use "conservative" to limit resyncing to copying newer master backend files over older (or non-existing) clone backend files. Cases that cannot be handled will result in operation abortion.
  • replication : Set to 'async' to defer file operations on the non-master backends. This will apply such updates post-send for web requests. Note that any checks from "syncChecks" are still synchronous.
Parameters
array$config
Exceptions
FileBackendError

Member Function Documentation

FileBackendMultiWrite::accessibilityCheck ( array  $paths)

Check that a set of file paths are usable across all internal backends

Parameters
array$pathsList of storage paths
Returns
Status
FileBackendMultiWrite::consistencyCheck ( array  $paths)

Check that a set of files are consistent across all internal backends

Parameters
array$pathsList of storage paths
Returns
Status
FileBackendMultiWrite::doDirectoryOp (   $method,
array  $params 
)
protected
Parameters
string$methodOne of (doPrepare,doSecure,doPublish,doClean)
array$paramsMethod arguments
Returns
Status
FileBackendMultiWrite::doOperationsInternal ( array  $ops,
array  $opts 
)
finalprotected

PhpUnusedLocalVariableInspection

FileBackendMultiWrite::fileStoragePathsForOps ( array  $ops)
protected

Get a list of file storage paths to read or write for a list of operations

Parameters
array$opsSame format as doOperations()
Returns
array List of storage paths to files (does not include directories)
FileBackendMultiWrite::getReadIndexFromParams ( array  $params)
protected
Parameters
array$params
Returns
int The master or read affinity backend index, based on $params['latest']
FileBackendMultiWrite::hasVolatileSources ( array  $ops)
protected
Parameters
array$opsFile operations for FileBackend::doOperations()
Returns
bool Whether there are file path sources with outside lifetime/ownership
FileBackendMultiWrite::resyncFiles ( array  $paths,
  $resyncMode = true 
)

Check that a set of files are consistent across all internal backends and re-synchronize those files against the "multi master" if needed.

Parameters
array$pathsList of storage paths
string | bool$resyncModeFalse, True, or "conservative"; see __construct()
Returns
Status
FileBackendMultiWrite::substOpBatchPaths ( array  $ops,
FileBackendStore  $backend 
)
protected

Substitute the backend name in storage path parameters for a set of operations with that of a given internal backend.

Parameters
array$opsList of file operation arrays
FileBackendStore$backend
Returns
array
FileBackendMultiWrite::substOpPaths ( array  $ops,
FileBackendStore  $backend 
)
protected

Same as substOpBatchPaths() but for a single operation

Parameters
array$opsFile operation array
FileBackendStore$backend
Returns
array
FileBackendMultiWrite::substPaths (   $paths,
FileBackendStore  $backend 
)
protected

Substitute the backend of storage paths with an internal backend's name

Parameters
array | string$pathsList of paths or single string path
FileBackendStore$backend
Returns
array|string
FileBackendMultiWrite::unsubstPaths (   $paths)
protected

Substitute the backend of internal storage paths with the proxy backend's name

Parameters
array | string$pathsList of paths or single string path
Returns
array|string

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