@Override protected void doRollback() throws InterruptedException { session.rollback(); }
@Override public synchronized void terminateActiveSessions() { terminated = true; for (final ProcessSession session : sessionMap.keySet()) { try { session.rollback(); } catch (final TerminatedTaskException tte) { // ignore } } sessionMap.clear(); } }
/** * <p>This method is identical to what {@link org.apache.nifi.processor.AbstractProcessor#onTrigger(ProcessContext, ProcessSession)} does.</p> * <p>Create a session from ProcessSessionFactory and execute specified onTrigger function, and commit the session if onTrigger finishes successfully.</p> * <p>When an Exception is thrown during execution of the onTrigger, the session will be rollback. FlowFiles being processed will be penalized.</p> */ public static void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory, ComponentLog logger, OnTrigger onTrigger) throws ProcessException { onTrigger(context, sessionFactory, logger, onTrigger, (session, t) -> session.rollback(true)); }
/** * Reverts any changes made during this session. All FlowFiles are restored * back to their initial session state and back to their original queues. If * this session is already committed or rolled back then no changes will * occur. This method can be called any number of times. Calling this method * is identical to calling {@link #rollback(boolean)} passing * <code>false</code> as the parameter. */ @Override public void rollback() { s.rollback(); onClear(); }
private void handleException(final HttpServletRequest request, final HttpServletResponse response, final ProcessSession session, String foundSubject, final Throwable t) throws IOException { session.rollback(); logger.error("Unable to receive file from Remote Host: [{}] SubjectDN [{}] due to {}", new Object[]{request.getRemoteHost(), foundSubject, t}); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.toString()); }
/** * Reverts any changes made during this session. All FlowFiles are restored * back to their initial session state and back to their original queues, * after optionally being penalized. If this session is already committed or * rolled back then no changes will occur. This method can be called any * number of times. * * @param penalize whether or not the FlowFiles that are being restored back to their queues should be penalized */ @Override public void rollback(boolean penalize) { s.rollback(penalize); onClear(); }
public void purge() { wLock.lock(); try { for (final List<Bin> binList : groupBinMap.values()) { for (final Bin bin : binList) { bin.getSession().rollback(); } } groupBinMap.clear(); binCount = 0; } finally { wLock.unlock(); } }
public synchronized void cancelOrComplete() { if (isComplete()) { completeSession(); return; } this.canceled = true; session.rollback(); successfulRanges.clear(); failedRanges.clear(); }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final ProcessException e) { session.rollback(); throw e; } catch (final Throwable t) { session.rollback(); throw new RuntimeException(t); } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final ProcessException e) { session.rollback(); throw e; } catch (final Throwable t) { session.rollback(); throw new RuntimeException(t); } }
@OnStopped public final void resetState() { binManager.purge(); Bin bin; while ((bin = readyBins.poll()) != null) { bin.getSession().rollback(); } }
public void close(final boolean forceClose) { if (closedConsumer) { return; } super.close(); if (session != null) { session.rollback(); setProcessSession(null); } if (forceClose || isPoisoned() || !pooledLeases.offer(this)) { closedConsumer = true; closeConsumer(consumer); } } }
public void close(final boolean forceClose) { if (closedConsumer) { return; } super.close(); if (session != null) { session.rollback(); setProcessSession(null, null); } if (forceClose || isPoisoned() || !pooledLeases.offer(this)) { closedConsumer = true; closeConsumer(consumer); } } }
public void close(final boolean forceClose) { if (closedConsumer) { return; } super.close(); if (session != null) { session.rollback(); setProcessSession(null, null); } if (forceClose || isPoisoned() || !pooledLeases.offer(this)) { closedConsumer = true; closeConsumer(consumer); } } }
public void close(final boolean forceClose) { if (closedConsumer) { return; } super.close(); if (session != null) { session.rollback(); setProcessSession(null, null); } if (forceClose || isPoisoned() || !pooledLeases.offer(this)) { closedConsumer = true; closeConsumer(consumer); } } }
public void close(final boolean forceClose) { if (closedConsumer) { return; } super.close(); if (session != null) { session.rollback(); setProcessSession(null, null); } if (forceClose || isPoisoned() || !pooledLeases.offer(this)) { closedConsumer = true; closeConsumer(consumer); } } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) { sessionFactoryReference.compareAndSet(null, sessionFactory); for (final String id : findOldFlowFileIds(context)) { final FlowFileEntryTimeWrapper wrapper = flowFileMap.remove(id); if (wrapper != null) { getLogger().warn("failed to received acknowledgment for HOLD with ID {} sent by {}; rolling back session", new Object[] {id, wrapper.getClientIP()}); wrapper.session.rollback(); } } context.yield(); }
@Override public final void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final Throwable t) { session.rollback(true); throw t; } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final Throwable t) { getLogger() .error("{} failed to process due to {}; rolling back session", new Object[]{this, t}); session.rollback(true); throw t; } }
public static <FCT extends RollbackOnFailure> void onTrigger( ProcessContext context, ProcessSessionFactory sessionFactory, FCT functionContext, ComponentLog logger, PartialFunctions.OnTrigger onTrigger) throws ProcessException { PartialFunctions.onTrigger(context, sessionFactory, logger, onTrigger, (session, t) -> { // If RollbackOnFailure is enabled, do not penalize processing FlowFiles when rollback, // in order to keep those in the incoming relationship to be processed again. final boolean shouldPenalize = !functionContext.isRollbackOnFailure(); session.rollback(shouldPenalize); // However, keeping failed FlowFile in the incoming relationship would retry it too often. // So, administratively yield the process. if (functionContext.isRollbackOnFailure()) { logger.warn("Administratively yielding {} after rolling back due to {}", new Object[]{context.getName(), t}, t); context.yield(); } }); }