| 113 | } |
| 114 | |
| 115 | bool SiteToSiteClient::transferFlowFiles(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) { |
| 116 | auto flow = session->get(); |
| 117 | |
| 118 | std::shared_ptr<Transaction> transaction = nullptr; |
| 119 | |
| 120 | if (!flow) { |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | if (peer_state_ != READY) { |
| 125 | if (!bootstrap()) |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | if (peer_state_ != READY) { |
| 130 | context->yield(); |
| 131 | tearDown(); |
| 132 | throw Exception(SITE2SITE_EXCEPTION, "Can not establish handshake with peer"); |
| 133 | } |
| 134 | |
| 135 | // Create the transaction |
| 136 | transaction = createTransaction(SEND); |
| 137 | if (transaction == nullptr) { |
| 138 | context->yield(); |
| 139 | tearDown(); |
| 140 | throw Exception(SITE2SITE_EXCEPTION, "Can not create transaction"); |
| 141 | } |
| 142 | utils::Identifier transactionID = transaction->getUUID(); |
| 143 | |
| 144 | bool continueTransaction = true; |
| 145 | uint64_t startSendingNanos = utils::timeutils::getTimeNano(); |
| 146 | |
| 147 | try { |
| 148 | while (continueTransaction) { |
| 149 | uint64_t startTime = utils::timeutils::getTimeMillis(); |
| 150 | std::string payload; |
| 151 | DataPacket packet(getLogger(), transaction, flow->getAttributes(), payload); |
| 152 | |
| 153 | int16_t resp = send(transactionID, &packet, flow, session); |
| 154 | if (resp == -1) { |
| 155 | throw Exception(SITE2SITE_EXCEPTION, "Send Failed"); |
| 156 | } |
| 157 | |
| 158 | logger_->log_debug("Site2Site transaction %s send flow record %s", transactionID.to_string(), flow->getUUIDStr()); |
| 159 | if (resp == 0) { |
| 160 | uint64_t endTime = utils::timeutils::getTimeMillis(); |
| 161 | std::string transitUri = peer_->getURL() + "/" + flow->getUUIDStr(); |
| 162 | std::string details = "urn:nifi:" + flow->getUUIDStr() + "Remote Host=" + peer_->getHostName(); |
| 163 | session->getProvenanceReporter()->send(flow, transitUri, details, endTime - startTime, false); |
| 164 | } |
| 165 | session->remove(flow); |
| 166 | |
| 167 | uint64_t transferNanos = utils::timeutils::getTimeNano() - startSendingNanos; |
| 168 | if (transferNanos > _batchSendNanos) |
| 169 | break; |
| 170 | |
| 171 | flow = session->get(); |
| 172 |
nothing calls this directly
no test coverage detected