Github user benqiu2016 commented on a diff in the pull request:
https://github.com/apache/nifi-minifi-cpp/pull/114#discussion_r123527427
--- Diff: libminifi/src/RemoteProcessorGroupPort.cpp ---
@@ -54,19 +57,29 @@ bool create = true) {
std::unique_ptr<Site2SiteClientProtocol> nextProtocol = nullptr;
if (!available_protocols_.try_dequeue(nextProtocol)) {
if (create) {
+ refreshPeerList();
// create
- nextProtocol = std::unique_ptr<Site2SiteClientProtocol>(new
Site2SiteClientProtocol(nullptr));
- nextProtocol->setPortId(protocol_uuid_);
- std::unique_ptr<org::apache::nifi::minifi::io::DataStream> str =
std::unique_ptr<org::apache::nifi::minifi::io::DataStream>(stream_factory_->createSocket(host_,
port_));
- std::unique_ptr<Site2SitePeer> peer_ =
std::unique_ptr<Site2SitePeer>(new Site2SitePeer(std::move(str), host_, port_));
- nextProtocol->setPeer(std::move(peer_));
+ for (auto peer : site2site_peer_status_list_) {
+ std::unique_ptr<Site2SiteClientProtocol> protocol = nullptr;
+ protocol = std::unique_ptr < Site2SiteClientProtocol
+ > (new Site2SiteClientProtocol(nullptr));
+ protocol->setPortId(protocol_uuid_);
+ std::unique_ptr<org::apache::nifi::minifi::io::DataStream> str =
+ std::unique_ptr < org::apache::nifi::minifi::io::DataStream
+ > (stream_factory_->createSocket(peer.host_, peer.port_));
+ std::unique_ptr<Site2SitePeer> peer_ = std::unique_ptr <
Site2SitePeer
+ > (new Site2SitePeer(std::move(str), peer.host_, peer.port_));
+ protocol->setPeer(std::move(peer_));
+ returnProtocol(std::move(protocol));
+ }
}
+ available_protocols_.try_dequeue(nextProtocol);
}
return std::move(nextProtocol);
}
void
RemoteProcessorGroupPort::returnProtocol(std::unique_ptr<Site2SiteClientProtocol>
return_protocol) {
- if (available_protocols_.size_approx() >= max_concurrent_tasks_) {
+ if (available_protocols_.size_approx() >= (max_concurrent_tasks_ *
site2site_peer_status_list_.size())) {
--- End diff --
i need to round robin the peer even for a single thread to distribute the
load cross all peers.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---