Search in sources :

Example 1 with SocketSessionConfig

use of org.apache.mina.transport.socket.SocketSessionConfig in project Openfire by igniterealtime.

the class MINAConnectionAcceptor method buildSocketAcceptor.

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;
}
Also used : NioSocketAcceptor(org.apache.mina.transport.socket.nio.NioSocketAcceptor) SocketSessionConfig(org.apache.mina.transport.socket.SocketSessionConfig)

Example 2 with SocketSessionConfig

use of org.apache.mina.transport.socket.SocketSessionConfig in project gitblit by gitblit.

the class SshServerSessionFactory method createSession.

@Override
protected AbstractSession createSession(final IoSession io) throws Exception {
    log.info("creating ssh session from {}", io.getRemoteAddress());
    if (io instanceof MinaSession) {
        if (((MinaSession) io).getSession().getConfig() instanceof SocketSessionConfig) {
            ((SocketSessionConfig) ((MinaSession) io).getSession().getConfig()).setKeepAlive(true);
        }
    }
    final SshServerSession session = (SshServerSession) super.createSession(io);
    SocketAddress peer = io.getRemoteAddress();
    SshDaemonClient client = new SshDaemonClient(peer);
    session.setAttribute(SshDaemonClient.KEY, client);
    // TODO(davido): Log a session close without authentication as a
    // failure.
    session.addCloseSessionListener(new SshFutureListener<CloseFuture>() {

        @Override
        public void operationComplete(CloseFuture future) {
            log.info("closed ssh session from {}", io.getRemoteAddress());
        }
    });
    return session;
}
Also used : CloseFuture(org.apache.sshd.common.future.CloseFuture) MinaSession(org.apache.sshd.common.io.mina.MinaSession) SocketAddress(java.net.SocketAddress) SocketSessionConfig(org.apache.mina.transport.socket.SocketSessionConfig)

Aggregations

SocketSessionConfig (org.apache.mina.transport.socket.SocketSessionConfig)2 SocketAddress (java.net.SocketAddress)1 NioSocketAcceptor (org.apache.mina.transport.socket.nio.NioSocketAcceptor)1 CloseFuture (org.apache.sshd.common.future.CloseFuture)1 MinaSession (org.apache.sshd.common.io.mina.MinaSession)1