| 781 | } |
| 782 | |
| 783 | void 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 | |
| 833 | void ProcessSession::persistFlowFilesBeforeTransfer( |
| 834 | std::map<std::shared_ptr<Connectable>, std::vector<std::shared_ptr<core::FlowFile> > >& transactionMap, |
nothing calls this directly
no test coverage detected