[Core] Minor fixes (#14411)

* Fix issue.

* Lint.

* Addressed code review.
This commit is contained in:
SangBin Cho 2021-03-01 18:37:05 -08:00 committed by GitHub
parent b1e0409447
commit 0ec8efbb47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View file

@ -134,10 +134,10 @@ ray::Status OwnershipBasedObjectDirectory::ReportObjectAdded(
request, [worker_id, object_id, node_id](
Status status, const rpc::AddObjectLocationOwnerReply &reply) {
if (!status.ok()) {
RAY_LOG(INFO) << "Worker " << worker_id << " failed to add the location "
<< node_id << " for " << object_id
<< ", the object has most likely been freed: "
<< status.ToString();
RAY_LOG(DEBUG) << "Worker " << worker_id << " failed to add the location "
<< node_id << " for " << object_id
<< ", the object has most likely been freed: "
<< status.ToString();
} else {
RAY_LOG(DEBUG) << "Added location " << node_id << " for object " << object_id
<< " on owner " << worker_id;
@ -168,10 +168,10 @@ ray::Status OwnershipBasedObjectDirectory::ReportObjectRemoved(
request, [worker_id, object_id, node_id](
Status status, const rpc::RemoveObjectLocationOwnerReply &reply) {
if (!status.ok()) {
RAY_LOG(INFO) << "Worker " << worker_id << " failed to remove the location "
<< node_id << " for " << object_id
<< ", the object has most likely been freed: "
<< status.ToString();
RAY_LOG(DEBUG) << "Worker " << worker_id << " failed to remove the location "
<< node_id << " for " << object_id
<< ", the object has most likely been freed: "
<< status.ToString();
} else {
RAY_LOG(DEBUG) << "Removed location " << node_id << " for object " << object_id
<< " on owner " << worker_id;

View file

@ -21,7 +21,8 @@ namespace ray {
ClusterResourceScheduler::ClusterResourceScheduler(
int64_t local_node_id, const NodeResources &local_node_resources)
: local_node_id_(local_node_id) {
: local_node_id_(local_node_id),
gen_(std::chrono::high_resolution_clock::now().time_since_epoch().count()) {
AddOrUpdateNode(local_node_id_, local_node_resources);
InitLocalResources(local_node_resources);
}
@ -233,7 +234,8 @@ int64_t ClusterResourceScheduler::GetBestSchedulableNode(const TaskRequest &task
// This an actor which requires no resources.
// Pick a random node to to avoid all scheduling all actors on the local node.
if (nodes_.size() > 0) {
int idx = std::rand() % nodes_.size();
std::uniform_int_distribution<int> distribution(0, nodes_.size() - 1);
int idx = distribution(gen_);
for (auto &node : nodes_) {
if (idx == 0) {
best_nodes.emplace_back(node.first);

View file

@ -436,6 +436,8 @@ class ClusterResourceScheduler : public ClusterResourceSchedulerInterface {
absl::flat_hash_map<int64_t, Node> nodes_;
/// Identifier of local node.
int64_t local_node_id_;
/// Internally maintained random number generator.
std::mt19937_64 gen_;
/// Resources of local node.
NodeResourceInstances local_resources_;
/// Keep the mapping between node and resource IDs in string representation