當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::getStatus方法代碼示例

本文整理匯總了PHP中Elastica\Client::getStatus方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::getStatus方法的具體用法?PHP Client::getStatus怎麽用?PHP Client::getStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Elastica\Client的用法示例。


在下文中一共展示了Client::getStatus方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: pickIndexIdentifierFromOption

 /**
  * Pick the index identifier from the provided command line option.
  * @param string $option command line option
  *          'now'        => current time
  *          'current'    => if there is just one index for this type then use its identifier
  *          other string => that string back
  * @param string $typeName
  * @return string index identifier to use
  */
 public function pickIndexIdentifierFromOption($option, $typeName)
 {
     if ($option === 'now') {
         $identifier = strval(time());
         $this->outputIndented("Setting index identifier...{$typeName}_{$identifier}\n");
         return $identifier;
     }
     if ($option === 'current') {
         $this->outputIndented('Infering index identifier...');
         $found = array();
         foreach ($this->client->getStatus()->getIndexNames() as $name) {
             if (substr($name, 0, strlen($typeName)) === $typeName) {
                 $found[] = $name;
             }
         }
         if (count($found) > 1) {
             $this->output("error\n");
             $this->error("Looks like the index has more than one identifier. You should delete all\n" . "but the one of them currently active. Here is the list: " . implode($found, ','), 1);
         }
         if ($found) {
             $identifier = substr($found[0], strlen($typeName) + 1);
             if (!$identifier) {
                 // This happens if there is an index named what the alias should be named.
                 // If the script is run with --startOver it should nuke it.
                 $identifier = 'first';
             }
         } else {
             $identifier = 'first';
         }
         $this->output("{$typeName}_{$identifier}\n");
         return $identifier;
     }
     return $option;
 }
開發者ID:jamesmontalvo3,項目名稱:mediawiki-extensions-CirrusSearch,代碼行數:43,代碼來源:ConfigUtils.php

示例2: initialize

 /**
  * До любых других действий
  */
 public function initialize()
 {
     $currentActionName = $this->dispatcher->getActiveMethod();
     $annotations = $this->annotations->getMethod(self::class, $currentActionName);
     if ($annotations->has('actionInfo')) {
         $annotation = $annotations->get('actionInfo');
         $actionTitle = $annotation->getNamedArgument('name');
         $this->log->info('Запустили: {actionTitle}', ['actionTitle' => $actionTitle]);
     } else {
         $currentTaskName = $this->dispatcher->getTaskName();
         $this->log->info('Запустили: {currentTaskName}::{currentActionName}', ['currentTaskName' => $currentTaskName, 'currentActionName' => $currentActionName]);
     }
     $this->indexName = $this->dispatcher->getParam('index', 'string', false);
     $this->typeName = $this->dispatcher->getParam('type', 'string', false);
     if (!$this->indexName) {
         $this->log->error('Указание индекса является обязательным параметром');
         die;
     }
     $this->sizePerShard = $this->dispatcher->getParam('sizePerShard', 'int', false) ?: $this->sizePerShard;
     $this->elasticsearchHost = $this->dispatcher->getParam('host', 'string', false) ?: $this->elasticsearchHost;
     $this->elasticsearchPort = $this->dispatcher->getParam('port', 'int', false) ?: $this->elasticsearchPort;
     $connectParams = ['host' => $this->elasticsearchHost, 'port' => $this->elasticsearchPort];
     $this->client = new Client($connectParams);
     try {
         $this->client->getStatus();
     } catch (\Elastica\Exception\Connection\HttpException $e) {
         $context = ['host' => $this->elasticsearchHost, 'port' => $this->elasticsearchPort];
         $this->log->error('Подключение к серверу elasticsearch отсутствует: http://{host}:{port}', $context);
         die;
     }
     $this->elasticaIndex = $this->client->getIndex($this->indexName);
     $this->elasticaType = $this->elasticaIndex->getType($this->typeName);
 }
