mirror of https://github.com/milvus-io/milvus.git
Merge branch 'branch-0.4.0' into 'branch-0.4.0'
MS-402 Add dump implementation for TaskTableItem See merge request megasearch/milvus!405 Former-commit-id: 2e0906cdbc8e4bae7c14e3ae25f71683a71344c0pull/191/head
commit
86779397b1
|
@ -39,6 +39,7 @@ Please mark all change in change log and use the ticket from JIRA.
|
|||
- MS-391 - Add PushTaskToNeighbourHasExecutor action
|
||||
- MS-394 - Update scheduler unittest
|
||||
- MS-400 - Add timestamp record in task state change function
|
||||
- MS-402 - Add dump implementation for TaskTableItem
|
||||
|
||||
## New Feature
|
||||
- MS-343 - Implement ResourceMgr
|
||||
|
|
|
@ -99,7 +99,8 @@ ResourceMgr::DumpTaskTables() {
|
|||
ss << ">>>>>>>>>>>>>>>ResourceMgr::DumpTaskTable<<<<<<<<<<<<<<<" << std::endl;
|
||||
for (auto &resource : resources_) {
|
||||
ss << resource->Dump() << std::endl;
|
||||
ss << resource->task_table().Dump() << std::endl;
|
||||
ss << resource->task_table().Dump();
|
||||
ss << resource->Dump() << std::endl << std::endl;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,35 @@ get_now_timestamp() {
|
|||
return millis;
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString(TaskTableItemState state) {
|
||||
switch (state) {
|
||||
case TaskTableItemState::INVALID: return "INVALID";
|
||||
case TaskTableItemState::START: return "START";
|
||||
case TaskTableItemState::LOADING: return "LOADING";
|
||||
case TaskTableItemState::LOADED: return "LOADED";
|
||||
case TaskTableItemState::EXECUTING: return "EXECUTING";
|
||||
case TaskTableItemState::EXECUTED: return "EXECUTED";
|
||||
case TaskTableItemState::MOVING: return "MOVING";
|
||||
case TaskTableItemState::MOVED: return "MOVED";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString(const TaskTimestamp ×tamp) {
|
||||
std::stringstream ss;
|
||||
ss << "<start=" << timestamp.start;
|
||||
ss << ", load=" << timestamp.load;
|
||||
ss << ", loaded=" << timestamp.loaded;
|
||||
ss << ", execute=" << timestamp.execute;
|
||||
ss << ", executed=" << timestamp.executed;
|
||||
ss << ", move=" << timestamp.move;
|
||||
ss << ", moved=" << timestamp.moved;
|
||||
ss << ">";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool
|
||||
TaskTableItem::Load() {
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
|
@ -90,6 +119,16 @@ TaskTableItem::Moved() {
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string
|
||||
TaskTableItem::Dump() {
|
||||
std::stringstream ss;
|
||||
ss << "<id=" << id;
|
||||
ss << ", task=" << task;
|
||||
ss << ", state=" << ToString(state);
|
||||
ss << ", timestamp=" << ToString(timestamp);
|
||||
ss << ">";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void
|
||||
TaskTable::Put(TaskPtr task) {
|
||||
|
@ -98,6 +137,7 @@ TaskTable::Put(TaskPtr task) {
|
|||
item->id = id_++;
|
||||
item->task = std::move(task);
|
||||
item->state = TaskTableItemState::START;
|
||||
item->timestamp.start = get_now_timestamp();
|
||||
table_.push_back(item);
|
||||
if (subscriber_) {
|
||||
subscriber_();
|
||||
|
@ -112,6 +152,7 @@ TaskTable::Put(std::vector<TaskPtr> &tasks) {
|
|||
item->id = id_++;
|
||||
item->task = std::move(task);
|
||||
item->state = TaskTableItemState::START;
|
||||
item->timestamp.start = get_now_timestamp();
|
||||
table_.push_back(item);
|
||||
}
|
||||
if (subscriber_) {
|
||||
|
@ -135,43 +176,12 @@ TaskTable::Clear() {
|
|||
// table_.erase(table_.begin(), iterator);
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString(TaskTableItemState state) {
|
||||
switch (state) {
|
||||
case TaskTableItemState::INVALID: return "INVALID";
|
||||
case TaskTableItemState::START: return "START";
|
||||
case TaskTableItemState::LOADING: return "LOADING";
|
||||
case TaskTableItemState::LOADED: return "LOADED";
|
||||
case TaskTableItemState::EXECUTING: return "EXECUTING";
|
||||
case TaskTableItemState::EXECUTED: return "EXECUTED";
|
||||
case TaskTableItemState::MOVING: return "MOVING";
|
||||
case TaskTableItemState::MOVED: return "MOVED";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString(const TaskTimestamp ×tamp) {
|
||||
std::stringstream ss;
|
||||
ss << "<start=" << timestamp.start;
|
||||
ss << ", load=" << timestamp.load;
|
||||
ss << ", loaded=" << timestamp.loaded;
|
||||
ss << ", execute=" << timestamp.execute;
|
||||
ss << ", executed=" << timestamp.executed;
|
||||
ss << ", move=" << timestamp.move;
|
||||
ss << ", moved=" << timestamp.moved;
|
||||
ss << ">";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string
|
||||
TaskTable::Dump() {
|
||||
std::stringstream ss;
|
||||
for (auto &item : table_) {
|
||||
ss << "<id=" << item->id;
|
||||
ss << ", state=" << ToString(item->state);
|
||||
ss << ", timestamp=" << ToString(item->timestamp);
|
||||
ss << ">" << std::endl;
|
||||
ss << item->Dump() << std::endl;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,9 @@ struct TaskTableItem {
|
|||
|
||||
bool
|
||||
Moved();
|
||||
|
||||
std::string
|
||||
Dump();
|
||||
};
|
||||
|
||||
using TaskTableItemPtr = std::shared_ptr<TaskTableItem>;
|
||||
|
|
Loading…
Reference in New Issue