jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/345459 )

Change subject: Split out some internal methods in QuorumLockManager for 
readability
......................................................................


Split out some internal methods in QuorumLockManager for readability

Change-Id: I74930b930b18110c9f20b945c87790f898258ad5
---
M includes/libs/lockmanager/QuorumLockManager.php
1 file changed, 38 insertions(+), 5 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/libs/lockmanager/QuorumLockManager.php 
b/includes/libs/lockmanager/QuorumLockManager.php
index a89d864..1d2e21a 100644
--- a/includes/libs/lockmanager/QuorumLockManager.php
+++ b/includes/libs/lockmanager/QuorumLockManager.php
@@ -127,6 +127,39 @@
         * @return StatusValue
         */
        final protected function doLockingRequestBucket( $bucket, array 
$pathsByType ) {
+               return $this->collectPledgeQuorum(
+                       $bucket,
+                       function ( $lockSrv ) use ( $pathsByType ) {
+                               return $this->getLocksOnServer( $lockSrv, 
$pathsByType );
+                       }
+               );
+       }
+
+       /**
+        * Attempt to release locks with the peers for a bucket
+        *
+        * @param int $bucket
+        * @param array $pathsByType Map of LockManager::LOCK_* constants to 
lists of paths
+        * @return StatusValue
+        */
+       final protected function doUnlockingRequestBucket( $bucket, array 
$pathsByType ) {
+               return $this->releasePledges(
+                       $bucket,
+                       function ( $lockSrv ) use ( $pathsByType ) {
+                               return $this->freeLocksOnServer( $lockSrv, 
$pathsByType );
+                       }
+               );
+       }
+
+       /**
+        * Attempt to acquire pledges with the peers for a bucket.
+        * This is all or nothing; if any key is already pledged then this 
totally fails.
+        *
+        * @param int $bucket
+        * @param callable $callback Pledge method taking a server name and 
yeilding a StatusValue
+        * @return StatusValue
+        */
+       final protected function collectPledgeQuorum( $bucket, callable 
$callback ) {
                $status = StatusValue::newGood();
 
                $yesVotes = 0; // locks made on trustable servers
@@ -141,7 +174,7 @@
                                continue; // server down?
                        }
                        // Attempt to acquire the lock on this peer
-                       $status->merge( $this->getLocksOnServer( $lockSrv, 
$pathsByType ) );
+                       $status->merge( $callback( $lockSrv ) );
                        if ( !$status->isOK() ) {
                                return $status; // vetoed; resource locked
                        }
@@ -162,13 +195,13 @@
        }
 
        /**
-        * Attempt to release locks with the peers for a bucket
+        * Attempt to release pledges with the peers for a bucket
         *
         * @param int $bucket
-        * @param array $pathsByType Map of LockManager::LOCK_* constants to 
lists of paths
+        * @param callable $callback Pledge method taking a server name and 
yeilding a StatusValue
         * @return StatusValue
         */
-       final protected function doUnlockingRequestBucket( $bucket, array 
$pathsByType ) {
+       final protected function releasePledges( $bucket, callable $callback ) {
                $status = StatusValue::newGood();
 
                $yesVotes = 0; // locks freed on trustable servers
@@ -180,7 +213,7 @@
                                $status->warning( 
'lockmanager-fail-svr-release', $lockSrv );
                        } else {
                                // Attempt to release the lock on this peer
-                               $status->merge( $this->freeLocksOnServer( 
$lockSrv, $pathsByType ) );
+                               $status->merge( $callback( $lockSrv ) );
                                ++$yesVotes; // success for this peer
                                // Normally the first peers form the quorum, 
and the others are ignored.
                                // Ignore them in this case, but not when an 
alternative quorum was used.

-- 
To view, visit https://gerrit.wikimedia.org/r/345459
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I74930b930b18110c9f20b945c87790f898258ad5
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to