• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HDFGroup / hermes / 4837525566

pending completion
4837525566

Pull #515

github

GitHub
Merge f018521fc into 87672e106
Pull Request #515: v1.0

5502 of 5502 new or added lines in 117 files covered. (100.0%)

4997 of 7300 relevant lines covered (68.45%)

6194762.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/config_server.cc
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 * Distributed under BSD 3-Clause license.                                   *
3
 * Copyright by The HDF Group.                                               *
4
 * Copyright by the Illinois Institute of Technology.                        *
5
 * All rights reserved.                                                      *
6
 *                                                                           *
7
 * This file is part of Hermes. The full Hermes copyright notice, including  *
8
 * terms governing use, modification, and redistribution, is contained in    *
9
 * the COPYING file, which can be found at the top directory. If you do not  *
10
 * have access to the file, you may request a copy from help@hdfgroup.org.   *
11
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12

13
#include <string.h>
14
#include <yaml-cpp/yaml.h>
15
#include <ostream>
16
#include "hermes_shm/util/logging.h"
17
#include "utils.h"
18
#include "config.h"
19
#include "hermes_shm/util/config_parse.h"
20

21
#include "config_server.h"
22
#include "config_server_default.h"
23

24
namespace hermes::config {
25

26
/** parse device information from YAML config */
27
void ServerConfig::ParseDeviceInfo(YAML::Node yaml_conf) {
210✔
28
  devices_ = hipc::make_uptr<hipc::vector<DeviceInfo>>();
210✔
29
  for (auto device : yaml_conf) {
3,360✔
30
    devices_->emplace_back();
840✔
31
    DeviceInfo &dev = devices_->back();
840✔
32
    auto dev_info = device.second;
1,680✔
33
    (*dev.dev_name_) = device.first.as<std::string>();
840✔
34
    (*dev.mount_dir_) = hshm::ConfigParse::ExpandPath(
1,680✔
35
        dev_info["mount_point"].as<std::string>());
2,520✔
36
    dev.borg_min_thresh_ =
1,680✔
37
        dev_info["borg_capacity_thresh"][0].as<float>();
840✔
38
    dev.borg_max_thresh_ =
1,680✔
39
        dev_info["borg_capacity_thresh"][1].as<float>();
840✔
40
    dev.is_shared_ =
1,680✔
41
        dev_info["is_shared_device"].as<bool>();
840✔
42
    dev.block_size_ =
840✔
43
        hshm::ConfigParse::ParseSize(dev_info["block_size"].as<std::string>());
1,680✔
44
    dev.capacity_ =
840✔
45
        hshm::ConfigParse::ParseSize(dev_info["capacity"].as<std::string>());
1,680✔
46
    dev.bandwidth_ =
840✔
47
        hshm::ConfigParse::ParseSize(dev_info["bandwidth"].as<std::string>());
1,680✔
48
    dev.latency_ =
840✔
49
        hshm::ConfigParse::ParseLatency(dev_info["latency"].as<std::string>());
1,680✔
50
    std::vector<std::string> size_vec;
1,680✔
51
    ParseVector<std::string, std::vector<std::string>>(
840✔
52
        dev_info["slab_sizes"], size_vec);
53
    dev.slab_sizes_->reserve(size_vec.size());
840✔
54
    for (const std::string &size_str : size_vec) {
4,200✔
55
      dev.slab_sizes_->emplace_back(hshm::ConfigParse::ParseSize(size_str));
3,360✔
56
    }
57
  }
58
}
210✔
59

60
/** parse RPC information from YAML config */
61
void ServerConfig::ParseRpcInfo(YAML::Node yaml_conf) {
210✔
62
  std::string suffix;
210✔
63

64
  if (yaml_conf["host_file"]) {
420✔
65
    rpc_.host_file_ =
210✔
66
        hshm::ConfigParse::ExpandPath(yaml_conf["host_file"].as<std::string>());
210✔
67
    rpc_.host_names_.clear();
210✔
68
  }
69
  if (yaml_conf["host_names"] && rpc_.host_file_.size() == 0) {
420✔
70
    // NOTE(llogan): host file is prioritized
71
    rpc_.host_names_.clear();
210✔
72
    for (YAML::Node host_name_gen : yaml_conf["host_names"]) {
1,680✔
73
      std::string host_names = host_name_gen.as<std::string>();
420✔
74
      hshm::ConfigParse::ParseHostNameString(host_names, rpc_.host_names_);
630✔
75
    }
76
  }
77
  if (yaml_conf["domain"]) {
420✔
78
    rpc_.domain_ = yaml_conf["domain"].as<std::string>();
210✔
79
  }
80
  if (yaml_conf["protocol"]) {
420✔
81
    rpc_.protocol_ = yaml_conf["protocol"].as<std::string>();
210✔
82
  }
83
  if (yaml_conf["port"]) {
420✔
84
    rpc_.port_ = yaml_conf["port"].as<int>();
210✔
85
  }
86
  if (yaml_conf["num_threads"]) {
420✔
87
    rpc_.num_threads_ = yaml_conf["num_threads"].as<int>();
210✔
88
  }
89
}
210✔
90

91
/** parse dpe information from YAML config */
92
void ServerConfig::ParseDpeInfo(YAML::Node yaml_conf) {
210✔
93
  if (yaml_conf["default_placement_policy"]) {
420✔
94
    std::string policy =
210✔
95
        yaml_conf["default_placement_policy"].as<std::string>();
420✔
96
    dpe_.default_policy_ = api::PlacementPolicyConv::to_enum(policy);
210✔
97
  }
98
}
210✔
99

100
/** parse buffer organizer information from YAML config */
101
void ServerConfig::ParseBorgInfo(YAML::Node yaml_conf) {
210✔
102
  if (yaml_conf["port"]) {
420✔
103
    borg_.port_ = yaml_conf["port"].as<int>();
210✔
104
  }
105
  if (yaml_conf["num_threads"]) {
420✔
106
    borg_.num_threads_ = yaml_conf["num_threads"].as<int>();
210✔
107
  }
108
}
210✔
109

110
/** parse I/O tracing information from YAML config */
111
void ServerConfig::ParseTracingInfo(YAML::Node yaml_conf) {
×
112
  if (yaml_conf["enabled"]) {
×
113
    tracing_.enabled_ = yaml_conf["enabled"].as<bool>();
×
114
  }
115
  if (yaml_conf["output"]) {
×
116
    tracing_.output_ = hshm::ConfigParse::ExpandPath(
×
117
        yaml_conf["output"].as<std::string>());
×
118
  }
119
}
×
120

121
/** parse prefetch information from YAML config */
122
void ServerConfig::ParsePrefetchInfo(YAML::Node yaml_conf) {
210✔
123
  if (yaml_conf["enabled"]) {
420✔
124
    prefetcher_.enabled_ = yaml_conf["enabled"].as<bool>();
210✔
125
  }
126
  if (yaml_conf["io_trace_path"]) {
420✔
127
    prefetcher_.trace_path_ = hshm::ConfigParse::ExpandPath(
210✔
128
        yaml_conf["io_trace_path"].as<std::string>());
315✔
129
  }
130
  if (yaml_conf["epoch_ms"]) {
420✔
131
    prefetcher_.epoch_ms_ = yaml_conf["epoch_ms"].as<size_t>();
105✔
132
  }
133
  if (yaml_conf["is_mpi"]) {
420✔
134
    prefetcher_.is_mpi_ = yaml_conf["is_mpi"].as<bool>();
105✔
135
  }
136
}
210✔
137

138
/** parse prefetch information from YAML config */
139
void ServerConfig::ParseTraitInfo(YAML::Node yaml_conf) {
105✔
140
  std::vector<std::string> trait_names;
210✔
141
  ParseVector<std::string, std::vector<std::string>>(
105✔
142
      yaml_conf, trait_names);
143
  trait_paths_.reserve(trait_names.size());
105✔
144
  for (auto &name : trait_names) {
525✔
145
    name = hshm::ConfigParse::ExpandPath(name);
1,260✔
146
    trait_paths_.emplace_back(
420✔
147
        hshm::Formatter::format("lib{}.so", name));
840✔
148
  }
149
}
105✔
150

151
/** parse the YAML node */
152
void ServerConfig::ParseYAML(YAML::Node &yaml_conf) {
210✔
153
  if (yaml_conf["devices"]) {
420✔
154
    ParseDeviceInfo(yaml_conf["devices"]);
210✔
155
  }
156
  if (yaml_conf["rpc"]) {
420✔
157
    ParseRpcInfo(yaml_conf["rpc"]);
210✔
158
  }
159
  if (yaml_conf["dpe"]) {
420✔
160
    ParseDpeInfo(yaml_conf["dpe"]);
210✔
161
  }
162
  if (yaml_conf["buffer_organizer"]) {
420✔
163
    ParseBorgInfo(yaml_conf["buffer_organizer"]);
210✔
164
  }
165
  if (yaml_conf["tracing"]) {
420✔
166
    ParsePrefetchInfo(yaml_conf["tracing"]);
105✔
167
  }
168
  if (yaml_conf["prefetch"]) {
420✔
169
    ParsePrefetchInfo(yaml_conf["prefetch"]);
105✔
170
  }
171
  if (yaml_conf["system_view_state_update_interval_ms"]) {
420✔
172
    system_view_state_update_interval_ms =
420✔
173
        yaml_conf["system_view_state_update_interval_ms"].as<int>();
210✔
174
  }
175
  if (yaml_conf["traits"]) {
420✔
176
    ParseTraitInfo(yaml_conf["traits"]);
105✔
177
  }
178
  if (yaml_conf["shmem_name"]) {
420✔
179
    shmem_name_ = yaml_conf["shmem_name"].as<std::string>();
210✔
180
  }
181
}
210✔
182

183
/** Load the default configuration */
184
void ServerConfig::LoadDefault() {
105✔
185
  LoadText(kServerDefaultConfigStr, false);
105✔
186
}
105✔
187

188
}  // namespace hermes::config
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc