[NO ISSUE] Warn when memory settings are invalid
Right now you can set memory settings that make the node's available memory
less than zero. This is easier to do than it sounds due to the difference
between runtime max memory and maximum overall heap size.
Change-Id: I7baace491b9542b6b69a8f697d29e036ec494a16
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2241
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java
index e1a75cb..e22372a 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplication.java
@@ -118,8 +118,8 @@
MessagingProperties messagingProperties = runtimeContext.getMessagingProperties();
IMessageBroker messageBroker = new NCMessageBroker(controllerService, messagingProperties);
this.ncServiceCtx.setMessageBroker(messageBroker);
- MessagingChannelInterfaceFactory interfaceFactory = new MessagingChannelInterfaceFactory(
- (NCMessageBroker) messageBroker, messagingProperties);
+ MessagingChannelInterfaceFactory interfaceFactory =
+ new MessagingChannelInterfaceFactory((NCMessageBroker) messageBroker, messagingProperties);
this.ncServiceCtx.setMessagingChannelInterfaceFactory(interfaceFactory);
final Checkpoint latestCheckpoint = runtimeContext.getTransactionSubsystem().getCheckpointManager().getLatest();
if (latestCheckpoint != null) {
@@ -221,6 +221,12 @@
// and deducts one core for processing heartbeats.
long memorySize = Runtime.getRuntime().maxMemory() - storageProperties.getBufferCacheSize()
- storageProperties.getMemoryComponentGlobalBudget();
+ if (memorySize <= 0) {
+ throw new IllegalStateException("Invalid node memory configuration, more memory budgeted than available "
+ + "in JVM. Runtime max memory: " + Runtime.getRuntime().maxMemory() + " Buffer cache size: "
+ + storageProperties.getBufferCacheSize() + " Memory component global budget: "
+ + storageProperties.getMemoryComponentGlobalBudget());
+ }
int allCores = Runtime.getRuntime().availableProcessors();
int maximumCoresForComputation = allCores > 1 ? allCores - 1 : allCores;
return new NodeCapacity(memorySize, maximumCoresForComputation);