Java Code Examples for org.apache.mina.transport.socket.nio.SocketAcceptorConfig#setThreadModel()

The following examples show how to use org.apache.mina.transport.socket.nio.SocketAcceptorConfig#setThreadModel() . 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: 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 2
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 3
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 4
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 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));
}