Package org.apache.geronimo.pool

Examples of org.apache.geronimo.pool.ThreadPool


    }

    class ServerAction implements PrivilegedExceptionAction {

        public Object run() throws Exception {
            ThreadPool tp = new ThreadPool();
            tp.setKeepAliveTime(1 * 1000);
            tp.setPoolSize(5);
            tp.setPoolName("Server TP");
            tp.doStart();

            ClockPool cp = new ClockPool();
            cp.setPoolName("Server CP");
            cp.doStart();

            SelectorManager sm = new SelectorManager();
            sm.setThreadPool(tp);
            sm.setThreadName("Server Selector Manager");
            sm.doStart();

            ControlServerProtocolStack templateStack = new ControlServerProtocolStack();

            SocketProtocol spt = new SocketProtocol();
            spt.setTimeout(10 * 1000);
            spt.setSelectorManager(sm);

            templateStack.push(spt);

            ControlServerProtocol csp = new ControlServerProtocol();
            csp.setTimeout(1 * 1000);
            csp.setThreadPool(tp);
            csp.setClockPool(cp);
            csp.setSelectorManager(sm);
            csp.setControlServerListener(new ControlServerListener() {
                public void shutdown() {
                    log.trace("SERVER SIDE SHUTDOWN");
                }
            });

            templateStack.push(csp);

            ControlServerProtocolWaiter waiter = new ControlServerProtocolWaiter();

            GSSAPIServerProtocol gsp = new GSSAPIServerProtocol();
            gsp.setThreadPool(tp);
            gsp.setMutualAuth(true);
            gsp.setConfidential(true);
            gsp.setIntegrity(true);
            gsp.setServerNameString(properties.getProperty("SERVER"));

            waiter.push(gsp);

            waiter.push(new CountingProtocol());

            TestProtocol test = new TestProtocol();
            test.setValue("SimpleTest");
            test.setThreadPool(tp);
            test.setClockPool(cp);
            test.setSelectorManager(sm);

            waiter.push(test);

            templateStack.push(waiter);

            ProtocolFactory pf = new ProtocolFactory();
            pf.setClockPool(cp);
            pf.setMaxAge(Long.MAX_VALUE);
            pf.setMaxInactivity(1 * 60 * 60 * 1000);
            pf.setReclaimPeriod(10 * 1000);
            pf.setTemplate(templateStack);

            ssa = new ServerSocketAcceptor();
            ssa.setSelectorManager(sm);
            ssa.setTimeOut(5 * 1000);
            ssa.setUri(new URI("async://localhost:0/?tcp.nodelay=true&tcp.backlog=5#"));
            ssa.setAcceptorListener(pf);
            ssa.startup();

            startLatch.release();

            shutdownLatch.acquire();

            ssa.drain();

            pf.drain();

            sm.doStop();

            cp.doStop();

            tp.doStop();

            return null;
        }
View Full Code Here


* @version $Revision: 1.7 $ $Date: 2004/08/01 13:03:51 $
*/
public class DatagramProtocolTest extends TestCase {

    public void test() throws Exception {
        ThreadPool tp = new ThreadPool();
        tp.setKeepAliveTime(100);
        tp.setPoolSize(5);
        tp.setPoolName("TP");
        tp.doStart();

        SelectorManager sm = new SelectorManager();
        sm.setThreadPool(tp);
        sm.setThreadName("SM");
        sm.setTimeout(500);
        sm.doStart();

        DatagramProtocol dgp = new DatagramProtocol();
        dgp.setUpProtocol(new Protocol() {
            public Protocol getUpProtocol() {
                throw new NoSuchMethodError();
            }

            public void setUpProtocol(Protocol up) {
                throw new NoSuchMethodError();
            }

            public Protocol getDownProtocol() {
                throw new NoSuchMethodError();
            }

            public void setDownProtocol(Protocol down) {
                throw new NoSuchMethodError();
            }

            public void clearLinks() {
            }

            public Protocol cloneProtocol() throws CloneNotSupportedException {
                return (Protocol) super.clone();
            }

            public void setup() {
            }

            public void drain() {
            }

            public void teardown() throws ProtocolException {
            }

            public void sendUp(UpPacket packet) {
                DatagramUpPacket datgramPacket = (DatagramUpPacket) packet;
                System.out.println("FOO " + datgramPacket.getAddress());
            }

            public void sendDown(DownPacket packet) {
            }

            public void flush() throws ProtocolException {
            }
        });

        dgp.setDestinationInterface(new InetSocketAddress("localhost", 0));
        dgp.setSourceAddress(new InetSocketAddress("localhost", 0));
        dgp.setSelectorManager(sm);

        dgp.setup();

        DatagramDownPacket packet = new DatagramDownPacket();
        packet.setAddress(new InetSocketAddress(dgp.getConnectURI().getHost(), dgp.getConnectURI().getPort()));
        packet.setBuffers(getByteBuffer());

        dgp.sendDown(packet);
        dgp.sendDown(packet);
        dgp.sendDown(packet);

        Thread.sleep(1 * 1000);

        dgp.drain();

        sm.doStop();

        tp.doStop();
    }
View Full Code Here

        tp.doStop();
    }

    public void testClone() throws Exception {
        ThreadPool tp = new ThreadPool();
        tp.setKeepAliveTime(100);
        tp.setPoolSize(5);
        tp.setPoolName("TP");
        tp.doStart();

        SelectorManager sm = new SelectorManager();
        sm.setThreadPool(tp);
        sm.setThreadName("SM");
        sm.doStart();

        DatagramProtocol dgp = new DatagramProtocol();
        dgp.setUpProtocol(new Protocol() {
            public Protocol getUpProtocol() {
                throw new NoSuchMethodError();
            }

            public void setUpProtocol(Protocol up) {
                throw new NoSuchMethodError();
            }

            public Protocol getDownProtocol() {
                throw new NoSuchMethodError();
            }

            public void setDownProtocol(Protocol down) {
                throw new NoSuchMethodError();
            }

            public void clearLinks() {
            }

            public Protocol cloneProtocol() throws CloneNotSupportedException {
                return (Protocol) super.clone();
            }

            public void setup() {
            }

            public void drain() {
            }

            public void teardown() throws ProtocolException {
            }

            public void sendUp(UpPacket packet) {
                DatagramUpPacket datgramPacket = (DatagramUpPacket) packet;
                System.out.println("FOO " + datgramPacket.getAddress());
            }

            public void sendDown(DownPacket packet) {
            }

            public void flush() throws ProtocolException {
            }
        });

        dgp.setDestinationInterface(new InetSocketAddress("localhost", 0));
        dgp.setSourceAddress(new InetSocketAddress("localhost", 8081));
        dgp.setSelectorManager(sm);

        DatagramProtocol dgp2 = (DatagramProtocol) dgp.cloneProtocol();

        dgp2.setup();

        DatagramDownPacket packet = new DatagramDownPacket();
        packet.setAddress(new InetSocketAddress("localhost", 8081));
        packet.setBuffers(getByteBuffer());

        dgp2.sendDown(packet);
        dgp2.sendDown(packet);
        dgp2.sendDown(packet);

        Thread.sleep(5 * 1000);

        dgp2.drain();

        sm.doStop();

        tp.doStop();
    }
View Full Code Here

    final static private Log log = LogFactory.getLog(ControlProtocolTest.class);

    public void testDummy() throws Exception { }

    public void test() throws Exception {
        ThreadPool tp = new ThreadPool();
        tp.setKeepAliveTime(100 * 1000);
        tp.setPoolSize(5);
        tp.setPoolName("TP");
        tp.doStart();

        ClockPool cp = new ClockPool();
        cp.setPoolName("CP");
        cp.doStart();

        SelectorManager sm = new SelectorManager();
        sm.setThreadPool(tp);
        sm.setThreadName("SM");
        sm.doStart();

        ControlServerProtocolStack templateStack = new ControlServerProtocolStack();

        SocketProtocol spt = new SocketProtocol();
        spt.setTimeout(10 * 1000);
        spt.setSelectorManager(sm);

        templateStack.push(spt);

        ControlServerProtocol csp = new ControlServerProtocol();
        csp.setTimeout(1 * 1000);
        csp.setThreadPool(tp);
        csp.setClockPool(cp);
        csp.setSelectorManager(sm);
        csp.setControlServerListener(new ControlServerListener() {
            public void shutdown() {
                log.trace("SERVER SIDE SHUTDOWN_REQ");
            }
        });

        templateStack.push(csp);

        ControlServerProtocolWaiter waiter = new ControlServerProtocolWaiter();

        waiter.push(new CountingProtocol());

        TestProtocol test = new TestProtocol();
        test.setValue("SimpleTest");
        test.setThreadPool(tp);
        test.setClockPool(cp);
        test.setSelectorManager(sm);

        waiter.push(test);

        templateStack.push(waiter);

        ProtocolFactory pf = new ProtocolFactory();
        pf.setClockPool(cp);
        pf.setMaxAge(Long.MAX_VALUE);
        pf.setMaxInactivity(1 * 60 * 60 * 1000);
        pf.setReclaimPeriod(10 * 1000);
        pf.setTemplate(templateStack);

        ServerSocketAcceptor ssa = new ServerSocketAcceptor();
        ssa.setSelectorManager(sm);
        ssa.setTimeOut(5 * 1000);
        ssa.setUri(new URI("async://localhost:0/?tcp.nodelay=true&tcp.backlog=5#"));
        ssa.setAcceptorListener(pf);
        ssa.startup();

        ControlClientProtocolStack clientStack = new ControlClientProtocolStack();
        clientStack.setClassLoader(Thread.currentThread().getContextClassLoader());
        clientStack.setThreadPool(tp);
        clientStack.setClockPool(cp);
        clientStack.setSelectorManager(sm);

        SocketProtocol sp = new SocketProtocol();
        sp.setTimeout(15 * 1000);
        sp.setInterface(new InetSocketAddress(ssa.getConnectURI().getHost(), 0));
        sp.setAddress(new InetSocketAddress(ssa.getConnectURI().getHost(), ssa.getConnectURI().getPort()));
        sp.setSelectorManager(sm);

        clientStack.push(sp);

        ControlClientProtocol ccp = new ControlClientProtocol();
        ccp.setTimeout(15 * 1000);

        clientStack.push(ccp);

        clientStack.setup();

        clientStack.sendDown(getDatagramPacket());
        clientStack.sendDown(getDatagramPacket());
        clientStack.sendDown(getDatagramPacket());

        Thread.sleep(5 * 1000);

        clientStack.drain();

        Thread.sleep(5 * 1000);

        ssa.drain();

        pf.drain();

        sm.doStop();

        cp.doStop();

        tp.doStop();
    }
View Full Code Here

public class SocketProtocolTest extends TestCase {

    public void testNothing() {}

    public void test() throws Exception {
        ThreadPool tp = new ThreadPool();
        tp.setKeepAliveTime(1 * 1000);
        tp.setPoolSize(5);
        tp.setPoolName("TP");
        tp.doStart();

        ClockPool cp = new ClockPool();
        cp.setPoolName("CP");
        cp.doStart();

        SelectorManager sm = new SelectorManager();
        sm.setThreadPool(tp);
        sm.setThreadName("SM");
        sm.setTimeout(500);
        sm.doStart();

        SocketProtocol spt = new SocketProtocol();
        spt.setUpProtocol(new Protocol() {
            public Protocol getUpProtocol() {
                throw new NoSuchMethodError();
            }

            public void setUpProtocol(Protocol up) {
                throw new NoSuchMethodError();
            }

            public Protocol getDownProtocol() {
                throw new NoSuchMethodError();
            }

            public void setDownProtocol(Protocol down) {
                throw new NoSuchMethodError();
            }

            public void clearLinks() {
            }

            public Protocol cloneProtocol() throws CloneNotSupportedException {
                return (Protocol) super.clone();
            }

            public void setup() {
            }

            public void drain() {
            }

            public void teardown() throws ProtocolException {
            }

            public void sendUp(UpPacket packet) {
                System.out.println("BAR ");
            }

            public void sendDown(DownPacket packet) {
            }

            public void flush() throws ProtocolException {
            }
        });
        spt.setTimeout(10 * 1000);
        spt.setSelectorManager(sm);

        ProtocolFactory pf = new ProtocolFactory();
        pf.setClockPool(cp);
        pf.setMaxAge(Long.MAX_VALUE);
        pf.setMaxInactivity(1 * 60 * 60 * 1000);
        pf.setReclaimPeriod(10 * 1000);
        pf.setTemplate(spt);

        ServerSocketAcceptor ssa = new ServerSocketAcceptor();
        ssa.setSelectorManager(sm);
        ssa.setTimeOut(5 * 1000);
        ssa.setUri(new URI("async://localhost:0/?tcp.nodelay=true&tcp.backlog=5#"));
        ssa.setAcceptorListener(pf);
        ssa.startup();

        SocketProtocol sp = new SocketProtocol();
        sp.setUpProtocol(new Protocol() {
            public Protocol getUpProtocol() {
                throw new NoSuchMethodError();
            }

            public void setUpProtocol(Protocol up) {
                throw new NoSuchMethodError();
            }

            public Protocol getDownProtocol() {
                throw new NoSuchMethodError();
            }

            public void setDownProtocol(Protocol down) {
                throw new NoSuchMethodError();
            }

            public void clearLinks() {
            }

            public Protocol cloneProtocol() throws CloneNotSupportedException {
                return (Protocol) super.clone();
            }

            public void setup() {
            }

            public void drain() {
            }

            public void teardown() throws ProtocolException {
            }

            public void sendUp(UpPacket packet) {
            }

            public void sendDown(DownPacket packet) {
            }

            public void flush() throws ProtocolException {
            }
        });

        sp.setTimeout(10 * 1000);
        sp.setInterface(new InetSocketAddress(ssa.getConnectURI().getHost(), 0));
        sp.setAddress(new InetSocketAddress(ssa.getConnectURI().getHost(), ssa.getConnectURI().getPort()));
        sp.setSelectorManager(sm);

        sp.setup();


        sp.sendDown(getDatagramPacket());
        sp.sendDown(getDatagramPacket());
        sp.sendDown(getDatagramPacket());

        DatagramDownPacket packet = getDatagramPacket();
        sp.sendDown(packet);
        sp.sendDown(packet);

        Thread.sleep(5 * 1000);

        sp.drain();

        ssa.drain();

        pf.drain();

        spt.drain();

        sm.doStop();

        cp.doStop();

        tp.doStop();
    }
View Full Code Here

    }

    public void setUp() throws Exception {
        count = 0;

        tp = new ThreadPool();
        tp.setKeepAliveTime(60 * 1000);
        tp.setPoolSize(5);
        tp.setPoolName("TP");
        tp.doStart();

View Full Code Here

*/
public class ProtocolStackTest extends TestCase {
    public void testNothing() {}

    public void test() throws Exception {
        ThreadPool tp = new ThreadPool();
        tp.setKeepAliveTime(1 * 1000);
        tp.setPoolSize(5);
        tp.setPoolName("TP");
        tp.doStart();

        ClockPool cp = new ClockPool();
        cp.setPoolName("CP");
        cp.doStart();

        SelectorManager sm = new SelectorManager();
        sm.setThreadPool(tp);
        sm.setThreadName("SM");
        sm.setTimeout(500);
        sm.doStart();

        AcceptableProtocolStack s = new AcceptableProtocolStack();

        SocketProtocol spt = new SocketProtocol();
        spt.setTimeout(10 * 1000);
        spt.setSelectorManager(sm);

        s.push(spt);

        TestProtocol test = new TestProtocol();
        test.setValue("SimpleTest");
        test.setThreadPool(tp);
        test.setClockPool(cp);
        test.setSelectorManager(sm);
        s.push(test);

        ProtocolFactory pf = new ProtocolFactory();
        pf.setClockPool(cp);
        pf.setMaxAge(Long.MAX_VALUE);
        pf.setMaxInactivity(1 * 60 * 60 * 1000);
        pf.setReclaimPeriod(10 * 1000);
        pf.setTemplate(s);

        ServerSocketAcceptor ssa = new ServerSocketAcceptor();
        ssa.setSelectorManager(sm);
        ssa.setTimeOut(5 * 1000);
        ssa.setUri(new URI("async://localhost:0/?tcp.nodelay=true&tcp.backlog=5#"));
        ssa.setAcceptorListener(pf);
        ssa.startup();

        SocketProtocol sp = new SocketProtocol();
        sp.setUpProtocol(new Protocol() {
            public Protocol getUpProtocol() {
                throw new NoSuchMethodError();
            }

            public void setUpProtocol(Protocol up) {
                throw new NoSuchMethodError();
            }

            public Protocol getDownProtocol() {
                throw new NoSuchMethodError();
            }

            public void setDownProtocol(Protocol down) {
                throw new NoSuchMethodError();
            }

            public void clearLinks() {
            }

            public Protocol cloneProtocol() throws CloneNotSupportedException {
                return (Protocol) super.clone();
            }

            public void setup() {
            }

            public void drain() {
            }

            public void teardown() throws ProtocolException {
            }

            public void sendUp(UpPacket packet) {
            }

            public void sendDown(DownPacket packet) {
            }

            public void flush() throws ProtocolException {
            }
        });

        sp.setTimeout(1000 * 1000)//todo set back to 10s
        sp.setInterface(new InetSocketAddress(ssa.getConnectURI().getHost(), 0));
        sp.setAddress(new InetSocketAddress(ssa.getConnectURI().getHost(), ssa.getConnectURI().getPort()));
        sp.setSelectorManager(sm);

        sp.setup();


        sp.sendDown(getDatagramPacket());
        sp.sendDown(getDatagramPacket());
        sp.sendDown(getDatagramPacket());

        DatagramDownPacket packet = getDatagramPacket();
        sp.sendDown(packet);
        sp.sendDown(packet);

        Thread.sleep(5 * 1000);

        sp.drain();

        ssa.drain();

        pf.drain();

        spt.drain();

        sm.doStop();

        cp.doStop();

        tp.doStop();
    }
View Full Code Here

    private Object userKey = "test user info";

    protected void setUp() throws Exception {
        userTaskFactory = new MockUserTaskFactory();
        threadPool = new ThreadPool(30, "TestPool", 10000, this.getClass().getClassLoader());
        WorkerPersistence workerPersistence = new VMWorkerPersistence();
        timer = new ThreadPooledTimer(executableWorkFactory, workerPersistence, threadPool, transactionContextManager);
        timer.doStart();

        counter.set(0);
View Full Code Here

        // Don't init if allready done.
        if (threadPool != null) {
            return;
        }

        threadPool = new ThreadPool();
        threadPool.setKeepAliveTime(1 * 1000);
        threadPool.setPoolSize(5);
        threadPool.setPoolName("S Pool");

        clockPool = new ClockPool();
View Full Code Here

        // Don't init if allready done.
        if (threadPool != null) {
            return;
        }

        threadPool = new ThreadPool();
        threadPool.setKeepAliveTime(1 * 1000);
        threadPool.setPoolSize(5);
        threadPool.setPoolName("C Pool");

        clockPool = new ClockPool();
View Full Code Here

TOP

Related Classes of org.apache.geronimo.pool.ThreadPool

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.