Commit 8958233e authored by Jin Hai's avatar Jin Hai Committed by GitHub
Browse files

Merge pull request #70 from scsven/dev

Improvement dump function in scheduler

Former-commit-id: f187d7db98df6c3baef87c1970f7ee586304ad3f
parents 5756ba1d 02aeb86b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ Please mark all change in change log and use the ticket from JIRA.

## Bug
## Improvement
- \#64 - Improvement dump function in scheduler

## Feature
## Task

+1 −0
Original line number Diff line number Diff line
@@ -26,4 +26,5 @@
| gperftools    | [BSD 3-Clause](https://github.com/gperftools/gperftools/blob/master/COPYING)                                                 |
| grpc          | [Apache 2.0](https://github.com/grpc/grpc/blob/master/LICENSE)                                                   |
| EASYLOGGINGPP | [MIT](https://github.com/zuhd-org/easyloggingpp/blob/master/LICENSEhttps://github.com/zuhd-org/easyloggingpp/blob/master/LICENSE)                                                          |
| Json          | [MIT](https://github.com/nlohmann/json/blob/develop/LICENSE.MIT)                                                          |
+22684 −0

File added.

Preview size limit exceeded, changes collapsed.

+19 −25
Original line number Diff line number Diff line
@@ -52,19 +52,13 @@ ToString(TaskTableItemState state) {
    }
}

std::string
ToString(const TaskTimestamp& timestamp) {
    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 << ", finish=" << timestamp.finish;
    ss << ">";
    return ss.str();
json
TaskTimestamp::Dump() {
    json ret{
        {"start", start},       {"load", load}, {"loaded", loaded}, {"execute", execute},
        {"executed", executed}, {"move", move}, {"moved", moved},   {"finish", finish},
    };
    return ret;
}

bool
@@ -146,15 +140,15 @@ TaskTableItem::Moved() {
    return false;
}

std::string
json
TaskTableItem::Dump() {
    std::stringstream ss;
    ss << "<id=" << id;
    ss << ", task=" << task;
    ss << ", state=" << ToString(state);
    ss << ", timestamp=" << ToString(timestamp);
    ss << ">";
    return ss.str();
    json ret{
        {"id", id},
        {"task", (int64_t)task.get()},
        {"state", ToString(state)},
        {"timestamp", timestamp.Dump()},
    };
    return ret;
}

std::vector<uint64_t>
@@ -268,13 +262,13 @@ TaskTable::Get(uint64_t index) {
////        table_.erase(table_.begin(), iterator);
//}

std::string
json
TaskTable::Dump() {
    std::stringstream ss;
    json ret;
    for (auto& item : table_) {
        ss << item->Dump() << std::endl;
        ret.push_back(item->Dump());
    }
    return ss.str();
    return ret;
}

}  // namespace scheduler
+11 −7
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <vector>

#include "event/Event.h"
#include "interface/interfaces.h"
#include "task/SearchTask.h"

namespace milvus {
@@ -42,7 +43,7 @@ enum class TaskTableItemState {
    MOVED,      // moved, termination state
};

struct TaskTimestamp {
struct TaskTimestamp : public interface::dumpable {
    uint64_t start = 0;
    uint64_t move = 0;
    uint64_t moved = 0;
@@ -51,9 +52,12 @@ struct TaskTimestamp {
    uint64_t execute = 0;
    uint64_t executed = 0;
    uint64_t finish = 0;

    json
    Dump() override;
};

struct TaskTableItem {
struct TaskTableItem : public interface::dumpable {
    TaskTableItem() : id(0), task(nullptr), state(TaskTableItemState::INVALID), mutex() {
    }

@@ -87,13 +91,13 @@ struct TaskTableItem {
    bool
    Moved();

    std::string
    Dump();
    json
    Dump() override;
};

using TaskTableItemPtr = std::shared_ptr<TaskTableItem>;

class TaskTable {
class TaskTable : public interface::dumpable {
 public:
    TaskTable() = default;

@@ -240,8 +244,8 @@ class TaskTable {
    /*
     * Dump;
     */
    std::string
    Dump();
    json
    Dump() override;

 private:
    std::uint64_t id_ = 0;
Loading