public class COMPRESS extends Protocol
限定符和类型 | 类和说明 |
---|---|
static class |
COMPRESS.CompressHeader |
限定符和类型 | 字段和说明 |
---|---|
protected int |
compression_level |
protected java.util.concurrent.BlockingQueue<java.util.zip.Deflater> |
deflater_pool |
protected java.util.concurrent.BlockingQueue<java.util.zip.Inflater> |
inflater_pool |
protected long |
min_size |
protected int |
pool_size |
构造器和说明 |
---|
COMPRESS() |
限定符和类型 | 方法和说明 |
---|---|
void |
destroy()
This method is called on a
Channel.close() . |
java.lang.Object |
down(Event evt)
We compress the payload if it is larger than
min_size . |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
protected Message |
uncompress(Message msg,
int original_size)
Returns a new message as a result of uncompressing msg, or null if msg couldn't be uncompressed
|
java.lang.Object |
up(Event evt)
If there is no header, we pass the message up.
|
void |
up(MessageBatch batch)
Sends up a multiple messages in a
MessageBatch . |
accept, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop
protected int compression_level
protected long min_size
protected int pool_size
protected java.util.concurrent.BlockingQueue<java.util.zip.Deflater> deflater_pool
protected java.util.concurrent.BlockingQueue<java.util.zip.Inflater> inflater_pool
public void init() throws java.lang.Exception
Protocol
public void destroy()
Protocol
Channel.close()
.
Does some cleanup; after the call the VM will terminatepublic java.lang.Object down(Event evt)
min_size
. In this case we add a header containing
the original size before compression. Otherwise we add no header.public java.lang.Object up(Event evt)
public void up(MessageBatch batch)
Protocol
MessageBatch
. The sender of the batch is always the same, and so is the
destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed
messages, although the transport itself will create initial MessageBatches that contain only either OOB or
regular messages.
The default processing below sends messages up the stack individually, based on a matching criteria
(calling Protocol.accept(Message)
), and - if true - calls Protocol.up(Event)
for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.
Subclasses should check if there are any messages destined for them (e.g. using
MessageBatch.getMatchingMessages(short, boolean)
), then possibly remove and process them and finally pass
the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all
encrypted messages in the batch, not remove them, and pass the batch up when done.