| 64 | core::Relationship RemoteProcessorGroupPort::relation; |
| 65 | |
| 66 | std::unique_ptr<sitetosite::SiteToSiteClient> RemoteProcessorGroupPort::getNextProtocol(bool create = true) { |
| 67 | std::unique_ptr<sitetosite::SiteToSiteClient> nextProtocol = nullptr; |
| 68 | if (!available_protocols_.try_dequeue(nextProtocol)) { |
| 69 | if (create) { |
| 70 | // create |
| 71 | if (bypass_rest_api_) { |
| 72 | if (nifi_instances_.size() > 0) { |
| 73 | auto rpg = nifi_instances_.front(); |
| 74 | auto host = rpg.host_; |
| 75 | #ifdef WIN32 |
| 76 | if ("localhost" == host) { |
| 77 | host = org::apache::nifi::minifi::io::Socket::getMyHostName(); |
| 78 | } |
| 79 | #endif |
| 80 | sitetosite::SiteToSiteClientConfiguration config(stream_factory_, std::make_shared<sitetosite::Peer>(protocol_uuid_, host, rpg.port_, ssl_service != nullptr), this->getInterface(), |
| 81 | client_type_); |
| 82 | config.setHTTPProxy(this->proxy_); |
| 83 | config.setIdleTimeout(idle_timeout_); |
| 84 | nextProtocol = sitetosite::createClient(config); |
| 85 | } |
| 86 | } else if (peer_index_ >= 0) { |
| 87 | std::lock_guard<std::mutex> lock(peer_mutex_); |
| 88 | logger_->log_debug("Creating client from peer %d", peer_index_.load()); |
| 89 | sitetosite::SiteToSiteClientConfiguration config(stream_factory_, peers_[this->peer_index_].getPeer(), local_network_interface_, client_type_); |
| 90 | config.setSecurityContext(ssl_service); |
| 91 | peer_index_++; |
| 92 | if (peer_index_ >= static_cast<int>(peers_.size())) { |
| 93 | peer_index_ = 0; |
| 94 | } |
| 95 | config.setHTTPProxy(this->proxy_); |
| 96 | config.setIdleTimeout(idle_timeout_); |
| 97 | nextProtocol = sitetosite::createClient(config); |
| 98 | } else { |
| 99 | logger_->log_debug("Refreshing the peer list since there are none configured."); |
| 100 | refreshPeerList(); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | logger_->log_debug("Obtained protocol from available_protocols_"); |
| 105 | return nextProtocol; |
| 106 | } |
| 107 | |
| 108 | void RemoteProcessorGroupPort::returnProtocol(std::unique_ptr<sitetosite::SiteToSiteClient> return_protocol) { |
| 109 | auto count = peers_.size(); |
nothing calls this directly
no test coverage detected