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

Enable map store config unless its disabled explicitly #18217

Merged
merged 1 commit into from Feb 16, 2021
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 @@ -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
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
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
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