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

Method onTrigger

extensions/libarchive/BinFiles.cpp:259–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259void BinFiles::onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) {
260 // Rollback is not viable for this processor!!
261 {
262 // process resurrected FlowFiles first
263 auto flowFiles = file_store_.getNewFlowFiles();
264 // these are already processed FlowFiles, that we own
265 bool hadFailure = false;
266 for (auto &file : flowFiles) {
267 std::string groupId = getGroupId(context.get(), file);
268 bool offer = this->binManager_.offer(groupId, file);
269 if (!offer) {
270 session->transfer(file, Failure);
271 hadFailure = true;
272 } else {
273 // no need to route successfully captured such files as we already own them
274 }
275 }
276 if (hadFailure) {
277 context->yield();
278 return;
279 }
280 }
281
282 for (size_t i = 0; i < batchSize_; ++i) {
283 auto flow = session->get();
284
285 if (flow == nullptr) {
286 break;
287 }
288
289 preprocessFlowFile(context.get(), session.get(), flow);
290 std::string groupId = getGroupId(context.get(), flow);
291
292 bool offer = this->binManager_.offer(groupId, flow);
293 if (!offer) {
294 session->transfer(flow, Failure);
295 context->yield();
296 return;
297 }
298 // assuming ownership over the incoming flowFile
299 session->transfer(flow, Self);
300 }
301
302 // migrate bin to ready bin
303 this->binManager_.gatherReadyBins();
304 if (this->binManager_.getBinCount() > maxBinCount_) {
305 // bin count reach max allowed
306 context->yield();
307 logger_->log_debug("BinFiles reach max bin count %d", this->binManager_.getBinCount());
308 this->binManager_.removeOldestBin();
309 }
310
311 // get the ready bin
312 std::deque<std::unique_ptr<Bin>> readyBins;
313 binManager_.getReadyBin(readyBins);
314
315 // process the ready bin
316 while (!readyBins.empty()) {

Callers

nothing calls this directly

Calls 15

addFlowsToSessionMethod · 0.95
processBinMethod · 0.95
transferFlowsToFailMethod · 0.95
getNewFlowFilesMethod · 0.80
gatherReadyBinsMethod · 0.80
getBinCountMethod · 0.80
log_debugMethod · 0.80
removeOldestBinMethod · 0.80
getReadyBinMethod · 0.80
getMethod · 0.45
offerMethod · 0.45
transferMethod · 0.45

Tested by

no test coverage detected