org.apache.mina.transport.socket.SocketSessionConfig类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.apache.mina.transport.socket.SocketSessionConfig类的一些代码示例,展示了SocketSessionConfig类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketSessionConfig类的具体详情如下:
包路径:org.apache.mina.transport.socket.SocketSessionConfig
类名称:SocketSessionConfig

SocketSessionConfig介绍

[英]An IoSessionConfig for socket transport type.
[中]套接字传输类型的IoSessionConfig。

代码示例

代码示例来源:origin: Red5/red5-server

sessionConf.setReuseAddress(true);
sessionConf.setTcpNoDelay(tcpNoDelay);
sessionConf.setSendBufferSize(sendBufferSize);
sessionConf.setReceiveBufferSize(receiveBufferSize);
sessionConf.setMaxReadBufferSize(receiveBufferSize);
sessionConf.setThroughputCalculationInterval(thoughputCalcInterval);
sessionConf.setIdleTime(IdleStatus.BOTH_IDLE, idleTime);
sessionConf.setKeepAlive(keepAlive);
  sessionConf.setTrafficClass(trafficClass);
log.info("Send buffer size: {} recv buffer size: {} so linger: {} traffic class: {}", new Object[] { sessionConf.getSendBufferSize(), sessionConf.getReceiveBufferSize(), sessionConf.getSoLinger(), sessionConf.getTrafficClass() });

代码示例来源:origin: apache/flume

acceptor.getSessionConfig().setReadBufferSize(readBufferSize);
acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);

代码示例来源:origin: igniterealtime/Openfire

private static NioSocketAcceptor buildSocketAcceptor()
{
  // Create SocketAcceptor with correct number of processors
  final int processorCount = JiveGlobals.getIntProperty( "xmpp.processor.count", Runtime.getRuntime().availableProcessors() );
  final NioSocketAcceptor socketAcceptor = new NioSocketAcceptor( processorCount );
  // Set that it will be possible to bind a socket if there is a connection in the timeout state.
  socketAcceptor.setReuseAddress( true );
  // Set the listen backlog (queue) length. Default is 50.
  socketAcceptor.setBacklog( JiveGlobals.getIntProperty( "xmpp.socket.backlog", 50 ) );
  // Set default (low level) settings for new socket connections
  final SocketSessionConfig socketSessionConfig = socketAcceptor.getSessionConfig();
  //socketSessionConfig.setKeepAlive();
  final int receiveBuffer = JiveGlobals.getIntProperty( "xmpp.socket.buffer.receive", -1 );
  if ( receiveBuffer > 0 )
  {
    socketSessionConfig.setReceiveBufferSize( receiveBuffer );
  }
  final int sendBuffer = JiveGlobals.getIntProperty( "xmpp.socket.buffer.send", -1 );
  if ( sendBuffer > 0 )
  {
    socketSessionConfig.setSendBufferSize( sendBuffer );
  }
  final int linger = JiveGlobals.getIntProperty( "xmpp.socket.linger", -1 );
  if ( linger > 0 )
  {
    socketSessionConfig.setSoLinger( linger );
  }
  socketSessionConfig.setTcpNoDelay( JiveGlobals.getBooleanProperty( "xmpp.socket.tcp-nodelay", socketSessionConfig.isTcpNoDelay() ) );
  return socketAcceptor;
}

代码示例来源:origin: quickfix-j/quickfixj

