/**
* Switch to the given node and map the cluster from its HELLO
*
* @param Node $node
*/
private function switchToNode(Node $node)
{
$nodeId = $node->getId();
// Return early if we're trying to switch to the current node.
if ($this->nodeId === $nodeId) {
// But return early only if the current node is connected to Disque.
// If it is disconnected, we want to overwrite it with the node
// from the method argument, because that one is connected.
if ($this->getCurrentNode()->isConnected()) {
return;
}
// Copy the stats from the now-disconnected node object
$this->copyNodeStats($this->getCurrentNode(), $node);
}
$this->resetNodeCounters();
$this->nodeId = $nodeId;
$this->nodes[$nodeId] = $node;
$this->revealClusterFromHello($node);
}