Package net.i2p.router.transport.ntcp
Class EventPumper
- java.lang.Object
-
- net.i2p.router.transport.ntcp.EventPumper
-
-
Constructor Summary
Constructors Constructor Description EventPumper(RouterContext ctx, NTCPTransport transport)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
blockIP(byte[] ip)
Temp.static void
clearInterest(SelectionKey key, int op)
Warning - caller should catch unchecked CancelledKeyExceptionlong
getIdleTimeout()
boolean
isAlive()
Selector can take quite a while to close after calling stopPumping()boolean
processWrite(NTCPConnection con, SelectionKey key)
Asynchronous write all buffers to the channel.void
register(ServerSocketChannel chan)
Register the acceptor.void
registerConnect(NTCPConnection con)
Outboundstatic void
releaseBuf(ByteBuffer buf)
Return a read buffer to the pool.void
run()
The selector loop.static void
setInterest(SelectionKey key, int op)
Warning - caller should catch unchecked CancelledKeyExceptionvoid
startPumping()
void
stopPumping()
void
wantsRead(NTCPConnection con)
This is only called from NTCPConnection.complete() if there is more data, which is rare (never?) so we don't need to check for dups or make _wantsRead a Set.void
wantsWrite(NTCPConnection con)
Called by the connection when it has data ready to write (after bw allocation).
-
-
-
Constructor Detail
-
EventPumper
public EventPumper(RouterContext ctx, NTCPTransport transport)
-
-
Method Detail
-
startPumping
public void startPumping()
-
stopPumping
public void stopPumping()
-
isAlive
public boolean isAlive()
Selector can take quite a while to close after calling stopPumping()
-
register
public void register(ServerSocketChannel chan)
Register the acceptor. This is only called from NTCPTransport.bindAddress(), so it isn't clear why this needs a queue.
-
registerConnect
public void registerConnect(NTCPConnection con)
Outbound
-
run
public void run()
The selector loop. On high-bandwidth routers, this is the thread with the highest CPU usage, so take care to minimize overhead and unnecessary debugging stuff.
-
wantsWrite
public void wantsWrite(NTCPConnection con)
Called by the connection when it has data ready to write (after bw allocation). Only wakeup if new.
-
wantsRead
public void wantsRead(NTCPConnection con)
This is only called from NTCPConnection.complete() if there is more data, which is rare (never?) so we don't need to check for dups or make _wantsRead a Set.
-
releaseBuf
public static void releaseBuf(ByteBuffer buf)
Return a read buffer to the pool. These buffers must be from acquireBuf(), i.e. capacity() == BUF_SIZE. High-frequency path in thread.
-
processWrite
public boolean processWrite(NTCPConnection con, SelectionKey key)
Asynchronous write all buffers to the channel. This method will disable the interest if no more writes remain. If this returns false, caller MUST call wantsWrite(con)- Parameters:
key
- non-null- Returns:
- true if all buffers were completely written, false if buffers remain
- Since:
- 0.9.53
-
blockIP
public void blockIP(byte[] ip)
Temp. block inbound from this IP- Since:
- 0.9.58
-
getIdleTimeout
public long getIdleTimeout()
-
setInterest
public static void setInterest(SelectionKey key, int op) throws CancelledKeyException
Warning - caller should catch unchecked CancelledKeyException- Throws:
CancelledKeyException
- which is unchecked- Since:
- 0.9.53
-
clearInterest
public static void clearInterest(SelectionKey key, int op) throws CancelledKeyException
Warning - caller should catch unchecked CancelledKeyException- Throws:
CancelledKeyException
- which is unchecked- Since:
- 0.9.53
-
-