当前位置: 首页>>代码示例>>PHP>>正文


PHP Solarium_Client::createPing方法代码示例

本文整理汇总了PHP中Solarium_Client::createPing方法的典型用法代码示例。如果您正苦于以下问题:PHP Solarium_Client::createPing方法的具体用法?PHP Solarium_Client::createPing怎么用?PHP Solarium_Client::createPing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Solarium_Client的用法示例。


在下文中一共展示了Solarium_Client::createPing方法的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());
             }
         }
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:24,代码来源:IndexController.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $parts = parse_url($input->getArgument('url'));
     $config = array('adapteroptions' => array('host' => $parts['host'], 'port' => isset($parts['port']) ? $parts['port'] : 80, 'path' => $parts['path']));
     $client = new \Solarium_Client($config);
     $ping = $client->createPing();
     $q_start = microtime(TRUE);
     $response = $client->execute($ping);
     $client_query_time = round((microtime(TRUE) - $q_start) * 1000, 1) . 'ms';
     $body = $response->getResponse()->getBody();
     if (!empty($body)) {
         $data = json_decode($body);
         $status = isset($data->status) ? $data->status : 'Unknown';
         $server_query_time = isset($data->responseHeader->QTime) ? $data->responseHeader->QTime . 'ms' : 'Unknown';
         $output->writeln("Ping status {$status} completed in (client/server) {$client_query_time}/{$server_query_time}");
     }
 }
开发者ID:danquah,项目名称:solr-tester,代码行数:19,代码来源:PingCommand.php

示例3: 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();
开发者ID:Bine0511,项目名称:RDF-Demo,代码行数:31,代码来源:7.1-plugin-loadbalancer.php

示例4: 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;
//.........这里部分代码省略.........
开发者ID:FreeLawFounders,项目名称:statedecoded,代码行数:101,代码来源:class.ParserController.inc.php

示例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 {
    $client->ping($ping);
    echo 'Ping query succesful';
} catch (Solarium_Exception $e) {
    echo 'Ping query failed';
}
htmlFooter();
开发者ID:swapnilphalak,项目名称:crawl-anywhere,代码行数:18,代码来源:1.1-check-solarium-and-ping.php


注:本文中的Solarium_Client::createPing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。