public class CleanupChannelMap<T> extends Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected ReentrantReadWriteLock |
closedLock |
Constructor and Description |
---|
CleanupChannelMap() |
Modifier and Type | Method and Description |
---|---|
HChannel |
addChannel(T key,
HChannel channel)
Add channel to the map.
|
void |
close()
Close the channels map.
|
HChannel |
getChannel(T key)
Returns the channel bound with
key . |
Collection<HChannel> |
getChannels()
Return the channels in the map.
|
HChannel |
removeChannel(T key)
Remove the channel bound with
key . |
boolean |
removeChannel(T key,
HChannel channel)
Remove the channel bound with
key . |
boolean |
replaceChannel(T key,
HChannel oldChannel,
HChannel newChannel)
Replace channel only if currently mapped to the given
oldChannel . |
protected boolean closed
protected final ReentrantReadWriteLock closedLock
public HChannel addChannel(T key, HChannel channel)
key
, the channel
would be
closed immediately and the old channel is returned. Otherwise,
the channel
is put in the map for future usage.
If the channel map has been closed, the channel would be closed
immediately.key
- Keychannel
- Channelpublic boolean replaceChannel(T key, HChannel oldChannel, HChannel newChannel)
oldChannel
.key
- KeyoldChannel
- Old ChannelnewChannel
- New Channelpublic HChannel getChannel(T key)
key
.key
- Keykey
.public HChannel removeChannel(T key)
key
.key
- Keykey
, null if no channel
is bound with key
.public boolean removeChannel(T key, HChannel channel)
key
.key
- Keychannel
- The channel expected to be bound with key
.public Collection<HChannel> getChannels()
public void close()
Copyright © 2011–2017 The Apache Software Foundation. All rights reserved.