Connection.h 1.6 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

W
wxyu 已提交
18 19 20 21
#pragma once

#include <string>
#include <sstream>
G
groot 已提交
22
#include <utility>
W
wxyu 已提交
23 24 25

namespace zilliz {
namespace milvus {
W
wxyu 已提交
26
namespace scheduler {
W
wxyu 已提交
27 28

class Connection {
G
groot 已提交
29
 public:
W
wxyu 已提交
30
    // TODO: update construct function, speed: double->uint64_t
W
wxyu 已提交
31
    Connection(std::string name, double speed)
G
groot 已提交
32 33
        : name_(std::move(name)), speed_(speed) {
    }
W
wxyu 已提交
34 35

    const std::string &
Y
Yu Kun 已提交
36
    name() const {
W
wxyu 已提交
37 38 39
        return name_;
    }

Y
Yu Kun 已提交
40 41
    uint64_t
    speed() const {
W
wxyu 已提交
42 43 44
        return speed_;
    }

45 46 47 48 49
    uint64_t
    transport_cost() {
        return 1024 / speed_;
    }

G
groot 已提交
50
 public:
W
wxyu 已提交
51 52 53 54 55 56 57
    std::string
    Dump() const {
        std::stringstream ss;
        ss << "<name: " << name_ << ", speed: " << speed_ << ">";
        return ss.str();
    }

G
groot 已提交
58
 private:
W
wxyu 已提交
59
    std::string name_;
Y
Yu Kun 已提交
60
    uint64_t speed_;
W
wxyu 已提交
61 62
};

G
groot 已提交
63 64 65
} // namespace scheduler
} // namespace milvus
} // namespace zilliz