You are here

function apachesolr_server_status in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 8 apachesolr.module \apachesolr_server_status()
  2. 6.3 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.

File

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

Code

function apachesolr_server_status($host = NULL, $port = NULL, $path = NULL) {
  if (empty($host)) {
    $host = variable_get('apachesolr_host', 'localhost');
  }
  if (empty($port)) {
    $port = variable_get('apachesolr_port', '8983');
  }
  if (empty($path)) {
    $path = variable_get('apachesolr_path', '/solr');
  }
  $ping = FALSE;
  try {
    $solr = apachesolr_get_solr($host, $port, $path);
    $ping = @$solr
      ->ping(variable_get('apachesolr_ping_timeout', 4));
  } catch (Exception $e) {
    watchdog('Apache Solr', check_plain($e
      ->getMessage()), NULL, WATCHDOG_ERROR);
  }
  return $ping;
}