public function execute(Command $command)
{
$response = $this->getActiveNode()->execute($command, $this->api);
// if more than 1 node configured, lets try a different node up to max connection attempts
if (empty($response) && count($this->nodes) > 1 && $this->attempts < $this->getConfigValue('max_connect_attempts')) {
$response = $this->pickNewNode()->execute($command);
} elseif (empty($response) && $this->attempts >= $this->getConfigValue('max_connect_attempts')) {
throw new Exception('Nodes unreachable. Error Msg: ' . $this->api->getError());
} elseif ($response == false) {
throw new Exception('Command failed to execute against Riak. Error Msg: ' . $this->api->getError());
}
return $response;
}