org.apache.mina.common.ThreadModel Java Examples

The following examples show how to use org.apache.mina.common.ThreadModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NioConfig.java    From cougar with Apache License 2.0 6 votes vote down vote up
protected void configureProtocol(BaseIoServiceConfig config, boolean isServer) throws IOException {

        ByteBuffer.setUseDirectBuffers(useDirectBuffersInMina);

        config.getFilterChain().addLast("slowHandling", new SessionWriteQueueMonitoring(nioLogger, maxWriteQueueSize));
        config.getFilterChain().addLast("codec",
                new ProtocolCodecFilter(new CougarProtocolEncoder(nioLogger), new CougarProtocolDecoder(nioLogger)));
        if (isServer) {
            config.getFilterChain().addLast("protocol", CougarProtocol.getServerInstance(nioLogger, keepAliveInterval, keepAliveTimeout, null, false, false));
        }
        else {
            config.getFilterChain().addLast("protocol", CougarProtocol.getClientInstance(nioLogger, keepAliveInterval, keepAliveTimeout, null, false, false, rpcTimeoutMillis));
        }

        config.setThreadModel(ThreadModel.MANUAL);
    }
 
Example #2
Source File: MinaServer.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
    protected void doOpen() throws Throwable {
        // set thread pool. iothreads线程数默认是Runtime.getRuntime().availableProcessors() + 1
        acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
//                线程池默认是缓存线程池
                Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker",
                        true)));
        // config
        SocketAcceptorConfig cfg = (SocketAcceptorConfig) acceptor.getDefaultConfig();
        cfg.setThreadModel(ThreadModel.MANUAL);
        // set codec.
        acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));

        acceptor.bind(getBindAddress(), new MinaHandler(getUrl(), this));
    }
 
Example #3
Source File: MinaServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
protected void doOpen() throws Throwable {
    // set thread pool.
    acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
                                   Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker",
                                                                                        true)));
    // config
    SocketAcceptorConfig cfg = (SocketAcceptorConfig) acceptor.getDefaultConfig();
    cfg.setThreadModel(ThreadModel.MANUAL);
    // set codec.
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
    
    acceptor.bind(getBindAddress(), new MinaHandler(getUrl(), this));
}
 
Example #4
Source File: MinaServer.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Override
protected void doOpen() throws Throwable {
    // set thread pool.
    acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
                                   Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker",
                                                                                        true)));
    // config
    SocketAcceptorConfig cfg = (SocketAcceptorConfig) acceptor.getDefaultConfig();
    cfg.setThreadModel(ThreadModel.MANUAL);
    // set codec.
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
    
    acceptor.bind(getBindAddress(), new MinaHandler(getUrl(), this));
}
 
Example #5
Source File: MinaServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
protected void doOpen() throws Throwable {
    // set thread pool.
    acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
                                   Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker",
                                                                                        true)));
    // config
    SocketAcceptorConfig cfg = (SocketAcceptorConfig) acceptor.getDefaultConfig();
    cfg.setThreadModel(ThreadModel.MANUAL);
    // set codec.
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
    
    acceptor.bind(getBindAddress(), new MinaHandler(getUrl(), this));
}
 
Example #6
Source File: MinaServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
protected void doOpen() throws Throwable {
    // set thread pool.
    acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
                                   Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker",
                                                                                        true)));
    // config
    SocketAcceptorConfig cfg = (SocketAcceptorConfig) acceptor.getDefaultConfig();
    cfg.setThreadModel(ThreadModel.MANUAL);
    // set codec.
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
    
    acceptor.bind(getBindAddress(), new MinaHandler(getUrl(), this));
}