Package com.alibaba.otter.shared.communication.core.impl.connection

Examples of com.alibaba.otter.shared.communication.core.impl.connection.CommunicationConnectionPoolFactory


    private boolean poolable = true;

    public void initial() {
        CommunicationConnectionFactory factory = null;
        if (poolable) {
            factory = new CommunicationConnectionPoolFactory(new RmiCommunicationConnectionFactory());
            ((CommunicationConnectionPoolFactory) factory).initial();
        } else {
            factory = new RmiCommunicationConnectionFactory();
        }
View Full Code Here


    }

    @Test
    public void testPool() {
        CommunicationConnectionFactory factory = new RmiCommunicationConnectionFactory();
        CommunicationConnectionFactory poolFactory = new CommunicationConnectionPoolFactory(factory);
        ((CommunicationConnectionPoolFactory) poolFactory).initial();
        CommunicationParam param = new CommunicationParam();
        param.setIp("127.0.0.1");
        param.setPort(1099);
        CommunicationRegistry.regist(PoolEventType.pool, new TestPoolService());

        CommunicationConnection last = null;
        for (int i = 0; i < 11; i++) {
            CommunicationConnection connection = null;
            try {
                connection = poolFactory.createConnection(param);
                connection.call(new PoolEvent(PoolEventType.pool));
                last = connection;
                if (last != null) { // 检查链接是否是重用
                    want.object(last).isEqualTo(connection);
                }
View Full Code Here

    }

    @Test
    public void testPool_exhaust() {
        CommunicationConnectionFactory factory = new RmiCommunicationConnectionFactory();
        CommunicationConnectionFactory poolFactory = new CommunicationConnectionPoolFactory(factory);
        ((CommunicationConnectionPoolFactory) poolFactory).initial();
        CommunicationParam param = new CommunicationParam();
        param.setIp("127.0.0.1");
        param.setPort(1099);
        CommunicationRegistry.regist(PoolEventType.exhaust, new TestPoolService());

        ExecutorService executor = Executors.newCachedThreadPool();
        long start = System.currentTimeMillis();
        final CountDownLatch count = new CountDownLatch(11);
        for (int i = 0; i < 11; i++) {
            final CommunicationConnection connection = poolFactory.createConnection(param);
            final PoolEvent event = new PoolEvent(PoolEventType.exhaust);
            event.setSleep(1000);
            executor.submit(new Callable() {

                public Object call() throws Exception {
View Full Code Here

        RmiCommunicationEndpoint endpoint1098 = new RmiCommunicationEndpoint(1098);
        endpoint1098.setAlwaysCreateRegistry(false);
        endpoint1098.initial();

        CommunicationConnectionPoolFactory factory = new CommunicationConnectionPoolFactory(
                                                                                            new RmiCommunicationConnectionFactory());
        factory.initial();
        client = new DefaultCommunicationClientImpl(factory);
        client.initial();
    }
View Full Code Here

TOP

Related Classes of com.alibaba.otter.shared.communication.core.impl.connection.CommunicationConnectionPoolFactory

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.