@Override protected void doOpen() throws Throwable { FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless(); filterChainBuilder.add(new TransportFilter()); filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this)); filterChainBuilder.add(new GrizzlyHandler(getUrl(), this)); TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance(); ThreadPoolConfig config = builder.getWorkerThreadPoolConfig(); config.setPoolName(SERVER_THREAD_POOL_NAME).setQueueLimit(-1); String threadpool = getUrl().getParameter(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL); if (Constants.DEFAULT_THREADPOOL.equals(threadpool)) { int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); config.setCorePoolSize(threads).setMaxPoolSize(threads) .setKeepAliveTime(0L, TimeUnit.SECONDS); } else if ("cached".equals(threadpool)) { int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Integer.MAX_VALUE); config.setCorePoolSize(0).setMaxPoolSize(threads) .setKeepAliveTime(60L, TimeUnit.SECONDS); } else { throw new IllegalArgumentException("Unsupported threadpool type " + threadpool); } builder.setKeepAlive(true).setReuseAddress(false) .setIOStrategy(SameThreadIOStrategy.getInstance()); transport = builder.build(); transport.setProcessor(filterChainBuilder.build()); transport.bind(getBindAddress()); transport.start(); }
@Override protected void doOpen() throws Throwable { FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless(); filterChainBuilder.add(new TransportFilter()); filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this)); filterChainBuilder.add(new GrizzlyHandler(getUrl(), this)); TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance(); ThreadPoolConfig config = builder.getWorkerThreadPoolConfig(); config.setPoolName(SERVER_THREAD_POOL_NAME).setQueueLimit(-1); String threadpool = getUrl().getParameter(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL); if (Constants.DEFAULT_THREADPOOL.equals(threadpool)) { int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); config.setCorePoolSize(threads).setMaxPoolSize(threads) .setKeepAliveTime(0L, TimeUnit.SECONDS); } else if ("cached".equals(threadpool)) { int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Integer.MAX_VALUE); config.setCorePoolSize(0).setMaxPoolSize(threads) .setKeepAliveTime(60L, TimeUnit.SECONDS); } else { throw new IllegalArgumentException("Unsupported threadpool type " + threadpool); } builder.setKeepAlive(true).setReuseAddress(false) .setIOStrategy(SameThreadIOStrategy.getInstance()); transport = builder.build(); transport.setProcessor(filterChainBuilder.build()); transport.bind(getBindAddress()); transport.start(); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final String host, final int port) throws IOException { return bind(host, port, serverConnectionBackLog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final SocketAddress socketAddress) throws IOException { return bind(socketAddress, serverConnectionBackLog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final SocketAddress socketAddress) throws IOException { return bind(socketAddress, serverConnectionBackLog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final SocketAddress socketAddress) throws IOException { return bind(socketAddress, serverConnectionBackLog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final String host, final int port) throws IOException { return bind(host, port, serverConnectionBackLog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final String host, final int port) throws IOException { return bind(host, port, serverConnectionBackLog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final SocketAddress socketAddress) throws IOException { return bind(socketAddress, serverConnectionBackLog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final SocketAddress socketAddress) throws IOException { return bind(socketAddress, serverConnectionBackLog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final String host, final int port, final int backlog) throws IOException { return bind(new InetSocketAddress(host, port), backlog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final int port) throws IOException { return bind(new InetSocketAddress(port)); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final String host, final int port, final int backlog) throws IOException { return bind(new InetSocketAddress(host, port), backlog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final String host, final int port, final int backlog) throws IOException { return bind(new InetSocketAddress(host, port), backlog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final int port) throws IOException { return bind(new InetSocketAddress(port)); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final String host, final int port, final int backlog) throws IOException { return bind(new InetSocketAddress(host, port), backlog); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final int port) throws IOException { return bind(new InetSocketAddress(port)); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final int port) throws IOException { return bind(new InetSocketAddress(port)); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final int port) throws IOException { return bind(new InetSocketAddress(port)); }
/** * {@inheritDoc} */ @Override public TCPNIOServerConnection bind(final int port) throws IOException { return bind(new InetSocketAddress(port)); }