| 387 | |
| 388 | |
| 389 | Try<bool> GroupProcess::authenticate() |
| 390 | { |
| 391 | CHECK_EQ(state, CONNECTED); |
| 392 | |
| 393 | // Authenticate if necessary. |
| 394 | if (auth.isSome()) { |
| 395 | LOG(INFO) << "Authenticating with ZooKeeper using " << auth->scheme; |
| 396 | |
| 397 | int code = zk->authenticate(auth->scheme, auth->credentials); |
| 398 | |
| 399 | if (code == ZINVALIDSTATE || (code != ZOK && zk->retryable(code))) { |
| 400 | return false; |
| 401 | } else if (code != ZOK) { |
| 402 | return Error( |
| 403 | "Failed to authenticate with ZooKeeper: " + zk->message(code)); |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | state = AUTHENTICATED; |
| 408 | return true; |
| 409 | } |
| 410 | |
| 411 | |
| 412 | Try<bool> GroupProcess::create() |