Java Code Examples for org.apache.mina.core.session.IoSessionConfig#setWriterIdleTime()

The following examples show how to use org.apache.mina.core.session.IoSessionConfig#setWriterIdleTime() . 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: MinaRemotingServer.java    From light-task-scheduler with Apache License 2.0 6 votes vote down vote up
@Override
protected void serverStart() throws RemotingException {

    acceptor = new NioSocketAcceptor(); //TCP Acceptor

    // acceptor.getFilterChain().addFirst("logging", new MinaLoggingFilter());
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecFactory(getCodec())));
    acceptor.getFilterChain().addLast("mdc", new MdcInjectionFilter());

    acceptor.setHandler(new MinaHandler(this));
    IoSessionConfig cfg = acceptor.getSessionConfig();
    cfg.setReaderIdleTime(remotingServerConfig.getReaderIdleTimeSeconds());
    cfg.setWriterIdleTime(remotingServerConfig.getWriterIdleTimeSeconds());
    cfg.setBothIdleTime(remotingServerConfig.getServerChannelMaxIdleTimeSeconds());

    bindAddress = new InetSocketAddress(remotingServerConfig.getListenPort());
    try {
        acceptor.bind(bindAddress);
    } catch (IOException e) {
        throw new RemotingException("Start Mina server error", e);
    }
}
 
Example 2
Source File: MinaRemotingClient.java    From light-task-scheduler with Apache License 2.0 6 votes vote down vote up
@Override
protected void clientStart() throws RemotingException {
    try {
        connector = new NioSocketConnector(); //TCP Connector

        // connector.getFilterChain().addFirst("logging", new MinaLoggingFilter());
        connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecFactory(getCodec())));
        connector.getFilterChain().addLast("mdc", new MdcInjectionFilter());

        connector.setHandler(new MinaHandler(this));
        IoSessionConfig cfg = connector.getSessionConfig();
        cfg.setReaderIdleTime(remotingClientConfig.getReaderIdleTimeSeconds());
        cfg.setWriterIdleTime(remotingClientConfig.getWriterIdleTimeSeconds());
        cfg.setBothIdleTime(remotingClientConfig.getClientChannelMaxIdleTimeSeconds());
    } catch (Exception e) {
        throw new RemotingException("Mina Client start error", e);
    }
}