Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
*/
public class Environment {
public String getJavaHeap() {
return System.getenv().get(ExecutorEnvironmentalVariables.JAVA_OPTS);
String javaOpts = System.getenv().get(ExecutorEnvironmentalVariables.JAVA_OPTS);
if (javaOpts == null || javaOpts.isEmpty()) {
javaOpts = System.getenv().get(ExecutorEnvironmentalVariables.ES_JAVA_OPTS);
}
return javaOpts;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ExecutorEnvironmentalVariables {
private static final String CONTAINER_PATH_SETTINGS = "/tmp/config";

public static final String JAVA_OPTS = "JAVA_OPTS";
public static final String ES_JAVA_OPTS = "ES_JAVA_OPTS";
public static final String ES_HEAP = "ES_HEAP_SIZE";
public static final int EXTERNAL_VOLUME_NOT_CONFIGURED = -1;
public static final String ELASTICSEARCH_NODE_ID = "ELASTICSEARCH_NODE_ID";
Expand Down Expand Up @@ -67,6 +68,7 @@ private void populateEnvMap(Configuration configuration) {
if (configuration.isFrameworkUseDocker()) {
addToList(native_mesos_library_key, native_mesos_library_path);
}
addToList(ES_JAVA_OPTS, getHeapSpaceString(configuration, 192));
}

private void populateEnvMapForMesos(Configuration configuration, Long nodeId) {
Expand Down Expand Up @@ -111,4 +113,15 @@ private String getHeapSpaceString(Configuration configuration) {
int osRam = (int) Math.min(256.0, configuration.getMem() / 4.0);
return "" + ((int) configuration.getMem() - osRam) + "m";
}
}

/**
* Gets the heap space settings. Will set minimum heap space as 256, minimum or available/4, whichever is smaller. Max heap will be available space.
* @param configuration The mesos cluster configuration
* @param min The minimum heap space; used if smaller than 256 and smaller than available/4
* @return A string representing the java heap space.
*/
private String getHeapSpaceString(Configuration configuration, int min) {
int osRam = (int) Math.min(256.0, min, configuration.getMem() / 4.0);
return "-Xms" + osRam + "m -Xmx"+ configuration.getMem() + "m";
}
}