開發者ID:mzf,項目名稱:phalcon-php-elasticsearch-backup,代碼行數:36,代碼來源:elasticsearch-dumper.php

示例3: validate

 /**
  * @return Status
  */
 public function validate()
 {
     // arrays of aliases to be added/removed
     $add = $remove = array();
     $this->outputIndented("\tValidating {$this->aliasName} alias...");
     $status = $this->client->getStatus();
     if ($status->indexExists($this->aliasName)) {
         $this->output("is an index...");
         if ($this->startOver) {
             $this->client->getIndex($this->aliasName)->delete();
             $this->output("index removed...");
             $add[] = $this->specificIndexName;
         } else {
             $this->output("cannot correct!\n");
             return Status::newFatal(new RawMessage("There is currently an index with the name of the alias.  Rerun this\n" . "script with --startOver and it'll remove the index and continue.\n"));
         }
     } else {
         foreach ($status->getIndicesWithAlias($this->aliasName) as $index) {
             if ($index->getName() === $this->specificIndexName) {
                 $this->output("ok\n");
                 return Status::newGood();
             } elseif ($this->shouldRemoveFromAlias($index->getName())) {
                 $remove[] = $index->getName();
             }
         }
         $add[] = $this->specificIndexName;
     }
     return $this->updateIndices($add, $remove);
 }
開發者ID:zoglun,項目名稱:mediawiki-extensions-CirrusSearch,代碼行數:32,代碼來源:IndexAliasValidator.php

示例4: checkConnectToSearch

 /**
  * @return void
  */
 private function checkConnectToSearch()
 {
     try {
         $this->client->getStatus();
     } catch (\Exception $e) {
         $this->addDysfunction(self::HEALTH_MESSAGE_UNABLE_TO_CONNECT_TO_SEARCH);
         $this->addDysfunction($e->getMessage());
     }
 }
開發者ID:spryker,項目名稱:Heartbeat,代碼行數:12,代碼來源:SearchHealthIndicator.php

示例5: testDynamicHttpMethodOnlyAffectsRequestsWithBody

 /**
  * @dataProvider getConfig
  */
 public function testDynamicHttpMethodOnlyAffectsRequestsWithBody(array $config, $httpMethod)
 {
     $client = new Client($config);
     $status = $client->getStatus();
     $info = $status->getResponse()->getTransferInfo();
     $this->assertStringStartsWith('GET', $info['request_header']);
 }
開發者ID:viz,項目名稱:wordpress-fantastic-elasticsearch,代碼行數:10,代碼來源:GuzzleTest.php

示例6: doGetStats

 /**
  * @test
  */
 public function doGetStats()
 {
     $data = ['foo' => 'bar'];
     $status = $this->prophesize('\\Elastica\\Status');
     $status->getServerStatus()->shouldBeCalled()->willReturn($data);
     $this->client->getStatus()->shouldBeCalled()->willReturn($status->reveal());
     self::assertEquals($data, $this->cache->getStats());
 }
開發者ID:basster,項目名稱:doctrine-elastica-cache,代碼行數:11,代碼來源:CacheTest.php

示例7: testInvalidHostRequest

 /**
  * @expectedException \Elastica\Exception\ConnectionException
  */
 public function testInvalidHostRequest()
 {
     $this->_checkPlugin();
     $client = new Client(array('host' => 'unknown', 'port' => 9555, 'transport' => 'Thrift'));
     $client->getStatus();
 }
開發者ID:viz,項目名稱:wordpress-fantastic-elasticsearch,代碼行數:9,代碼來源:ThriftTest.php

示例8: doGetStats

 /**
  * Retrieves cached information from the data store.
  *
  * @since 2.2
  *
  * @return array|null An associative array with server's statistics if available, NULL otherwise.
  */
 protected function doGetStats()
 {
     return $this->client->getStatus()->getServerStatus();
 }
開發者ID:basster,項目名稱:doctrine-elastica-cache,代碼行數:11,代碼來源:Cache.php


注:本文中的Elastica\Client::getStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。