@Override public void run() { worker.execute(new Runnable() { @Override public void run() { long currentTime = System.currentTimeMillis(); if(currentTime >= expireTime) { invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT); } else { timerCancelKey = WorkerUtils.executeAfter(executor, cancelTask, expireTime - currentTime, TimeUnit.MILLISECONDS); } } }); } };
@Override public void failed() { if (healthCheckFailed() == threshold) { // Remove using the executor task pool ioThread.getWorker().execute(new Runnable() { @Override public void run() { container.removeNode(Node.this, true); clearActivePing(); } }); } else { clearActivePing(); } } }, healthChecker, ioThread, bufferPool, container.getClient(), container.getXnioSsl(), OptionMap.EMPTY);
public void execute(final Runnable command) { final AtomicInteger count = this.count; final int i = count.getAndIncrement(); boolean ok = false; try { if (i == 0) { executorUntick(this); } worker.execute(() -> { try { command.run(); } finally { finishWork(); } }); ok = true; } finally { if (! ok) { finishWork(); } } }
@Override public void close() throws IOException { IoUtils.safeClose(fileChannel); //we have to dispatch this, as it may result in file IO final List<Path> files = new ArrayList<>(getCreatedFiles()); exchange.getConnection().getWorker().execute(new Runnable() { @Override public void run() { for (final Path file : files) { if (Files.exists(file)) { try { Files.delete(file); } catch (NoSuchFileException e) { // ignore } catch (IOException e) { UndertowLogger.REQUEST_LOGGER.cannotRemoveUploadedFile(file); } } } } }); }
outstandingTasks += tasks.size(); for (final Runnable task : tasks) { getWorker().execute(new Runnable() { @Override public void run() {
/** * Dispatches this request to the given executor. Once the call stack returns * the given runnable will be submitted to the executor. * <p> * In general handlers should first check the value of {@link #isInIoThread()} before * calling this method, and only dispatch if the request is actually running in the IO * thread. * * @param runnable The task to run * @throws IllegalStateException If this exchange has already been dispatched */ public HttpServerExchange dispatch(final Executor executor, final Runnable runnable) { if (isInCall()) { if (executor != null) { this.dispatchExecutor = executor; } state |= FLAG_DISPATCHED; if(anyAreSet(state, FLAG_SHOULD_RESUME_READS | FLAG_SHOULD_RESUME_WRITES)) { throw UndertowMessages.MESSAGES.resumedAndDispatched(); } this.dispatchTask = runnable; } else { if (executor == null) { getConnection().getWorker().execute(runnable); } else { executor.execute(runnable); } } return this; }
getWorker().execute(new TaskWrapper(tasks.get(i)));
connection.getConnection().getWorker().execute(() -> { try (OutputStream outputStream = new WildflyClientOutputStream(result.getRequestChannel(), result.getConnection().getBufferPool())) {
@Override public void run() { worker.execute(new Runnable() { @Override public void run() { long currentTime = System.currentTimeMillis(); if(currentTime >= expireTime) { invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT); } else { timerCancelKey = WorkerUtils.executeAfter(executor, cancelTask, expireTime - currentTime, TimeUnit.MILLISECONDS); } } }); } };
@Override public void run() { worker.execute(new Runnable() { @Override public void run() { long currentTime = System.currentTimeMillis(); if(currentTime >= expireTime) { invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT); } else { timerCancelKey = WorkerUtils.executeAfter(executor, cancelTask, expireTime - currentTime, TimeUnit.MILLISECONDS); } } }); } };
@Override public void run() { worker.execute(new Runnable() { @Override public void run() { long currentTime = System.currentTimeMillis(); if(currentTime >= expireTime) { invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT); } else { timerCancelKey = executor.executeAfter(cancelTask, expireTime - currentTime, TimeUnit.MILLISECONDS); } } }); } };
@Override public void run() { worker.execute(new Runnable() { @Override public void run() { long currentTime = System.currentTimeMillis(); if(currentTime >= expireTime) { invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT); } else { timerCancelKey = executor.executeAfter(cancelTask, expireTime - currentTime, TimeUnit.MILLISECONDS); } } }); } };
@Override public void run() { getWorker().execute(new Runnable() { @Override public void run() { if (stream.isOpen()) { stream.getChannel().sendPing(stream.getStreamId()); } } }); } }
@Override public void run() { getWorker().execute(new Runnable() { @Override public void run() { if (stream.isOpen()) { stream.getChannel().sendPing(stream.getStreamId()); } } }); } }
@Override public void failed() { if (healthCheckFailed() == threshold) { // Remove using the executor task pool ioThread.getWorker().execute(new Runnable() { @Override public void run() { container.removeNode(Node.this, true); clearActivePing(); } }); } else { clearActivePing(); } } }, healthChecker, ioThread, bufferPool, container.getClient(), container.getXnioSsl(), OptionMap.EMPTY);
@Override public void failed() { if (healthCheckFailed() == threshold) { // Remove using the executor task pool ioThread.getWorker().execute(new Runnable() { @Override public void run() { container.removeNode(Node.this, true); clearActivePing(); } }); } else { clearActivePing(); } } }, healthChecker, ioThread, bufferPool, container.getClient(), container.getXnioSsl(), OptionMap.EMPTY);
@Override protected void execute(Runnable runnable) { this.exchange .getConnection() .getWorker() .execute(runnable); }
private void delayedSending(HttpServerExchange exchange, AttachmentContent attachment) { exchange.getConnection().getWorker().execute(() -> { try { messageEndProcessor.bufferedButDelayed(exchange, attachment); } catch (RuntimeException exception) { messageErrorProcessor.sendAndLog(exchange, "Exception while handling delayed message sending.", exception); } }); }
private void dispatchToWorker(HttpServerExchange exchange, AttachmentContent attachment) { // exchange.dispatch(next) is not called here because async io read flag can be still set to true which combined with // dispatch() leads to an exception exchange.getConnection().getWorker().execute(() -> { try { next.handleRequest(exchange); } catch (Exception e) { attachment.removeTimeout(); messageErrorProcessor.sendAndLog(exchange, attachment.getTopic(), attachment.getMessageId(), error("Error while executing next handler after read handler", INTERNAL_ERROR), e); } }); }
@Override public void onPublished(Message message, Topic topic) { exchange.getConnection().getWorker().execute(() -> { brokerLatencyTimers.close(); if (messageState.setSentToKafka()) { attachment.removeTimeout(); messageEndProcessor.sent(exchange, attachment); } else if (messageState.setDelayedSentToKafka()) { messageEndProcessor.delayedSent(exchange, attachment.getCachedTopic(), message); } }); }