mirror of
https://github.com/wassname/ray.git
synced 2026-07-25 13:30:52 +08:00
[ID Refactor] Rename DriverID to JobID (#5004)
* WIP WIP WIP Rename Driver -> Job Fix complition Fix Rename in Java In py WIP Fix WIP Fix Fix test Fix Fix C++ linting Fix * Update java/runtime/src/main/java/org/ray/runtime/config/RayConfig.java Co-Authored-By: Stephanie Wang <swang@cs.berkeley.edu> * Update src/ray/core_worker/core_worker.cc Co-Authored-By: Stephanie Wang <swang@cs.berkeley.edu> * Address comments * Fix * Fix CI * Fix cpp linting * Fix py lint * FIx * Address comments and fix * Address comments * Address * Fix import_threading
This commit is contained in:
+13
-3
@@ -85,7 +85,7 @@ uint64_t MurmurHash64A(const void *key, int len, unsigned int seed) {
|
||||
return h;
|
||||
}
|
||||
|
||||
TaskID TaskID::GetDriverTaskID(const DriverID &driver_id) {
|
||||
TaskID TaskID::GetDriverTaskID(const WorkerID &driver_id) {
|
||||
std::string driver_id_str = driver_id.Binary();
|
||||
driver_id_str.resize(Size());
|
||||
return TaskID::FromBinary(driver_id_str);
|
||||
@@ -113,12 +113,12 @@ ObjectID ObjectID::ForTaskReturn(const TaskID &task_id, int64_t return_index) {
|
||||
return object_id;
|
||||
}
|
||||
|
||||
const TaskID GenerateTaskId(const DriverID &driver_id, const TaskID &parent_task_id,
|
||||
const TaskID GenerateTaskId(const JobID &job_id, const TaskID &parent_task_id,
|
||||
int parent_task_counter) {
|
||||
// Compute hashes.
|
||||
SHA256_CTX ctx;
|
||||
sha256_init(&ctx);
|
||||
sha256_update(&ctx, reinterpret_cast<const BYTE *>(driver_id.Data()), driver_id.Size());
|
||||
sha256_update(&ctx, reinterpret_cast<const BYTE *>(job_id.Data()), job_id.Size());
|
||||
sha256_update(&ctx, reinterpret_cast<const BYTE *>(parent_task_id.Data()),
|
||||
parent_task_id.Size());
|
||||
sha256_update(&ctx, (const BYTE *)&parent_task_counter, sizeof(parent_task_counter));
|
||||
@@ -129,6 +129,16 @@ const TaskID GenerateTaskId(const DriverID &driver_id, const TaskID &parent_task
|
||||
return TaskID::FromBinary(std::string(buff, buff + TaskID::Size()));
|
||||
}
|
||||
|
||||
const WorkerID ComputeDriverId(const JobID &job_id) {
|
||||
// Currently, a job id equals its driver id.
|
||||
return WorkerID(job_id);
|
||||
}
|
||||
|
||||
const JobID ComputeJobId(const WorkerID &driver_id) {
|
||||
// Currently, a job id equals its driver id.
|
||||
return JobID(driver_id);
|
||||
}
|
||||
|
||||
#define ID_OSTREAM_OPERATOR(id_type) \
|
||||
std::ostream &operator<<(std::ostream &os, const id_type &id) { \
|
||||
if (id.IsNil()) { \
|
||||
|
||||
+4
-4
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace ray {
|
||||
|
||||
class DriverID;
|
||||
class WorkerID;
|
||||
class UniqueID;
|
||||
|
||||
// Declaration.
|
||||
@@ -72,7 +72,7 @@ class TaskID : public BaseID<TaskID> {
|
||||
public:
|
||||
TaskID() : BaseID() {}
|
||||
static size_t Size() { return kTaskIDSize; }
|
||||
static TaskID GetDriverTaskID(const DriverID &driver_id);
|
||||
static TaskID GetDriverTaskID(const WorkerID &driver_id);
|
||||
|
||||
private:
|
||||
uint8_t id_[kTaskIDSize];
|
||||
@@ -152,11 +152,11 @@ std::ostream &operator<<(std::ostream &os, const ObjectID &id);
|
||||
|
||||
/// Generate a task ID from the given info.
|
||||
///
|
||||
/// \param driver_id The driver that creates the task.
|
||||
/// \param job_id The job that creates the task.
|
||||
/// \param parent_task_id The parent task of this task.
|
||||
/// \param parent_task_counter The task index of the worker.
|
||||
/// \return The task ID generated from the given info.
|
||||
const TaskID GenerateTaskId(const DriverID &driver_id, const TaskID &parent_task_id,
|
||||
const TaskID GenerateTaskId(const JobID &job_id, const TaskID &parent_task_id,
|
||||
int parent_task_counter);
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -10,6 +10,6 @@ DEFINE_UNIQUE_ID(ActorID)
|
||||
DEFINE_UNIQUE_ID(ActorHandleID)
|
||||
DEFINE_UNIQUE_ID(ActorCheckpointID)
|
||||
DEFINE_UNIQUE_ID(WorkerID)
|
||||
DEFINE_UNIQUE_ID(DriverID)
|
||||
DEFINE_UNIQUE_ID(JobID)
|
||||
DEFINE_UNIQUE_ID(ConfigID)
|
||||
DEFINE_UNIQUE_ID(ClientID)
|
||||
|
||||
@@ -38,35 +38,34 @@ struct WorkerThreadContext {
|
||||
thread_local std::unique_ptr<WorkerThreadContext> WorkerContext::thread_context_ =
|
||||
nullptr;
|
||||
|
||||
WorkerContext::WorkerContext(WorkerType worker_type, const DriverID &driver_id)
|
||||
WorkerContext::WorkerContext(WorkerType worker_type, const JobID &job_id)
|
||||
: worker_type(worker_type),
|
||||
worker_id(worker_type == WorkerType::DRIVER
|
||||
? ClientID::FromBinary(driver_id.Binary())
|
||||
: ClientID::FromRandom()),
|
||||
current_driver_id(worker_type == WorkerType::DRIVER ? driver_id : DriverID::Nil()) {
|
||||
worker_id(worker_type == WorkerType::DRIVER ? WorkerID::FromBinary(job_id.Binary())
|
||||
: WorkerID::FromRandom()),
|
||||
current_job_id(worker_type == WorkerType::DRIVER ? job_id : JobID::Nil()) {
|
||||
// For worker main thread which initializes the WorkerContext,
|
||||
// set task_id according to whether current worker is a driver.
|
||||
// (For other threads it's set to randmom ID via GetThreadContext).
|
||||
// (For other threads it's set to random ID via GetThreadContext).
|
||||
GetThreadContext().SetCurrentTask(
|
||||
(worker_type == WorkerType::DRIVER) ? TaskID::FromRandom() : TaskID::Nil());
|
||||
}
|
||||
|
||||
const WorkerType WorkerContext::GetWorkerType() const { return worker_type; }
|
||||
|
||||
const ClientID &WorkerContext::GetWorkerID() const { return worker_id; }
|
||||
const WorkerID &WorkerContext::GetWorkerID() const { return worker_id; }
|
||||
|
||||
int WorkerContext::GetNextTaskIndex() { return GetThreadContext().GetNextTaskIndex(); }
|
||||
|
||||
int WorkerContext::GetNextPutIndex() { return GetThreadContext().GetNextPutIndex(); }
|
||||
|
||||
const DriverID &WorkerContext::GetCurrentDriverID() const { return current_driver_id; }
|
||||
const JobID &WorkerContext::GetCurrentJobID() const { return current_job_id; }
|
||||
|
||||
const TaskID &WorkerContext::GetCurrentTaskID() const {
|
||||
return GetThreadContext().GetCurrentTaskID();
|
||||
}
|
||||
|
||||
void WorkerContext::SetCurrentTask(const raylet::TaskSpecification &spec) {
|
||||
current_driver_id = spec.DriverId();
|
||||
current_job_id = spec.JobId();
|
||||
GetThreadContext().SetCurrentTask(spec);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ struct WorkerThreadContext;
|
||||
|
||||
class WorkerContext {
|
||||
public:
|
||||
WorkerContext(WorkerType worker_type, const DriverID &driver_id);
|
||||
WorkerContext(WorkerType worker_type, const JobID &job_id);
|
||||
|
||||
const WorkerType GetWorkerType() const;
|
||||
|
||||
const ClientID &GetWorkerID() const;
|
||||
const WorkerID &GetWorkerID() const;
|
||||
|
||||
const DriverID &GetCurrentDriverID() const;
|
||||
const JobID &GetCurrentJobID() const;
|
||||
|
||||
const TaskID &GetCurrentTaskID() const;
|
||||
|
||||
@@ -31,10 +31,10 @@ class WorkerContext {
|
||||
const WorkerType worker_type;
|
||||
|
||||
/// ID for this worker.
|
||||
const ClientID worker_id;
|
||||
const WorkerID worker_id;
|
||||
|
||||
/// Driver ID for this worker.
|
||||
DriverID current_driver_id;
|
||||
/// Job ID for this worker.
|
||||
JobID current_job_id;
|
||||
|
||||
private:
|
||||
static WorkerThreadContext &GetThreadContext();
|
||||
|
||||
@@ -6,15 +6,16 @@ namespace ray {
|
||||
CoreWorker::CoreWorker(const enum WorkerType worker_type,
|
||||
const enum WorkerLanguage language,
|
||||
const std::string &store_socket, const std::string &raylet_socket,
|
||||
DriverID driver_id)
|
||||
const JobID &job_id)
|
||||
: worker_type_(worker_type),
|
||||
language_(language),
|
||||
store_socket_(store_socket),
|
||||
raylet_socket_(raylet_socket),
|
||||
worker_context_(worker_type, driver_id),
|
||||
raylet_client_(raylet_socket_, worker_context_.GetWorkerID(),
|
||||
worker_context_(worker_type, job_id),
|
||||
raylet_client_(raylet_socket_,
|
||||
ClientID::FromBinary(worker_context_.GetWorkerID().Binary()),
|
||||
(worker_type_ == ray::WorkerType::WORKER),
|
||||
worker_context_.GetCurrentDriverID(), ToTaskLanguage(language_)),
|
||||
worker_context_.GetCurrentJobID(), ToTaskLanguage(language_)),
|
||||
task_interface_(*this),
|
||||
object_interface_(*this),
|
||||
task_execution_interface_(*this) {
|
||||
|
||||
@@ -24,7 +24,7 @@ class CoreWorker {
|
||||
/// NOTE(zhijunfu): the constructor would throw if a failure happens.
|
||||
CoreWorker(const WorkerType worker_type, const WorkerLanguage language,
|
||||
const std::string &store_socket, const std::string &raylet_socket,
|
||||
DriverID driver_id = DriverID::Nil());
|
||||
const JobID &job_id = JobID::Nil());
|
||||
|
||||
/// Type of this worker.
|
||||
enum WorkerType WorkerType() const { return worker_type_; }
|
||||
|
||||
@@ -126,7 +126,7 @@ class CoreWorkerTest : public ::testing::Test {
|
||||
void TestNormalTask(const std::unordered_map<std::string, double> &resources) {
|
||||
CoreWorker driver(WorkerType::DRIVER, WorkerLanguage::PYTHON,
|
||||
raylet_store_socket_names_[0], raylet_socket_names_[0],
|
||||
DriverID::FromRandom());
|
||||
JobID::FromRandom());
|
||||
|
||||
// Test pass by value.
|
||||
{
|
||||
@@ -184,7 +184,7 @@ class CoreWorkerTest : public ::testing::Test {
|
||||
void TestActorTask(const std::unordered_map<std::string, double> &resources) {
|
||||
CoreWorker driver(WorkerType::DRIVER, WorkerLanguage::PYTHON,
|
||||
raylet_store_socket_names_[0], raylet_socket_names_[0],
|
||||
DriverID::FromRandom());
|
||||
JobID::FromRandom());
|
||||
|
||||
std::unique_ptr<ActorHandle> actor_handle;
|
||||
|
||||
@@ -275,9 +275,9 @@ TEST_F(ZeroNodeTest, TestTaskArg) {
|
||||
}
|
||||
|
||||
TEST_F(ZeroNodeTest, TestWorkerContext) {
|
||||
auto driver_id = DriverID::FromRandom();
|
||||
auto job_id = JobID::FromRandom();
|
||||
|
||||
WorkerContext context(WorkerType::WORKER, driver_id);
|
||||
WorkerContext context(WorkerType::WORKER, job_id);
|
||||
ASSERT_TRUE(context.GetCurrentTaskID().IsNil());
|
||||
ASSERT_EQ(context.GetNextTaskIndex(), 1);
|
||||
ASSERT_EQ(context.GetNextTaskIndex(), 2);
|
||||
@@ -302,7 +302,7 @@ TEST_F(ZeroNodeTest, TestWorkerContext) {
|
||||
TEST_F(SingleNodeTest, TestObjectInterface) {
|
||||
CoreWorker core_worker(WorkerType::DRIVER, WorkerLanguage::PYTHON,
|
||||
raylet_store_socket_names_[0], raylet_socket_names_[0],
|
||||
DriverID::FromRandom());
|
||||
JobID::FromRandom());
|
||||
|
||||
uint8_t array1[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
uint8_t array2[] = {10, 11, 12, 13, 14, 15};
|
||||
@@ -358,11 +358,11 @@ TEST_F(SingleNodeTest, TestObjectInterface) {
|
||||
TEST_F(TwoNodeTest, TestObjectInterfaceCrossNodes) {
|
||||
CoreWorker worker1(WorkerType::DRIVER, WorkerLanguage::PYTHON,
|
||||
raylet_store_socket_names_[0], raylet_socket_names_[0],
|
||||
DriverID::FromRandom());
|
||||
JobID::FromRandom());
|
||||
|
||||
CoreWorker worker2(WorkerType::DRIVER, WorkerLanguage::PYTHON,
|
||||
raylet_store_socket_names_[1], raylet_socket_names_[1],
|
||||
DriverID::FromRandom());
|
||||
JobID::FromRandom());
|
||||
|
||||
uint8_t array1[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
uint8_t array2[] = {10, 11, 12, 13, 14, 15};
|
||||
@@ -446,7 +446,7 @@ TEST_F(TwoNodeTest, TestActorTaskCrossNodes) {
|
||||
TEST_F(SingleNodeTest, TestCoreWorkerConstructorFailure) {
|
||||
try {
|
||||
CoreWorker core_worker(WorkerType::DRIVER, WorkerLanguage::PYTHON, "",
|
||||
raylet_socket_names_[0], DriverID::FromRandom());
|
||||
raylet_socket_names_[0], JobID::FromRandom());
|
||||
} catch (const std::exception &e) {
|
||||
std::cout << "Caught exception when constructing core worker: " << e.what();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class MockWorker {
|
||||
public:
|
||||
MockWorker(const std::string &store_socket, const std::string &raylet_socket)
|
||||
: worker_(WorkerType::WORKER, WorkerLanguage::PYTHON, store_socket, raylet_socket,
|
||||
DriverID::FromRandom()) {}
|
||||
JobID::FromRandom()) {}
|
||||
|
||||
void Run() {
|
||||
auto executor_func = [this](const RayFunction &ray_function,
|
||||
|
||||
@@ -20,7 +20,7 @@ Status CoreWorkerTaskInterface::SubmitTask(const RayFunction &function,
|
||||
std::vector<ObjectID> *return_ids) {
|
||||
auto &context = core_worker_.worker_context_;
|
||||
auto next_task_index = context.GetNextTaskIndex();
|
||||
const auto task_id = GenerateTaskId(context.GetCurrentDriverID(),
|
||||
const auto task_id = GenerateTaskId(context.GetCurrentJobID(),
|
||||
context.GetCurrentTaskID(), next_task_index);
|
||||
|
||||
auto num_returns = task_options.num_returns;
|
||||
@@ -32,7 +32,7 @@ Status CoreWorkerTaskInterface::SubmitTask(const RayFunction &function,
|
||||
auto task_arguments = BuildTaskArguments(args);
|
||||
auto language = core_worker_.ToTaskLanguage(function.language);
|
||||
|
||||
ray::raylet::TaskSpecification spec(context.GetCurrentDriverID(),
|
||||
ray::raylet::TaskSpecification spec(context.GetCurrentJobID(),
|
||||
context.GetCurrentTaskID(), next_task_index,
|
||||
task_arguments, num_returns, task_options.resources,
|
||||
language, function.function_descriptor);
|
||||
@@ -48,7 +48,7 @@ Status CoreWorkerTaskInterface::CreateActor(
|
||||
std::unique_ptr<ActorHandle> *actor_handle) {
|
||||
auto &context = core_worker_.worker_context_;
|
||||
auto next_task_index = context.GetNextTaskIndex();
|
||||
const auto task_id = GenerateTaskId(context.GetCurrentDriverID(),
|
||||
const auto task_id = GenerateTaskId(context.GetCurrentJobID(),
|
||||
context.GetCurrentTaskID(), next_task_index);
|
||||
|
||||
std::vector<ObjectID> return_ids;
|
||||
@@ -66,7 +66,7 @@ Status CoreWorkerTaskInterface::CreateActor(
|
||||
// Note that the caller is supposed to specify required placement resources
|
||||
// correctly via actor_creation_options.resources.
|
||||
ray::raylet::TaskSpecification spec(
|
||||
context.GetCurrentDriverID(), context.GetCurrentTaskID(), next_task_index,
|
||||
context.GetCurrentJobID(), context.GetCurrentTaskID(), next_task_index,
|
||||
actor_creation_id, ObjectID::Nil(), actor_creation_options.max_reconstructions,
|
||||
ActorID::Nil(), ActorHandleID::Nil(), 0, {}, task_arguments, 1,
|
||||
actor_creation_options.resources, actor_creation_options.resources, language,
|
||||
@@ -84,7 +84,7 @@ Status CoreWorkerTaskInterface::SubmitActorTask(ActorHandle &actor_handle,
|
||||
std::vector<ObjectID> *return_ids) {
|
||||
auto &context = core_worker_.worker_context_;
|
||||
auto next_task_index = context.GetNextTaskIndex();
|
||||
const auto task_id = GenerateTaskId(context.GetCurrentDriverID(),
|
||||
const auto task_id = GenerateTaskId(context.GetCurrentJobID(),
|
||||
context.GetCurrentTaskID(), next_task_index);
|
||||
|
||||
// add one for actor cursor object id.
|
||||
@@ -102,7 +102,7 @@ Status CoreWorkerTaskInterface::SubmitActorTask(ActorHandle &actor_handle,
|
||||
|
||||
std::vector<ActorHandleID> new_actor_handles;
|
||||
ray::raylet::TaskSpecification spec(
|
||||
context.GetCurrentDriverID(), context.GetCurrentTaskID(), next_task_index,
|
||||
context.GetCurrentJobID(), context.GetCurrentTaskID(), next_task_index,
|
||||
ActorID::Nil(), actor_creation_dummy_object_id, 0, actor_handle.ActorID(),
|
||||
actor_handle.ActorHandleID(), actor_handle.IncreaseTaskCounter(), new_actor_handles,
|
||||
task_arguments, num_returns, task_options.resources, task_options.resources,
|
||||
|
||||
@@ -109,7 +109,7 @@ AsyncGcsClient::AsyncGcsClient(const std::string &address, int port,
|
||||
actor_table_.reset(new ActorTable({primary_context_}, this));
|
||||
client_table_.reset(new ClientTable({primary_context_}, this, client_id));
|
||||
error_table_.reset(new ErrorTable({primary_context_}, this));
|
||||
driver_table_.reset(new DriverTable({primary_context_}, this));
|
||||
job_table_.reset(new JobTable({primary_context_}, this));
|
||||
heartbeat_batch_table_.reset(new HeartbeatBatchTable({primary_context_}, this));
|
||||
// Tables below would be sharded.
|
||||
object_table_.reset(new ObjectTable(shard_contexts_, this));
|
||||
@@ -188,7 +188,7 @@ std::string AsyncGcsClient::DebugString() const {
|
||||
result << "\n- ErrorTable: " << error_table_->DebugString();
|
||||
result << "\n- ProfileTable: " << profile_table_->DebugString();
|
||||
result << "\n- ClientTable: " << client_table_->DebugString();
|
||||
result << "\n- DriverTable: " << driver_table_->DebugString();
|
||||
result << "\n- JobTable: " << job_table_->DebugString();
|
||||
return result.str();
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ HeartbeatBatchTable &AsyncGcsClient::heartbeat_batch_table() {
|
||||
|
||||
ErrorTable &AsyncGcsClient::error_table() { return *error_table_; }
|
||||
|
||||
DriverTable &AsyncGcsClient::driver_table() { return *driver_table_; }
|
||||
JobTable &AsyncGcsClient::job_table() { return *job_table_; }
|
||||
|
||||
ProfileTable &AsyncGcsClient::profile_table() { return *profile_table_; }
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class RAY_EXPORT AsyncGcsClient {
|
||||
HeartbeatTable &heartbeat_table();
|
||||
HeartbeatBatchTable &heartbeat_batch_table();
|
||||
ErrorTable &error_table();
|
||||
DriverTable &driver_table();
|
||||
JobTable &job_table();
|
||||
ProfileTable &profile_table();
|
||||
ActorCheckpointTable &actor_checkpoint_table();
|
||||
ActorCheckpointIdTable &actor_checkpoint_id_table();
|
||||
@@ -64,8 +64,8 @@ class RAY_EXPORT AsyncGcsClient {
|
||||
// driver (to set the PYTHONPATH)
|
||||
|
||||
using GetExportCallback = std::function<void(const std::string &data)>;
|
||||
Status AddExport(const std::string &driver_id, std::string &export_data);
|
||||
Status GetExport(const std::string &driver_id, int64_t export_index,
|
||||
Status AddExport(const std::string &job_id, std::string &export_data);
|
||||
Status GetExport(const std::string &job_id, int64_t export_index,
|
||||
const GetExportCallback &done_callback);
|
||||
|
||||
std::vector<std::shared_ptr<RedisContext>> shard_contexts() { return shard_contexts_; }
|
||||
@@ -96,7 +96,7 @@ class RAY_EXPORT AsyncGcsClient {
|
||||
std::vector<std::unique_ptr<RedisAsioClient>> shard_asio_subscribe_clients_;
|
||||
// The following context writes everything to the primary shard
|
||||
std::shared_ptr<RedisContext> primary_context_;
|
||||
std::unique_ptr<DriverTable> driver_table_;
|
||||
std::unique_ptr<JobTable> job_table_;
|
||||
std::unique_ptr<RedisAsioClient> asio_async_auxiliary_client_;
|
||||
std::unique_ptr<RedisAsioClient> asio_subscribe_auxiliary_client_;
|
||||
CommandType command_type_;
|
||||
@@ -105,14 +105,14 @@ class RAY_EXPORT AsyncGcsClient {
|
||||
class SyncGcsClient {
|
||||
Status LogEvent(const std::string &key, const std::string &value, double timestamp);
|
||||
Status NotifyError(const std::map<std::string, std::string> &error_info);
|
||||
Status RegisterFunction(const DriverID &driver_id, const FunctionID &function_id,
|
||||
Status RegisterFunction(const JobID &job_id, const FunctionID &function_id,
|
||||
const std::string &language, const std::string &name,
|
||||
const std::string &data);
|
||||
Status RetrieveFunction(const DriverID &driver_id, const FunctionID &function_id,
|
||||
Status RetrieveFunction(const JobID &job_id, const FunctionID &function_id,
|
||||
std::string *name, std::string *data);
|
||||
|
||||
Status AddExport(const std::string &driver_id, std::string &export_data);
|
||||
Status GetExport(const std::string &driver_id, int64_t export_index, std::string *data);
|
||||
Status AddExport(const std::string &job_id, std::string &export_data);
|
||||
Status GetExport(const std::string &job_id, int64_t export_index, std::string *data);
|
||||
};
|
||||
|
||||
} // namespace gcs
|
||||
|
||||
+202
-214
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,8 @@ table Arg {
|
||||
}
|
||||
|
||||
table TaskInfo {
|
||||
// ID of the driver that created this task.
|
||||
driver_id: string;
|
||||
// ID of the job that created this task.
|
||||
job_id: string;
|
||||
// Task ID of the task.
|
||||
task_id: string;
|
||||
// Task ID of the parent task.
|
||||
|
||||
+50
-51
@@ -39,7 +39,7 @@ namespace ray {
|
||||
namespace gcs {
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Log<ID, Data>::Append(const DriverID &driver_id, const ID &id,
|
||||
Status Log<ID, Data>::Append(const JobID &job_id, const ID &id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done) {
|
||||
num_appends_++;
|
||||
auto callback = [this, id, data, done](const CallbackReply &reply) {
|
||||
@@ -58,7 +58,7 @@ Status Log<ID, Data>::Append(const DriverID &driver_id, const ID &id,
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Log<ID, Data>::AppendAt(const DriverID &driver_id, const ID &id,
|
||||
Status Log<ID, Data>::AppendAt(const JobID &job_id, const ID &id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done,
|
||||
const WriteCallback &failure, int log_length) {
|
||||
num_appends_++;
|
||||
@@ -81,8 +81,7 @@ Status Log<ID, Data>::AppendAt(const DriverID &driver_id, const ID &id,
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Log<ID, Data>::Lookup(const DriverID &driver_id, const ID &id,
|
||||
const Callback &lookup) {
|
||||
Status Log<ID, Data>::Lookup(const JobID &job_id, const ID &id, const Callback &lookup) {
|
||||
num_lookups_++;
|
||||
auto callback = [this, id, lookup](const CallbackReply &reply) {
|
||||
if (lookup != nullptr) {
|
||||
@@ -106,7 +105,7 @@ Status Log<ID, Data>::Lookup(const DriverID &driver_id, const ID &id,
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Log<ID, Data>::Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Log<ID, Data>::Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const Callback &subscribe,
|
||||
const SubscriptionCallback &done) {
|
||||
auto subscribe_wrapper = [subscribe](AsyncGcsClient *client, const ID &id,
|
||||
@@ -115,11 +114,11 @@ Status Log<ID, Data>::Subscribe(const DriverID &driver_id, const ClientID &clien
|
||||
RAY_CHECK(change_mode != GcsChangeMode::REMOVE);
|
||||
subscribe(client, id, data);
|
||||
};
|
||||
return Subscribe(driver_id, client_id, subscribe_wrapper, done);
|
||||
return Subscribe(job_id, client_id, subscribe_wrapper, done);
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Log<ID, Data>::Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Log<ID, Data>::Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const NotificationCallback &subscribe,
|
||||
const SubscriptionCallback &done) {
|
||||
RAY_CHECK(subscribe_callback_index_ == -1)
|
||||
@@ -160,7 +159,7 @@ Status Log<ID, Data>::Subscribe(const DriverID &driver_id, const ClientID &clien
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Log<ID, Data>::RequestNotifications(const DriverID &driver_id, const ID &id,
|
||||
Status Log<ID, Data>::RequestNotifications(const JobID &job_id, const ID &id,
|
||||
const ClientID &client_id) {
|
||||
RAY_CHECK(subscribe_callback_index_ >= 0)
|
||||
<< "Client requested notifications on a key before Subscribe completed";
|
||||
@@ -170,7 +169,7 @@ Status Log<ID, Data>::RequestNotifications(const DriverID &driver_id, const ID &
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Log<ID, Data>::CancelNotifications(const DriverID &driver_id, const ID &id,
|
||||
Status Log<ID, Data>::CancelNotifications(const JobID &job_id, const ID &id,
|
||||
const ClientID &client_id) {
|
||||
RAY_CHECK(subscribe_callback_index_ >= 0)
|
||||
<< "Client canceled notifications on a key before Subscribe completed";
|
||||
@@ -180,7 +179,7 @@ Status Log<ID, Data>::CancelNotifications(const DriverID &driver_id, const ID &i
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
void Log<ID, Data>::Delete(const DriverID &driver_id, const std::vector<ID> &ids) {
|
||||
void Log<ID, Data>::Delete(const JobID &job_id, const std::vector<ID> &ids) {
|
||||
if (ids.empty()) {
|
||||
return;
|
||||
}
|
||||
@@ -214,8 +213,8 @@ void Log<ID, Data>::Delete(const DriverID &driver_id, const std::vector<ID> &ids
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
void Log<ID, Data>::Delete(const DriverID &driver_id, const ID &id) {
|
||||
Delete(driver_id, std::vector<ID>({id}));
|
||||
void Log<ID, Data>::Delete(const JobID &job_id, const ID &id) {
|
||||
Delete(job_id, std::vector<ID>({id}));
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
@@ -226,7 +225,7 @@ std::string Log<ID, Data>::DebugString() const {
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Table<ID, Data>::Add(const DriverID &driver_id, const ID &id,
|
||||
Status Table<ID, Data>::Add(const JobID &job_id, const ID &id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done) {
|
||||
num_adds_++;
|
||||
auto callback = [this, id, data, done](const CallbackReply &reply) {
|
||||
@@ -241,10 +240,10 @@ Status Table<ID, Data>::Add(const DriverID &driver_id, const ID &id,
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Table<ID, Data>::Lookup(const DriverID &driver_id, const ID &id,
|
||||
const Callback &lookup, const FailureCallback &failure) {
|
||||
Status Table<ID, Data>::Lookup(const JobID &job_id, const ID &id, const Callback &lookup,
|
||||
const FailureCallback &failure) {
|
||||
num_lookups_++;
|
||||
return Log<ID, Data>::Lookup(driver_id, id,
|
||||
return Log<ID, Data>::Lookup(job_id, id,
|
||||
[lookup, failure](AsyncGcsClient *client, const ID &id,
|
||||
const std::vector<Data> &data) {
|
||||
if (data.empty()) {
|
||||
@@ -261,12 +260,12 @@ Status Table<ID, Data>::Lookup(const DriverID &driver_id, const ID &id,
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Table<ID, Data>::Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Table<ID, Data>::Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const Callback &subscribe,
|
||||
const FailureCallback &failure,
|
||||
const SubscriptionCallback &done) {
|
||||
return Log<ID, Data>::Subscribe(
|
||||
driver_id, client_id,
|
||||
job_id, client_id,
|
||||
[subscribe, failure](AsyncGcsClient *client, const ID &id,
|
||||
const std::vector<Data> &data) {
|
||||
RAY_CHECK(data.empty() || data.size() == 1);
|
||||
@@ -289,8 +288,8 @@ std::string Table<ID, Data>::DebugString() const {
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Set<ID, Data>::Add(const DriverID &driver_id, const ID &id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done) {
|
||||
Status Set<ID, Data>::Add(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done) {
|
||||
num_adds_++;
|
||||
auto callback = [this, id, data, done](const CallbackReply &reply) {
|
||||
if (done != nullptr) {
|
||||
@@ -303,7 +302,7 @@ Status Set<ID, Data>::Add(const DriverID &driver_id, const ID &id,
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Set<ID, Data>::Remove(const DriverID &driver_id, const ID &id,
|
||||
Status Set<ID, Data>::Remove(const JobID &job_id, const ID &id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done) {
|
||||
num_removes_++;
|
||||
auto callback = [this, id, data, done](const CallbackReply &reply) {
|
||||
@@ -325,8 +324,8 @@ std::string Set<ID, Data>::DebugString() const {
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Hash<ID, Data>::Update(const DriverID &driver_id, const ID &id,
|
||||
const DataMap &data_map, const HashCallback &done) {
|
||||
Status Hash<ID, Data>::Update(const JobID &job_id, const ID &id, const DataMap &data_map,
|
||||
const HashCallback &done) {
|
||||
num_adds_++;
|
||||
auto callback = [this, id, data_map, done](const CallbackReply &reply) {
|
||||
if (done != nullptr) {
|
||||
@@ -346,7 +345,7 @@ Status Hash<ID, Data>::Update(const DriverID &driver_id, const ID &id,
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Hash<ID, Data>::RemoveEntries(const DriverID &driver_id, const ID &id,
|
||||
Status Hash<ID, Data>::RemoveEntries(const JobID &job_id, const ID &id,
|
||||
const std::vector<std::string> &keys,
|
||||
const HashRemoveCallback &remove_callback) {
|
||||
num_removes_++;
|
||||
@@ -375,7 +374,7 @@ std::string Hash<ID, Data>::DebugString() const {
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Hash<ID, Data>::Lookup(const DriverID &driver_id, const ID &id,
|
||||
Status Hash<ID, Data>::Lookup(const JobID &job_id, const ID &id,
|
||||
const HashCallback &lookup) {
|
||||
num_lookups_++;
|
||||
auto callback = [this, id, lookup](const CallbackReply &reply) {
|
||||
@@ -403,7 +402,7 @@ Status Hash<ID, Data>::Lookup(const DriverID &driver_id, const ID &id,
|
||||
}
|
||||
|
||||
template <typename ID, typename Data>
|
||||
Status Hash<ID, Data>::Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Hash<ID, Data>::Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const HashNotificationCallback &subscribe,
|
||||
const SubscriptionCallback &done) {
|
||||
RAY_CHECK(subscribe_callback_index_ == -1)
|
||||
@@ -450,25 +449,25 @@ Status Hash<ID, Data>::Subscribe(const DriverID &driver_id, const ClientID &clie
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status ErrorTable::PushErrorToDriver(const DriverID &driver_id, const std::string &type,
|
||||
Status ErrorTable::PushErrorToDriver(const JobID &job_id, const std::string &type,
|
||||
const std::string &error_message, double timestamp) {
|
||||
auto data = std::make_shared<ErrorTableData>();
|
||||
data->set_driver_id(driver_id.Binary());
|
||||
data->set_job_id(job_id.Binary());
|
||||
data->set_type(type);
|
||||
data->set_error_message(error_message);
|
||||
data->set_timestamp(timestamp);
|
||||
return Append(DriverID(driver_id), driver_id, data, /*done_callback=*/nullptr);
|
||||
return Append(job_id, job_id, data, /*done_callback=*/nullptr);
|
||||
}
|
||||
|
||||
std::string ErrorTable::DebugString() const {
|
||||
return Log<DriverID, ErrorTableData>::DebugString();
|
||||
return Log<JobID, ErrorTableData>::DebugString();
|
||||
}
|
||||
|
||||
Status ProfileTable::AddProfileEventBatch(const ProfileTableData &profile_events) {
|
||||
// TODO(hchen): Change the parameter to shared_ptr to avoid copying data.
|
||||
auto data = std::make_shared<ProfileTableData>();
|
||||
data->CopyFrom(profile_events);
|
||||
return Append(DriverID::Nil(), UniqueID::FromRandom(), data,
|
||||
return Append(JobID::Nil(), UniqueID::FromRandom(), data,
|
||||
/*done_callback=*/nullptr);
|
||||
}
|
||||
|
||||
@@ -476,11 +475,11 @@ std::string ProfileTable::DebugString() const {
|
||||
return Log<UniqueID, ProfileTableData>::DebugString();
|
||||
}
|
||||
|
||||
Status DriverTable::AppendDriverData(const DriverID &driver_id, bool is_dead) {
|
||||
auto data = std::make_shared<DriverTableData>();
|
||||
data->set_driver_id(driver_id.Binary());
|
||||
Status JobTable::AppendJobData(const JobID &job_id, bool is_dead) {
|
||||
auto data = std::make_shared<JobTableData>();
|
||||
data->set_job_id(job_id.Binary());
|
||||
data->set_is_dead(is_dead);
|
||||
return Append(DriverID(driver_id), driver_id, data, /*done_callback=*/nullptr);
|
||||
return Append(JobID(job_id), job_id, data, /*done_callback=*/nullptr);
|
||||
}
|
||||
|
||||
void ClientTable::RegisterClientAddedCallback(const ClientTableCallback &callback) {
|
||||
@@ -694,13 +693,13 @@ Status ClientTable::Connect(const ClientTableData &local_client) {
|
||||
// Callback to request notifications from the client table once we've
|
||||
// successfully subscribed.
|
||||
auto subscription_callback = [this](AsyncGcsClient *c) {
|
||||
RAY_CHECK_OK(RequestNotifications(DriverID::Nil(), client_log_key_, client_id_));
|
||||
RAY_CHECK_OK(RequestNotifications(JobID::Nil(), client_log_key_, client_id_));
|
||||
};
|
||||
// Subscribe to the client table.
|
||||
RAY_CHECK_OK(Subscribe(DriverID::Nil(), client_id_, notification_callback,
|
||||
RAY_CHECK_OK(Subscribe(JobID::Nil(), client_id_, notification_callback,
|
||||
subscription_callback));
|
||||
};
|
||||
return Append(DriverID::Nil(), client_log_key_, data, add_callback);
|
||||
return Append(JobID::Nil(), client_log_key_, data, add_callback);
|
||||
}
|
||||
|
||||
Status ClientTable::Disconnect(const DisconnectCallback &callback) {
|
||||
@@ -709,12 +708,12 @@ Status ClientTable::Disconnect(const DisconnectCallback &callback) {
|
||||
auto add_callback = [this, callback](AsyncGcsClient *client, const ClientID &id,
|
||||
const ClientTableData &data) {
|
||||
HandleConnected(client, data);
|
||||
RAY_CHECK_OK(CancelNotifications(DriverID::Nil(), client_log_key_, id));
|
||||
RAY_CHECK_OK(CancelNotifications(JobID::Nil(), client_log_key_, id));
|
||||
if (callback != nullptr) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
RAY_RETURN_NOT_OK(Append(DriverID::Nil(), client_log_key_, data, add_callback));
|
||||
RAY_RETURN_NOT_OK(Append(JobID::Nil(), client_log_key_, data, add_callback));
|
||||
// We successfully added the deletion entry. Mark ourselves as disconnected.
|
||||
disconnected_ = true;
|
||||
return Status::OK();
|
||||
@@ -724,7 +723,7 @@ ray::Status ClientTable::MarkDisconnected(const ClientID &dead_client_id) {
|
||||
auto data = std::make_shared<ClientTableData>();
|
||||
data->set_client_id(dead_client_id.Binary());
|
||||
data->set_entry_type(ClientTableData::DELETION);
|
||||
return Append(DriverID::Nil(), client_log_key_, data, nullptr);
|
||||
return Append(JobID::Nil(), client_log_key_, data, nullptr);
|
||||
}
|
||||
|
||||
void ClientTable::GetClient(const ClientID &client_id,
|
||||
@@ -744,7 +743,7 @@ const std::unordered_map<ClientID, ClientTableData> &ClientTable::GetAllClients(
|
||||
|
||||
Status ClientTable::Lookup(const Callback &lookup) {
|
||||
RAY_CHECK(lookup != nullptr);
|
||||
return Log::Lookup(DriverID::Nil(), client_log_key_, lookup);
|
||||
return Log::Lookup(JobID::Nil(), client_log_key_, lookup);
|
||||
}
|
||||
|
||||
std::string ClientTable::DebugString() const {
|
||||
@@ -755,10 +754,10 @@ std::string ClientTable::DebugString() const {
|
||||
return result.str();
|
||||
}
|
||||
|
||||
Status ActorCheckpointIdTable::AddCheckpointId(const DriverID &driver_id,
|
||||
Status ActorCheckpointIdTable::AddCheckpointId(const JobID &job_id,
|
||||
const ActorID &actor_id,
|
||||
const ActorCheckpointID &checkpoint_id) {
|
||||
auto lookup_callback = [this, checkpoint_id, driver_id, actor_id](
|
||||
auto lookup_callback = [this, checkpoint_id, job_id, actor_id](
|
||||
ray::gcs::AsyncGcsClient *client, const UniqueID &id,
|
||||
const ActorCheckpointIdData &data) {
|
||||
std::shared_ptr<ActorCheckpointIdData> copy =
|
||||
@@ -772,20 +771,20 @@ Status ActorCheckpointIdTable::AddCheckpointId(const DriverID &driver_id,
|
||||
RAY_LOG(DEBUG) << "Deleting checkpoint " << to_delete << " for actor " << actor_id;
|
||||
copy->mutable_checkpoint_ids()->erase(copy->mutable_checkpoint_ids()->begin());
|
||||
copy->mutable_timestamps()->erase(copy->mutable_timestamps()->begin());
|
||||
client_->actor_checkpoint_table().Delete(driver_id, to_delete);
|
||||
client_->actor_checkpoint_table().Delete(job_id, to_delete);
|
||||
}
|
||||
RAY_CHECK_OK(Add(driver_id, actor_id, copy, nullptr));
|
||||
RAY_CHECK_OK(Add(job_id, actor_id, copy, nullptr));
|
||||
};
|
||||
auto failure_callback = [this, checkpoint_id, driver_id, actor_id](
|
||||
auto failure_callback = [this, checkpoint_id, job_id, actor_id](
|
||||
ray::gcs::AsyncGcsClient *client, const UniqueID &id) {
|
||||
std::shared_ptr<ActorCheckpointIdData> data =
|
||||
std::make_shared<ActorCheckpointIdData>();
|
||||
data->set_actor_id(id.Binary());
|
||||
data->add_timestamps(current_sys_time_ms());
|
||||
*data->add_checkpoint_ids() = checkpoint_id.Binary();
|
||||
RAY_CHECK_OK(Add(driver_id, actor_id, data, nullptr));
|
||||
RAY_CHECK_OK(Add(job_id, actor_id, data, nullptr));
|
||||
};
|
||||
return Lookup(driver_id, actor_id, lookup_callback, failure_callback);
|
||||
return Lookup(job_id, actor_id, lookup_callback, failure_callback);
|
||||
}
|
||||
|
||||
template class Log<ObjectID, ObjectTableData>;
|
||||
@@ -797,9 +796,9 @@ template class Log<TaskID, TaskReconstructionData>;
|
||||
template class Table<TaskID, TaskLeaseData>;
|
||||
template class Table<ClientID, HeartbeatTableData>;
|
||||
template class Table<ClientID, HeartbeatBatchTableData>;
|
||||
template class Log<DriverID, ErrorTableData>;
|
||||
template class Log<JobID, ErrorTableData>;
|
||||
template class Log<ClientID, ClientTableData>;
|
||||
template class Log<DriverID, DriverTableData>;
|
||||
template class Log<JobID, JobTableData>;
|
||||
template class Log<UniqueID, ProfileTableData>;
|
||||
template class Table<ActorCheckpointID, ActorCheckpointData>;
|
||||
template class Table<ActorID, ActorCheckpointIdData>;
|
||||
|
||||
+77
-82
@@ -24,12 +24,12 @@ using rpc::ActorCheckpointData;
|
||||
using rpc::ActorCheckpointIdData;
|
||||
using rpc::ActorTableData;
|
||||
using rpc::ClientTableData;
|
||||
using rpc::DriverTableData;
|
||||
using rpc::ErrorTableData;
|
||||
using rpc::GcsChangeMode;
|
||||
using rpc::GcsEntry;
|
||||
using rpc::HeartbeatBatchTableData;
|
||||
using rpc::HeartbeatTableData;
|
||||
using rpc::JobTableData;
|
||||
using rpc::ObjectTableData;
|
||||
using rpc::ProfileTableData;
|
||||
using rpc::RayResource;
|
||||
@@ -55,9 +55,9 @@ enum class CommandType { kRegular, kChain };
|
||||
template <typename ID>
|
||||
class PubsubInterface {
|
||||
public:
|
||||
virtual Status RequestNotifications(const DriverID &driver_id, const ID &id,
|
||||
virtual Status RequestNotifications(const JobID &job_id, const ID &id,
|
||||
const ClientID &client_id) = 0;
|
||||
virtual Status CancelNotifications(const DriverID &driver_id, const ID &id,
|
||||
virtual Status CancelNotifications(const JobID &job_id, const ID &id,
|
||||
const ClientID &client_id) = 0;
|
||||
virtual ~PubsubInterface(){};
|
||||
};
|
||||
@@ -67,9 +67,9 @@ class LogInterface {
|
||||
public:
|
||||
using WriteCallback =
|
||||
std::function<void(AsyncGcsClient *client, const ID &id, const Data &data)>;
|
||||
virtual Status Append(const DriverID &driver_id, const ID &id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done) = 0;
|
||||
virtual Status AppendAt(const DriverID &driver_id, const ID &task_id,
|
||||
virtual Status Append(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done) = 0;
|
||||
virtual Status AppendAt(const JobID &job_id, const ID &task_id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done,
|
||||
const WriteCallback &failure, int log_length) = 0;
|
||||
virtual ~LogInterface(){};
|
||||
@@ -119,20 +119,20 @@ class Log : public LogInterface<ID, Data>, virtual public PubsubInterface<ID> {
|
||||
|
||||
/// Append a log entry to a key.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is added to the GCS.
|
||||
/// \param data Data to append to the log. TODO(rkn): This can be made const,
|
||||
/// right?
|
||||
/// \param done Callback that is called once the data has been written to the
|
||||
/// GCS.
|
||||
/// \return Status
|
||||
Status Append(const DriverID &driver_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
Status Append(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done);
|
||||
|
||||
/// Append a log entry to a key if and only if the log has the given number
|
||||
/// of entries.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is added to the GCS.
|
||||
/// \param data Data to append to the log.
|
||||
/// \param done Callback that is called if the data was appended to the log.
|
||||
@@ -141,25 +141,22 @@ class Log : public LogInterface<ID, Data>, virtual public PubsubInterface<ID> {
|
||||
/// \param log_length The number of entries that the log must have for the
|
||||
/// append to succeed.
|
||||
/// \return Status
|
||||
Status AppendAt(const DriverID &driver_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
Status AppendAt(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done, const WriteCallback &failure,
|
||||
int log_length);
|
||||
|
||||
/// Lookup the log values at a key asynchronously.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is looked up in the GCS.
|
||||
/// \param lookup Callback that is called after lookup. If the callback is
|
||||
/// called with an empty vector, then there was no data at the key.
|
||||
/// \return Status
|
||||
Status Lookup(const DriverID &driver_id, const ID &id, const Callback &lookup);
|
||||
|
||||
Status Lookup(const JobID &job_id, const ID &id, const Callback &lookup);
|
||||
/// Subscribe to any Append operations to this table. The caller may choose
|
||||
/// to subscribe to all Appends, or to subscribe only to keys that it
|
||||
/// requests notifications for. This may only be called once per Log
|
||||
/// instance.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param client_id The type of update to listen to. If this is nil, then a
|
||||
/// message for each Add to the table will be received. Else, only
|
||||
/// messages for the given client will be received. In the latter
|
||||
@@ -170,7 +167,7 @@ class Log : public LogInterface<ID, Data>, virtual public PubsubInterface<ID> {
|
||||
/// \param done Callback that is called when subscription is complete and we
|
||||
/// are ready to receive messages.
|
||||
/// \return Status
|
||||
Status Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const Callback &subscribe, const SubscriptionCallback &done);
|
||||
|
||||
/// Request notifications about a key in this table.
|
||||
@@ -182,37 +179,37 @@ class Log : public LogInterface<ID, Data>, virtual public PubsubInterface<ID> {
|
||||
/// notifications can be requested, the caller must first call `Subscribe`,
|
||||
/// with the same `client_id`.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the key to request notifications for.
|
||||
/// \param client_id The client who is requesting notifications. Before
|
||||
/// notifications can be requested, a call to `Subscribe` to this
|
||||
/// table with the same `client_id` must complete successfully.
|
||||
/// \return Status
|
||||
Status RequestNotifications(const DriverID &driver_id, const ID &id,
|
||||
Status RequestNotifications(const JobID &job_id, const ID &id,
|
||||
const ClientID &client_id);
|
||||
|
||||
/// Cancel notifications about a key in this table.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the key to request notifications for.
|
||||
/// \param client_id The client who originally requested notifications.
|
||||
/// \return Status
|
||||
Status CancelNotifications(const DriverID &driver_id, const ID &id,
|
||||
Status CancelNotifications(const JobID &job_id, const ID &id,
|
||||
const ClientID &client_id);
|
||||
|
||||
/// Delete an entire key from redis.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data to delete from the GCS.
|
||||
/// \return Void.
|
||||
void Delete(const DriverID &driver_id, const ID &id);
|
||||
void Delete(const JobID &job_id, const ID &id);
|
||||
|
||||
/// Delete several keys from redis.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param ids The vector of IDs to delete from the GCS.
|
||||
/// \return Void.
|
||||
void Delete(const DriverID &driver_id, const std::vector<ID> &ids);
|
||||
void Delete(const JobID &job_id, const std::vector<ID> &ids);
|
||||
|
||||
/// Returns debug string for class.
|
||||
///
|
||||
@@ -232,7 +229,7 @@ class Log : public LogInterface<ID, Data>, virtual public PubsubInterface<ID> {
|
||||
/// an additional parameter change_mode in NotificationCallback. Therefore this
|
||||
/// function supports notifications of remove operations.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param client_id The type of update to listen to. If this is nil, then a
|
||||
/// message for each Add to the table will be received. Else, only
|
||||
/// messages for the given client will be received. In the latter
|
||||
@@ -243,7 +240,7 @@ class Log : public LogInterface<ID, Data>, virtual public PubsubInterface<ID> {
|
||||
/// \param done Callback that is called when subscription is complete and we
|
||||
/// are ready to receive messages.
|
||||
/// \return Status
|
||||
Status Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const NotificationCallback &subscribe,
|
||||
const SubscriptionCallback &done);
|
||||
|
||||
@@ -275,8 +272,8 @@ template <typename ID, typename Data>
|
||||
class TableInterface {
|
||||
public:
|
||||
using WriteCallback = typename Log<ID, Data>::WriteCallback;
|
||||
virtual Status Add(const DriverID &driver_id, const ID &task_id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done) = 0;
|
||||
virtual Status Add(const JobID &job_id, const ID &task_id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done) = 0;
|
||||
virtual ~TableInterface(){};
|
||||
};
|
||||
|
||||
@@ -312,32 +309,32 @@ class Table : private Log<ID, Data>,
|
||||
|
||||
/// Add an entry to the table. This overwrites any existing data at the key.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is added to the GCS.
|
||||
/// \param data Data that is added to the GCS.
|
||||
/// \param done Callback that is called once the data has been written to the
|
||||
/// GCS.
|
||||
/// \return Status
|
||||
Status Add(const DriverID &driver_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
Status Add(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done);
|
||||
|
||||
/// Lookup an entry asynchronously.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is looked up in the GCS.
|
||||
/// \param lookup Callback that is called after lookup if there was data the
|
||||
/// key.
|
||||
/// \param failure Callback that is called after lookup if there was no data
|
||||
/// at the key.
|
||||
/// \return Status
|
||||
Status Lookup(const DriverID &driver_id, const ID &id, const Callback &lookup,
|
||||
Status Lookup(const JobID &job_id, const ID &id, const Callback &lookup,
|
||||
const FailureCallback &failure);
|
||||
|
||||
/// Subscribe to any Add operations to this table. The caller may choose to
|
||||
/// subscribe to all Adds, or to subscribe only to keys that it requests
|
||||
/// notifications for. This may only be called once per Table instance.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param client_id The type of update to listen to. If this is nil, then a
|
||||
/// message for each Add to the table will be received. Else, only
|
||||
/// messages for the given client will be received. In the latter
|
||||
@@ -350,16 +347,14 @@ class Table : private Log<ID, Data>,
|
||||
/// \param done Callback that is called when subscription is complete and we
|
||||
/// are ready to receive messages.
|
||||
/// \return Status
|
||||
Status Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const Callback &subscribe, const FailureCallback &failure,
|
||||
const SubscriptionCallback &done);
|
||||
|
||||
void Delete(const DriverID &driver_id, const ID &id) {
|
||||
Log<ID, Data>::Delete(driver_id, id);
|
||||
}
|
||||
void Delete(const JobID &job_id, const ID &id) { Log<ID, Data>::Delete(job_id, id); }
|
||||
|
||||
void Delete(const DriverID &driver_id, const std::vector<ID> &ids) {
|
||||
Log<ID, Data>::Delete(driver_id, ids);
|
||||
void Delete(const JobID &job_id, const std::vector<ID> &ids) {
|
||||
Log<ID, Data>::Delete(job_id, ids);
|
||||
}
|
||||
|
||||
/// Returns debug string for class.
|
||||
@@ -383,10 +378,10 @@ template <typename ID, typename Data>
|
||||
class SetInterface {
|
||||
public:
|
||||
using WriteCallback = typename Log<ID, Data>::WriteCallback;
|
||||
virtual Status Add(const DriverID &driver_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
virtual Status Add(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done) = 0;
|
||||
virtual Status Remove(const DriverID &driver_id, const ID &id,
|
||||
std::shared_ptr<Data> &data, const WriteCallback &done) = 0;
|
||||
virtual Status Remove(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done) = 0;
|
||||
virtual ~SetInterface(){};
|
||||
};
|
||||
|
||||
@@ -419,30 +414,30 @@ class Set : private Log<ID, Data>,
|
||||
|
||||
/// Add an entry to the set.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is added to the GCS.
|
||||
/// \param data Data to add to the set.
|
||||
/// \param done Callback that is called once the data has been written to the
|
||||
/// GCS.
|
||||
/// \return Status
|
||||
Status Add(const DriverID &driver_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
Status Add(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done);
|
||||
|
||||
/// Remove an entry from the set.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is removed from the GCS.
|
||||
/// \param data Data to remove from the set.
|
||||
/// \param done Callback that is called once the data has been written to the
|
||||
/// GCS.
|
||||
/// \return Status
|
||||
Status Remove(const DriverID &driver_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
Status Remove(const JobID &job_id, const ID &id, std::shared_ptr<Data> &data,
|
||||
const WriteCallback &done);
|
||||
|
||||
Status Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const NotificationCallback &subscribe,
|
||||
const SubscriptionCallback &done) {
|
||||
return Log<ID, Data>::Subscribe(driver_id, client_id, subscribe, done);
|
||||
return Log<ID, Data>::Subscribe(job_id, client_id, subscribe, done);
|
||||
}
|
||||
|
||||
/// Returns debug string for class.
|
||||
@@ -499,40 +494,40 @@ class HashInterface {
|
||||
|
||||
/// Add entries of a hash table.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is added to the GCS.
|
||||
/// \param pairs Map data to add to the hash table.
|
||||
/// \param done HashCallback that is called once the request data has been written to
|
||||
/// the GCS.
|
||||
/// \return Status
|
||||
virtual Status Update(const DriverID &driver_id, const ID &id, const DataMap &pairs,
|
||||
virtual Status Update(const JobID &job_id, const ID &id, const DataMap &pairs,
|
||||
const HashCallback &done) = 0;
|
||||
|
||||
/// Remove entries from the hash table.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is removed from the GCS.
|
||||
/// \param keys The entry keys of the hash table.
|
||||
/// \param remove_callback HashRemoveCallback that is called once the data has been
|
||||
/// written to the GCS no matter whether the key exists in the hash table.
|
||||
/// \return Status
|
||||
virtual Status RemoveEntries(const DriverID &driver_id, const ID &id,
|
||||
virtual Status RemoveEntries(const JobID &job_id, const ID &id,
|
||||
const std::vector<std::string> &keys,
|
||||
const HashRemoveCallback &remove_callback) = 0;
|
||||
|
||||
/// Lookup the map data of a hash table.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param id The ID of the data that is looked up in the GCS.
|
||||
/// \param lookup HashCallback that is called after lookup. If the callback is
|
||||
/// called with an empty hash table, then there was no data in the callback.
|
||||
/// \return Status
|
||||
virtual Status Lookup(const DriverID &driver_id, const ID &id,
|
||||
virtual Status Lookup(const JobID &job_id, const ID &id,
|
||||
const HashCallback &lookup) = 0;
|
||||
|
||||
/// Subscribe to any Update or Remove operations to this hash table.
|
||||
///
|
||||
/// \param driver_id The ID of the driver.
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param client_id The type of update to listen to. If this is nil, then a
|
||||
/// message for each Update to the table will be received. Else, only
|
||||
/// messages for the given client will be received. In the latter
|
||||
@@ -542,7 +537,7 @@ class HashInterface {
|
||||
/// \param done SubscriptionCallback that is called when subscription is complete and
|
||||
/// we are ready to receive messages.
|
||||
/// \return Status
|
||||
virtual Status Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
virtual Status Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const HashNotificationCallback &subscribe,
|
||||
const SubscriptionCallback &done) = 0;
|
||||
|
||||
@@ -567,17 +562,16 @@ class Hash : private Log<ID, Data>,
|
||||
using Log<ID, Data>::RequestNotifications;
|
||||
using Log<ID, Data>::CancelNotifications;
|
||||
|
||||
Status Update(const DriverID &driver_id, const ID &id, const DataMap &pairs,
|
||||
Status Update(const JobID &job_id, const ID &id, const DataMap &pairs,
|
||||
const HashCallback &done) override;
|
||||
|
||||
Status Subscribe(const DriverID &driver_id, const ClientID &client_id,
|
||||
Status Subscribe(const JobID &job_id, const ClientID &client_id,
|
||||
const HashNotificationCallback &subscribe,
|
||||
const SubscriptionCallback &done) override;
|
||||
|
||||
Status Lookup(const DriverID &driver_id, const ID &id,
|
||||
const HashCallback &lookup) override;
|
||||
Status Lookup(const JobID &job_id, const ID &id, const HashCallback &lookup) override;
|
||||
|
||||
Status RemoveEntries(const DriverID &driver_id, const ID &id,
|
||||
Status RemoveEntries(const JobID &job_id, const ID &id,
|
||||
const std::vector<std::string> &keys,
|
||||
const HashRemoveCallback &remove_callback) override;
|
||||
|
||||
@@ -645,23 +639,23 @@ class HeartbeatBatchTable : public Table<ClientID, HeartbeatBatchTableData> {
|
||||
virtual ~HeartbeatBatchTable() {}
|
||||
};
|
||||
|
||||
class DriverTable : public Log<DriverID, DriverTableData> {
|
||||
class JobTable : public Log<JobID, JobTableData> {
|
||||
public:
|
||||
DriverTable(const std::vector<std::shared_ptr<RedisContext>> &contexts,
|
||||
AsyncGcsClient *client)
|
||||
JobTable(const std::vector<std::shared_ptr<RedisContext>> &contexts,
|
||||
AsyncGcsClient *client)
|
||||
: Log(contexts, client) {
|
||||
pubsub_channel_ = TablePubsub::DRIVER_PUBSUB;
|
||||
prefix_ = TablePrefix::DRIVER;
|
||||
pubsub_channel_ = TablePubsub::JOB_PUBSUB;
|
||||
prefix_ = TablePrefix::JOB;
|
||||
};
|
||||
|
||||
virtual ~DriverTable() {}
|
||||
virtual ~JobTable() {}
|
||||
|
||||
/// Appends driver data to the driver table.
|
||||
/// Appends job data to the job table.
|
||||
///
|
||||
/// \param driver_id The driver id.
|
||||
/// \param is_dead Whether the driver is dead.
|
||||
/// \param job_id The job id.
|
||||
/// \param is_dead Whether the job is dead.
|
||||
/// \return The return status.
|
||||
Status AppendDriverData(const DriverID &driver_id, bool is_dead);
|
||||
Status AppendJobData(const JobID &job_id, bool is_dead);
|
||||
};
|
||||
|
||||
/// Actor table starts with an ALIVE entry, which represents the first time the actor
|
||||
@@ -697,9 +691,9 @@ class TaskLeaseTable : public Table<TaskID, TaskLeaseData> {
|
||||
prefix_ = TablePrefix::TASK_LEASE;
|
||||
}
|
||||
|
||||
Status Add(const DriverID &driver_id, const TaskID &id,
|
||||
std::shared_ptr<TaskLeaseData> &data, const WriteCallback &done) override {
|
||||
RAY_RETURN_NOT_OK((Table<TaskID, TaskLeaseData>::Add(driver_id, id, data, done)));
|
||||
Status Add(const JobID &job_id, const TaskID &id, std::shared_ptr<TaskLeaseData> &data,
|
||||
const WriteCallback &done) override {
|
||||
RAY_RETURN_NOT_OK((Table<TaskID, TaskLeaseData>::Add(job_id, id, data, done)));
|
||||
// Mark the entry for expiration in Redis. It's okay if this command fails
|
||||
// since the lease entry itself contains the expiration period. In the
|
||||
// worst case, if the command fails, then a client that looks up the lease
|
||||
@@ -733,11 +727,11 @@ class ActorCheckpointIdTable : public Table<ActorID, ActorCheckpointIdData> {
|
||||
/// Add a checkpoint id to an actor, and remove a previous checkpoint if the
|
||||
/// total number of checkpoints in GCS exceeds the max allowed value.
|
||||
///
|
||||
/// \param driver_id The ID of the job (= driver).
|
||||
/// \param job_id The ID of the job.
|
||||
/// \param actor_id ID of the actor.
|
||||
/// \param checkpoint_id ID of the checkpoint.
|
||||
/// \return Status.
|
||||
Status AddCheckpointId(const DriverID &driver_id, const ActorID &actor_id,
|
||||
Status AddCheckpointId(const JobID &job_id, const ActorID &actor_id,
|
||||
const ActorCheckpointID &checkpoint_id);
|
||||
};
|
||||
|
||||
@@ -761,7 +755,7 @@ class TaskTable : public Table<TaskID, TaskTableData> {
|
||||
|
||||
} // namespace raylet
|
||||
|
||||
class ErrorTable : private Log<DriverID, ErrorTableData> {
|
||||
class ErrorTable : private Log<JobID, ErrorTableData> {
|
||||
public:
|
||||
ErrorTable(const std::vector<std::shared_ptr<RedisContext>> &contexts,
|
||||
AsyncGcsClient *client)
|
||||
@@ -770,19 +764,20 @@ class ErrorTable : private Log<DriverID, ErrorTableData> {
|
||||
prefix_ = TablePrefix::ERROR_INFO;
|
||||
};
|
||||
|
||||
/// Push an error message for a specific job.
|
||||
/// Push an error message for the driver of a specific.
|
||||
///
|
||||
/// TODO(rkn): We need to make sure that the errors are unique because
|
||||
/// duplicate messages currently cause failures (the GCS doesn't allow it). A
|
||||
/// natural way to do this is to have finer-grained time stamps.
|
||||
///
|
||||
/// \param driver_id The ID of the job that generated the error. If the error
|
||||
/// should be pushed to all jobs, then this should be nil.
|
||||
/// \param job_id The ID of the job that generated the error. If the error
|
||||
/// should be pushed to all drivers, then this should be nil.
|
||||
/// \param type The type of the error.
|
||||
/// \param error_message The error message to push.
|
||||
/// \param timestamp The timestamp of the error.
|
||||
/// \return Status.
|
||||
Status PushErrorToDriver(const DriverID &driver_id, const std::string &type,
|
||||
// TODO(qwang): refactor this API to implement broadcast.
|
||||
Status PushErrorToDriver(const JobID &job_id, const std::string &type,
|
||||
const std::string &error_message, double timestamp);
|
||||
|
||||
/// Returns debug string for class.
|
||||
|
||||
@@ -74,7 +74,7 @@ void ObjectDirectory::RegisterBackend() {
|
||||
}
|
||||
};
|
||||
RAY_CHECK_OK(gcs_client_->object_table().Subscribe(
|
||||
DriverID::Nil(), gcs_client_->client_table().GetLocalClientId(),
|
||||
JobID::Nil(), gcs_client_->client_table().GetLocalClientId(),
|
||||
object_notification_callback, nullptr));
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ ray::Status ObjectDirectory::ReportObjectAdded(
|
||||
data->set_manager(client_id.Binary());
|
||||
data->set_object_size(object_info.data_size);
|
||||
ray::Status status =
|
||||
gcs_client_->object_table().Add(DriverID::Nil(), object_id, data, nullptr);
|
||||
gcs_client_->object_table().Add(JobID::Nil(), object_id, data, nullptr);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ ray::Status ObjectDirectory::ReportObjectRemoved(
|
||||
data->set_manager(client_id.Binary());
|
||||
data->set_object_size(object_info.data_size);
|
||||
ray::Status status =
|
||||
gcs_client_->object_table().Remove(DriverID::Nil(), object_id, data, nullptr);
|
||||
gcs_client_->object_table().Remove(JobID::Nil(), object_id, data, nullptr);
|
||||
return status;
|
||||
};
|
||||
|
||||
@@ -159,7 +159,7 @@ ray::Status ObjectDirectory::SubscribeObjectLocations(const UniqueID &callback_i
|
||||
if (it == listeners_.end()) {
|
||||
it = listeners_.emplace(object_id, LocationListenerState()).first;
|
||||
status = gcs_client_->object_table().RequestNotifications(
|
||||
DriverID::Nil(), object_id, gcs_client_->client_table().GetLocalClientId());
|
||||
JobID::Nil(), object_id, gcs_client_->client_table().GetLocalClientId());
|
||||
}
|
||||
auto &listener_state = it->second;
|
||||
// TODO(hme): Make this fatal after implementing Pull suppression.
|
||||
@@ -187,7 +187,7 @@ ray::Status ObjectDirectory::UnsubscribeObjectLocations(const UniqueID &callback
|
||||
entry->second.callbacks.erase(callback_id);
|
||||
if (entry->second.callbacks.empty()) {
|
||||
status = gcs_client_->object_table().CancelNotifications(
|
||||
DriverID::Nil(), object_id, gcs_client_->client_table().GetLocalClientId());
|
||||
JobID::Nil(), object_id, gcs_client_->client_table().GetLocalClientId());
|
||||
listeners_.erase(entry);
|
||||
}
|
||||
return status;
|
||||
@@ -210,7 +210,7 @@ ray::Status ObjectDirectory::LookupLocations(const ObjectID &object_id,
|
||||
// SubscribeObjectLocations call, so look up the object's locations
|
||||
// directly from the GCS.
|
||||
status = gcs_client_->object_table().Lookup(
|
||||
DriverID::Nil(), object_id,
|
||||
JobID::Nil(), object_id,
|
||||
[this, callback](gcs::AsyncGcsClient *client, const ObjectID &object_id,
|
||||
const std::vector<ObjectTableData> &location_updates) {
|
||||
// Build the set of current locations based on the entries in the log.
|
||||
|
||||
@@ -25,7 +25,7 @@ enum TablePrefix {
|
||||
HEARTBEAT = 9;
|
||||
HEARTBEAT_BATCH = 10;
|
||||
ERROR_INFO = 11;
|
||||
DRIVER = 12;
|
||||
JOB = 12;
|
||||
PROFILE = 13;
|
||||
TASK_LEASE = 14;
|
||||
ACTOR_CHECKPOINT = 15;
|
||||
@@ -47,7 +47,7 @@ enum TablePubsub {
|
||||
HEARTBEAT_BATCH_PUBSUB = 8;
|
||||
ERROR_INFO_PUBSUB = 9;
|
||||
TASK_LEASE_PUBSUB = 10;
|
||||
DRIVER_PUBSUB = 11;
|
||||
JOB_PUBSUB = 11;
|
||||
NODE_RESOURCE_PUBSUB = 12;
|
||||
TABLE_PUBSUB_MAX = 13;
|
||||
}
|
||||
@@ -102,8 +102,8 @@ message ActorTableData {
|
||||
// dies, then this is the object that should be reconstructed for the actor
|
||||
// to be recreated.
|
||||
bytes actor_creation_dummy_object_id = 2;
|
||||
// The ID of the driver that created the actor.
|
||||
bytes driver_id = 3;
|
||||
// The ID of the job that created the actor.
|
||||
bytes job_id = 3;
|
||||
// The ID of the node manager that created the actor.
|
||||
bytes node_manager_id = 4;
|
||||
// Current state of this actor.
|
||||
@@ -115,8 +115,8 @@ message ActorTableData {
|
||||
}
|
||||
|
||||
message ErrorTableData {
|
||||
// The ID of the driver that the error is for.
|
||||
bytes driver_id = 1;
|
||||
// The ID of the job that the error is for.
|
||||
bytes job_id = 1;
|
||||
// The type of the error.
|
||||
string type = 2;
|
||||
// The error message.
|
||||
@@ -222,9 +222,9 @@ message TaskLeaseData {
|
||||
uint64 timeout = 3;
|
||||
}
|
||||
|
||||
message DriverTableData {
|
||||
// The driver ID.
|
||||
bytes driver_id = 1;
|
||||
message JobTableData {
|
||||
// The job ID.
|
||||
bytes job_id = 1;
|
||||
// Whether it's dead.
|
||||
bool is_dead = 2;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ const ObjectID ActorRegistration::GetExecutionDependency() const {
|
||||
return execution_dependency_;
|
||||
}
|
||||
|
||||
const DriverID ActorRegistration::GetDriverId() const {
|
||||
return DriverID::FromBinary(actor_table_data_.driver_id());
|
||||
const JobID ActorRegistration::GetJobId() const {
|
||||
return JobID::FromBinary(actor_table_data_.job_id());
|
||||
}
|
||||
|
||||
const int64_t ActorRegistration::GetMaxReconstructions() const {
|
||||
|
||||
@@ -73,8 +73,8 @@ class ActorRegistration {
|
||||
/// \return The execution dependency returned by the actor's creation task.
|
||||
const ObjectID GetActorCreationDependency() const;
|
||||
|
||||
/// Get actor's driver ID.
|
||||
const DriverID GetDriverId() const;
|
||||
/// Get actor's job ID.
|
||||
const JobID GetJobId() const;
|
||||
|
||||
/// Get the max number of times this actor should be reconstructed.
|
||||
const int64_t GetMaxReconstructions() const;
|
||||
|
||||
@@ -135,6 +135,7 @@ table RegisterClientRequest {
|
||||
// The process ID of this worker.
|
||||
worker_pid: long;
|
||||
// The driver ID. This is non-nil if the client is a driver.
|
||||
// TODO(qwang): rename this to driver_task_id.
|
||||
driver_id: string;
|
||||
// Language of this worker.
|
||||
language: Language;
|
||||
@@ -196,7 +197,7 @@ table WaitReply {
|
||||
// This struct is the same as ErrorTableData.
|
||||
table PushErrorRequest {
|
||||
// The ID of the job that the error is for.
|
||||
driver_id: string;
|
||||
job_id: string;
|
||||
// The type of the error.
|
||||
type: string;
|
||||
// The error message.
|
||||
|
||||
@@ -43,12 +43,12 @@ inline bool ThrowRayExceptionIfNotOK(JNIEnv *env, const ray::Status &status) {
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_ray_runtime_raylet_RayletClientImpl_nativeInit(
|
||||
JNIEnv *env, jclass, jstring sockName, jbyteArray workerId, jboolean isWorker,
|
||||
jbyteArray driverId) {
|
||||
jbyteArray jobId) {
|
||||
UniqueIdFromJByteArray<ClientID> worker_id(env, workerId);
|
||||
UniqueIdFromJByteArray<DriverID> driver_id(env, driverId);
|
||||
UniqueIdFromJByteArray<JobID> job_id(env, jobId);
|
||||
const char *nativeString = env->GetStringUTFChars(sockName, JNI_FALSE);
|
||||
auto raylet_client = new RayletClient(nativeString, worker_id.GetId(), isWorker,
|
||||
driver_id.GetId(), Language::JAVA);
|
||||
job_id.GetId(), Language::JAVA);
|
||||
env->ReleaseStringUTFChars(sockName, nativeString);
|
||||
return reinterpret_cast<jlong>(raylet_client);
|
||||
}
|
||||
@@ -224,13 +224,13 @@ Java_org_ray_runtime_raylet_RayletClientImpl_nativeWaitObject(
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_org_ray_runtime_raylet_RayletClientImpl_nativeGenerateTaskId(
|
||||
JNIEnv *env, jclass, jbyteArray driverId, jbyteArray parentTaskId,
|
||||
JNIEnv *env, jclass, jbyteArray jobId, jbyteArray parentTaskId,
|
||||
jint parent_task_counter) {
|
||||
UniqueIdFromJByteArray<DriverID> driver_id(env, driverId);
|
||||
UniqueIdFromJByteArray<JobID> job_id(env, jobId);
|
||||
UniqueIdFromJByteArray<TaskID> parent_task_id(env, parentTaskId);
|
||||
|
||||
TaskID task_id =
|
||||
ray::GenerateTaskId(driver_id.GetId(), parent_task_id.GetId(), parent_task_counter);
|
||||
ray::GenerateTaskId(job_id.GetId(), parent_task_id.GetId(), parent_task_counter);
|
||||
jbyteArray result = env->NewByteArray(task_id.Size());
|
||||
if (nullptr == result) {
|
||||
return nullptr;
|
||||
|
||||
@@ -275,9 +275,8 @@ void LineageCache::FlushTask(const TaskID &task_id) {
|
||||
// TODO(swang): Make this better...
|
||||
auto task_data = std::make_shared<TaskTableData>();
|
||||
task_data->set_task(task->TaskData().Serialize());
|
||||
RAY_CHECK_OK(
|
||||
task_storage_.Add(DriverID(task->TaskData().GetTaskSpecification().DriverId()),
|
||||
task_id, task_data, task_callback));
|
||||
RAY_CHECK_OK(task_storage_.Add(JobID(task->TaskData().GetTaskSpecification().JobId()),
|
||||
task_id, task_data, task_callback));
|
||||
|
||||
// We successfully wrote the task, so mark it as committing.
|
||||
// TODO(swang): Use a batched interface and write with all object entries.
|
||||
@@ -290,7 +289,7 @@ bool LineageCache::SubscribeTask(const TaskID &task_id) {
|
||||
if (unsubscribed) {
|
||||
// Request notifications for the task if we haven't already requested
|
||||
// notifications for it.
|
||||
RAY_CHECK_OK(task_pubsub_.RequestNotifications(DriverID::Nil(), task_id, client_id_));
|
||||
RAY_CHECK_OK(task_pubsub_.RequestNotifications(JobID::Nil(), task_id, client_id_));
|
||||
}
|
||||
// Return whether we were previously unsubscribed to this task and are now
|
||||
// subscribed.
|
||||
@@ -303,7 +302,7 @@ bool LineageCache::UnsubscribeTask(const TaskID &task_id) {
|
||||
if (subscribed) {
|
||||
// Cancel notifications for the task if we previously requested
|
||||
// notifications for it.
|
||||
RAY_CHECK_OK(task_pubsub_.CancelNotifications(DriverID::Nil(), task_id, client_id_));
|
||||
RAY_CHECK_OK(task_pubsub_.CancelNotifications(JobID::Nil(), task_id, client_id_));
|
||||
subscribed_tasks_.erase(it);
|
||||
}
|
||||
// Return whether we were previously subscribed to this task and are now
|
||||
|
||||
@@ -22,7 +22,7 @@ class MockGcs : public gcs::TableInterface<TaskID, TaskTableData>,
|
||||
notification_callback_ = notification_callback;
|
||||
}
|
||||
|
||||
Status Add(const DriverID &driver_id, const TaskID &task_id,
|
||||
Status Add(const JobID &job_id, const TaskID &task_id,
|
||||
std::shared_ptr<TaskTableData> &task_data,
|
||||
const gcs::TableInterface<TaskID, TaskTableData>::WriteCallback &done) {
|
||||
task_table_[task_id] = task_data;
|
||||
@@ -57,10 +57,10 @@ class MockGcs : public gcs::TableInterface<TaskID, TaskTableData>,
|
||||
notification_callback_(client, task_id, data);
|
||||
}
|
||||
};
|
||||
return Add(DriverID::Nil(), task_id, task_data, callback);
|
||||
return Add(JobID::Nil(), task_id, task_data, callback);
|
||||
}
|
||||
|
||||
Status RequestNotifications(const DriverID &driver_id, const TaskID &task_id,
|
||||
Status RequestNotifications(const JobID &job_id, const TaskID &task_id,
|
||||
const ClientID &client_id) {
|
||||
subscribed_tasks_.insert(task_id);
|
||||
if (task_table_.count(task_id) == 1) {
|
||||
@@ -70,7 +70,7 @@ class MockGcs : public gcs::TableInterface<TaskID, TaskTableData>,
|
||||
return ray::Status::OK();
|
||||
}
|
||||
|
||||
Status CancelNotifications(const DriverID &driver_id, const TaskID &task_id,
|
||||
Status CancelNotifications(const JobID &job_id, const TaskID &task_id,
|
||||
const ClientID &client_id) {
|
||||
subscribed_tasks_.erase(task_id);
|
||||
return ray::Status::OK();
|
||||
@@ -133,7 +133,7 @@ static inline Task ExampleTask(const std::vector<ObjectID> &arguments,
|
||||
task_arguments.emplace_back(std::make_shared<TaskArgumentByReference>(references));
|
||||
}
|
||||
std::vector<std::string> function_descriptor(3);
|
||||
auto spec = TaskSpecification(DriverID::Nil(), TaskID::FromRandom(), 0, task_arguments,
|
||||
auto spec = TaskSpecification(JobID::Nil(), TaskID::FromRandom(), 0, task_arguments,
|
||||
num_returns, required_resources, Language::PYTHON,
|
||||
function_descriptor);
|
||||
auto execution_spec = TaskExecutionSpecification(std::vector<ObjectID>());
|
||||
|
||||
@@ -35,7 +35,7 @@ void Monitor::Start() {
|
||||
HandleHeartbeat(id, heartbeat_data);
|
||||
};
|
||||
RAY_CHECK_OK(gcs_client_.heartbeat_table().Subscribe(
|
||||
DriverID::Nil(), ClientID::Nil(), heartbeat_callback, nullptr, nullptr));
|
||||
JobID::Nil(), ClientID::Nil(), heartbeat_callback, nullptr, nullptr));
|
||||
Tick();
|
||||
}
|
||||
|
||||
@@ -68,9 +68,9 @@ void Monitor::Tick() {
|
||||
error_message << "The node with client ID " << client_id
|
||||
<< " has been marked dead because the monitor"
|
||||
<< " has missed too many heartbeats from it.";
|
||||
// We use the nil DriverID to broadcast the message to all drivers.
|
||||
// We use the nil JobID to broadcast the message to all drivers.
|
||||
RAY_CHECK_OK(gcs_client_.error_table().PushErrorToDriver(
|
||||
DriverID::Nil(), type, error_message.str(), current_time_ms()));
|
||||
JobID::Nil(), type, error_message.str(), current_time_ms()));
|
||||
}
|
||||
};
|
||||
RAY_CHECK_OK(gcs_client_.client_table().Lookup(lookup_callback));
|
||||
@@ -88,7 +88,7 @@ void Monitor::Tick() {
|
||||
for (const auto &heartbeat : heartbeat_buffer_) {
|
||||
batch->add_batch()->CopyFrom(heartbeat.second);
|
||||
}
|
||||
RAY_CHECK_OK(gcs_client_.heartbeat_batch_table().Add(DriverID::Nil(), ClientID::Nil(),
|
||||
RAY_CHECK_OK(gcs_client_.heartbeat_batch_table().Add(JobID::Nil(), ClientID::Nil(),
|
||||
batch, nullptr));
|
||||
heartbeat_buffer_.clear();
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ ray::Status NodeManager::RegisterGcs() {
|
||||
lineage_cache_.HandleEntryCommitted(task_id);
|
||||
};
|
||||
RAY_RETURN_NOT_OK(gcs_client_->raylet_task_table().Subscribe(
|
||||
DriverID::Nil(), gcs_client_->client_table().GetLocalClientId(),
|
||||
JobID::Nil(), gcs_client_->client_table().GetLocalClientId(),
|
||||
task_committed_callback, nullptr, nullptr));
|
||||
|
||||
const auto task_lease_notification_callback = [this](gcs::AsyncGcsClient *client,
|
||||
@@ -160,7 +160,7 @@ ray::Status NodeManager::RegisterGcs() {
|
||||
reconstruction_policy_.HandleTaskLeaseNotification(task_id, 0);
|
||||
};
|
||||
RAY_RETURN_NOT_OK(gcs_client_->task_lease_table().Subscribe(
|
||||
DriverID::Nil(), gcs_client_->client_table().GetLocalClientId(),
|
||||
JobID::Nil(), gcs_client_->client_table().GetLocalClientId(),
|
||||
task_lease_notification_callback, task_lease_empty_callback, nullptr));
|
||||
|
||||
// Register a callback to handle actor notifications.
|
||||
@@ -175,7 +175,7 @@ ray::Status NodeManager::RegisterGcs() {
|
||||
};
|
||||
|
||||
RAY_RETURN_NOT_OK(gcs_client_->actor_table().Subscribe(
|
||||
DriverID::Nil(), ClientID::Nil(), actor_notification_callback, nullptr));
|
||||
JobID::Nil(), ClientID::Nil(), actor_notification_callback, nullptr));
|
||||
|
||||
// Register a callback on the client table for new clients.
|
||||
auto node_manager_client_added = [this](gcs::AsyncGcsClient *client, const UniqueID &id,
|
||||
@@ -210,18 +210,17 @@ ray::Status NodeManager::RegisterGcs() {
|
||||
HeartbeatBatchAdded(heartbeat_batch);
|
||||
};
|
||||
RAY_RETURN_NOT_OK(gcs_client_->heartbeat_batch_table().Subscribe(
|
||||
DriverID::Nil(), ClientID::Nil(), heartbeat_batch_added,
|
||||
JobID::Nil(), ClientID::Nil(), heartbeat_batch_added,
|
||||
/*subscribe_callback=*/nullptr,
|
||||
/*done_callback=*/nullptr));
|
||||
|
||||
// Subscribe to driver table updates.
|
||||
const auto driver_table_handler =
|
||||
[this](gcs::AsyncGcsClient *client, const DriverID &client_id,
|
||||
const std::vector<DriverTableData> &driver_data) {
|
||||
HandleDriverTableUpdate(client_id, driver_data);
|
||||
};
|
||||
RAY_RETURN_NOT_OK(gcs_client_->driver_table().Subscribe(
|
||||
DriverID::Nil(), ClientID::Nil(), driver_table_handler, nullptr));
|
||||
const auto job_table_handler = [this](gcs::AsyncGcsClient *client, const JobID &job_id,
|
||||
const std::vector<JobTableData> &job_data) {
|
||||
HandleJobTableUpdate(job_id, job_data);
|
||||
};
|
||||
RAY_RETURN_NOT_OK(gcs_client_->job_table().Subscribe(JobID::Nil(), ClientID::Nil(),
|
||||
job_table_handler, nullptr));
|
||||
|
||||
// Start sending heartbeats to the GCS.
|
||||
last_heartbeat_at_ms_ = current_time_ms();
|
||||
@@ -252,14 +251,14 @@ void NodeManager::KillWorker(std::shared_ptr<Worker> worker) {
|
||||
});
|
||||
}
|
||||
|
||||
void NodeManager::HandleDriverTableUpdate(
|
||||
const DriverID &id, const std::vector<DriverTableData> &driver_data) {
|
||||
for (const auto &entry : driver_data) {
|
||||
RAY_LOG(DEBUG) << "HandleDriverTableUpdate "
|
||||
<< UniqueID::FromBinary(entry.driver_id()) << " " << entry.is_dead();
|
||||
void NodeManager::HandleJobTableUpdate(const JobID &id,
|
||||
const std::vector<JobTableData> &job_data) {
|
||||
for (const auto &entry : job_data) {
|
||||
RAY_LOG(DEBUG) << "HandleJobTableUpdate " << UniqueID::FromBinary(entry.job_id())
|
||||
<< " " << entry.is_dead();
|
||||
if (entry.is_dead()) {
|
||||
auto driver_id = DriverID::FromBinary(entry.driver_id());
|
||||
auto workers = worker_pool_.GetWorkersRunningTasksForDriver(driver_id);
|
||||
auto job_id = JobID::FromBinary(entry.job_id());
|
||||
auto workers = worker_pool_.GetWorkersRunningTasksForJob(job_id);
|
||||
|
||||
// Kill all the workers. The actual cleanup for these workers is done
|
||||
// later when we receive the DisconnectClient message from them.
|
||||
@@ -271,11 +270,11 @@ void NodeManager::HandleDriverTableUpdate(
|
||||
KillWorker(worker);
|
||||
}
|
||||
|
||||
// Remove all tasks for this driver from the scheduling queues, mark
|
||||
// Remove all tasks for this job from the scheduling queues, mark
|
||||
// the results for these tasks as not required, cancel any attempts
|
||||
// at reconstruction. Note that at this time the workers are likely
|
||||
// alive because of the delay in killing workers.
|
||||
CleanUpTasksForDeadDriver(driver_id);
|
||||
CleanUpTasksForFinishedJob(job_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,7 +312,7 @@ void NodeManager::Heartbeat() {
|
||||
}
|
||||
|
||||
ray::Status status = heartbeat_table.Add(
|
||||
DriverID::Nil(), gcs_client_->client_table().GetLocalClientId(), heartbeat_data,
|
||||
JobID::Nil(), gcs_client_->client_table().GetLocalClientId(), heartbeat_data,
|
||||
/*success_callback=*/nullptr);
|
||||
RAY_CHECK_OK_PREPEND(status, "Heartbeat failed");
|
||||
|
||||
@@ -605,7 +604,7 @@ void NodeManager::PublishActorStateTransition(
|
||||
RAY_CHECK_OK(redis_context->RunArgvAsync(args));
|
||||
}
|
||||
};
|
||||
RAY_CHECK_OK(gcs_client_->actor_table().AppendAt(DriverID::Nil(), actor_id,
|
||||
RAY_CHECK_OK(gcs_client_->actor_table().AppendAt(JobID::Nil(), actor_id,
|
||||
actor_notification, success_callback,
|
||||
failure_callback, log_length));
|
||||
}
|
||||
@@ -690,8 +689,8 @@ void NodeManager::HandleActorStateTransition(const ActorID &actor_id,
|
||||
}
|
||||
}
|
||||
|
||||
void NodeManager::CleanUpTasksForDeadDriver(const DriverID &driver_id) {
|
||||
auto tasks_to_remove = local_queues_.GetTaskIdsForDriver(driver_id);
|
||||
void NodeManager::CleanUpTasksForFinishedJob(const JobID &job_id) {
|
||||
auto tasks_to_remove = local_queues_.GetTaskIdsForJob(job_id);
|
||||
task_dependency_manager_.RemoveTasksAndRelatedObjects(tasks_to_remove);
|
||||
// NOTE(swang): SchedulingQueue::RemoveTasks modifies its argument so we must
|
||||
// call it last.
|
||||
@@ -749,7 +748,7 @@ void NodeManager::ProcessClientMessage(
|
||||
<< (registered_worker ? std::to_string(registered_worker->Pid())
|
||||
: "nil");
|
||||
if (registered_worker && registered_worker->IsDead()) {
|
||||
// For a worker that is marked as dead (because the driver has died already),
|
||||
// For a worker that is marked as dead (because the job has died already),
|
||||
// all the messages are ignored except DisconnectClient.
|
||||
if ((message_type_value != protocol::MessageType::DisconnectClient) &&
|
||||
(message_type_value != protocol::MessageType::IntentionalDisconnectClient)) {
|
||||
@@ -824,7 +823,7 @@ void NodeManager::ProcessClientMessage(
|
||||
for (const auto &object_id : object_ids) {
|
||||
creating_task_ids.push_back(object_id.TaskId());
|
||||
}
|
||||
gcs_client_->raylet_task_table().Delete(DriverID::Nil(), creating_task_ids);
|
||||
gcs_client_->raylet_task_table().Delete(JobID::Nil(), creating_task_ids);
|
||||
}
|
||||
} break;
|
||||
case protocol::MessageType::PrepareActorCheckpointRequest: {
|
||||
@@ -857,10 +856,11 @@ void NodeManager::ProcessRegisterClientRequestMessage(
|
||||
// message is actually the ID of the driver task, while client_id represents the
|
||||
// real driver ID, which can associate all the tasks/actors for a given driver,
|
||||
// which is set to the worker ID.
|
||||
const DriverID driver_id = from_flatbuf<DriverID>(*message->driver_id());
|
||||
// TODO(qwang): Use driver_task_id instead here.
|
||||
const WorkerID driver_id = from_flatbuf<WorkerID>(*message->driver_id());
|
||||
TaskID driver_task_id = TaskID::GetDriverTaskID(driver_id);
|
||||
worker->AssignTaskId(driver_task_id);
|
||||
worker->AssignDriverId(from_flatbuf<DriverID>(*message->client_id()));
|
||||
worker->AssignJobId(from_flatbuf<JobID>(*message->client_id()));
|
||||
worker_pool_.RegisterDriver(std::move(worker));
|
||||
local_queues_.AddDriverTaskId(driver_task_id);
|
||||
}
|
||||
@@ -992,14 +992,14 @@ void NodeManager::ProcessDisconnectClientMessage(
|
||||
|
||||
if (!intentional_disconnect) {
|
||||
// Push the error to driver.
|
||||
const DriverID &driver_id = worker->GetAssignedDriverId();
|
||||
const JobID &job_id = worker->GetAssignedJobId();
|
||||
// TODO(rkn): Define this constant somewhere else.
|
||||
std::string type = "worker_died";
|
||||
std::ostringstream error_message;
|
||||
error_message << "A worker died or was killed while executing task " << task_id
|
||||
<< ".";
|
||||
RAY_CHECK_OK(gcs_client_->error_table().PushErrorToDriver(
|
||||
driver_id, type, error_message.str(), current_time_ms()));
|
||||
job_id, type, error_message.str(), current_time_ms()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1022,22 +1022,21 @@ void NodeManager::ProcessDisconnectClientMessage(
|
||||
worker->ResetLifetimeResourceIds();
|
||||
|
||||
RAY_LOG(DEBUG) << "Worker (pid=" << worker->Pid() << ") is disconnected. "
|
||||
<< "driver_id: " << worker->GetAssignedDriverId();
|
||||
<< "job_id: " << worker->GetAssignedJobId();
|
||||
|
||||
// Since some resources may have been released, we can try to dispatch more tasks.
|
||||
DispatchTasks(local_queues_.GetReadyTasksWithResources());
|
||||
} else if (is_driver) {
|
||||
// The client is a driver.
|
||||
RAY_CHECK_OK(
|
||||
gcs_client_->driver_table().AppendDriverData(DriverID(client->GetClientId()),
|
||||
/*is_dead=*/true));
|
||||
auto driver_id = worker->GetAssignedTaskId();
|
||||
RAY_CHECK(!driver_id.IsNil());
|
||||
local_queues_.RemoveDriverTaskId(driver_id);
|
||||
RAY_CHECK_OK(gcs_client_->job_table().AppendJobData(JobID(client->GetClientId()),
|
||||
/*is_dead=*/true));
|
||||
auto job_id = worker->GetAssignedTaskId();
|
||||
RAY_CHECK(!job_id.IsNil());
|
||||
local_queues_.RemoveDriverTaskId(job_id);
|
||||
worker_pool_.DisconnectDriver(worker);
|
||||
|
||||
RAY_LOG(DEBUG) << "Driver (pid=" << worker->Pid() << ") is disconnected. "
|
||||
<< "driver_id: " << worker->GetAssignedDriverId();
|
||||
<< "job_id: " << worker->GetAssignedJobId();
|
||||
}
|
||||
|
||||
// TODO(rkn): Tell the object manager that this client has disconnected so
|
||||
@@ -1142,13 +1141,13 @@ void NodeManager::ProcessWaitRequestMessage(
|
||||
void NodeManager::ProcessPushErrorRequestMessage(const uint8_t *message_data) {
|
||||
auto message = flatbuffers::GetRoot<protocol::PushErrorRequest>(message_data);
|
||||
|
||||
DriverID driver_id = from_flatbuf<DriverID>(*message->driver_id());
|
||||
JobID job_id = from_flatbuf<JobID>(*message->job_id());
|
||||
auto const &type = string_from_flatbuf(*message->type());
|
||||
auto const &error_message = string_from_flatbuf(*message->error_message());
|
||||
double timestamp = message->timestamp();
|
||||
|
||||
RAY_CHECK_OK(gcs_client_->error_table().PushErrorToDriver(driver_id, type,
|
||||
error_message, timestamp));
|
||||
RAY_CHECK_OK(gcs_client_->error_table().PushErrorToDriver(job_id, type, error_message,
|
||||
timestamp));
|
||||
}
|
||||
|
||||
void NodeManager::ProcessPrepareActorCheckpointRequest(
|
||||
@@ -1173,7 +1172,7 @@ void NodeManager::ProcessPrepareActorCheckpointRequest(
|
||||
|
||||
// Write checkpoint data to GCS.
|
||||
RAY_CHECK_OK(gcs_client_->actor_checkpoint_table().Add(
|
||||
DriverID::Nil(), checkpoint_id, checkpoint_data,
|
||||
JobID::Nil(), checkpoint_id, checkpoint_data,
|
||||
[worker, actor_id, this](ray::gcs::AsyncGcsClient *client,
|
||||
const ActorCheckpointID &checkpoint_id,
|
||||
const ActorCheckpointData &data) {
|
||||
@@ -1182,7 +1181,7 @@ void NodeManager::ProcessPrepareActorCheckpointRequest(
|
||||
// Save this actor-to-checkpoint mapping, and remove old checkpoints associated
|
||||
// with this actor.
|
||||
RAY_CHECK_OK(gcs_client_->actor_checkpoint_id_table().AddCheckpointId(
|
||||
DriverID::Nil(), actor_id, checkpoint_id));
|
||||
JobID::Nil(), actor_id, checkpoint_id));
|
||||
// Send reply to worker.
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto reply = ray::protocol::CreatePrepareActorCheckpointReply(
|
||||
@@ -1284,7 +1283,7 @@ void NodeManager::ProcessSetResourceRequest(
|
||||
auto data_shared_ptr = std::make_shared<ClientTableData>(data);
|
||||
auto client_table = gcs_client_->client_table();
|
||||
RAY_CHECK_OK(gcs_client_->client_table().Append(
|
||||
DriverID::Nil(), client_table.client_log_key_, data_shared_ptr, nullptr));
|
||||
JobID::Nil(), client_table.client_log_key_, data_shared_ptr, nullptr));
|
||||
}
|
||||
|
||||
void NodeManager::ScheduleTasks(
|
||||
@@ -1354,7 +1353,7 @@ void NodeManager::ScheduleTasks(
|
||||
<< task.GetTaskSpecification().GetRequiredPlacementResources().ToString()
|
||||
<< " for placement. Check the client table to view node resources.";
|
||||
RAY_CHECK_OK(gcs_client_->error_table().PushErrorToDriver(
|
||||
task.GetTaskSpecification().DriverId(), type, error_message.str(),
|
||||
task.GetTaskSpecification().JobId(), type, error_message.str(),
|
||||
current_time_ms()));
|
||||
}
|
||||
// Assert that this placeable task is not feasible locally (necessary but not
|
||||
@@ -1415,8 +1414,7 @@ void NodeManager::TreatTaskAsFailed(const Task &task, const ErrorType &error_typ
|
||||
std::string error_message = stream.str();
|
||||
RAY_LOG(WARNING) << error_message;
|
||||
RAY_CHECK_OK(gcs_client_->error_table().PushErrorToDriver(
|
||||
task.GetTaskSpecification().DriverId(), "task", error_message,
|
||||
current_time_ms()));
|
||||
task.GetTaskSpecification().JobId(), "task", error_message, current_time_ms()));
|
||||
}
|
||||
}
|
||||
task_dependency_manager_.TaskCanceled(spec.TaskId());
|
||||
@@ -1558,7 +1556,7 @@ void NodeManager::SubmitTask(const Task &task, const Lineage &uncommitted_lineag
|
||||
HandleActorStateTransition(actor_id, ActorRegistration(data.back()));
|
||||
}
|
||||
};
|
||||
RAY_CHECK_OK(gcs_client_->actor_table().Lookup(DriverID::Nil(), spec.ActorId(),
|
||||
RAY_CHECK_OK(gcs_client_->actor_table().Lookup(JobID::Nil(), spec.ActorId(),
|
||||
lookup_callback));
|
||||
actor_creation_dummy_object = spec.ActorCreationDummyObjectId();
|
||||
} else {
|
||||
@@ -1783,7 +1781,7 @@ bool NodeManager::AssignTask(const Task &task) {
|
||||
auto spec = assigned_task.GetTaskSpecification();
|
||||
// We successfully assigned the task to the worker.
|
||||
worker->AssignTaskId(spec.TaskId());
|
||||
worker->AssignDriverId(spec.DriverId());
|
||||
worker->AssignJobId(spec.JobId());
|
||||
// Actor tasks require extra accounting to track the actor's state.
|
||||
if (spec.IsActorTask()) {
|
||||
auto actor_entry = actor_registry_.find(spec.ActorId());
|
||||
@@ -1870,10 +1868,10 @@ void NodeManager::FinishAssignedTask(Worker &worker) {
|
||||
|
||||
// Unset the worker's assigned task.
|
||||
worker.AssignTaskId(TaskID::Nil());
|
||||
// Unset the worker's assigned driver Id if this is not an actor.
|
||||
// Unset the worker's assigned job Id if this is not an actor.
|
||||
if (!task.GetTaskSpecification().IsActorCreationTask() &&
|
||||
!task.GetTaskSpecification().IsActorTask()) {
|
||||
worker.AssignDriverId(DriverID::Nil());
|
||||
worker.AssignJobId(JobID::Nil());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1892,7 +1890,7 @@ ActorTableData NodeManager::CreateActorTableDataFromCreationTask(const Task &tas
|
||||
new_actor_data.set_actor_id(actor_id.Binary());
|
||||
new_actor_data.set_actor_creation_dummy_object_id(
|
||||
task.GetTaskSpecification().ActorDummyObject().Binary());
|
||||
new_actor_data.set_driver_id(task.GetTaskSpecification().DriverId().Binary());
|
||||
new_actor_data.set_job_id(task.GetTaskSpecification().JobId().Binary());
|
||||
new_actor_data.set_max_reconstructions(
|
||||
task.GetTaskSpecification().MaxActorReconstructions());
|
||||
// This is the first time that the actor has been created, so the number
|
||||
@@ -1948,7 +1946,7 @@ void NodeManager::FinishAssignedActorTask(Worker &worker, const Task &task) {
|
||||
RAY_LOG(DEBUG) << "Looking up checkpoint " << checkpoint_id << " for actor "
|
||||
<< actor_id;
|
||||
RAY_CHECK_OK(gcs_client_->actor_checkpoint_table().Lookup(
|
||||
DriverID::Nil(), checkpoint_id,
|
||||
JobID::Nil(), checkpoint_id,
|
||||
[this, actor_id, new_actor_data](ray::gcs::AsyncGcsClient *client,
|
||||
const UniqueID &checkpoint_id,
|
||||
const ActorCheckpointData &checkpoint_data) {
|
||||
@@ -2017,7 +2015,7 @@ void NodeManager::FinishAssignedActorTask(Worker &worker, const Task &task) {
|
||||
void NodeManager::HandleTaskReconstruction(const TaskID &task_id) {
|
||||
// Retrieve the task spec in order to re-execute the task.
|
||||
RAY_CHECK_OK(gcs_client_->raylet_task_table().Lookup(
|
||||
DriverID::Nil(), task_id,
|
||||
JobID::Nil(), task_id,
|
||||
/*success_callback=*/
|
||||
[this](ray::gcs::AsyncGcsClient *client, const TaskID &task_id,
|
||||
const TaskTableData &task_data) {
|
||||
@@ -2072,7 +2070,7 @@ void NodeManager::ResubmitTask(const Task &task) {
|
||||
<< " is a driver task and so the object created by ray.put "
|
||||
<< "could not be reconstructed.";
|
||||
RAY_CHECK_OK(gcs_client_->error_table().PushErrorToDriver(
|
||||
task.GetTaskSpecification().DriverId(), type, error_message.str(),
|
||||
task.GetTaskSpecification().JobId(), type, error_message.str(),
|
||||
current_time_ms()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace raylet {
|
||||
|
||||
using rpc::ActorTableData;
|
||||
using rpc::ClientTableData;
|
||||
using rpc::DriverTableData;
|
||||
using rpc::ErrorType;
|
||||
using rpc::HeartbeatBatchTableData;
|
||||
using rpc::HeartbeatTableData;
|
||||
using rpc::JobTableData;
|
||||
|
||||
struct NodeManagerConfig {
|
||||
/// The node's resource configuration.
|
||||
@@ -326,12 +326,12 @@ class NodeManager : public rpc::NodeManagerServiceHandler {
|
||||
const ActorID &actor_id, const ActorTableData &data,
|
||||
const ray::gcs::ActorTable::WriteCallback &failure_callback);
|
||||
|
||||
/// When a driver dies, loop over all of the queued tasks for that driver and
|
||||
/// When a job finished, loop over all of the queued tasks for that job and
|
||||
/// treat them as failed.
|
||||
///
|
||||
/// \param driver_id The driver that died.
|
||||
/// \param job_id The job that exited.
|
||||
/// \return Void.
|
||||
void CleanUpTasksForDeadDriver(const DriverID &driver_id);
|
||||
void CleanUpTasksForFinishedJob(const JobID &job_id);
|
||||
|
||||
/// Handle an object becoming local. This updates any local accounting, but
|
||||
/// does not write to any global accounting in the GCS.
|
||||
@@ -346,13 +346,12 @@ class NodeManager : public rpc::NodeManagerServiceHandler {
|
||||
/// \return Void.
|
||||
void HandleObjectMissing(const ObjectID &object_id);
|
||||
|
||||
/// Handles updates to driver table.
|
||||
/// Handles updates to job table.
|
||||
///
|
||||
/// \param id An unused value. TODO(rkn): Should this be removed?
|
||||
/// \param driver_data Data associated with a driver table event.
|
||||
/// \param job_data Data associated with a job table event.
|
||||
/// \return Void.
|
||||
void HandleDriverTableUpdate(const DriverID &id,
|
||||
const std::vector<DriverTableData> &driver_data);
|
||||
void HandleJobTableUpdate(const JobID &id, const std::vector<JobTableData> &job_data);
|
||||
|
||||
/// Check if certain invariants associated with the task dependency manager
|
||||
/// and the local queues are satisfied. This is only used for debugging
|
||||
|
||||
@@ -202,18 +202,14 @@ ray::Status RayletConnection::AtomicRequestReply(
|
||||
}
|
||||
|
||||
RayletClient::RayletClient(const std::string &raylet_socket, const ClientID &client_id,
|
||||
bool is_worker, const DriverID &driver_id,
|
||||
const Language &language)
|
||||
: client_id_(client_id),
|
||||
is_worker_(is_worker),
|
||||
driver_id_(driver_id),
|
||||
language_(language) {
|
||||
bool is_worker, const JobID &job_id, const Language &language)
|
||||
: client_id_(client_id), is_worker_(is_worker), job_id_(job_id), language_(language) {
|
||||
// For C++14, we could use std::make_unique
|
||||
conn_ = std::unique_ptr<RayletConnection>(new RayletConnection(raylet_socket, -1, -1));
|
||||
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = ray::protocol::CreateRegisterClientRequest(
|
||||
fbb, is_worker, to_flatbuf(fbb, client_id), getpid(), to_flatbuf(fbb, driver_id),
|
||||
fbb, is_worker, to_flatbuf(fbb, client_id), getpid(), to_flatbuf(fbb, job_id),
|
||||
language);
|
||||
fbb.Finish(message);
|
||||
// Register the process ID with the raylet.
|
||||
@@ -323,11 +319,11 @@ ray::Status RayletClient::Wait(const std::vector<ObjectID> &object_ids, int num_
|
||||
return ray::Status::OK();
|
||||
}
|
||||
|
||||
ray::Status RayletClient::PushError(const DriverID &driver_id, const std::string &type,
|
||||
ray::Status RayletClient::PushError(const ray::JobID &job_id, const std::string &type,
|
||||
const std::string &error_message, double timestamp) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = ray::protocol::CreatePushErrorRequest(
|
||||
fbb, to_flatbuf(fbb, driver_id), fbb.CreateString(type),
|
||||
fbb, to_flatbuf(fbb, job_id), fbb.CreateString(type),
|
||||
fbb.CreateString(error_message), timestamp);
|
||||
fbb.Finish(message);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
using ray::ActorCheckpointID;
|
||||
using ray::ActorID;
|
||||
using ray::ClientID;
|
||||
using ray::DriverID;
|
||||
using ray::JobID;
|
||||
using ray::ObjectID;
|
||||
using ray::TaskID;
|
||||
using ray::UniqueID;
|
||||
@@ -30,7 +30,7 @@ class RayletConnection {
|
||||
/// \param worker_id A unique ID to represent the worker.
|
||||
/// \param is_worker Whether this client is a worker. If it is a worker, an
|
||||
/// additional message will be sent to register as one.
|
||||
/// \param driver_id The ID of the driver. This is non-nil if the client is a
|
||||
/// \param job_id The ID of the driver. This is non-nil if the client is a
|
||||
/// driver.
|
||||
/// \return The connection information.
|
||||
RayletConnection(const std::string &raylet_socket, int num_retries, int64_t timeout);
|
||||
@@ -66,10 +66,10 @@ class RayletClient {
|
||||
/// \param worker_id A unique ID to represent the worker.
|
||||
/// \param is_worker Whether this client is a worker. If it is a worker, an
|
||||
/// additional message will be sent to register as one.
|
||||
/// \param driver_id The ID of the driver. This is non-nil if the client is a driver.
|
||||
/// \param job_id The ID of the driver. This is non-nil if the client is a driver.
|
||||
/// \return The connection information.
|
||||
RayletClient(const std::string &raylet_socket, const ClientID &client_id,
|
||||
bool is_worker, const DriverID &driver_id, const Language &language);
|
||||
bool is_worker, const JobID &job_id, const Language &language);
|
||||
|
||||
ray::Status Disconnect() { return conn_->Disconnect(); };
|
||||
|
||||
@@ -125,12 +125,12 @@ class RayletClient {
|
||||
|
||||
/// Push an error to the relevant driver.
|
||||
///
|
||||
/// \param The ID of the job that the error is for.
|
||||
/// \param The ID of the job_id that the error is for.
|
||||
/// \param The type of the error.
|
||||
/// \param The error message.
|
||||
/// \param The timestamp of the error.
|
||||
/// \return ray::Status.
|
||||
ray::Status PushError(const DriverID &driver_id, const std::string &type,
|
||||
ray::Status PushError(const ray::JobID &job_id, const std::string &type,
|
||||
const std::string &error_message, double timestamp);
|
||||
|
||||
/// Store some profile events in the GCS.
|
||||
@@ -177,7 +177,7 @@ class RayletClient {
|
||||
|
||||
ClientID GetClientID() const { return client_id_; }
|
||||
|
||||
DriverID GetDriverID() const { return driver_id_; }
|
||||
JobID GetJobID() const { return job_id_; }
|
||||
|
||||
bool IsWorker() const { return is_worker_; }
|
||||
|
||||
@@ -186,7 +186,7 @@ class RayletClient {
|
||||
private:
|
||||
const ClientID client_id_;
|
||||
const bool is_worker_;
|
||||
const DriverID driver_id_;
|
||||
const JobID job_id_;
|
||||
const Language language_;
|
||||
/// A map from resource name to the resource IDs that are currently reserved
|
||||
/// for this worker. Each pair consists of the resource ID and the fraction
|
||||
|
||||
@@ -52,7 +52,7 @@ void ReconstructionPolicy::SetTaskTimeout(
|
||||
// required by the task are no longer needed soon after. If the
|
||||
// task is still required after this initial period, then we now
|
||||
// subscribe to task lease notifications.
|
||||
RAY_CHECK_OK(task_lease_pubsub_.RequestNotifications(DriverID::Nil(), task_id,
|
||||
RAY_CHECK_OK(task_lease_pubsub_.RequestNotifications(JobID::Nil(), task_id,
|
||||
client_id_));
|
||||
it->second.subscribed = true;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ void ReconstructionPolicy::AttemptReconstruction(const TaskID &task_id,
|
||||
reconstruction_entry->set_num_reconstructions(reconstruction_attempt);
|
||||
reconstruction_entry->set_node_manager_id(client_id_.Binary());
|
||||
RAY_CHECK_OK(task_reconstruction_log_.AppendAt(
|
||||
DriverID::Nil(), task_id, reconstruction_entry,
|
||||
JobID::Nil(), task_id, reconstruction_entry,
|
||||
/*success_callback=*/
|
||||
[this](gcs::AsyncGcsClient *client, const TaskID &task_id,
|
||||
const TaskReconstructionData &data) {
|
||||
@@ -199,7 +199,7 @@ void ReconstructionPolicy::Cancel(const ObjectID &object_id) {
|
||||
// Cancel notifications for the task lease if we were subscribed to them.
|
||||
if (it->second.subscribed) {
|
||||
RAY_CHECK_OK(
|
||||
task_lease_pubsub_.CancelNotifications(DriverID::Nil(), task_id, client_id_));
|
||||
task_lease_pubsub_.CancelNotifications(JobID::Nil(), task_id, client_id_));
|
||||
}
|
||||
listening_tasks_.erase(it);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class MockGcs : public gcs::PubsubInterface<TaskID>,
|
||||
failure_callback_ = failure_callback;
|
||||
}
|
||||
|
||||
void Add(const DriverID &driver_id, const TaskID &task_id,
|
||||
void Add(const JobID &job_id, const TaskID &task_id,
|
||||
std::shared_ptr<TaskLeaseData> &task_lease_data) {
|
||||
task_lease_table_[task_id] = task_lease_data;
|
||||
if (subscribed_tasks_.count(task_id) == 1) {
|
||||
@@ -92,7 +92,7 @@ class MockGcs : public gcs::PubsubInterface<TaskID>,
|
||||
}
|
||||
}
|
||||
|
||||
Status RequestNotifications(const DriverID &driver_id, const TaskID &task_id,
|
||||
Status RequestNotifications(const JobID &job_id, const TaskID &task_id,
|
||||
const ClientID &client_id) {
|
||||
subscribed_tasks_.insert(task_id);
|
||||
auto entry = task_lease_table_.find(task_id);
|
||||
@@ -104,14 +104,14 @@ class MockGcs : public gcs::PubsubInterface<TaskID>,
|
||||
return ray::Status::OK();
|
||||
}
|
||||
|
||||
Status CancelNotifications(const DriverID &driver_id, const TaskID &task_id,
|
||||
Status CancelNotifications(const JobID &job_id, const TaskID &task_id,
|
||||
const ClientID &client_id) {
|
||||
subscribed_tasks_.erase(task_id);
|
||||
return ray::Status::OK();
|
||||
}
|
||||
|
||||
Status AppendAt(
|
||||
const DriverID &driver_id, const TaskID &task_id,
|
||||
const JobID &job_id, const TaskID &task_id,
|
||||
std::shared_ptr<TaskReconstructionData> &task_data,
|
||||
const ray::gcs::LogInterface<TaskID, TaskReconstructionData>::WriteCallback
|
||||
&success_callback,
|
||||
@@ -134,7 +134,7 @@ class MockGcs : public gcs::PubsubInterface<TaskID>,
|
||||
MOCK_METHOD4(
|
||||
Append,
|
||||
ray::Status(
|
||||
const DriverID &, const TaskID &, std::shared_ptr<TaskReconstructionData> &,
|
||||
const JobID &, const TaskID &, std::shared_ptr<TaskReconstructionData> &,
|
||||
const ray::gcs::LogInterface<TaskID, TaskReconstructionData>::WriteCallback &));
|
||||
|
||||
private:
|
||||
@@ -320,7 +320,7 @@ TEST_F(ReconstructionPolicyTest, TestReconstructionSuppressed) {
|
||||
task_lease_data->set_node_manager_id(ClientID::FromRandom().Binary());
|
||||
task_lease_data->set_acquired_at(current_sys_time_ms());
|
||||
task_lease_data->set_timeout(2 * test_period);
|
||||
mock_gcs_.Add(DriverID::Nil(), task_id, task_lease_data);
|
||||
mock_gcs_.Add(JobID::Nil(), task_id, task_lease_data);
|
||||
|
||||
// Listen for an object.
|
||||
reconstruction_policy_->ListenAndMaybeReconstruct(object_id);
|
||||
@@ -347,7 +347,7 @@ TEST_F(ReconstructionPolicyTest, TestReconstructionContinuallySuppressed) {
|
||||
task_lease_data->set_node_manager_id(ClientID::FromRandom().Binary());
|
||||
task_lease_data->set_acquired_at(current_sys_time_ms());
|
||||
task_lease_data->set_timeout(reconstruction_timeout_ms_);
|
||||
mock_gcs_.Add(DriverID::Nil(), task_id, task_lease_data);
|
||||
mock_gcs_.Add(JobID::Nil(), task_id, task_lease_data);
|
||||
});
|
||||
// Run the test for much longer than the reconstruction timeout.
|
||||
Run(reconstruction_timeout_ms_ * 2);
|
||||
@@ -399,7 +399,7 @@ TEST_F(ReconstructionPolicyTest, TestSimultaneousReconstructionSuppressed) {
|
||||
task_reconstruction_data->set_node_manager_id(ClientID::FromRandom().Binary());
|
||||
task_reconstruction_data->set_num_reconstructions(0);
|
||||
RAY_CHECK_OK(
|
||||
mock_gcs_.AppendAt(DriverID::Nil(), task_id, task_reconstruction_data, nullptr,
|
||||
mock_gcs_.AppendAt(JobID::Nil(), task_id, task_reconstruction_data, nullptr,
|
||||
/*failure_callback=*/
|
||||
[](ray::gcs::AsyncGcsClient *client, const TaskID &task_id,
|
||||
const TaskReconstructionData &data) { ASSERT_TRUE(false); },
|
||||
|
||||
@@ -19,15 +19,14 @@ inline const char *GetTaskStateString(ray::raylet::TaskState task_state) {
|
||||
return task_state_strings[static_cast<int>(task_state)];
|
||||
}
|
||||
|
||||
// Helper function to get tasks for a driver from a given state.
|
||||
// Helper function to get tasks for a job from a given state.
|
||||
template <typename TaskQueue>
|
||||
inline void GetDriverTasksFromQueue(const TaskQueue &queue,
|
||||
const ray::DriverID &driver_id,
|
||||
inline void GetTasksForJobFromQueue(const TaskQueue &queue, const ray::JobID &job_id,
|
||||
std::unordered_set<ray::TaskID> &task_ids) {
|
||||
const auto &tasks = queue.GetTasks();
|
||||
for (const auto &task : tasks) {
|
||||
auto const &spec = task.GetTaskSpecification();
|
||||
if (driver_id == spec.DriverId()) {
|
||||
if (job_id == spec.JobId()) {
|
||||
task_ids.insert(spec.TaskId());
|
||||
}
|
||||
}
|
||||
@@ -187,9 +186,9 @@ void SchedulingQueue::FilterState(std::unordered_set<TaskID> &task_ids,
|
||||
}
|
||||
} break;
|
||||
case TaskState::DRIVER: {
|
||||
const auto driver_ids = GetDriverTaskIds();
|
||||
const auto driver_task_ids = GetDriverTaskIds();
|
||||
for (auto it = task_ids.begin(); it != task_ids.end();) {
|
||||
if (driver_ids.count(*it) == 1) {
|
||||
if (driver_task_ids.count(*it) == 1) {
|
||||
it = task_ids.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
@@ -356,11 +355,10 @@ bool SchedulingQueue::HasTask(const TaskID &task_id) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unordered_set<TaskID> SchedulingQueue::GetTaskIdsForDriver(
|
||||
const DriverID &driver_id) const {
|
||||
std::unordered_set<TaskID> SchedulingQueue::GetTaskIdsForJob(const JobID &job_id) const {
|
||||
std::unordered_set<TaskID> task_ids;
|
||||
for (const auto &task_queue : task_queues_) {
|
||||
GetDriverTasksFromQueue(*task_queue, driver_id, task_ids);
|
||||
GetTasksForJobFromQueue(*task_queue, job_id, task_ids);
|
||||
}
|
||||
return task_ids;
|
||||
}
|
||||
@@ -394,15 +392,15 @@ void SchedulingQueue::RemoveBlockedTaskId(const TaskID &task_id) {
|
||||
RAY_CHECK(erased == 1);
|
||||
}
|
||||
|
||||
void SchedulingQueue::AddDriverTaskId(const TaskID &driver_id) {
|
||||
RAY_LOG(DEBUG) << "Added driver task " << driver_id;
|
||||
auto inserted = driver_task_ids_.insert(driver_id);
|
||||
void SchedulingQueue::AddDriverTaskId(const TaskID &task_id) {
|
||||
RAY_LOG(DEBUG) << "Added driver task " << task_id;
|
||||
auto inserted = driver_task_ids_.insert(task_id);
|
||||
RAY_CHECK(inserted.second);
|
||||
}
|
||||
|
||||
void SchedulingQueue::RemoveDriverTaskId(const TaskID &driver_id) {
|
||||
RAY_LOG(DEBUG) << "Removed driver task " << driver_id;
|
||||
auto erased = driver_task_ids_.erase(driver_id);
|
||||
void SchedulingQueue::RemoveDriverTaskId(const TaskID &task_id) {
|
||||
RAY_LOG(DEBUG) << "Removed driver task " << task_id;
|
||||
auto erased = driver_task_ids_.erase(task_id);
|
||||
RAY_CHECK(erased == 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -283,11 +283,11 @@ class SchedulingQueue {
|
||||
/// \param filter_state The task state to filter out.
|
||||
void FilterState(std::unordered_set<TaskID> &task_ids, TaskState filter_state) const;
|
||||
|
||||
/// \brief Get all the task IDs for a driver.
|
||||
/// \brief Get all the task IDs for a job.
|
||||
///
|
||||
/// \param driver_id All the tasks that have the given driver_id are returned.
|
||||
/// \return All the tasks that have the given driver ID.
|
||||
std::unordered_set<TaskID> GetTaskIdsForDriver(const DriverID &driver_id) const;
|
||||
/// \param job_id All the tasks that have the given job_id are returned.
|
||||
/// \return All the tasks that have the given job ID.
|
||||
std::unordered_set<TaskID> GetTaskIdsForJob(const JobID &job_id) const;
|
||||
|
||||
/// \brief Get all the task IDs for an actor.
|
||||
///
|
||||
|
||||
@@ -265,7 +265,7 @@ void TaskDependencyManager::AcquireTaskLease(const TaskID &task_id) {
|
||||
task_lease_data->set_node_manager_id(client_id_.Hex());
|
||||
task_lease_data->set_acquired_at(current_sys_time_ms());
|
||||
task_lease_data->set_timeout(it->second.lease_period);
|
||||
RAY_CHECK_OK(task_lease_table_.Add(DriverID::Nil(), task_id, task_lease_data, nullptr));
|
||||
RAY_CHECK_OK(task_lease_table_.Add(JobID::Nil(), task_id, task_lease_data, nullptr));
|
||||
|
||||
auto period = boost::posix_time::milliseconds(it->second.lease_period / 2);
|
||||
it->second.lease_timer->expires_from_now(period);
|
||||
|
||||
@@ -29,7 +29,7 @@ class MockGcs : public gcs::TableInterface<TaskID, TaskLeaseData> {
|
||||
public:
|
||||
MOCK_METHOD4(
|
||||
Add,
|
||||
ray::Status(const DriverID &driver_id, const TaskID &task_id,
|
||||
ray::Status(const JobID &job_id, const TaskID &task_id,
|
||||
std::shared_ptr<TaskLeaseData> &task_data,
|
||||
const gcs::TableInterface<TaskID, TaskLeaseData>::WriteCallback &done));
|
||||
};
|
||||
@@ -75,7 +75,7 @@ static inline Task ExampleTask(const std::vector<ObjectID> &arguments,
|
||||
task_arguments.emplace_back(std::make_shared<TaskArgumentByReference>(references));
|
||||
}
|
||||
std::vector<std::string> function_descriptor(3);
|
||||
auto spec = TaskSpecification(DriverID::Nil(), TaskID::FromRandom(), 0, task_arguments,
|
||||
auto spec = TaskSpecification(JobID::Nil(), TaskID::FromRandom(), 0, task_arguments,
|
||||
num_returns, required_resources, Language::PYTHON,
|
||||
function_descriptor);
|
||||
auto execution_spec = TaskExecutionSpecification(std::vector<ObjectID>());
|
||||
|
||||
@@ -61,18 +61,18 @@ TaskSpecification::TaskSpecification(const uint8_t *spec, size_t spec_size) {
|
||||
}
|
||||
|
||||
TaskSpecification::TaskSpecification(
|
||||
const DriverID &driver_id, const TaskID &parent_task_id, int64_t parent_counter,
|
||||
const JobID &job_id, const TaskID &parent_task_id, int64_t parent_counter,
|
||||
const std::vector<std::shared_ptr<TaskArgument>> &task_arguments, int64_t num_returns,
|
||||
const std::unordered_map<std::string, double> &required_resources,
|
||||
const Language &language, const std::vector<std::string> &function_descriptor)
|
||||
: TaskSpecification(driver_id, parent_task_id, parent_counter, ActorID::Nil(),
|
||||
: TaskSpecification(job_id, parent_task_id, parent_counter, ActorID::Nil(),
|
||||
ObjectID::Nil(), 0, ActorID::Nil(), ActorHandleID::Nil(), -1, {},
|
||||
task_arguments, num_returns, required_resources,
|
||||
std::unordered_map<std::string, double>(), language,
|
||||
function_descriptor) {}
|
||||
|
||||
TaskSpecification::TaskSpecification(
|
||||
const DriverID &driver_id, const TaskID &parent_task_id, int64_t parent_counter,
|
||||
const JobID &job_id, const TaskID &parent_task_id, int64_t parent_counter,
|
||||
const ActorID &actor_creation_id, const ObjectID &actor_creation_dummy_object_id,
|
||||
const int64_t max_actor_reconstructions, const ActorID &actor_id,
|
||||
const ActorHandleID &actor_handle_id, int64_t actor_counter,
|
||||
@@ -85,7 +85,7 @@ TaskSpecification::TaskSpecification(
|
||||
: spec_() {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
TaskID task_id = GenerateTaskId(driver_id, parent_task_id, parent_counter);
|
||||
TaskID task_id = GenerateTaskId(job_id, parent_task_id, parent_counter);
|
||||
// Add argument object IDs.
|
||||
std::vector<flatbuffers::Offset<Arg>> arguments;
|
||||
for (auto &argument : task_arguments) {
|
||||
@@ -94,7 +94,7 @@ TaskSpecification::TaskSpecification(
|
||||
|
||||
// Serialize the TaskSpecification.
|
||||
auto spec = CreateTaskInfo(
|
||||
fbb, to_flatbuf(fbb, driver_id), to_flatbuf(fbb, task_id),
|
||||
fbb, to_flatbuf(fbb, job_id), to_flatbuf(fbb, task_id),
|
||||
to_flatbuf(fbb, parent_task_id), parent_counter, to_flatbuf(fbb, actor_creation_id),
|
||||
to_flatbuf(fbb, actor_creation_dummy_object_id), max_actor_reconstructions,
|
||||
to_flatbuf(fbb, actor_id), to_flatbuf(fbb, actor_handle_id), actor_counter,
|
||||
@@ -123,9 +123,9 @@ TaskID TaskSpecification::TaskId() const {
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec_.data());
|
||||
return from_flatbuf<TaskID>(*message->task_id());
|
||||
}
|
||||
DriverID TaskSpecification::DriverId() const {
|
||||
JobID TaskSpecification::JobId() const {
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec_.data());
|
||||
return from_flatbuf<DriverID>(*message->driver_id());
|
||||
return from_flatbuf<JobID>(*message->job_id());
|
||||
}
|
||||
TaskID TaskSpecification::ParentTaskId() const {
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec_.data());
|
||||
|
||||
@@ -86,7 +86,7 @@ class TaskSpecification {
|
||||
/// Create a task specification from the raw fields. This constructor omits
|
||||
/// some values and sets them to sensible defaults.
|
||||
///
|
||||
/// \param driver_id The driver ID, representing the job that this task is a
|
||||
/// \param job_id The driver ID, representing the job that this task is a
|
||||
/// part of.
|
||||
/// \param parent_task_id The task ID of the task that spawned this task.
|
||||
/// \param parent_counter The number of tasks that this task's parent spawned
|
||||
@@ -96,7 +96,7 @@ class TaskSpecification {
|
||||
/// \param num_returns The number of values returned by the task.
|
||||
/// \param required_resources The task's resource demands.
|
||||
/// \param language The language of the worker that must execute the function.
|
||||
TaskSpecification(const DriverID &driver_id, const TaskID &parent_task_id,
|
||||
TaskSpecification(const JobID &job_id, const TaskID &parent_task_id,
|
||||
int64_t parent_counter,
|
||||
const std::vector<std::shared_ptr<TaskArgument>> &task_arguments,
|
||||
int64_t num_returns,
|
||||
@@ -107,7 +107,7 @@ class TaskSpecification {
|
||||
// TODO(swang): Define an actor task constructor.
|
||||
/// Create a task specification from the raw fields.
|
||||
///
|
||||
/// \param driver_id The driver ID, representing the job that this task is a
|
||||
/// \param job_id The driver ID, representing the job that this task is a
|
||||
/// part of.
|
||||
/// \param parent_task_id The task ID of the task that spawned this task.
|
||||
/// \param parent_counter The number of tasks that this task's parent spawned
|
||||
@@ -130,7 +130,7 @@ class TaskSpecification {
|
||||
/// \param function_descriptor The function descriptor.
|
||||
/// \param dynamic_worker_options The dynamic options for starting an actor worker.
|
||||
TaskSpecification(
|
||||
const DriverID &driver_id, const TaskID &parent_task_id, int64_t parent_counter,
|
||||
const JobID &job_id, const TaskID &parent_task_id, int64_t parent_counter,
|
||||
const ActorID &actor_creation_id, const ObjectID &actor_creation_dummy_object_id,
|
||||
int64_t max_actor_reconstructions, const ActorID &actor_id,
|
||||
const ActorHandleID &actor_handle_id, int64_t actor_counter,
|
||||
@@ -171,7 +171,7 @@ class TaskSpecification {
|
||||
|
||||
// TODO(swang): Finalize and document these methods.
|
||||
TaskID TaskId() const;
|
||||
DriverID DriverId() const;
|
||||
JobID JobId() const;
|
||||
TaskID ParentTaskId() const;
|
||||
int64_t ParentCounter() const;
|
||||
std::vector<std::string> FunctionDescriptor() const;
|
||||
|
||||
@@ -64,7 +64,7 @@ TEST(TaskSpecTest, TaskInfoSize) {
|
||||
}
|
||||
// General task.
|
||||
auto spec = CreateTaskInfo(
|
||||
fbb, to_flatbuf(fbb, DriverID::FromRandom()), to_flatbuf(fbb, task_id),
|
||||
fbb, to_flatbuf(fbb, JobID::FromRandom()), to_flatbuf(fbb, task_id),
|
||||
to_flatbuf(fbb, TaskID::FromRandom()), 0, to_flatbuf(fbb, ActorID::Nil()),
|
||||
to_flatbuf(fbb, ObjectID::Nil()), 0, to_flatbuf(fbb, ActorID::Nil()),
|
||||
to_flatbuf(fbb, ActorHandleID::Nil()), 0,
|
||||
@@ -83,7 +83,7 @@ TEST(TaskSpecTest, TaskInfoSize) {
|
||||
}
|
||||
// General task.
|
||||
auto spec = CreateTaskInfo(
|
||||
fbb, to_flatbuf(fbb, DriverID::FromRandom()), to_flatbuf(fbb, task_id),
|
||||
fbb, to_flatbuf(fbb, JobID::FromRandom()), to_flatbuf(fbb, task_id),
|
||||
to_flatbuf(fbb, TaskID::FromRandom()), 10, to_flatbuf(fbb, ActorID::FromRandom()),
|
||||
to_flatbuf(fbb, ObjectID::FromRandom()), 10000000,
|
||||
to_flatbuf(fbb, ActorID::FromRandom()),
|
||||
|
||||
@@ -50,11 +50,9 @@ const std::unordered_set<TaskID> &Worker::GetBlockedTaskIds() const {
|
||||
return blocked_task_ids_;
|
||||
}
|
||||
|
||||
void Worker::AssignDriverId(const DriverID &driver_id) {
|
||||
assigned_driver_id_ = driver_id;
|
||||
}
|
||||
void Worker::AssignJobId(const JobID &job_id) { assigned_job_id_ = job_id; }
|
||||
|
||||
const DriverID &Worker::GetAssignedDriverId() const { return assigned_driver_id_; }
|
||||
const JobID &Worker::GetAssignedJobId() const { return assigned_job_id_; }
|
||||
|
||||
void Worker::AssignActorId(const ActorID &actor_id) {
|
||||
RAY_CHECK(actor_id_.IsNil())
|
||||
|
||||
@@ -34,8 +34,8 @@ class Worker {
|
||||
bool AddBlockedTaskId(const TaskID &task_id);
|
||||
bool RemoveBlockedTaskId(const TaskID &task_id);
|
||||
const std::unordered_set<TaskID> &GetBlockedTaskIds() const;
|
||||
void AssignDriverId(const DriverID &driver_id);
|
||||
const DriverID &GetAssignedDriverId() const;
|
||||
void AssignJobId(const JobID &job_id);
|
||||
const JobID &GetAssignedJobId() const;
|
||||
void AssignActorId(const ActorID &actor_id);
|
||||
const ActorID &GetActorId() const;
|
||||
/// Return the worker's connection.
|
||||
@@ -60,8 +60,8 @@ class Worker {
|
||||
std::shared_ptr<LocalClientConnection> connection_;
|
||||
/// The worker's currently assigned task.
|
||||
TaskID assigned_task_id_;
|
||||
/// Driver ID for the worker's current assigned task.
|
||||
DriverID assigned_driver_id_;
|
||||
/// Job ID for the worker's current assigned task.
|
||||
JobID assigned_job_id_;
|
||||
/// The worker's actor ID. If this is nil, then the worker is not an actor.
|
||||
ActorID actor_id_;
|
||||
/// Whether the worker is dead.
|
||||
|
||||
@@ -319,13 +319,13 @@ inline WorkerPool::State &WorkerPool::GetStateForLanguage(const Language &langua
|
||||
return state->second;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Worker>> WorkerPool::GetWorkersRunningTasksForDriver(
|
||||
const DriverID &driver_id) const {
|
||||
std::vector<std::shared_ptr<Worker>> WorkerPool::GetWorkersRunningTasksForJob(
|
||||
const JobID &job_id) const {
|
||||
std::vector<std::shared_ptr<Worker>> workers;
|
||||
|
||||
for (const auto &entry : states_by_lang_) {
|
||||
for (const auto &worker : entry.second.registered_workers) {
|
||||
if (worker->GetAssignedDriverId() == driver_id) {
|
||||
if (worker->GetAssignedJobId() == job_id) {
|
||||
workers.push_back(worker);
|
||||
}
|
||||
}
|
||||
@@ -355,7 +355,7 @@ void WorkerPool::WarnAboutSize() {
|
||||
<< "(see https://github.com/ray-project/ray/issues/3644) for "
|
||||
<< "some a discussion of workarounds.";
|
||||
RAY_CHECK_OK(gcs_client_->error_table().PushErrorToDriver(
|
||||
DriverID::Nil(), "worker_pool_large", warning_message.str(), current_time_ms()));
|
||||
JobID::Nil(), "worker_pool_large", warning_message.str(), current_time_ms()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,12 +102,12 @@ class WorkerPool {
|
||||
/// \return The total count of all workers (actor and non-actor) in the pool.
|
||||
uint32_t Size(const Language &language) const;
|
||||
|
||||
/// Get all the workers which are running tasks for a given driver.
|
||||
/// Get all the workers which are running tasks for a given job.
|
||||
///
|
||||
/// \param driver_id The driver ID.
|
||||
/// \return A list containing all the workers which are running tasks for the driver.
|
||||
std::vector<std::shared_ptr<Worker>> GetWorkersRunningTasksForDriver(
|
||||
const DriverID &driver_id) const;
|
||||
/// \param job_id The job ID.
|
||||
/// \return A list containing all the workers which are running tasks for the job.
|
||||
std::vector<std::shared_ptr<Worker>> GetWorkersRunningTasksForJob(
|
||||
const JobID &job_id) const;
|
||||
|
||||
/// Whether there is a pending worker for the given task.
|
||||
/// Note that, this is only used for actor creation task with dynamic options.
|
||||
|
||||
@@ -109,7 +109,7 @@ static inline TaskSpecification ExampleTaskSpec(
|
||||
const ActorID actor_id = ActorID::Nil(), const Language &language = Language::PYTHON,
|
||||
const ActorID actor_creation_id = ActorID::Nil()) {
|
||||
std::vector<std::string> function_descriptor(3);
|
||||
return TaskSpecification(DriverID::Nil(), TaskID::Nil(), 0, actor_creation_id,
|
||||
return TaskSpecification(JobID::Nil(), TaskID::Nil(), 0, actor_creation_id,
|
||||
ObjectID::Nil(), 0, actor_id, ActorHandleID::Nil(), 0, {}, {},
|
||||
0, {}, {}, language, function_descriptor);
|
||||
}
|
||||
@@ -226,7 +226,7 @@ TEST_F(WorkerPoolTest, StartWorkerWithDynamicOptionsCommand) {
|
||||
SetWorkerCommands({{Language::PYTHON, {"dummy_py_worker_command"}},
|
||||
{Language::JAVA, java_worker_command}});
|
||||
|
||||
TaskSpecification task_spec(DriverID::Nil(), TaskID::Nil(), 0, ActorID::FromRandom(),
|
||||
TaskSpecification task_spec(JobID::Nil(), TaskID::Nil(), 0, ActorID::FromRandom(),
|
||||
ObjectID::Nil(), 0, ActorID::Nil(), ActorHandleID::Nil(), 0,
|
||||
{}, {}, 0, {}, {}, Language::JAVA, {"", "", ""},
|
||||
{"test_op_0", "test_op_1"});
|
||||
|
||||
Reference in New Issue
Block a user