/** * Sends a ping to the solr server to see whether it is available. * * @return boolean Returns TRUE on successful ping. * @throws Exception Throws an exception in case ping was not successful. */ public function ping() { $solrAvailable = FALSE; try { if (!$this->solr->ping()) { throw new Exception('Solr Server not responding.', 1237475791); } $solrAvailable = TRUE; } catch (Exception $e) { if ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['logging.']['exceptions']) { t3lib_div::devLog('exception while trying to ping the solr server', 'tx_solr', 3, array($e->__toString())); } } return $solrAvailable; }
/** * Checks whether a Solr server is available and provides some information. * * @param tx_solr_SolrService Solr connection * @return tx_reports_reports_status_Status Status of the Solr connection */ protected function getConnectionStatus(tx_solr_SolrService $solr) { $value = 'Your site was unable to contact the Apache Solr server.'; $severity = tx_reports_reports_status_Status::ERROR; $message = '<ul>' . '<li>Host: ' . $solr->getHost() . '</li>' . '<li>Port: ' . $solr->getPort() . '</li>' . '<li style="padding-bottom: 10px;">Path: ' . $solr->getPath() . '</li>'; if ($solr->ping()) { $severity = tx_reports_reports_status_Status::OK; $value = 'Your site has contacted the Apache Solr server.'; $solrVersion = $this->formatSolrVersion($solr->getSolrServerVersion()); $message .= '<li>Apache Solr: ' . $solrVersion . '</li>'; $message .= '<li>schema.xml: ' . $solr->getSchemaName() . '</li>'; $message .= '<li>solrconfig.xml: ' . $solr->getSolrconfigName() . '</li>'; $accessFilterPluginStatus = t3lib_div::makeInstance('tx_solr_report_AccessFilterPluginInstalledStatus'); $accessFilterPluginVersion = $accessFilterPluginStatus->getInstalledPluginVersion($solr); $message .= '<li>Access Filter Plugin: ' . $accessFilterPluginVersion . '</li>'; } $message .= '</ul>'; return t3lib_div::makeInstance('tx_reports_reports_status_Status', 'Apache Solr', $value, $message, $severity); }