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

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


    // 是否使用链接池
    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


        endpoint2088.initial();

        DubboCommunicationEndpoint endpoint2089 = new DubboCommunicationEndpoint(2089);
        endpoint2089.initial();

        CommunicationConnectionFactory factory = new DubboCommunicationConnectionFactory();
        client = new DefaultCommunicationClientImpl(factory);
        client.initial();
    }
View Full Code Here

        endpoint.initial();
    }

    @Test
    public void testSingle() {
        CommunicationConnectionFactory factory = new DubboCommunicationConnectionFactory();
        CommunicationParam param = new CommunicationParam();
        param.setIp("127.0.0.1");
        param.setPort(2088);
        CommunicationConnection connection = factory.createConnection(param);
        Object result = connection.call(new HeartEvent());
        want.object(result).notNull();
    }
View Full Code Here

        endpoint.initial();
    }

    @Test
    public void testSingle() {
        CommunicationConnectionFactory factory = new RmiCommunicationConnectionFactory();
        CommunicationParam param = new CommunicationParam();
        param.setIp("127.0.0.1");
        param.setPort(1099);
        CommunicationConnection connection = factory.createConnection(param);
        Object result = connection.call(new HeartEvent());
        want.object(result).notNull();
    }
View Full Code Here

        want.object(result).notNull();
    }

    @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

TOP

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

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.