예제 #1
0
 /**
  * Attempt recovery of database errors using fail over to another database
  * server.
  *
  * @return bool true if successfully recovered
  */
 private function _tryDatabaseRecovery()
 {
     /* Only run failover if failover is actually configured and enabled. */
     if (!(isset($this->_config->database->failover) && $this->_config->database->failover->enabled)) {
         return false;
     }
     /* If no database configuration is stored, there probably aren't any
      * suitable database servers to connect to. */
     if (!file_exists($this->_config->database->failover->file)) {
         return false;
     }
     $this->_logger->info('Previously chosen database server not longer appears to be online. Attempting to fail ' . 'over to another database server.');
     /* If the error type is a database error, we may be able to fail-over
      * the connection to another database server. */
     if (Sahara_Database::performFailover()) {
         $this->_logger->warn('Database error occurred, was able to fail over to another database server.');
         return true;
     }
 }