check connected (#6565)

This commit is contained in:
Edward Oakes 2019-12-20 22:04:25 -07:00 committed by GitHub
parent f06d7422db
commit 932cb3c297
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -156,6 +156,7 @@ CoreWorker::CoreWorker(const WorkerType worker_type, const Language language,
WorkerID::FromBinary(worker_context_.GetWorkerID().Binary()),
(worker_type_ == ray::WorkerType::WORKER), worker_context_.GetCurrentJobID(),
language_, &local_raylet_id, core_worker_server_.GetPort()));
connected_ = true;
// Set our own address.
RAY_CHECK(!local_raylet_id.IsNil());
@ -266,11 +267,14 @@ void CoreWorker::Shutdown() {
void CoreWorker::Disconnect() {
io_service_.stop();
if (gcs_client_) {
gcs_client_->Disconnect();
}
if (local_raylet_client_) {
RAY_IGNORE_EXPR(local_raylet_client_->Disconnect());
if (connected_) {
connected_ = false;
if (gcs_client_) {
gcs_client_->Disconnect();
}
if (local_raylet_client_) {
RAY_IGNORE_EXPR(local_raylet_client_->Disconnect());
}
}
}

View file

@ -560,6 +560,9 @@ class CoreWorker {
/// Address of our RPC server.
rpc::Address rpc_address_;
/// Whether or not this worker is connected to the raylet and GCS.
bool connected_ = false;
// Client to the GCS shared by core worker interfaces.
std::shared_ptr<gcs::RedisGcsClient> gcs_client_;