本文整理汇总了PHP中Solarium_Client::ping方法的典型用法代码示例。如果您正苦于以下问题:PHP Solarium_Client::ping方法的具体用法?PHP Solarium_Client::ping怎么用?PHP Solarium_Client::ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solarium_Client
的用法示例。
在下文中一共展示了Solarium_Client::ping方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
/** List of the papers available
* @access public
* @return void
*/
public function indexAction()
{
$ping = $this->_solr->createPing();
if (!$this->_solr->ping($ping)) {
echo '<h2>Search engine system error</h2>';
echo '<p>Solr service not responding.</p>';
} else {
$form = new SolrForm();
$form->removeElement('thumbnail');
$this->view->form = $form;
if ($this->_request->isPost()) {
$data = $this->getAllParams();
if ($form->isValid($data)) {
$this->redirect($this->view->url(array('module' => 'search', 'controller' => 'results', 'action' => 'index', 'q' => $data['q'])));
} else {
$form->populate($form->getValues());
}
}
}
}
示例2: array
$optionsSolrOne = array('host' => '127.0.0.1', 'port' => 8983);
$optionsSolrTwo = array('host' => '127.0.0.1', 'port' => 7574);
$loadbalancer->addServer('solr1', $optionsSolrOne, 100);
$loadbalancer->addServer('solr2', $optionsSolrTwo, 200);
$loadbalancer->addServer('solr3', $optionsSolrTwo, 1);
// create a basic query to execute
$query = $client->createSelect();
// execute the query multiple times, displaying the server for each execution
for ($i = 1; $i <= 8; $i++) {
$resultset = $client->select($query);
echo 'Query execution #' . $i . '<br/>';
echo 'NumFound: ' . $resultset->getNumFound() . '<br/>';
echo 'Server: ' . $loadbalancer->getLastServerKey() . '<hr/>';
}
// force a server for a query (normally solr 3 is extremely unlikely based on it's weight)
$loadbalancer->setForcedServerForNextQuery('solr3');
$resultset = $client->select($query);
echo 'Query execution with server forced to solr3<br/>';
echo 'NumFound: ' . $resultset->getNumFound() . '<br/>';
echo 'Server: ' . $loadbalancer->getLastServerKey() . '<hr/>';
// test a ping query
$query = $client->createPing();
$client->ping($query);
echo 'Loadbalanced ping query, should display a loadbalancing server:<br/>';
echo 'Ping server: ' . $loadbalancer->getLastServerKey() . '<hr/>';
// exclude ping query from loadbalancing
$loadbalancer->addBlockedQueryType(Solarium_Client::QUERYTYPE_PING);
$client->ping($query);
echo 'Non-loadbalanced ping query, should not display a loadbalancing server:<br/>';
echo 'Ping server: ' . $loadbalancer->getLastServerKey() . '<hr/>';
htmlFooter();
示例3: Objects
/**
* Test whether the server environment is configured properly.
*
* Run a series of tests to determine whether the correct software is installed, permissions
* are correct, and settings are enabled.
*
* @throws Exception if the environment test fails
*/
function test_environment()
{
/*
* Make sure that the PHP Data Objects extension is enabled.
*/
if (!defined('PDO::ATTR_DRIVER_NAME')) {
$this->logger->message('PHP Data Objects (PDO) must be enabled.', 10);
$error = TRUE;
}
/*
* Make sure that PDO MySQL support exists.
*/
if (!in_array('mysql', PDO::getAvailableDrivers())) {
$this->logger->message('PHP Data Objects (PDO) must have a MySQL driver enabled.', 10);
$error = TRUE;
}
/*
* Make sure that HTML Tidy is available within PHP or, failing that, at the command line.
*/
if (class_exists('tidy', FALSE) == FALSE) {
/*
* A non-zero return status from a program called via exec() indicates an error.
*/
exec('which tidy', $result, $status);
if ($status != 0) {
$this->logger->message('HTML Tidy must be installed.', 10);
$error = TRUE;
}
}
/*
* Make sure that php-xml is installed.
*/
if (extension_loaded('xml') == FALSE) {
$this->logger->message('PHP’s XML extension must be installed and enabled.', 10);
$error = TRUE;
}
/*
* Make sure that xmllint is installed.
*/
exec('which xmllint', $result, $status);
if ($status != 0) {
$this->logger->message('xmllint must be installed.', 10);
$error = TRUE;
}
/*
* Make sure that zip is installed.
*/
exec('which zip', $result, $status);
if ($status != 0) {
$this->logger->message('zip must be installed.', 10);
$error = TRUE;
}
/*
* Make sure that the configuration file is writable.
*/
if (is_writable(INCLUDE_PATH . '/config.inc.php') !== TRUE) {
$this->logger->message('config.inc.php must be writable by the server.', 10);
$error = TRUE;
}
/*
* Make sure that sitemap.xml is writable.
*/
if (is_writable(WEB_ROOT . '/sitemap.xml') !== TRUE) {
$this->logger->message('sitemap.xml must be writable by the server', 3);
$error = TRUE;
}
/*
* Make sure that .htaccess is writable.
*/
if (is_writable(WEB_ROOT . '/.htaccess') !== TRUE) {
$this->logger->message('.htaccess must be writable by the server', 3);
$error = TRUE;
}
/*
* If the Downloads directory exists, make sure that it's writable.
*/
if (is_writable(WEB_ROOT . '/downloads') !== TRUE) {
$this->logger->message('The downloads directory (' . WEB_ROOT . '/downloads/' . ') must be writable by the server.', 10);
$error = TRUE;
}
if (defined('SOLR_URL')) {
/*
* Make sure that Solr is responsive.
*/
Solarium_Autoloader::register();
$client = new Solarium_Client($GLOBALS['solr_config']);
$ping = $client->createPing();
try {
$result = $client->ping($ping);
} catch (Solarium_Exception $e) {
$this->logger->message('Solr must be installed, configured in config.inc.php, and running.', 10);
$error = TRUE;
//.........这里部分代码省略.........
示例4: catch
<?php
require 'init.php';
htmlHeader();
// check solarium version available
echo 'Solarium library version: ' . Solarium_Version::VERSION . ' - ';
// create a client instance
$client = new Solarium_Client($config);
// create a ping query
$ping = $client->createPing();
// execute the ping query
try {
$client->ping($ping);
echo 'Ping query succesful';
} catch (Solarium_Exception $e) {
echo 'Ping query failed';
}
htmlFooter();
示例5: catch
<?php
require 'init.php';
htmlHeader();
// check solarium version available
echo 'Solarium library version: ' . Solarium_Version::VERSION . ' - ';
// create a client instance
$client = new Solarium_Client($config);
// create a ping query
$ping = $client->createPing();
// execute the ping query
try {
$result = $client->ping($ping);
echo 'Ping query successful';
echo '<br/><pre>';
var_dump($result->getData());
} catch (Solarium_Exception $e) {
echo 'Ping query failed';
}
htmlFooter();