Package com.rackspacecloud.blueflood.concurrent

Examples of com.rackspacecloud.blueflood.concurrent.InstrumentedThreadPoolExecutor


        // NOTE: higher locatorFetchConcurrency means that the queue used in rollupReadExecutors needs to be correspondingly
        // higher.
        Configuration config = Configuration.getInstance();
        final int locatorFetchConcurrency = config.getIntegerProperty(CoreConfig.MAX_LOCATOR_FETCH_THREADS);
        locatorFetchExecutors = new InstrumentedThreadPoolExecutor(
            "LocatorFetchThreadPool",
            locatorFetchConcurrency, locatorFetchConcurrency,
            30, TimeUnit.SECONDS,
            new ArrayBlockingQueue<Runnable>(locatorFetchConcurrency * 5),
            Executors.defaultThreadFactory(),
            new RejectedExecutionHandler() {
                public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                    // in this case, we want to throw a RejectedExecutionException so that the slot can be removed
                    // from the running queue.
                    throw new RejectedExecutionException("Threadpool is saturated. unable to service this slot.");
                }
            }
        ) {
            @Override
            protected void afterExecute(Runnable r, Throwable t) {
                lastSlotCheckFinishedAt = RollupService.this.context.getCurrentTimeMillis();
                super.afterExecute(r, t);
            }
        };

        // unbounded work queue.
        final BlockingQueue<Runnable> rollupReadQueue = new LinkedBlockingQueue<Runnable>();

        rollupReadExecutors = new InstrumentedThreadPoolExecutor(
            "RollupReadsThreadpool",
            config.getIntegerProperty(CoreConfig.MAX_ROLLUP_READ_THREADS),
            config.getIntegerProperty(CoreConfig.MAX_ROLLUP_READ_THREADS),
            30, TimeUnit.SECONDS,
            rollupReadQueue,
            Executors.defaultThreadFactory(),
            new ThreadPoolExecutor.AbortPolicy()
        );
        final BlockingQueue<Runnable> rollupWriteQueue = new LinkedBlockingQueue<Runnable>();
        rollupWriteExecutors = new InstrumentedThreadPoolExecutor(
                "RollupWritesThreadpool",
                config.getIntegerProperty(CoreConfig.MAX_ROLLUP_WRITE_THREADS),
                config.getIntegerProperty(CoreConfig.MAX_ROLLUP_WRITE_THREADS),
                30, TimeUnit.SECONDS,
                rollupWriteQueue,
View Full Code Here

TOP

Related Classes of com.rackspacecloud.blueflood.concurrent.InstrumentedThreadPoolExecutor

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.