| 189 | } |
| 190 | |
| 191 | void NetworkPrioritizerService::onEnable() { |
| 192 | std::string controllers; |
| 193 | if (getProperty(NetworkControllers.getName(), controllers) || !linked_services_.empty()) { |
| 194 | // if this controller service is defined, it will be an intersection of this config with linked services. |
| 195 | if (getProperty(MaxThroughput.getName(), max_throughput_)) { |
| 196 | logger_->log_trace("Max throughput is %d", max_throughput_); |
| 197 | if (max_throughput_ < 1000) { |
| 198 | bytes_per_token_ = 1; |
| 199 | tokens_ = gsl::narrow<uint32_t>(max_throughput_); |
| 200 | } else { |
| 201 | bytes_per_token_ = gsl::narrow<uint32_t>(max_throughput_ / 1000); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | getProperty(MaxPayload.getName(), max_payload_); |
| 206 | |
| 207 | if (!controllers.empty()) { |
| 208 | network_controllers_ = utils::StringUtils::split(controllers, ","); |
| 209 | for (const auto &ifc : network_controllers_) { |
| 210 | logger_->log_trace("%s added to list of applied interfaces", ifc); |
| 211 | } |
| 212 | } |
| 213 | bool is_default = false; |
| 214 | if (getProperty(DefaultPrioritizer.getName(), is_default)) { |
| 215 | if (is_default) { |
| 216 | if (io::NetworkPrioritizerFactory::getInstance()->setPrioritizer(shared_from_this()) < 0) { |
| 217 | std::runtime_error("Can only have one prioritizer"); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | getProperty(VerifyInterfaces.getName(), verify_interfaces_); |
| 222 | timestamp_ = clock_->timeSinceEpoch().count(); |
| 223 | enabled_ = true; |
| 224 | logger_->log_trace("Enabled"); |
| 225 | } else { |
| 226 | logger_->log_trace("Could not enable "); |
| 227 | } |
| 228 | } |
| 229 | } /* namespace controllers */ |
| 230 | } /* namespace minifi */ |
| 231 | } /* namespace nifi */ |
nothing calls this directly
no test coverage detected