[GCS]GCS based Actor Scheduling support actor colocation (#12707)

* [GCS]GCS based Actor Scheduling support actor colocation

* fix review comment

Co-authored-by: 灵洵 <fengbin.ffb@antgroup.com>
This commit is contained in:
fangfengbin
2020-12-10 03:54:23 +08:00
committed by Max Fitton
parent ec81eca6b0
commit 1305f5d4e5
+12 -1
View File
@@ -45,7 +45,18 @@ void GcsActorScheduler::Schedule(std::shared_ptr<GcsActor> actor) {
RAY_CHECK(actor->GetNodeID().IsNil() && actor->GetWorkerID().IsNil());
// Select a node to lease worker for the actor.
auto node = SelectNodeRandomly();
std::shared_ptr<rpc::GcsNodeInfo> node;
// If an actor is non-detached and has resource requirements, We will try to schedule it
// on the same node as the owner if possible.
const auto &task_spec = actor->GetCreationTaskSpecification();
if (!actor->IsDetached() && !task_spec.GetRequiredResources().IsEmpty()) {
auto maybe_node = gcs_node_manager_.GetNode(actor->GetOwnerNodeID());
node = maybe_node.has_value() ? maybe_node.value() : SelectNodeRandomly();
} else {
node = SelectNodeRandomly();
}
if (node == nullptr) {
// There are no available nodes to schedule the actor, so just trigger the failed
// handler.