Package java.util.concurrent

Examples of java.util.concurrent.RejectedExecutionHandler


                        e.printStackTrace(System.err);
                    }
                });
                return thread;
            }
        }, new RejectedExecutionHandler() {
            @Override
            public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) {
                final int currentPoolSize = executor.getPoolSize();
                final int maximumPoolSize = executor.getMaximumPoolSize();
                throw new IllegalStateException("The thread pool executor cannot run the task. " +
View Full Code Here


        final ThreadFactory threadFactory = new PoolExecutorThreadFactory(node.threadGroup,
                node.getThreadPoolNamePrefix("cached"), classLoader);

        cachedExecutorService = new ThreadPoolExecutor(
                CORE_POOL_SIZE, Integer.MAX_VALUE, KEEP_ALIVE_TIME, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>(), threadFactory, new RejectedExecutionHandler() {
            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                if (logger.isFinestEnabled()) {
                    logger.finest("Node is shutting down; discarding the task: " + r);
                }
            }
View Full Code Here

    }

    protected void doStart() throws Exception {
        shutdown.set(false);
        if (executor != null) {
            executor.setRejectedExecutionHandler(new RejectedExecutionHandler() {
                public void rejectedExecution(Runnable runnable, ThreadPoolExecutor executor) {
                    ProcessCall call = (ProcessCall)runnable;
                    call.exchange.setException(new RejectedExecutionException());
                    call.callback.done(false);
                }
View Full Code Here

      queue.drainTo(tmp);
      queue = new LinkedBlockingQueue(size);
      queue.addAll(tmp);

      ThreadFactory tf = executor.getThreadFactory();
      RejectedExecutionHandler handler = executor.getRejectedExecutionHandler();
      long keepAlive = executor.getKeepAliveTime(TimeUnit.SECONDS);
      int cs = executor.getCorePoolSize();
      int mcs = executor.getMaximumPoolSize();
      executor = new ThreadPoolExecutor(cs, mcs, keepAlive, TimeUnit.SECONDS, queue);
      executor.setThreadFactory(tf);
View Full Code Here

    }
    return config;
  }

  private RejectedExecutionHandler createAsyncRejectedExecutionHandler() {
    return new RejectedExecutionHandler() {
      @Override
      public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        if (!executor.isShutdown()) {
          // TODO: Should be a gauge, not increment. Need to wait till metrics system supports it
          metricsCollector.increment("collect.async.reject", 1);
View Full Code Here

    private final AtomicInteger connectionsCount = new AtomicInteger();


    public AprSocketContext() {
        connectExecutor =new ThreadPoolExecutor(0, 64, 5, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(), new RejectedExecutionHandler() {
                    @Override
                    public void rejectedExecution(Runnable r,
                            java.util.concurrent.ThreadPoolExecutor executor) {
                        AprSocket s = (AprSocket) r;
                        log.severe("Rejecting " + s);
View Full Code Here

                return t;
            }

        });

        executorService.setRejectedExecutionHandler(new RejectedExecutionHandler() {
            @Override
            public void rejectedExecution(final Runnable r, final ThreadPoolExecutor tpe) {

                if (null == r || null == tpe || tpe.isShutdown() || tpe.isTerminated() || tpe.isTerminating()) {
                    return;
View Full Code Here

        }

        internalExecutor = new ThreadPoolExecutor(2, 2, 0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(),
                new PoolExecutorThreadFactory(threadGroup, name + ".internal-", classLoader),
                new RejectedExecutionHandler() {
                    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                        String message = "Internal executor rejected task: " + r + ", because client is shutting down...";
                        LOGGER.finest(message);
                        throw new RejectedExecutionException(message);
                    }
                });
        executor = new ThreadPoolExecutor(executorPoolSize, executorPoolSize, 0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(),
                new PoolExecutorThreadFactory(threadGroup, name + ".cached-", classLoader),
                new RejectedExecutionHandler() {
                    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                        String message = "Internal executor rejected task: " + r + ", because client is shutting down...";
                        LOGGER.finest(message);
                        throw new RejectedExecutionException(message);
                    }
View Full Code Here

  public void afterPropertiesSet() throws Exception {
    executor = new ThreadPoolExecutor(config.getPoolCoreSize(),
        config.getPoolMaxSize(), config.getPoolExecutionTimeout(),
        TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(
            config.getPoolMaxQueueSize()),
        new RejectedExecutionHandler() {
          @Override
          public void rejectedExecution(Runnable r,
              ThreadPoolExecutor executor) {
            ((RejectableRunnable) r).onExecutionRejected();
          }
View Full Code Here

    AtomicInteger connectionsCount = new AtomicInteger();


    public AprSocketContext() {
        connectExecutor =new ThreadPoolExecutor(0, 64, 5, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(), new RejectedExecutionHandler() {
                    @Override
                    public void rejectedExecution(Runnable r,
                            java.util.concurrent.ThreadPoolExecutor executor) {
                        AprSocket s = (AprSocket) r;
                        log.severe("Rejecting " + s);
View Full Code Here

TOP

Related Classes of java.util.concurrent.RejectedExecutionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.