SocketSessionConfig socketSessionConfig = (SocketSessionConfig) sessionConfig;
if (keepAlive != null) {
  socketSessionConfig.setKeepAlive(keepAlive);
  socketSessionConfig.setOobInline(oobInline);
  socketSessionConfig.setReceiveBufferSize(receiveBufferSize);
  socketSessionConfig.setReuseAddress(reuseAddress);
  socketSessionConfig.setSendBufferSize(sendBufferSize);
  socketSessionConfig.setSoLinger(linger);
  socketSessionConfig.setTcpNoDelay(tcpNoDelay);
  socketSessionConfig.setTrafficClass(trafficClass);

代码示例来源:origin: kaazing/gateway

setKeepAlive(cfg.isKeepAlive());
setOobInline(cfg.isOobInline());
setReceiveBufferSize(cfg.getReceiveBufferSize());
setReuseAddress(cfg.isReuseAddress());
setSendBufferSize(cfg.getSendBufferSize());
setSoLinger(cfg.getSoLinger());
setTcpNoDelay(cfg.isTcpNoDelay());
cfg.getTrafficClass();

代码示例来源:origin: jzyong/game-server

@Override
  public void run() {
    DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
    chain.addLast("codec", new HttpServerCodecImpl());
    // // 线程队列池
    OrderedThreadPoolExecutor threadpool = new OrderedThreadPoolExecutor(minaServerConfig.getOrderedThreadPoolExecutorSize());
    chain.addLast("threadPool", new ExecutorFilter(threadpool));
    acceptor.setReuseAddress(minaServerConfig.isReuseAddress()); // 允许地址重用
    SocketSessionConfig sc = acceptor.getSessionConfig();
    sc.setReuseAddress(minaServerConfig.isReuseAddress());
    sc.setReceiveBufferSize(minaServerConfig.getMaxReadSize());
    sc.setSendBufferSize(minaServerConfig.getSendBufferSize());
    sc.setTcpNoDelay(minaServerConfig.isTcpNoDelay());
    sc.setSoLinger(minaServerConfig.getSoLinger());
    sc.setIdleTime(IdleStatus.READER_IDLE, minaServerConfig.getReaderIdleTime());
    sc.setIdleTime(IdleStatus.WRITER_IDLE, minaServerConfig.getWriterIdleTime());
    acceptor.setHandler(ioHandler);
    try {
      acceptor.bind(new InetSocketAddress(minaServerConfig.getHttpPort()));
      LOG.warn("已开始监听HTTP端口:{}", minaServerConfig.getHttpPort());
    } catch (IOException e) {
      SysUtil.exit(getClass(), e, "监听HTTP端口:{}已被占用", minaServerConfig.getHttpPort());
    }
  }
}

代码示例来源:origin: Red5/red5-websocket

sessionConf.setReuseAddress(true);
sessionConf.setTcpNoDelay(true);
sessionConf.setSendBufferSize(sendBufferSize);
sessionConf.setReadBufferSize(receiveBufferSize);
sessionConf.setUseReadOperation(false);
sessionConf.setWriteTimeout(writeTimeout);
  sessionConf.setIdleTime(IdleStatus.BOTH_IDLE, idleTimeout);
  log.debug("Acceptor sizes - send: {} recv: {}", acceptor.getSessionConfig().getSendBufferSize(), acceptor.getSessionConfig().getReadBufferSize());

代码示例来源:origin: org.apache.sshd/sshd-mina

