@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getConnectTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }
this.config.setKeepAlive( cfg.isKeepAlive() ); this.config.setOobInline( cfg.isOobInline() ); this.config.setReceiveBufferSize( cfg.getReceiveBufferSize() ); this.readBufferSize = cfg.getReceiveBufferSize(); this.config.setReuseAddress( cfg.isReuseAddress() ); this.config.setSendBufferSize( cfg.getSendBufferSize() ); this.config.setSoLinger( cfg.getSoLinger() ); this.config.setTcpNoDelay( cfg.isTcpNoDelay() ); if( this.config.getTrafficClass() != cfg.getTrafficClass() ) this.config.setTrafficClass( cfg.getTrafficClass() );
/** * Construct a new SocketConnection with the given listener, filter, and * session. * * @param listener the {@code ConnectionListener} for the * {@code Connection} * @param filter the {@code CompleteMessageFilter} for the * {@code Connection} * @param session the {@code IoSession} for the {@code Connection} */ SocketConnection(ConnectionListener listener, CompleteMessageFilter filter, IoSession session) { if (listener == null || filter == null || session == null) { throw new NullPointerException("null argument to constructor"); } this.listener = listener; this.filter = filter; this.session = session; if (session.getTransportType() == TransportType.SOCKET) { SocketSessionConfig cfg = (SocketSessionConfig) session.getConfig(); cfg.setTcpNoDelay(true); } }
public static void initialize( IoSession session ) { IoSessionConfig cfg = session.getConfig(); if( cfg instanceof SocketSessionConfig ) { SocketSessionConfig sCfg = ( SocketSessionConfig ) cfg; sCfg.setReuseAddress( true ); sCfg.setKeepAlive( true ); } else if( cfg instanceof DatagramSessionConfig ) { DatagramSessionConfig dCfg = ( DatagramSessionConfig ) cfg; dCfg.setReuseAddress( true ); } }
( ( SocketSessionConfig ) cfg.getSessionConfig() ).getReceiveBufferSize() );
connectionTimeout = MIN_CONN_TIMEOUT; cfg.setConnectTimeout((int) connectionTimeout / 1000); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getFilterChain().addLast("objectserialize", new TairProtocolCodecFilter(pstreamer));
@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getConnectTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }
@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getConnectTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }
@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getConnectTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }
@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getConnectTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }
@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }
@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }
@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getConnectTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }
@Override protected void doOpen() throws Throwable { connectorKey = getUrl().toFullString(); SocketConnector c = connectors.get(connectorKey); if (c != null) { connector = c; } else { // set thread pool. connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); cfg.setThreadModel(ThreadModel.MANUAL); cfg.getSessionConfig().setTcpNoDelay(true); cfg.getSessionConfig().setKeepAlive(true); int timeout = getTimeout(); cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000); // set codec. connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this))); connectors.put(connectorKey, connector); } }