Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

http://tracker.moodle.org/browse/MDL-17032 : Add NFS support by softl…

…ocking the index (bloc search global configuration option).

Required for clustering using NFS shared mounting of FS.
  • Loading branch information...
commit a07107a0a48e3ba19ce7de06220d3a87b62d7039 1 parent 2a78d7b
diml authored
View
4 search/Zend/Search/Lucene.php
@@ -61,7 +61,7 @@
require_once "Zend/Search/Lucene/Index/SegmentInfoPriorityQueue.php";
/** Zend_Search_Lucene_LockManager */
-if (@$CFG->block_search_softlock){
+if (!empty($CFG->block_search_softlock)){
require_once "Zend/Search/Lucene/SoftLockManager.php";
} else {
require_once "Zend/Search/Lucene/LockManager.php";
@@ -448,6 +448,8 @@ public function __construct($directory = null, $create = false)
}
if ($this->_generation == -1) {
+ Zend_Search_Lucene_LockManager::deEscalateReadLock($this->_directory);
+ Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory);
throw new Zend_Search_Lucene_Exception('Index doesn\'t exists in the specified directory.');
} else if ($this->_generation == 0) {
$this->_readPre21SegmentsFile();
View
6 search/Zend/Search/Lucene/Index/SegmentInfo.php
@@ -27,10 +27,10 @@
require_once 'Zend/Search/Lucene/Exception.php';
/** Zend_Search_Lucene_LockManager */
-if (@$CFG->block_search_softlock){
- require_once "Zend/Search/Lucene/SoftLockManager.php";
+if (!empty($CFG->block_search_softlock)){
+ require_once 'Zend/Search/Lucene/SoftLockManager.php';
} else {
- require_once "Zend/Search/Lucene/LockManager.php";
+ require_once 'Zend/Search/Lucene/LockManager.php';
}
View
8 search/Zend/Search/Lucene/Index/Writer.php
@@ -30,13 +30,15 @@
require_once 'Zend/Search/Lucene/Index/SegmentMerger.php';
/** Zend_Search_Lucene_LockManager */
-if (@$CFG->block_search_softlock){
- require_once "Zend/Search/Lucene/SoftLockManager.php";
+if (!empty($CFG->block_search_softlock)){
+ require_once 'Zend/Search/Lucene/SoftLockManager.php';
} else {
- require_once "Zend/Search/Lucene/LockManager.php";
+ require_once 'Zend/Search/Lucene/LockManager.php';
}
+
+
/**
* @category Zend
* @package Zend_Search_Lucene
View
7 search/Zend/Search/Lucene/SoftLockManager.php
@@ -54,6 +54,7 @@ class Zend_Search_Lucene_LockManager
*/
public static function obtainWriteLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
{
+ // echo "obtain WL ";
if ($lockDirectory->fileExists(self::WRITE_LOCK_FILE)){
throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock : somebody else is writing');
}
@@ -74,6 +75,7 @@ public static function obtainWriteLock(Zend_Search_Lucene_Storage_Directory $loc
*/
public static function releaseWriteLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
{
+ // echo "release WL ";
$lockDirectory->deleteFile(self::WRITE_LOCK_FILE);
}
@@ -88,6 +90,8 @@ public static function releaseWriteLock(Zend_Search_Lucene_Storage_Directory $lo
*/
public static function obtainReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
{
+ // echo "obtain RL ";
+
// is being written. Can't read
if ($lockDirectory->fileExists(self::WRITE_LOCK_FILE)){
throw new Zend_Search_Lucene_Exception('Can\'t obtain shared reading index lock : write in progress');
@@ -138,6 +142,7 @@ public static function releaseReadLock(Zend_Search_Lucene_Storage_Directory $loc
{
// get exclusive operation lock on read lock file.
+ // echo "release RL ";
if ($lockDirectory->fileExists(self::EXCLUSIVE_READ_LOCK_FILE)){
throw new Zend_Search_Lucene_Exception('Can\'t obtain shared reading index lock : read lock operation in progress');
} else {
@@ -177,6 +182,7 @@ public static function releaseReadLock(Zend_Search_Lucene_Storage_Directory $loc
*/
public static function escalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
{
+ // echo "escalate RL ";
// get exclusive operation lock on read lock file.
if ($lockDirectory->fileExists(self::EXCLUSIVE_READ_LOCK_FILE)){
return false;
@@ -193,6 +199,7 @@ public static function escalateReadLock(Zend_Search_Lucene_Storage_Directory $lo
*/
public static function deEscalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
{
+ // echo "deescalate RL ";
$lockDirectory->deleteFile(self::EXCLUSIVE_READ_LOCK_FILE);
}

0 comments on commit a07107a

Please sign in to comment.
Something went wrong with that request. Please try again.