Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.PooledExecutor$AbortWhenBlocked


        final boolean useQueueing = poolConfig.getChild("use-queueing").getValueAsBoolean(false);
        final int queueSize = poolConfig.getChild("queue-size").getValueAsInteger(-1);

        if (useQueueing) {
            if (queueSize > 0) {
                this.executor = new PooledExecutor(new BoundedBuffer(queueSize));
            } else {
                this.executor = new PooledExecutor(new LinkedQueue());
            }
        } else {
            this.executor = new PooledExecutor();
        }

        final int maxPoolSize = poolConfig.getChild("max-pool-size").getValueAsInteger(-1);

        if (maxPoolSize > 0) {
View Full Code Here


     * @param config
     * @return A ThreadPoll wrapper
     */
    private ThreadPool createPool( PoolConfiguration config )
    {
        PooledExecutor pool = null;
        Channel queue = null;
        if ( config.isUseBoundary() )
        {
            if ( log.isDebugEnabled() )
            {
                log.debug( "Creating a Bounded Buffer to use for the pool" );
            }
            queue = new BoundedBuffer( config.getBoundarySize() );
            pool = new PooledExecutor( queue, config.getMaximumPoolSize() );
            pool.setThreadFactory( new MyThreadFactory() );
        }
        else
        {
            if ( log.isDebugEnabled() )
            {
                log.debug( "Creating a non bounded Linked Queue to use for the pool" );
            }
            queue = new LinkedQueue();
            pool = new PooledExecutor( queue, config.getMaximumPoolSize() );
        }

        pool.setMinimumPoolSize( config.getMinimumPoolSize() );
        pool.setKeepAliveTime( config.getKeepAliveTime() );

        // when blocked policy
        if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_ABORT ) )
        {
            pool.abortWhenBlocked();
        }
        else if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_RUN ) )
        {
            pool.runWhenBlocked();
        }
        else if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_WAIT ) )
        {
            pool.waitWhenBlocked();
        }
        else if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_ABORT ) )
        {
            pool.abortWhenBlocked();
        }
        else if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_DISCARDOLDEST ) )
        {
            pool.discardOldestWhenBlocked();
        }

        pool.createThreads( config.getStartUpSize() );

        return new ThreadPool( pool, queue );
    }
View Full Code Here

        this.multicastAddressString = multicastAddressString;
        this.multicastPort = multicastPort;
        this.cacheMgr = cacheMgr;

        // create a small thread pool to handle a barage
        pooledExecutor = new PooledExecutor( new BoundedBuffer( 100 ), maxPoolSize );
        pooledExecutor.discardOldestWhenBlocked();
        //pooledExecutor.setMinimumPoolSize(1);
        pooledExecutor.setThreadFactory( new MyThreadFactory() );

        if ( log.isInfoEnabled() )
View Full Code Here

            receiver = new ListenerThread();
            receiver.setDaemon( true );
            receiver.start();

            pooledExecutor = new PooledExecutor();
            pooledExecutor.setThreadFactory( new MyThreadFactory() );
        }
        catch ( Exception ex )
        {
            log.error( ex );
View Full Code Here

      {
         m_preallocPoolSize = (int) m_discoveryConfig.getPoolPreallocSize(  );
      }

      // Configure threadpool
      m_pool = new PooledExecutor( m_maxPoolSize );
      m_pool.setThreadFactory( new NamedThread.ConcurrentThreadFactory( "discovery-agent-registry" ) );
      m_pool.waitWhenBlocked(  );
      m_pool.setMinimumPoolSize( m_minPoolSize );
      m_pool.createThreads( m_preallocPoolSize );
      m_pool.setKeepAliveTime( m_PoolKeepAliveTime );
View Full Code Here

         // create our LRU map that will maintain those resources that do not support WS-RL
         m_noTerminationTimeSupport = new LRUCache(  );
         m_noTerminationTimeSupport.setMaxCapacity( 50 ); // TODO: make this configurable

         // create our reaper thread pool that will provide the threads used to actually check for and destroy expired resources
         m_reaperThreadPool = new PooledExecutor(  );
         m_reaperThreadPool.setThreadFactory( new NamedThread.ConcurrentThreadFactory( "resource-reaper", true ) );
         m_reaperThreadPool.setMinimumPoolSize( 0 );
         m_reaperThreadPool.setMaximumPoolSize( 10 ); // TODO: make this configurable

         // create and start the main thread that periodically examines resources
View Full Code Here

        final boolean useQueueing = poolConfig.getChild("use-queueing").getValueAsBoolean(false);
        final int queueSize = poolConfig.getChild("queue-size").getValueAsInteger(-1);

        if (useQueueing) {
            if (queueSize > 0) {
                m_executor = new PooledExecutor(new BoundedBuffer(queueSize));
            } else {
                m_executor = new PooledExecutor(new LinkedQueue());
            }
        } else {
            m_executor = new PooledExecutor();
        }

        final int maxPoolSize = poolConfig.getChild("max-pool-size").getValueAsInteger(-1);

        if (maxPoolSize > 0) {
View Full Code Here

    private PoolStatsImpl stats = new PoolStatsImpl();
    private Map clients = new HashMap();


    public ThreadPool(int poolSize, String poolName, long keepAliveTime, ClassLoader classLoader, String objectName) {
        PooledExecutor p = new PooledExecutor(poolSize);
        p.abortWhenBlocked();
        p.setKeepAliveTime(keepAliveTime);
        p.setMinimumPoolSize(poolSize);
        p.setThreadFactory(new ThreadPoolThreadFactory(poolName, classLoader));
        try {
            this.objectName = ObjectName.getInstance(objectName);
        } catch (MalformedObjectNameException e) {
            throw new IllegalStateException("Bad object name injected: " + e.getMessage());
        }
View Full Code Here

            };
        } else {
            command = runnable;
        }

        PooledExecutor p;
        synchronized (this) {
            p = executor;
        }
        if (p == null) {
            throw new IllegalStateException("ThreadPool has been stopped");
        }
        Runnable task = new ContextClassLoaderRunnable(command, classLoader);
        p.execute(task);
    }
View Full Code Here

    public void doStart() throws Exception {
    }

    public void doStop() throws Exception {
        PooledExecutor p;
        synchronized (this) {
            p = executor;
            executor = null;
            classLoader = null;
        }
        if (p != null) {
            p.shutdownNow();
        }
    }
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.PooledExecutor$AbortWhenBlocked

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.