| 248 | } |
| 249 | |
| 250 | Status WaitForServer(const string& host, int port, int num_retries, |
| 251 | int retry_interval_ms) { |
| 252 | int retry_count = 0; |
| 253 | while (retry_count < num_retries) { |
| 254 | try { |
| 255 | TSocket socket(host, port); |
| 256 | // Timeout is in ms |
| 257 | socket.setConnTimeout(500); |
| 258 | socket.open(); |
| 259 | socket.close(); |
| 260 | return Status::OK(); |
| 261 | } catch (const TException& e) { |
| 262 | VLOG_QUERY << "Connection failed: " << e.what(); |
| 263 | } |
| 264 | ++retry_count; |
| 265 | VLOG_QUERY << "Waiting " << retry_interval_ms << "ms for Thrift server at " |
| 266 | << host << ":" << port |
| 267 | << " to come up, failed attempt " << retry_count |
| 268 | << " of " << num_retries; |
| 269 | SleepForMs(retry_interval_ms); |
| 270 | } |
| 271 | return Status("Server did not come up"); |
| 272 | } |
| 273 | |
| 274 | void PrintTColumnValue(std::ostream& out, const TColumnValue& colval) { |
| 275 | if (colval.__isset.bool_val) { |