Package java.util.concurrent

Examples of java.util.concurrent.RejectedExecutionHandler


        {
            if ( executor.isShutdown() )
            {
                shutdown( false );
            }
            final RejectedExecutionHandler poolHandler = this.poolHandler;
            if ( poolHandler != null )
            {
                poolHandler.rejectedExecution( r, executor );
            }
        }
View Full Code Here


        logger.debug("Processing the fetched data");

        // Create new pool to process.
        int queueLen = workerCount; // * 10; // TODO: explain why *10.
        BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(queueLen);
        RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();
        pool = new ThreadPoolExecutor(queueLen, queueLen, 0, TimeUnit.SECONDS, queue, handler);


        Iterator<FetchDocument> iter = fetchdata.iterator();

View Full Code Here

        if (poolSize == null || poolSize <= 0) {
            throw new IllegalArgumentException("PoolSize must be a positive number");
        }

        int max = getMaxPoolSize() != null ? getMaxPoolSize() : getPoolSize();
        RejectedExecutionHandler rejected = null;
        if (rejectedPolicy != null) {
            rejected = rejectedPolicy.asRejectedExecutionHandler();
        }

        ExecutorService answer = camelContext.getExecutorServiceStrategy().newThreadPool(getId(), getThreadName(), getPoolSize(), max,
View Full Code Here

                // use a custom pool based on the settings
                int max = getMaxPoolSize() != null ? getMaxPoolSize() : profile.getMaxPoolSize();
                long keepAlive = getKeepAliveTime() != null ? getKeepAliveTime() : profile.getKeepAliveTime();
                int maxQueue = getMaxQueueSize() != null ? getMaxQueueSize() : profile.getMaxQueueSize();
                TimeUnit tu = getTimeUnit() != null ? getTimeUnit() : profile.getTimeUnit();
                RejectedExecutionHandler rejected = profile.getRejectedExecutionHandler();
                if (rejectedPolicy != null) {
                    rejected = rejectedPolicy.asRejectedExecutionHandler();
                }

                executorService = routeContext.getCamelContext().getExecutorServiceStrategy()
View Full Code Here

            Integer poolSize = profile.getPoolSize() != null ? profile.getPoolSize() : defaultProfile.getPoolSize();
            Integer maxPoolSize = profile.getMaxPoolSize() != null ? profile.getMaxPoolSize() : defaultProfile.getMaxPoolSize();
            Long keepAliveTime = profile.getKeepAliveTime() != null ? profile.getKeepAliveTime() : defaultProfile.getKeepAliveTime();
            TimeUnit timeUnit = profile.getTimeUnit() != null ? profile.getTimeUnit() : defaultProfile.getTimeUnit();
            Integer maxQueueSize = profile.getMaxQueueSize() != null ? profile.getMaxQueueSize() : defaultProfile.getMaxQueueSize();
            RejectedExecutionHandler handler = profile.getRejectedExecutionHandler() != null ? profile.getRejectedExecutionHandler() : defaultProfile.getRejectedExecutionHandler();
            // create the pool
            return newThreadPool(source, name, poolSize, maxPoolSize, keepAliveTime, timeUnit, maxQueueSize, handler, false);
        } else {
            // no profile with that id
            return null;
View Full Code Here

            Integer poolSize = profile.getPoolSize() != null ? profile.getPoolSize() : defaultProfile.getPoolSize();
            Integer maxPoolSize = profile.getMaxPoolSize() != null ? profile.getMaxPoolSize() : defaultProfile.getMaxPoolSize();
            Long keepAliveTime = profile.getKeepAliveTime() != null ? profile.getKeepAliveTime() : defaultProfile.getKeepAliveTime();
            TimeUnit timeUnit = profile.getTimeUnit() != null ? profile.getTimeUnit() : defaultProfile.getTimeUnit();
            Integer maxQueueSize = profile.getMaxQueueSize() != null ? profile.getMaxQueueSize() : defaultProfile.getMaxQueueSize();
            RejectedExecutionHandler handler = profile.getRejectedExecutionHandler() != null ? profile.getRejectedExecutionHandler() : defaultProfile.getRejectedExecutionHandler();
            // create the pool
            return newThreadPool(threadPoolProfileId, source, name, poolSize, maxPoolSize, keepAliveTime, timeUnit, maxQueueSize, handler, true);
        } else {
            // no profile with that id
            return null;
View Full Code Here

            }
        } else {
            queue = new SynchronousQueue<Runnable>();
        }

        RejectedExecutionHandler handler = null;
        switch (this.configuration.getBlockPolicy()) {
            case ABORT :
                handler = new ThreadPoolExecutor.AbortPolicy();
                break;
            case DISCARD :
View Full Code Here

                Thread t = new Thread(r);
                t.setName("CHMQ-RemoteQueueTransfer-" + sequence.getAndIncrement());
                t.setDaemon(true);
                return t;
            }
      }, new RejectedExecutionHandler() {
        public void rejectedExecution(Runnable r,
              ThreadPoolExecutor executor) {
      logger.warn("Rejected execution of {} by executor with {} current threads in the pool", r.getClass().getName(), executor.getPoolSize());
        }
    });
View Full Code Here

            final ThreadFactory threadFactory = new ThreadFactoryBuilder()
                    .setNameFormat("jersey-background-task-scheduler-%d")
                    .setThreadFactory(runtimeThreadProvider.getBackgroundThreadFactory())
                    .build();

            return new ScheduledThreadPoolExecutor(1, threadFactory, new RejectedExecutionHandler() {
                @Override
                public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                    // TODO: implement method.
                }
            });
View Full Code Here

                    return t;
                }

            },
            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

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.