Skip to content

Commit

Permalink
Allocating executor resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Westergaard Lassen authored and mwl committed Nov 9, 2015
1 parent be76616 commit f1bc8f2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class Configuration {
public static final String ELASTICSEARCH_CPU = "--elasticsearchCpu";
public static final String ELASTICSEARCH_RAM = "--elasticsearchRam";
public static final String ELASTICSEARCH_DISK = "--elasticsearchDisk";
public static final String ELASTICSEARCH_EXECUTOR_CPU = "--elasticsearchExecutorCpu";
public static final String ELASTICSEARCH_EXECUTOR_RAM = "--elasticsearchExecutorRam";
// **** WEB UI
public static final String WEB_UI_PORT = "--webUiPort";
public static final String FRAMEWORK_NAME = "--frameworkName";
Expand Down Expand Up @@ -55,6 +57,10 @@ public class Configuration {
private double mem = 256;
@Parameter(names = {ELASTICSEARCH_DISK}, description = "The amount of Disk resource to allocate to the elasticsearch instance (MB).", validateValueWith = CLIValidators.PositiveDouble.class)
private double disk = 1024;
@Parameter(names = {ELASTICSEARCH_EXECUTOR_CPU}, description = "The amount of CPU resource to allocate to the elasticsearch executor.", validateValueWith = CLIValidators.PositiveDouble.class)
private double executorCpus = 0.1;
@Parameter(names = {ELASTICSEARCH_EXECUTOR_RAM}, description = "The amount of ram resource to allocate to the elasticsearch executor (MB).", validateValueWith = CLIValidators.PositiveDouble.class)
private double executorMem = 32;
@Parameter(names = {WEB_UI_PORT}, description = "TCP port for web ui interface.", validateValueWith = CLIValidators.PositiveInteger.class)
private int webUiPort = 31100; // Default is more likely to work on a default Mesos installation
// **** FRAMEWORK
Expand Down Expand Up @@ -115,6 +121,14 @@ public double getDisk() {
return disk;
}

public double getExecutorCpus() {
return executorCpus;
}

public double getExecutorMem() {
return executorMem;
}

public int getElasticsearchNodes() {
return elasticsearchCLI.getElasticsearchNodes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public static List<Integer> selectTwoPortsFromRange(List<Protos.Resource> offere
}

public static ArrayList<Protos.Resource> buildFrameworkResources(Configuration configuration) {
Protos.Resource cpus = Resources.cpus(configuration.getCpus(), configuration.getFrameworkRole());
Protos.Resource mem = Resources.mem(configuration.getMem(), configuration.getFrameworkRole());
Protos.Resource cpus = Resources.cpus(configuration.getCpus() - configuration.getExecutorCpus(), configuration.getFrameworkRole());
Protos.Resource mem = Resources.mem(configuration.getMem() - configuration.getExecutorMem(), configuration.getFrameworkRole());
Protos.Resource disk = Resources.disk(configuration.getDisk(), configuration.getFrameworkRole());
return new ArrayList<>(Arrays.asList(cpus, mem, disk));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ private Protos.ExecutorInfo.Builder newExecutorInfo(Configuration configuration,
.setDocker(containerBuilder)
.addVolumes(Protos.Volume.newBuilder().setHostPath(SETTINGS_PATH_VOLUME).setContainerPath(SETTINGS_PATH_VOLUME).setMode(Protos.Volume.Mode.RO)) // Temporary fix until we get a data container.
.addVolumes(Protos.Volume.newBuilder().setContainerPath(SETTINGS_DATA_VOLUME_CONTAINER).setHostPath(configuration.getDataDir()).setMode(Protos.Volume.Mode.RW).build())
.build());
.build())
.addResources(Resources.cpus(configuration.getExecutorCpus(), configuration.getFrameworkRole()))
.addResources(Resources.mem(configuration.getExecutorMem(), configuration.getFrameworkRole()))
;
}
return executorInfoBuilder;
}
Expand Down

0 comments on commit f1bc8f2

Please sign in to comment.