MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / receive

Method receive

libminifi/src/sitetosite/SiteToSiteClient.cpp:531–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531bool SiteToSiteClient::receive(const utils::Identifier& transactionID, DataPacket *packet, bool &eof) {
532 int ret;
533 std::shared_ptr<Transaction> transaction = NULL;
534
535 if (peer_state_ != READY) {
536 bootstrap();
537 }
538
539 if (peer_state_ != READY) {
540 return false;
541 }
542
543 auto it = this->known_transactions_.find(transactionID);
544
545 if (it == known_transactions_.end()) {
546 return false;
547 }
548
549 transaction = it->second;
550
551 if (transaction->getState() != TRANSACTION_STARTED && transaction->getState() != DATA_EXCHANGED) {
552 logger_->log_warn("Site2Site transaction %s is not at started or exchanged state", transactionID.to_string());
553 return false;
554 }
555
556 if (transaction->getDirection() != RECEIVE) {
557 logger_->log_warn("Site2Site transaction %s direction is wrong", transactionID.to_string());
558 return false;
559 }
560
561 if (!transaction->isDataAvailable()) {
562 eof = true;
563 return true;
564 }
565
566 if (transaction->current_transfers_ > 0) {
567 // if we already has transfer before, check to see whether another one is available
568 RespondCode code;
569 std::string message;
570
571 ret = readResponse(transaction, code, message);
572
573 if (ret <= 0) {
574 return false;
575 }
576 if (code == CONTINUE_TRANSACTION) {
577 logger_->log_debug("Site2Site transaction %s peer indicate continue transaction", transactionID.to_string());
578 transaction->_dataAvailable = true;
579 } else if (code == FINISH_TRANSACTION) {
580 logger_->log_debug("Site2Site transaction %s peer indicate finish transaction", transactionID.to_string());
581 transaction->_dataAvailable = false;
582 eof = true;
583 return true;
584 } else {
585 logger_->log_debug("Site2Site transaction %s peer indicate wrong respond code %d", transactionID.to_string(), code);
586 return false;
587 }
588 }

Callers 1

receiveFlowFilesMethod · 0.45

Calls 12

bootstrapFunction · 0.85
readResponseFunction · 0.85
log_warnMethod · 0.80
getDirectionMethod · 0.80
isDataAvailableMethod · 0.80
log_debugMethod · 0.80
getStreamMethod · 0.80
findMethod · 0.45
endMethod · 0.45
getStateMethod · 0.45
to_stringMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected