/** To be used to flush an executor from a different thread. * WARNING: Do not call this within the executor. That would be stoopid ;) * * @param timeout * @param unit * @return */ default boolean flush(long timeout, TimeUnit unit) { CountDownLatch latch = new CountDownLatch(1); execute(latch::countDown); try { return latch.await(timeout, unit); } catch (Exception e) { return false; } }
/** * It will wait the current execution (if there is one) to finish * but will not complete any further executions */ default int shutdownNow() { return shutdownNow(t -> { }); }
@Override public ArtemisExecutor getExecutor() { return ArtemisExecutor.delegate(executor); } };
@Override public void flushExecutors() { if (!executor.flush(10, TimeUnit.SECONDS)) { ActiveMQServerLogger.LOGGER.timedOutFlushingExecutorsPagingCursor(this); } }
if (deliveriesInTransit.getCount() == 0 && getExecutor().isFlushed() && intermediateMessageReferences.isEmpty() && messageReferences.isEmpty() && !pageIterator.hasNext() && !pageSubscription.isPaging()) {
@Override public ArtemisExecutor getExecutor() { return ArtemisExecutor.delegate(executor); } };
private void waitForFuture() { if (!executor.flush(10, TimeUnit.SECONDS)) { ActiveMQServerLogger.LOGGER.timedOutStoppingPagingCursor(executor); } }
/** * This will verify if the executor is flushed with no wait (or very minimal wait if not the {@link org.apache.activemq.artemis.utils.actors.OrderedExecutor} * @return */ default boolean isFlushed() { CountDownLatch latch = new CountDownLatch(1); Runnable runnable = new Runnable() { @Override public void run() { latch.countDown(); } }; execute(runnable); try { return latch.await(100, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { return false; } }
/** * It will wait the current execution (if there is one) to finish * but will not complete any further executions */ default int shutdownNow() { return shutdownNow(t -> { }); }
@Override public ArtemisExecutor getExecutor() { return ArtemisExecutor.delegate(executor); } };
private boolean internalFlushExecutor(long timeout, boolean log) { if (!getExecutor().flush(timeout, TimeUnit.MILLISECONDS)) { if (log) { ActiveMQServerLogger.LOGGER.queueBusy(this.name.toString(), timeout); } return false; } else { return true; } }
@Override public void afterCommit(final Transaction tx1) { executor.execute(new Runnable() { @Override public void run() { if (!completeDelete) { cursorProvider.scheduleCleanup(); } } }); } });
/** * It will wait the current execution (if there is one) to finish * but will not complete any further executions */ default int shutdownNow() { return shutdownNow(t -> { }); }
@Deprecated @Override public Queue createQueue(final long persistenceID, final SimpleString address, final SimpleString name, final Filter filter, final PageSubscription subscription, final SimpleString user, final boolean durable, final boolean temporary, final boolean autoCreated) { return new QueueImpl(persistenceID, address, name, filter, subscription, user, durable, temporary, autoCreated, scheduledExecutor, postOffice, null, null, ArtemisExecutor.delegate(executor), null, this); }
@Override public void execute(Runnable command) { executor.execute(command); } }
/** * It will wait the current execution (if there is one) to finish * but will not complete any further executions */ default int shutdownNow() { return shutdownNow(t -> { }); }
private QueueImpl getQueue(SimpleString name, boolean durable, boolean temporary, Filter filter) { return new QueueImpl(1, QueueImplTest.address1, name, filter, null, durable, temporary, false, scheduledExecutor, new FakePostOffice(), null, null, ArtemisExecutor.delegate(executor), null, null); } }
public void runOnPool(Runnable runnable) { poolExecutor.execute(runnable); }
/** * It will wait the current execution (if there is one) to finish * but will not complete any further executions */ default int shutdownNow() { return shutdownNow(t -> { }); }
@Override public Queue createQueueWith(final QueueConfig config) { return new QueueImpl(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), scheduledExecutor, postOffice, null, null, ArtemisExecutor.delegate(executor), null, this); }