Class MerkleTreeConfig
- java.lang.Object
-
- com.hazelcast.config.MerkleTreeConfig
-
- All Implemented Interfaces:
DataSerializable
,IdentifiedDataSerializable
,com.hazelcast.nio.serialization.impl.Versioned
public class MerkleTreeConfig extends java.lang.Object implements IdentifiedDataSerializable, com.hazelcast.nio.serialization.impl.Versioned
Configuration for a merkle tree. The merkle tree is a data structure used for efficient comparison of the difference in the contents of large data structures. The precision of such a comparison mechanism is defined by the depth of the merkle tree.A larger depth means that a data synchronization mechanism will be able to pinpoint a smaller subset of the data structure contents in which a change occurred. This causes the synchronization mechanism to be more efficient. On the other hand, a larger tree depth means the merkle tree will consume more memory.
A smaller depth means the data synchronization mechanism will have to transfer larger chunks of the data structure in which a possible change happened. On the other hand, a shallower tree consumes less memory. The depth must be between 2 and 27 (exclusive). The default depth is 10.
As the comparison mechanism is iterative, a larger depth will also prolong the duration of the comparison mechanism. Care must be taken to not have large tree depths if the latency of the comparison operation is high. The default depth is 10.
See https://en.wikipedia.org/wiki/Merkle_tree.
- Since:
- 3.11
-
-
Constructor Summary
Constructors Constructor Description MerkleTreeConfig()
MerkleTreeConfig(MerkleTreeConfig config)
Clones aMerkleTreeConfig
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
int
getClassId()
Returns type identifier for this class.int
getDepth()
Returns the depth of the merkle tree.java.lang.Boolean
getEnabled()
Returns if the merkle tree is enabled.int
getFactoryId()
Returns DataSerializableFactory factory ID for this class.int
hashCode()
boolean
isEnabled()
Deprecated.usegetEnabled()
instead.boolean
isEnabledSet()
Method introduced for client protocol compatibility.void
readData(ObjectDataInput in)
Reads fields from the input streamMerkleTreeConfig
setDepth(int depth)
Sets the depth of the merkle tree.MerkleTreeConfig
setEnabled(boolean enabled)
Enables or disables the merkle tree.java.lang.String
toString()
void
writeData(ObjectDataOutput out)
Writes object fields to output stream
-
-
-
Constructor Detail
-
MerkleTreeConfig
public MerkleTreeConfig()
-
MerkleTreeConfig
public MerkleTreeConfig(MerkleTreeConfig config)
Clones aMerkleTreeConfig
.- Parameters:
config
- the merkle tree config to clone- Throws:
java.lang.NullPointerException
- if the config is null
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getDepth
public int getDepth()
Returns the depth of the merkle tree. The default depth is 10.
-
setDepth
public MerkleTreeConfig setDepth(int depth)
- Parameters:
depth
- the depth of the merkle tree- Returns:
- the updated config
- Throws:
InvalidConfigurationException
- if thedepth
is greater than 27 or less than 2
-
isEnabled
@Deprecated public boolean isEnabled()
Deprecated.usegetEnabled()
instead.Returns if the merkle tree is enabled.- Returns:
true
if the merkle tree is enabled,false
otherwise
-
getEnabled
public java.lang.Boolean getEnabled()
Returns if the merkle tree is enabled.- Returns:
TRUE
if the merkle tree is enabled,FALSE
if disabled ornull
if user did not explicitly configure Merkle trees, so it may or may not be enabled by Hazelcast.
-
isEnabledSet
@PrivateApi public boolean isEnabledSet()
Method introduced for client protocol compatibility.- Returns:
- whether
enabled
field is set or not.
-
setEnabled
public MerkleTreeConfig setEnabled(boolean enabled)
Enables or disables the merkle tree.- Parameters:
enabled
-true
if enabled,false
otherwise.- Returns:
- the updated config
-
getFactoryId
public int getFactoryId()
Description copied from interface:IdentifiedDataSerializable
Returns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryId
in interfaceIdentifiedDataSerializable
- Returns:
- factory ID
-
getClassId
public int getClassId()
Description copied from interface:IdentifiedDataSerializable
Returns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassId
in interfaceIdentifiedDataSerializable
- Returns:
- type ID
-
writeData
public void writeData(ObjectDataOutput out) throws java.io.IOException
Description copied from interface:DataSerializable
Writes object fields to output stream- Specified by:
writeData
in interfaceDataSerializable
- Parameters:
out
- output- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the output stream has been closed.
-
readData
public void readData(ObjectDataInput in) throws java.io.IOException
Description copied from interface:DataSerializable
Reads fields from the input stream- Specified by:
readData
in interfaceDataSerializable
- Parameters:
in
- input- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the input stream has been closed.
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-