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

Method rollback

libminifi/src/core/ProcessSession.cpp:783–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

781}
782
783void ProcessSession::rollback() {
784 // new FlowFiles are only persisted during commit
785 // no need to delete them here
786 std::map<std::shared_ptr<Connectable>, std::vector<std::shared_ptr<FlowFile>>> connectionQueues;
787
788 try {
789 // Requeue the snapshot of the flowfile back
790 for (const auto &it : _updatedFlowFiles) {
791 auto flowFile = it.second.modified;
792 // restore flowFile to original state
793 *flowFile = *it.second.snapshot;
794 logger_->log_debug("ProcessSession rollback for %s, record %s, to connection %s",
795 process_context_->getProcessorNode()->getName(),
796 flowFile->getUUIDStr(),
797 flowFile->getConnection()->getName());
798 connectionQueues[flowFile->getConnection()].push_back(flowFile);
799 }
800
801 for (const auto& record : _deletedFlowFiles) {
802 record->setDeleted(false);
803 }
804
805 // put everything back where it came from
806 for (auto& cq : connectionQueues) {
807 auto connection = std::dynamic_pointer_cast<Connection>(cq.first);
808 if (connection) {
809 connection->multiPut(cq.second);
810 } else {
811 for (auto& flow : cq.second) {
812 cq.first->put(flow);
813 }
814 }
815 }
816
817 content_session_->rollback();
818
819 _clonedFlowFiles.clear();
820 _addedFlowFiles.clear();
821 _updatedFlowFiles.clear();
822 _deletedFlowFiles.clear();
823 logger_->log_warn("ProcessSession rollback for %s executed", process_context_->getProcessorNode()->getName());
824 } catch (std::exception &exception) {
825 logger_->log_warn("Caught Exception during process session rollback: %s", exception.what());
826 throw;
827 } catch (...) {
828 logger_->log_warn("Caught Exception during process session rollback");
829 throw;
830 }
831}
832
833void ProcessSession::persistFlowFilesBeforeTransfer(
834 std::map<std::shared_ptr<Connectable>, std::vector<std::shared_ptr<core::FlowFile> > >& transactionMap,

Callers

nothing calls this directly

Calls 11

log_debugMethod · 0.80
getProcessorNodeMethod · 0.80
setDeletedMethod · 0.80
multiPutMethod · 0.80
log_warnMethod · 0.80
getNameMethod · 0.45
getUUIDStrMethod · 0.45
getConnectionMethod · 0.45
putMethod · 0.45
clearMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected