Skip to content

Commit

Permalink
Enable map store config unless its disabled explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
blazember committed Feb 15, 2021
1 parent 5c9b3a2 commit e4da790
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2205,16 +2205,19 @@ protected void queryCachePredicateHandler(Node childNode, QueryCacheConfig query

private MapStoreConfig handleMapStoreConfig(Node node, MapStoreConfig mapStoreConfig) {
NamedNodeMap attributes = node.getAttributes();
boolean enabled = true;
for (int a = 0; a < attributes.getLength(); a++) {
Node att = attributes.item(a);
if (matches("enabled", att.getNodeName())) {
mapStoreConfig.setEnabled(getBooleanValue(getTextContent(att)));
enabled = getBooleanValue(getTextContent(att));
} else if (matches("initial-mode", att.getNodeName())) {
MapStoreConfig.InitialLoadMode mode = MapStoreConfig.InitialLoadMode
.valueOf(upperCaseInternal(getTextContent(att)));
mapStoreConfig.setInitialLoadMode(mode);
}
}
mapStoreConfig.setEnabled(enabled);

for (Node n : childElements(node)) {
String nodeName = cleanNodeName(n);
if (matches("class-name", nodeName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ public abstract class AbstractConfigBuilderTest extends HazelcastTestSupport {
@Test
public abstract void testMapStoreInitialModeEager();

@Test
public abstract void testMapStoreEnabled();

@Test
public abstract void testMapStoreEnabledIfNotDisabled();

@Test
public abstract void testMapStoreDisabled();

@Test
public abstract void testMapStoreWriteBatchSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,51 @@ public void testMapStoreWriteBatchSize() {
assertEquals(23, mapStoreConfig.getWriteBatchSize());
}

@Override
@Test
public void testMapStoreEnabled() {
String xml = HAZELCAST_START_TAG
+ "<map name=\"mymap\">"
+ "<map-store enabled=\"true\" />"
+ "</map>"
+ HAZELCAST_END_TAG;

Config config = buildConfig(xml);
MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();

assertTrue(mapStoreConfig.isEnabled());
}

@Override
@Test
public void testMapStoreEnabledIfNotDisabled() {
String xml = HAZELCAST_START_TAG
+ "<map name=\"mymap\">"
+ "<map-store />"
+ "</map>"
+ HAZELCAST_END_TAG;

Config config = buildConfig(xml);
MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();

assertTrue(mapStoreConfig.isEnabled());
}

@Override
@Test
public void testMapStoreDisabled() {
String xml = HAZELCAST_START_TAG
+ "<map name=\"mymap\">"
+ "<map-store enabled=\"false\" />"
+ "</map>"
+ HAZELCAST_END_TAG;

Config config = buildConfig(xml);
MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();

assertFalse(mapStoreConfig.isEnabled());
}

@Override
@Test
public void testMapStoreConfig_writeCoalescing_whenDefault() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,56 @@ public void testMapStoreInitialModeEager() {
assertEquals(MapStoreConfig.InitialLoadMode.EAGER, mapStoreConfig.getInitialLoadMode());
}

@Override
@Test
public void testMapStoreEnabled() {
String yaml = ""
+ "hazelcast:\n"
+ " map:\n"
+ " mymap:\n"
+ " map-store:\n"
+ " enabled: true\n"
+ " initial-mode: EAGER\n";

Config config = buildConfig(yaml);
MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();

assertTrue(mapStoreConfig.isEnabled());
}

@Override
@Test
public void testMapStoreEnabledIfNotDisabled() {
String yaml = ""
+ "hazelcast:\n"
+ " map:\n"
+ " mymap:\n"
+ " map-store:\n"
+ " initial-mode: EAGER\n";

Config config = buildConfig(yaml);
MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();

assertTrue(mapStoreConfig.isEnabled());
}

@Override
@Test
public void testMapStoreDisabled() {
String yaml = ""
+ "hazelcast:\n"
+ " map:\n"
+ " mymap:\n"
+ " map-store:\n"
+ " enabled: false\n"
+ " initial-mode: EAGER\n";

Config config = buildConfig(yaml);
MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();

assertFalse(mapStoreConfig.isEnabled());
}

@Override
@Test
public void testMapStoreWriteBatchSize() {
Expand Down

0 comments on commit e4da790

Please sign in to comment.