if (boolVal != null) {
  try {
    config.setKeepAlive(boolVal);
  } catch (RuntimeIoException t) {
    handleConfigurationError(config, FactoryManager.SOCKET_KEEPALIVE, boolVal, t);
if (intVal != null) {
  try {
    config.setSendBufferSize(intVal);
  } catch (RuntimeIoException t) {
    handleConfigurationError(config, FactoryManager.SOCKET_SNDBUF, intVal, t);
if (intVal != null) {
  try {
    config.setReceiveBufferSize(intVal);
  } catch (RuntimeIoException t) {
    handleConfigurationError(config, FactoryManager.SOCKET_RCVBUF, intVal, t);
if (intVal != null) {
  try {
    config.setSoLinger(intVal);
  } catch (RuntimeIoException t) {
    handleConfigurationError(config, FactoryManager.SOCKET_LINGER, intVal, t);
if (boolVal != null) {
  try {
    config.setTcpNoDelay(boolVal);
  } catch (RuntimeIoException t) {
    handleConfigurationError(config, FactoryManager.TCP_NODELAY, boolVal, t);

代码示例来源:origin: org.apache.ftpserver/ftpserver-core

acceptor.getSessionConfig().setReadBufferSize(2048);
acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE,
    getIdleTimeout());
acceptor.getSessionConfig().setReceiveBufferSize(512);

代码示例来源:origin: youtongluan/sumk

acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, AppInfo.getInt("soa.session.idle", 60 * 5));
if (SocketSessionConfig.class.isInstance(acceptor.getSessionConfig())) {
  SocketSessionConfig conf = (SocketSessionConfig) acceptor.getSessionConfig();
  conf.setKeepAlive(true);
  conf.setReceiveBufferSize(100);
  conf.setSendBufferSize(8192);

代码示例来源:origin: jzyong/game-server

/**
 * 设置连接配置
 * @param minaClientConfig
 */
public void setMinaClientConfig(MinaClientConfig minaClientConfig) {
  if (minaClientConfig == null) {
    return;
  }
  this.minaClientConfig = minaClientConfig;
  SocketSessionConfig sc = connector.getSessionConfig();
  maxConnectCount = minaClientConfig.getMaxConnectCount();
  sc.setReceiveBufferSize(minaClientConfig.getReceiveBufferSize()); // 524288
  sc.setSendBufferSize(minaClientConfig.getSendBufferSize()); // 1048576
  sc.setMaxReadBufferSize(minaClientConfig.getMaxReadSize()); // 1048576
  factory.getDecoder().setMaxReadSize(minaClientConfig.getMaxReadSize());
  sc.setSoLinger(minaClientConfig.getSoLinger()); // 0
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-api

/**
 * Create the connector
 * 
 * @throws LdapException If the connector can't be created
 */
private void createConnector() throws LdapException
{
  // Use only one thread inside the connector
  connector = new NioSocketConnector( 1 );
  
  if ( connectionConfig != null )
  {
    ( ( SocketSessionConfig ) connector.getSessionConfig() ).setAll( connectionConfig );
  }
  else
  {
    ( ( SocketSessionConfig ) connector.getSessionConfig() ).setReuseAddress( true );
  }
  // Add the codec to the chain
  connector.getFilterChain().addLast( "ldapCodec", ldapProtocolFilter );
  // If we use SSL, we have to add the SslFilter to the chain
  if ( config.isUseSsl() )
  {
    addSslFilter();
  }
  // Inject the protocolHandler
  connector.setHandler( this );
}

代码示例来源:origin: r17171709/android_demo

private PushManager() {
  connector=new NioSocketConnector();
  connector.setConnectTimeoutMillis(Params.CONNECT_TIMEOUT);
  //为接收器设置管理服务
  connector.setHandler(new ClientSessionHandler());
  //设置过滤器(使用Mina提供的文本换行符编解码器)
  connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"), LineDelimiter.WINDOWS.getValue(),LineDelimiter.WINDOWS.getValue())));
  //读写通道5秒内无操作进入空闲状态
  connector.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, Params.REQUEST_TIMEOUT);
  //设置读取数据的缓冲区大小
  connector.getSessionConfig().setReadBufferSize(2048);
  //设置心跳
  KeepAliveMessageFactory heartBeatFactory = new ClientKeepAliveMessageFactoryImp();
  KeepAliveRequestTimeoutHandler heartBeatHandler = new ClientKeepAliveMessageTimeoutFactoryImp();
  KeepAliveFilter heartBeat = new KeepAliveFilter(heartBeatFactory, IdleStatus.BOTH_IDLE, heartBeatHandler);
  //是否回发
  heartBeat.setForwardEvent(true);
  //心跳发送频率
  heartBeat.setRequestInterval(Params.REQUEST_INTERVAL);
  connector.getSessionConfig().setKeepAlive(true);
  connector.getFilterChain().addLast("keepalive", heartBeat);
}

代码示例来源:origin: miltonio/milton2

@Override
  public void sessionCreated(IoSession session) throws Exception {
    log.info("Session created...");
    ((SocketSessionConfig) session.getConfig()).setReceiveBufferSize(2048);
    ((SocketSessionConfig) session.getConfig()).setIdleTime(IdleStatus.BOTH_IDLE, 10);
    PopSession sess = new PopSession(session, resourceFactory);
    session.setAttribute("stateMachine", sess);
  }
}

代码示例来源:origin: Red5/red5-server

/** {@inheritDoc} */
@Override
public void sessionOpened(IoSession session) throws Exception {
  SocketSessionConfig ssc = (SocketSessionConfig) session.getConfig();
  ssc.setTcpNoDelay(true);
  super.sessionOpened(session);
}

代码示例来源:origin: kingston-csj/jforgame

private SocketSessionConfig getSessionConfig() {
  SocketSessionConfig config = new DefaultSocketSessionConfig();
  config.setKeepAlive(true);
  config.setReuseAddress(true);
  return config;
}

代码示例来源:origin: sics-sse/moped

if (!server.equals("none")) {
  NioSocketConnector connector = new NioSocketConnector();
  connector.getSessionConfig().setKeepAlive(true);

代码示例来源:origin: OpenNMS/opennms

connector.getSessionConfig().setReuseAddress(true);

代码示例来源:origin: org.codehaus.fabric3/fabric3-ftp-server

/**
 * Starts the FTP server.
 *
 * @throws IOException If unable to start the FTP server.
 */
@Init
public void start() throws IOException {
  InetSocketAddress socketAddress;
  if (listenAddress == null) {
    socketAddress = new InetSocketAddress(InetAddress.getLocalHost(), commandPort);
  } else {
    socketAddress = new InetSocketAddress(listenAddress, commandPort);
  }
  acceptor = new NioSocketAcceptor();
  SocketSessionConfig config = acceptor.getSessionConfig();
  config.setIdleTime(IdleStatus.BOTH_IDLE, idleTimeout);
  acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(executorService));
  acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(codecFactory));
  acceptor.setHandler(ftpHandler);
  acceptor.bind(socketAddress);
  monitor.startFtpListener(commandPort);
}

代码示例来源:origin: kaazing/gateway

public void initSessionConfig() throws RuntimeIoException {
  this.config.setAll(service.getSessionConfig());
}

相关文章