private void notifyIdle(NioChannelImpl channel, IdleState state, long currentTime, long idleTime, long lastIoTime) { if ((idleTime > 0) && (lastIoTime != 0) && (currentTime - lastIoTime >= idleTime)) { channel.fireChannelIdle(state, currentTime); } } }
@Override public boolean isClosed() { return !isOpen(); }
public boolean isOpen() { return javaChannel().isOpen(); }
public void initChannel(NioChannel ch) { NioChannelImpl channel = (NioChannelImpl)ch; channel.setDecoder(getDecoder()); channel.setEncoder(getEncoder()); }
public Futures.CloseFuture close() { try { javaChannel().close(); closeFuture.setSuccess(true); } catch (final IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("caught connection exception", e); } closeFuture.setSuccess(false); closeFuture.setCause(e); eventHandler().exceptionCaught(this, e); } closeFuture.notifyListeners(); return closeFuture; }
private void idleCheck0(NioChannelImpl channel, long currentTime) { IdleInfo idle = channel.getIdleInfo(); long lastReadTime = idle.getLastReadTime(); long lastWriteTime = idle.getLastWriteTime(); long lastIoTime = Math.max(lastReadTime, lastWriteTime); NioConfig config = channel.getConfig(); if (config.getIdleTimeBoth() > 0) { notifyIdle(channel, IdleState.BOTH_IDLE, currentTime, config.getIdleTimeBoth() * 1000, Math.max(lastIoTime, idle.getLastBothIdleTime())); } if (config.getIdleTimeRead() > 0) { notifyIdle(channel, IdleState.READER_IDLE, currentTime, config.getIdleTimeRead() * 1000, Math.max(lastIoTime, idle.getLastReadIdleTime())); } if (config.getIdleTimeWrite() > 0) { notifyIdle(channel, IdleState.WRITER_IDLE, currentTime, config.getIdleTimeWrite() * 1000, Math.max(lastIoTime, idle.getLastWriteIdleTime())); } notifyWriteTimeout(channel, currentTime); }
@Override public SocketAddress localAddress() { return socketChannel().socket().getLocalSocketAddress(); }
socketChannel.socket().setSoLinger(true, serverConfig.getSoLinger()); channel = new NioChannelImpl(selectorLoop, this, socketChannel, eventHandler(), serverConfig); channelInitializer.initChannel(channel); this.idleDetector.addChannel(channel);
public void fireChannelIdle(IdleState state, long currentTime) { switch (state) { case BOTH_IDLE: idleInfo.setLastBothIdleTime(currentTime); break; case WRITER_IDLE: idleInfo.setLastWriteIdleTime(currentTime); break; case READER_IDLE: idleInfo.setLastReadIdleTime(currentTime); break; } eventHandler().channelIdle(this, state); }
public void initChannel(NioChannel ch) { NioChannelImpl channel = (NioChannelImpl)ch; channel.setDecoder(getDecoder()); channel.setEncoder(getEncoder()); }
public Futures.CloseFuture close() { try { javaChannel().close(); closeFuture.setSuccess(true); } catch (final IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("caught connection exception", e); } closeFuture.setSuccess(false); closeFuture.setCause(e); eventHandler().exceptionCaught(this, e); } closeFuture.notifyListeners(); return closeFuture; }
private void idleCheck0(NioChannelImpl channel, long currentTime) { IdleInfo idle = channel.getIdleInfo(); long lastReadTime = idle.getLastReadTime(); long lastWriteTime = idle.getLastWriteTime(); long lastIoTime = Math.max(lastReadTime, lastWriteTime); NioConfig config = channel.getConfig(); if (config.getIdleTimeBoth() > 0) { notifyIdle(channel, IdleState.BOTH_IDLE, currentTime, config.getIdleTimeBoth() * 1000, Math.max(lastIoTime, idle.getLastBothIdleTime())); } if (config.getIdleTimeRead() > 0) { notifyIdle(channel, IdleState.READER_IDLE, currentTime, config.getIdleTimeRead() * 1000, Math.max(lastIoTime, idle.getLastReadIdleTime())); } if (config.getIdleTimeWrite() > 0) { notifyIdle(channel, IdleState.WRITER_IDLE, currentTime, config.getIdleTimeWrite() * 1000, Math.max(lastIoTime, idle.getLastWriteIdleTime())); } notifyWriteTimeout(channel, currentTime); }
@Override public SocketAddress remoteAddress() { return socketChannel().socket().getRemoteSocketAddress(); }
socketChannel.socket().setSoLinger(true, serverConfig.getSoLinger()); channel = new NioChannelImpl(selectorLoop, this, socketChannel, eventHandler(), serverConfig); channelInitializer.initChannel(channel); this.idleDetector.addChannel(channel);
public void fireChannelIdle(IdleState state, long currentTime) { switch (state) { case BOTH_IDLE: idleInfo.setLastBothIdleTime(currentTime); break; case WRITER_IDLE: idleInfo.setLastWriteIdleTime(currentTime); break; case READER_IDLE: idleInfo.setLastReadIdleTime(currentTime); break; } eventHandler().channelIdle(this, state); }
public void initChannel(NioChannel ch) { NioChannelImpl channel = (NioChannelImpl)ch; channel.setDecoder(getDecoder()); channel.setEncoder(getEncoder()); }
public Futures.CloseFuture close() { try { javaChannel().close(); closeFuture.setSuccess(true); } catch (final IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("caught connection exception", e); } closeFuture.setSuccess(false); closeFuture.setCause(e); eventHandler().exceptionCaught(this, e); } closeFuture.notifyListeners(); return closeFuture; }
private void idleCheck0(NioChannelImpl channel, long currentTime) { IdleInfo idle = channel.getIdleInfo(); long lastReadTime = idle.getLastReadTime(); long lastWriteTime = idle.getLastWriteTime(); long lastIoTime = Math.max(lastReadTime, lastWriteTime); NioConfig config = channel.getConfig(); if (config.getIdleTimeBoth() > 0) { notifyIdle(channel, IdleState.BOTH_IDLE, currentTime, config.getIdleTimeBoth() * 1000, Math.max(lastIoTime, idle.getLastBothIdleTime())); } if (config.getIdleTimeRead() > 0) { notifyIdle(channel, IdleState.READER_IDLE, currentTime, config.getIdleTimeRead() * 1000, Math.max(lastIoTime, idle.getLastReadIdleTime())); } if (config.getIdleTimeWrite() > 0) { notifyIdle(channel, IdleState.WRITER_IDLE, currentTime, config.getIdleTimeWrite() * 1000, Math.max(lastIoTime, idle.getLastWriteIdleTime())); } notifyWriteTimeout(channel, currentTime); }
@Override public SocketAddress localAddress() { return socketChannel().socket().getLocalSocketAddress(); }
this.channel = new NioChannelImpl(selectorLoop, this, socketChannel, eventHandler(), clientConfig);