/** * @param \Elasticsearch\Connections\Connection $connection * * @return bool */ private function readyToRevive(Connection $connection) { $timeout = min($this->pingTimeout * pow(2, $connection->getPingFailures()), $this->maxPingTimeout); if ($connection->getLastPing() + $timeout < time()) { return true; } else { return false; } }
/** * @param Connection $connection * @return bool */ private function sniffConnection(Connection $connection) { try { $response = $connection->sniff(); } catch (OperationTimeoutException $exception) { return false; } $nodes = $this->parseClusterState($connection->getTransportSchema(), $response); if (count($nodes) === 0) { return false; } $this->connections = array(); foreach ($nodes as $node) { $nodeDetails = array('host' => $node['host'], 'port' => $node['port']); $this->connections[] = $this->connectionFactory->create($nodeDetails); } $this->nextSniff = time() + $this->sniffingInterval; return true; }