当前位置: 首页>>代码示例>>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;未经允许,请勿转载。