@Override public boolean isForceExecution() { return in.isForceExecution(); }
protected void doExecute(final Runnable command) { try { super.execute(command); } catch (EsRejectedExecutionException ex) { if (command instanceof AbstractRunnable) { // If we are an abstract runnable we can handle the rejection // directly and don't need to rethrow it. try { ((AbstractRunnable) command).onRejection(ex); } finally { ((AbstractRunnable) command).onAfter(); } } else { throw ex; } } }
/** * This should be executed if the thread-pool executing this action rejected the execution. * The default implementation forwards to {@link #onFailure(Exception)} */ public void onRejection(Exception e) { onFailure(e); }
@Override public void onRejection(final Exception e) { if (original instanceof AbstractRunnable) { ((AbstractRunnable) original).onRejection(e); } }
@Override protected void doRun() throws Exception { if (hasRun.compareAndSet(false, true)) { delegate.run(); } }
@Override public void onAfter() { if (original instanceof AbstractRunnable) { ((AbstractRunnable) original).onAfter(); } }
@Override protected void doRun() throws Exception { boolean whileRunning = false; threadsOriginalContext = stashContext(); try { creatorsContext.restore(); whileRunning = true; in.doRun(); whileRunning = false; } catch (IllegalStateException ex) { if (whileRunning || threadLocal.closed.get() == false) { throw ex; } // if we hit an ISE here we have been shutting down // this comes from the threadcontext and barfs if // our threadpool has been shutting down } }
@Override public void onFailure(final Exception e) { if (original instanceof AbstractRunnable) { ((AbstractRunnable) original).onFailure(e); } }
@Override public void onRejection(Exception e) { in.onRejection(e); }
@Override protected void doRun() throws Exception { if (hasRun.compareAndSet(false, true)) { delegate.run(); } }
@Override public void onAfter() { try { in.onAfter(); } finally { if (threadsOriginalContext != null) { threadsOriginalContext.restore(); } } }
@Override protected void doRun() throws Exception { boolean whileRunning = false; threadsOriginalContext = stashContext(); try { creatorsContext.restore(); whileRunning = true; in.doRun(); whileRunning = false; } catch (IllegalStateException ex) { if (whileRunning || threadLocal.closed.get() == false) { throw ex; } // if we hit an ISE here we have been shutting down // this comes from the threadcontext and barfs if // our threadpool has been shutting down } }
@Override public void onFailure(Exception e) { in.onFailure(e); }
protected void doExecute(final Runnable command) { try { super.execute(command); } catch (EsRejectedExecutionException ex) { if (command instanceof AbstractRunnable) { // If we are an abstract runnable we can handle the rejection // directly and don't need to rethrow it. try { ((AbstractRunnable) command).onRejection(ex); } finally { ((AbstractRunnable) command).onAfter(); } } else { throw ex; } } }
@Override public boolean isForceExecution() { return original instanceof AbstractRunnable && ((AbstractRunnable) original).isForceExecution(); }
@Override public void onRejection(Exception e) { IOUtils.closeWhileHandlingException(releasable); super.onRejection(e); }
@Override protected void doRun() throws Exception { // Paranoia to prevent furiously rethrottling from running the command multiple times. Without this we totally can. if (hasRun.compareAndSet(false, true)) { prepareBulkRequestRunnable.run(); } }
@Override public void onAfter() { if (original instanceof AbstractRunnable) { ((AbstractRunnable) original).onAfter(); } }