You are here

function apachesolr_server_status in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 apachesolr.module \apachesolr_server_status()
  2. 6.2 apachesolr.module \apachesolr_server_status()
  3. 7 apachesolr.module \apachesolr_server_status()

Checks if a specific Apache Solr server is available.

Return value

boolean TRUE if the server can be pinged, FALSE otherwise.

5 calls to apachesolr_server_status()
AbstractDrupalSolrOnlineWebTestCase::setUpSolr in tests/solr_index_and_search.test
apachesolr_environment_edit_test_submit in ./apachesolr.admin.inc
apachesolr_settings in ./apachesolr.admin.inc
Form builder for general settings used as a menu callback.
apachesolr_status_page in ./apachesolr.admin.inc
Gets information about the fields already in solr index.
DrupalSolrOfflineEnvironmentWebTestCase::testServerOffline in tests/apachesolr_base.test
Asserts that the module was installed and that a notice appears that the server is offline

File

./apachesolr.module, line 1466
Integration with the Apache Solr search application.

Code

function apachesolr_server_status($url, $class = NULL, $class_info = NULL) {
  static $status = array();
  $class = apachesolr_load_service_class($class, $class_info);
  $key = $url . '|' . $class;

  // Static store insures we don't ping the server more than once per page load.
  if (!isset($status[$key])) {
    $ping = FALSE;
    try {

      // Takes advantage of auto-loading.
      // @Todo : Do we have to specify the env_id?
      $solr = new $class($url);
      $ping = @$solr
        ->ping(variable_get('apachesolr_ping_timeout', 4));
    } catch (Exception $e) {
      watchdog('Apache Solr', nl2br(check_plain($e
        ->getMessage())), NULL, WATCHDOG_ERROR);
    }
    $status[$key] = $ping;
  }
  return $status[$key];
}