本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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());
}
}
示例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']);
}
示例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());
}
示例7: testInvalidHostRequest
/**
* @expectedException \Elastica\Exception\ConnectionException
*/
public function testInvalidHostRequest()
{
$this->_checkPlugin();
$client = new Client(array('host' => 'unknown', 'port' => 9555, 'transport' => 'Thrift'));
$client->getStatus();
}
示例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();
}