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


PHP Client::getCluster方法代码示例

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


在下文中一共展示了Client::getCluster方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $table = new Console\Helper\TableHelper();
     $output->writeln('Cluster overview:');
     $output->writeln('');
     $output->writeln('Nodes:');
     $cluster = $this->elastica->getCluster();
     $table->setHeaders(['name', 'documents', 'node', 'ip', 'port', 'hostname', 'version', 'transport address', 'http address']);
     $nodes = $cluster->getNodes();
     foreach ($nodes as $node) {
         $name = $node->getName();
         $ip = $node->getInfo()->getIp();
         $data = $node->getInfo()->getData();
         $port = $node->getInfo()->getPort();
         $stats = $node->getStats()->get();
         //dump($stats->get());exit;
         $table->addRow([$data['name'], $stats['indices']['docs']['count'], $name, $ip, $port, $data['hostname'], $data['version'], $data['transport_address'], $data['http_address']]);
     }
     $table->render($output);
     $table->setRows([]);
     /* INFO */
     $info = $this->elastica->request('', 'GET')->getData();
     $table->setHeaders(['name', 'version', 'status', 'ok']);
     $table->addRow([$info['name'], $info['version']['number'], $info['status'], $info['ok']]);
     $table->render($output);
     $table->setRows([]);
     $output->writeln('');
 }
开发者ID:bazo,项目名称:nette-elasticsearch-extension,代码行数:28,代码来源:ElasticSearchInfo.php

示例2: testShutdown

 /**
  * Shuts one of two nodes down (if two available)
  */
 public function testShutdown()
 {
     $client = $this->_getClient();
     $nodes = $client->getCluster()->getNodes();
     $count = count($nodes);
     if ($count < 2) {
         $this->markTestSkipped('At least two nodes have to be running, because 1 node is shutdown');
     }
     // Store node info of node with port 9200 for later
     foreach ($nodes as $key => $node) {
         if ($node->getInfo()->getPort() == 9200) {
             $info = $node->getInfo();
             unset($nodes[$key]);
         }
     }
     // Select one of the not port 9200 nodes and shut it down
     $node = array_shift($nodes);
     $node->shutdown('2s');
     // Wait until node is shutdown
     sleep(5);
     // Use still existing node
     $client = new Client(array('host' => $info->getIp(), 'port' => $info->getPort()));
     $names = $client->getCluster()->getNodeNames();
     // One node less ...
     $this->assertEquals($count - 1, count($names));
 }
开发者ID:kskod,项目名称:Elastica,代码行数:29,代码来源:NodeTest.php

示例3: reindex

 /**
  * @param string $newIndexName
  * @throws IndexAlreadyExistsException
  * @throws IndexDoesNotExistsException
  */
 public function reindex($newIndexName)
 {
     $newIndex = $this->getIndex($newIndexName);
     if ($newIndex->exists()) {
         throw new IndexAlreadyExistsException("Index '{$newIndexName}' already exists!");
     }
     if (count($this->client->getCluster()->getIndexNames()) < 1) {
         throw new IndexDoesNotExistsException('Old index was not found in Elastic!');
     }
     $this->createNewIndexMapping($newIndexName);
     $oldIndexEntity = $this->findNewestIndex();
     $oldIndex = $this->getIndex($oldIndexEntity->getName());
     if (!$oldIndex->exists()) {
         throw new IndexDoesNotExistsException('Old index was not found in Elastic!');
     }
     $this->onBeforeReindex($newIndex, $oldIndex);
     $this->moveDataBetweenIndices($oldIndex, $newIndex);
     $this->onAfterReindex($newIndex, $oldIndex);
     $this->onBeforeChangingAlias($oldIndex, $newIndex);
     $this->moveAliasBetweenIndices($oldIndex, $newIndex);
     $this->onAfterChangingAlias($oldIndex, $newIndex);
     $oldIndex->delete();
     $this->onFinish($newIndex);
 }
开发者ID:legendik,项目名称:DwarfSearch,代码行数:29,代码来源:Reindexator.php


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