/** * @param AbstractConnection $connection * @return bool */ private function sniffConnection(AbstractConnection $connection) { try { $response = $connection->sniff(); } catch (OperationTimeoutException $exception) { return false; } // TODO wire in the serializer? $nodeInfo = json_decode($response['text'], true); $nodes = $this->parseClusterState($connection->getTransportSchema(), $nodeInfo); 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; }
/** * @param AbstractConnection $connection * @return bool */ private function sniffConnection(AbstractConnection $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) { $this->connections[] = $this->connectionFactory->create($node['host'], $node['port']); } $this->nextSniff = time() + $this->sniffingInterval; return true; }