| 910 | } |
| 911 | |
| 912 | std::shared_ptr<core::FlowFile> ProcessSession::get() { |
| 913 | std::shared_ptr<Connectable> first = process_context_->getProcessorNode()->pickIncomingConnection(); |
| 914 | |
| 915 | if (first == nullptr) { |
| 916 | logger_->log_trace("Get is null for %s", process_context_->getProcessorNode()->getName()); |
| 917 | return nullptr; |
| 918 | } |
| 919 | |
| 920 | std::shared_ptr<Connection> current = std::static_pointer_cast<Connection>(first); |
| 921 | |
| 922 | do { |
| 923 | std::set<std::shared_ptr<core::FlowFile> > expired; |
| 924 | std::shared_ptr<core::FlowFile> ret = current->poll(expired); |
| 925 | if (!expired.empty()) { |
| 926 | // Remove expired flow record |
| 927 | for (const auto& record : expired) { |
| 928 | std::stringstream details; |
| 929 | details << process_context_->getProcessorNode()->getName() << " expire flow record " << record->getUUIDStr(); |
| 930 | provenance_report_->expire(record, details.str()); |
| 931 | // there is no rolling back expired FlowFiles |
| 932 | if (record->isStored() && process_context_->getFlowFileRepository()->Delete(record->getUUIDStr())) { |
| 933 | record->setStoredToRepository(false); |
| 934 | } |
| 935 | } |
| 936 | } |
| 937 | if (ret) { |
| 938 | // add the flow record to the current process session update map |
| 939 | ret->setDeleted(false); |
| 940 | std::shared_ptr<FlowFile> snapshot = std::make_shared<FlowFileRecord>(); |
| 941 | *snapshot = *ret; |
| 942 | logger_->log_debug("Create Snapshot FlowFile with UUID %s", snapshot->getUUIDStr()); |
| 943 | utils::Identifier uuid = ret->getUUID(); |
| 944 | _updatedFlowFiles[uuid] = {ret, snapshot}; |
| 945 | auto flow_version = process_context_->getProcessorNode()->getFlowIdentifier(); |
| 946 | if (flow_version != nullptr) { |
| 947 | ret->setAttribute(SpecialFlowAttribute::FLOW_ID, flow_version->getFlowId()); |
| 948 | } |
| 949 | return ret; |
| 950 | } |
| 951 | current = std::static_pointer_cast<Connection>(process_context_->getProcessorNode()->pickIncomingConnection()); |
| 952 | } while (current != nullptr && current != first); |
| 953 | |
| 954 | return nullptr; |
| 955 | } |
| 956 | |
| 957 | void ProcessSession::flushContent() { |
| 958 | content_session_->commit(); |
no test coverage detected