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

Method receiveFlowFiles

libminifi/src/sitetosite/SiteToSiteClient.cpp:644–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642}
643
644bool SiteToSiteClient::receiveFlowFiles(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) {
645 uint64_t bytes = 0;
646 int transfers = 0;
647 std::shared_ptr<Transaction> transaction = NULL;
648
649 if (peer_state_ != READY) {
650 if (!bootstrap()) {
651 return false;
652 }
653 }
654
655 if (peer_state_ != READY) {
656 context->yield();
657 tearDown();
658 throw Exception(SITE2SITE_EXCEPTION, "Can not establish handshake with peer");
659 }
660
661 // Create the transaction
662 transaction = createTransaction(RECEIVE);
663
664 if (transaction == NULL) {
665 context->yield();
666 tearDown();
667 throw Exception(SITE2SITE_EXCEPTION, "Can not create transaction");
668 }
669
670 utils::Identifier transactionID = transaction->getUUID();
671
672 try {
673 while (true) {
674 std::map<std::string, std::string> empty;
675 uint64_t startTime = utils::timeutils::getTimeMillis();
676 std::string payload;
677 DataPacket packet(getLogger(), transaction, empty, payload);
678 bool eof = false;
679
680 if (!receive(transactionID, &packet, eof)) {
681 throw Exception(SITE2SITE_EXCEPTION, "Receive Failed " + transactionID.to_string());
682 }
683 if (eof) {
684 // transaction done
685 break;
686 }
687 auto flowFile = session->create();
688
689 if (!flowFile) {
690 throw Exception(SITE2SITE_EXCEPTION, "Flow File Creation Failed");
691 }
692 std::map<std::string, std::string>::iterator it;
693 std::string sourceIdentifier;
694 for (it = packet._attributes.begin(); it != packet._attributes.end(); it++) {
695 if (it->first == core::SpecialFlowAttribute::UUID)
696 sourceIdentifier = it->second;
697 flowFile->addAttribute(it->first, it->second);
698 }
699
700 if (packet._size > 0) {
701 sitetosite::WriteCallback callback(&packet);

Callers

nothing calls this directly

Calls 15

bootstrapFunction · 0.85
tearDownFunction · 0.85
ExceptionClass · 0.85
createTransactionFunction · 0.85
getTimeMillisFunction · 0.85
confirmFunction · 0.85
completeFunction · 0.85
deleteTransactionFunction · 0.85
log_debugMethod · 0.80
getHostNameMethod · 0.80
log_warnMethod · 0.80
yieldMethod · 0.45

Tested by

no test coverage detected