public class DeflaterSerializer extends ChainedSerializer
Transporter trans = new NatsTransporter("localhost"); trans.setSerializer(new DeflaterSerializer()); ServiceBroker broker = ServiceBroker.builder().nodeID("node1").transporter(trans).build();Chaining Serializers (serialize then compress then encrypt packets):
Transporter trans = new NatsTransporter("localhost"); MsgPackSerializer msgPack = new MsgPackSerializer(); DeflaterSerializer deflater = new DeflaterSerializer(msgPack); BlockCipherSerializer cipher = new BlockCipherSerializer(deflater); trans.setSerializer(cipher);
Modifier and Type | Field and Description |
---|---|
protected int |
compressionLevel
Compression level (best speed = 1, best compression = 9)
|
protected int |
threshold
Compress key and/or value above this size (BYTES), 0 = disable
compression
|
parent
debug, format, reader, writer
broker, logger, name
Constructor and Description |
---|
DeflaterSerializer()
Creates a JSON-based Serializer that compresses content above 1024 bytes
with compression level "1".
|
DeflaterSerializer(int threshold)
Creates a JSON-based Serializer that compresses content above a specified
size (see the "compressAbove" parameter).
|
DeflaterSerializer(int threshold,
int compressionLevel)
Creates a JSON-based Serializer that compresses content above a specified
size with the specified compression level (1-9).
|
DeflaterSerializer(Serializer parent)
Creates a custom Serializer that compresses content above 1024 bytes size
with the compression level "1".
|
DeflaterSerializer(Serializer parent,
int threshold,
int compressionLevel)
Creates a custom Serializer that compresses content above a specified
size with the specified compression level (1-9).
|
Modifier and Type | Method and Description |
---|---|
int |
getCompressionLevel() |
int |
getThreshold() |
io.datatree.Tree |
read(byte[] source) |
void |
setCompressionLevel(int compressionLevel) |
void |
setThreshold(int threshold) |
byte[] |
write(io.datatree.Tree value) |
getFormat, setDebug, started, stopped
isDebug
getBroker, getLogger, getName
protected int threshold
protected int compressionLevel
public DeflaterSerializer()
public DeflaterSerializer(int threshold)
threshold
- Compress key and/or value above this size (BYTES), 0 = disable
compressionpublic DeflaterSerializer(int threshold, int compressionLevel)
threshold
- Compress key and/or value above this size (BYTES), 0 = disable
compressioncompressionLevel
- Compression level (best speed = 1, best compression = 9)public DeflaterSerializer(Serializer parent)
parent
- parent Serializer (eg. a JsonSerializer)public DeflaterSerializer(Serializer parent, int threshold, int compressionLevel)
parent
- parent Serializer (eg. a JsonSerializer)threshold
- Compress key and/or value above this size (BYTES), 0 = disable
compressioncompressionLevel
- Compression level (best speed = 1, best compression = 9)public byte[] write(io.datatree.Tree value) throws java.lang.Exception
write
in class Serializer
java.lang.Exception
public io.datatree.Tree read(byte[] source) throws java.lang.Exception
read
in class Serializer
java.lang.Exception
public int getCompressionLevel()
public void setCompressionLevel(int compressionLevel)
public int getThreshold()
public void setThreshold(int threshold)