Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move MerkleTreeConfig inside MapConfig #15180

Merged
merged 5 commits into from Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -29,7 +29,6 @@
import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddListConfigCodec;
import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddLockConfigCodec;
import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddMapConfigCodec;
import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddMerkleTreeConfigCodec;
import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddMultiMapConfigCodec;
import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddPNCounterConfigCodec;
import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddQueueConfigCodec;
Expand Down Expand Up @@ -70,7 +69,6 @@
import com.hazelcast.config.ManagementCenterConfig;
import com.hazelcast.config.MapConfig;
import com.hazelcast.config.MemberAttributeConfig;
import com.hazelcast.config.MerkleTreeConfig;
import com.hazelcast.config.MultiMapConfig;
import com.hazelcast.config.NativeMemoryConfig;
import com.hazelcast.config.NetworkConfig;
Expand All @@ -96,7 +94,6 @@
import com.hazelcast.core.ManagedContext;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.spi.serialization.SerializationService;
import com.hazelcast.util.Preconditions;
import com.hazelcast.util.StringUtil;

import java.io.File;
Expand Down Expand Up @@ -145,6 +142,7 @@ public Config addMapConfig(MapConfig mapConfig) {
Data partitioningStrategy = mapConfig.getPartitioningStrategyConfig() == null
? null : serializationService.toData(mapConfig.getPartitioningStrategyConfig().getPartitioningStrategy());

// todo add merkle tree config
ClientMessage request = DynamicConfigAddMapConfigCodec.encodeRequest(mapConfig.getName(),
mapConfig.getBackupCount(), mapConfig.getAsyncBackupCount(), mapConfig.getTimeToLiveSeconds(),
mapConfig.getMaxIdleSeconds(), mapConfig.getEvictionPolicy().name(), mapConfig.isReadBackupData(),
Expand Down Expand Up @@ -449,36 +447,6 @@ public Config setCacheEventJournalConfigs(Map<String, EventJournalConfig> eventJ
throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE);
}

@Override
public MerkleTreeConfig findMapMerkleTreeConfig(String name) {
throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE);
}

@Override
public MerkleTreeConfig getMapMerkleTreeConfig(String name) {
throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE);
}

@Override
public Config addMerkleTreeConfig(MerkleTreeConfig merkleTreeConfig) {
String mapName = merkleTreeConfig.getMapName();
Preconditions.checkHasText(mapName, "Merkle tree config must define a map name");
ClientMessage request = DynamicConfigAddMerkleTreeConfigCodec.encodeRequest(
merkleTreeConfig.getMapName(), merkleTreeConfig.isEnabled(), merkleTreeConfig.getDepth());
invoke(request);
return this;
}

@Override
public Map<String, MerkleTreeConfig> getMapMerkleTreeConfigs() {
throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE);
}

@Override
public Config setMapMerkleTreeConfigs(Map<String, MerkleTreeConfig> merkleTreeConfigs) {
throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE);
}

