Package org.apache.avalon.excalibur.thread.impl

Examples of org.apache.avalon.excalibur.thread.impl.ResourceLimitingThreadPool


        final long blockTimeout = configuration.getChild( "block-timeout" ).getValueAsLong( 0 );
        final long trimInterval = configuration.getChild( "trim-interval" ).getValueAsLong( 10000 );

        try
        {
            final ResourceLimitingThreadPool threadPool = new ResourceLimitingThreadPool(
                name, max, maxStrict, blocking, blockTimeout, trimInterval );
            threadPool.setDaemon( isDaemon );
            threadPool.enableLogging( getLogger() );
            threadPools.put( name, threadPool );
        }
        catch( final Exception e )
        {
            final String message = "Error creating ThreadPool named " + name;
View Full Code Here


                             boolean blocking,
                             long blockTimeout,
                             long trimInterval )
    {
        BufferedLogger logger = new BufferedLogger();
        ResourceLimitingThreadPool pool = new ResourceLimitingThreadPool(
            "Test Worker Pool", max, maxStrict, blocking, blockTimeout, trimInterval );
        pool.enableLogging( logger );

        Runnable runner = new Runnable()
        {
            public void run()
            {
                try
                {
                    Thread.sleep( 200 );
                }
                catch( InterruptedException e )
                {
                }

                incCompleteCount();
            }
        };

        long start = System.currentTimeMillis();
        m_completeCount = 0;
        for( int i = 0; i < taskCount; i++ )
        {
            if( maxStrict && ( !blocking ) && i >= max )
            {
                // This request shoudl throw an exception.
                try
                {
                    pool.execute( runner );
                    fail( "Should have failed when requesting more than max resources." );
                }
                catch( Exception e )
                {
                    // Ok
                    incCompleteCount();
                }
            }
            else
            {
                pool.execute( runner );
            }
        }
        long dur = System.currentTimeMillis() - start;

        // Make sure that the size of the pool is what is expected.
        assertEquals( "The pool size was not what it should be.", firstSize, pool.getSize() );

        // Make sure this took about the right amount of time to get here.
        //System.out.println( "First time: " + dur );
        if( Math.abs( dur - firstTime ) > 500 )
        {
View Full Code Here

                             boolean blocking,
                             long blockTimeout,
                             long trimInterval )
    {
        BufferedLogger logger = new BufferedLogger();
        ResourceLimitingThreadPool pool = new ResourceLimitingThreadPool(
            "Test Worker Pool", max, maxStrict, blocking, blockTimeout, trimInterval );
        pool.enableLogging( logger );

        Runnable runner = new Runnable()
        {
            public void run()
            {
                try
                {
                    Thread.sleep( 200 );
                }
                catch( InterruptedException e )
                {
                }

                incCompleteCount();
            }
        };

        long start = System.currentTimeMillis();
        m_completeCount = 0;
        for( int i = 0; i < taskCount; i++ )
        {
            if( maxStrict && ( !blocking ) && i >= max )
            {
                // This request shoudl throw an exception.
                try
                {
                    pool.execute( runner );
                    fail( "Should have failed when requesting more than max resources." );
                }
                catch( Exception e )
                {
                    // Ok
                    incCompleteCount();
                }
            }
            else
            {
                pool.execute( runner );
            }
        }
        long dur = System.currentTimeMillis() - start;

        // Make sure that the size of the pool is what is expected.
        assertEquals( "The pool size was not what it should be.", firstSize, pool.getSize() );

        // Make sure this took about the right amount of time to get here.
        //System.out.println( "First time: " + dur );
        if( Math.abs( dur - firstTime ) > 500 )
        {
View Full Code Here

        final long blockTimeout = configuration.getChild( "block-timeout" ).getValueAsLong( 0 );
        final long trimInterval = configuration.getChild( "trim-interval" ).getValueAsLong( 10000 );

        try
        {
            final ResourceLimitingThreadPool threadPool = new ResourceLimitingThreadPool(
                name, max, maxStrict, blocking, blockTimeout, trimInterval );
            threadPool.setDaemon( isDaemon );
            threadPool.enableLogging( getLogger() );
            threadPools.put( name, threadPool );
        }
        catch( final Exception e )
        {
            final String message = "Error creating ThreadPool named " + name;
View Full Code Here

        final long blockTimeout = configuration.getChild( "block-timeout" ).getValueAsLong( 0 );
        final long trimInterval = configuration.getChild( "trim-interval" ).getValueAsLong( 10000 );

        try
        {
            final ResourceLimitingThreadPool threadPool = new ResourceLimitingThreadPool(
                name, max, maxStrict, blocking, blockTimeout, trimInterval );
            threadPool.setDaemon( isDaemon );
            threadPool.enableLogging( getLogger() );
            threadPools.put( name, threadPool );
        }
        catch( final Exception e )
        {
            final String message = "Error creating ThreadPool named " + name;
View Full Code Here

TOP

Related Classes of org.apache.avalon.excalibur.thread.impl.ResourceLimitingThreadPool

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.