org.jgroups.protocols

## Class COMPRESS

- java.lang.Object
- - org.jgroups.stack.Protocol
  - - org.jgroups.protocols.COMPRESS

    public class COMPRESS
    extends Protocol

Compresses the payload of a message. Goal is to reduce the number of messages sent across the wire. Should ideally be layered somewhere above a fragmentation protocol (e.g. FRAG).

Author:
  Bela Ban

### Nested Class Summary

Nested Classes
`static class` `COMPRESS.CompressHeader`

### Field Summary

### Fields inherited from class org.jgroups.stack.Protocol

`down_prot, ergonomics, id, log, name, stack, stats, up_prot`

### Constructor Summary

Constructors
Constructor and Description
`COMPRESS()`

### Method Summary

Methods
`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.
`java.lang.Object` `up(Event evt)` If there is no header, we pass the message up.

### Methods inherited from class org.jgroups.stack.Protocol

`downThreadEnabled, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop, upThreadEnabled`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### COMPRESS

    public COMPRESS()

### Method Detail

#### init

    public void init()
              throws java.lang.Exception

Description copied from class: `Protocol`
Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.

Overrides:
  `init` in class `Protocol`
Throws:
  `java.lang.Exception` - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the channel constructor will throw an exception

#### destroy

    public void destroy()

Description copied from class: `Protocol`
This method is called on a `Channel.close()`. Does some cleanup; after the call the VM will terminate

Overrides:
  `destroy` in class `Protocol`

#### down

    public java.lang.Object down(Event evt)

We compress the payload if it is larger than `min_size`. In this case we add a header containing the original size before compression. Otherwise we add no header.
Note that we compress either the entire buffer (if offset/length are not used), or a subset (if offset/length are used)

Overrides:
  `down` in class `Protocol`
Parameters:
  `evt` -

#### up

    public java.lang.Object up(Event evt)

If there is no header, we pass the message up. Otherwise we uncompress the payload to its original size.

Overrides:
  `up` in class `Protocol`
Parameters:
  `evt` -