Open Stajor opened 9 years ago
My solution
public function getRandomNode() {
if (empty($this->nodes)) throw new ClusterException('Node list is empty.');
$array_random_assoc = function($arr, $num = 1) {
$keys = array_keys($arr);
shuffle($keys);
$r = array();
for ($i = 0; $i < $num; $i++) {
$r[$keys[$i]] = $arr[$keys[$i]];
}
return $r;
};
$this->nodes = $array_random_assoc($this->nodes, count($this->nodes));
// shuffle($this->nodes);
while(!empty($this->nodes)) {
...
can't connect to cassandra if I use host as a key and username, password as a value
The bug in Cassandra/Cluster.php in method getRandomNode
after shuffle($this->nodes); the host become zero