RemoteAddressBasedOMATPE executor = ...; on every 3 seconds: for (Iterator<Object> i = executor.getChildExecutorKeySet().iterator; i.hasNext();) { InetAddress ip = (InetAddress) i.next(); if (there is no active connection from 'ip' now && there has been no incoming connection from 'ip' for last 10 minutes) { i.remove(); } }If the expected maximum number of keys is small and deterministic, you could use a weak key map such as ConcurrentWeakHashMap or synchronized {@link WeakHashMap} instead of managing the life cycle of thekeys by yourself. @apiviz.landmark
RemoteAddressBasedOMATPE executor = ...; on every 3 seconds: for (Iterator<Object> i = executor.getChildExecutorKeySet().iterator; i.hasNext();) { InetAddress ip = (InetAddress) i.next(); if (there is no active connection from 'ip' now && there has been no incoming connection from 'ip' for last 10 minutes) { i.remove(); } }If the expected maximum number of keys is small and deterministic, you could use a weak key map such as ConcurrentWeakHashMap or synchronized {@link WeakHashMap} instead of managing the life cycle of thekeys by yourself. @apiviz.landmark
Although {@link OrderedMemoryAwareThreadPoolExecutor} guarantees the orderof {@link ChannelEvent}s. It does not guarantee that the invocation will be made by the same thread for the same channel, but it does guarantee that the invocation will be made sequentially for the events of the same channel. For example, the events can be processed as depicted below:
-----------------------------------> Timeline -----------------------------------> Thread X: --- Channel A (Event 1) --. .-- Channel B (Event 2) --- Channel B (Event 3) ---> \ / X / \ Thread Y: --- Channel B (Event 1) --' '-- Channel A (Event 2) --- Channel A (Event 3) --->Please note that the events of different channels are independent from each other. That is, an event of Channel B will not be blocked by an event of Channel A and vice versa, unless the thread pool is exhausted. @author The Netty Project (netty-dev@lists.jboss.org) @author Trustin Lee (tlee@redhat.com) @author David M. Lloyd (david.lloyd@redhat.com) @version $Rev: 990 $, $Date: 2009-03-06 15:52:26 +0900 (Fri, 06 Mar 2009) $ @apiviz.landmark
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|