@Override
public Config addFlakeIdGeneratorConfig(FlakeIdGeneratorConfig flakeIdGeneratorConfig) {
ClientMessage request = DynamicConfigAddFlakeIdGeneratorConfigCodec.encodeRequest(
Expand Down
Expand Up @@ -213,7 +213,6 @@ private class SpringXmlConfigBuilder extends SpringXmlBuilderHelper {
private ManagedMap<String, AbstractBeanDefinition> scheduledExecutorManagedMap;
private ManagedMap<String, AbstractBeanDefinition> mapEventJournalManagedMap;
private ManagedMap<String, AbstractBeanDefinition> cacheEventJournalManagedMap;
private ManagedMap<String, AbstractBeanDefinition> mapMerkleTreeManagedMap;
private ManagedMap<String, AbstractBeanDefinition> cardinalityEstimatorManagedMap;
private ManagedMap<String, AbstractBeanDefinition> wanReplicationManagedMap;
private ManagedMap<String, AbstractBeanDefinition> replicatedMapManagedMap;
Expand Down Expand Up @@ -247,7 +246,6 @@ private class SpringXmlConfigBuilder extends SpringXmlBuilderHelper {
this.scheduledExecutorManagedMap = createManagedMap("scheduledExecutorConfigs");
this.mapEventJournalManagedMap = createManagedMap("mapEventJournalConfigs");
this.cacheEventJournalManagedMap = createManagedMap("cacheEventJournalConfigs");
this.mapMerkleTreeManagedMap = createManagedMap("mapMerkleTreeConfigs");
this.cardinalityEstimatorManagedMap = createManagedMap("cardinalityEstimatorConfigs");
this.wanReplicationManagedMap = createManagedMap("wanReplicationConfigs");
this.replicatedMapManagedMap = createManagedMap("replicatedMapConfigs");
Expand Down Expand Up @@ -289,8 +287,6 @@ public void handleConfig(Element element) {
handleScheduledExecutor(node);
} else if ("event-journal".equals(nodeName)) {
handleEventJournal(node);
} else if ("merkle-tree".equals(nodeName)) {
handleMerkleTree(node);
} else if ("cardinality-estimator".equals(nodeName)) {
handleCardinalityEstimator(node);
} else if ("queue".equals(nodeName)) {
Expand Down Expand Up @@ -543,11 +539,11 @@ private QuorumConfigBuilder handleProbabilisticQuorum(String name, Node node, in
getAttribute(node, "heartbeat-interval-millis"),
ProbabilisticQuorumConfigBuilder.DEFAULT_HEARTBEAT_INTERVAL_MILLIS);
quorumConfigBuilder = QuorumConfig.newProbabilisticQuorumConfigBuilder(name, quorumSize)
.withAcceptableHeartbeatPauseMillis(acceptableHeartPause)
.withSuspicionThreshold(threshold)
.withHeartbeatIntervalMillis(heartbeatIntervalMillis)
.withMinStdDeviationMillis(minStdDeviation)
.withMaxSampleSize(maxSampleSize);
.withAcceptableHeartbeatPauseMillis(acceptableHeartPause)
.withSuspicionThreshold(threshold)
.withHeartbeatIntervalMillis(heartbeatIntervalMillis)
.withMinStdDeviationMillis(minStdDeviation)
.withMaxSampleSize(maxSampleSize);
return quorumConfigBuilder;
}

Expand Down Expand Up @@ -760,7 +756,7 @@ void handleRestServerSocketEndpointConfig(Node node) {
handleServerSocketEndpointConfig(node, ProtocolType.REST, endpointConfigBuilder);

ManagedSet<RestEndpointGroup> groupSet = new ManagedSet<RestEndpointGroup>();
for (RestEndpointGroup group: RestEndpointGroup.values()) {
for (RestEndpointGroup group : RestEndpointGroup.values()) {
if (group.isEnabledByDefault()) {
groupSet.add(group);
}
Expand Down Expand Up @@ -1095,13 +1091,6 @@ public void handleLock(Node node) {
lockManagedMap.put(getAttribute(node, "name"), lockConfigBuilder.getBeanDefinition());
}

public void handleMerkleTree(Node node) {
BeanDefinitionBuilder merkleTreeBuilder = createBeanBuilder(MerkleTreeConfig.class);
fillAttributeValues(node, merkleTreeBuilder);
String mapName = getAttribute(node, "map-name");
mapMerkleTreeManagedMap.put(mapName, merkleTreeBuilder.getBeanDefinition());
}

public void handleEventJournal(Node node) {
BeanDefinitionBuilder eventJournalBuilder = createBeanBuilder(EventJournalConfig.class);
fillAttributeValues(node, eventJournalBuilder);
Expand Down Expand Up @@ -1342,6 +1331,8 @@ public void handleMap(Node node) {
} else if ("partition-lost-listeners".endsWith(nodeName)) {
ManagedList listeners = parseListeners(childNode, MapPartitionLostListenerConfig.class);
mapConfigBuilder.addPropertyValue("partitionLostListenerConfigs", listeners);
} else if ("merkle-tree".equals(nodeName)) {
handleMerkleTreeConfig(mapConfigBuilder, childNode);
} else if ("hot-restart".equals(nodeName)) {
handleHotRestartConfig(mapConfigBuilder, childNode);
} else if ("map-eviction-policy".equals(nodeName)) {
Expand Down Expand Up @@ -1379,6 +1370,12 @@ private void handleMapEvictionPolicyConfig(BeanDefinitionBuilder mapConfigBuilde
}
}

private void handleMerkleTreeConfig(BeanDefinitionBuilder configBuilder, Node node) {
BeanDefinitionBuilder merkleTreeBuilder = createBeanBuilder(MerkleTreeConfig.class);
fillAttributeValues(node, merkleTreeBuilder);
configBuilder.addPropertyValue("merkleTreeConfig", merkleTreeBuilder.getBeanDefinition());
}

private void handleHotRestartConfig(BeanDefinitionBuilder configBuilder, Node node) {
BeanDefinitionBuilder hotRestartConfigBuilder = createBeanBuilder(HotRestartConfig.class);
fillAttributeValues(node, hotRestartConfigBuilder);
Expand Down Expand Up @@ -2060,7 +2057,7 @@ private void handleRestApi(Node node, BeanDefinitionBuilder networkConfigBuilder
AbstractBeanDefinition beanDefinition = restApiConfigBuilder.getBeanDefinition();
fillAttributeValues(node, restApiConfigBuilder);
ManagedSet<RestEndpointGroup> groupSet = new ManagedSet<RestEndpointGroup>();
for (RestEndpointGroup group: RestEndpointGroup.values()) {
for (RestEndpointGroup group : RestEndpointGroup.values()) {
if (group.isEnabledByDefault()) {
groupSet.add(group);
}
Expand Down
107 changes: 49 additions & 58 deletions hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd
Expand Up @@ -713,6 +713,7 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="merkle-tree" type="merkle-tree" minOccurs="0" maxOccurs="1"/>
<xs:element name="hot-restart" type="hot-restart" minOccurs="0" maxOccurs="1"/>
<xs:element name="map-eviction-policy" type="map-eviction-policy" minOccurs="0" maxOccurs="1">
<xs:annotation>
Expand Down Expand Up @@ -1234,64 +1235,6 @@
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="merkle-tree" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:annotation>
<xs:documentation>
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).
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.
This configuration is not tied to a specific data structure and can be
reused.
See https://en.wikipedia.org/wiki/Merkle_tree.
</xs:documentation>
</xs:annotation>
<xs:attribute name="map-name" type="xs:string">
<xs:annotation>
<xs:documentation>
The name of the map to which this config applies.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="enabled" type="parameterized-boolean" default="true">
<xs:annotation>
<xs:documentation>
True if the merkle tree is enabled, false otherwise.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="depth" type="parameterized-unsigned-int">
<xs:annotation>
<xs:documentation>
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.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="multimap" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
Expand Down Expand Up @@ -4219,6 +4162,54 @@
</xs:attribute>
</xs:complexType>

<xs:complexType name="merkle-tree">
<xs:annotation>
<xs:documentation>
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).
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.
</xs:documentation>
</xs:annotation>
<xs:attribute name="enabled" type="parameterized-boolean" default="false">
<xs:annotation>
<xs:documentation>
True if the merkle tree is enabled, false otherwise.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="depth" type="parameterized-unsigned-int">
<xs:annotation>
<xs:documentation>
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.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>

<xs:complexType name="connection-strategy">
<xs:choice>
<xs:element name="connection-retry" type="connection-retry" minOccurs="0"
Expand Down