This is an automated email from the ASF dual-hosted git repository.

wonook pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nemo.git


The following commit(s) were added to refs/heads/master by this push:
     new 1124353  [NEMO-420] OffHeapMemory configuration only supports a single 
type of executor (#279)
1124353 is described below

commit 11243536c5f8409e482f4edee58ef451b84d8152
Author: polarcoke2 <[email protected]>
AuthorDate: Thu Jan 16 17:02:36 2020 +0900

    [NEMO-420] OffHeapMemory configuration only supports a single type of 
executor (#279)
    
    JIRA: [NEMO-420: OffHeapMemory configuration only supports a single type of 
executor
    ](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-420)
    
    **Major changes:**
    - enabled OffHeapMemory configuration for multiple types of executors
    - refactored initialization of MaxOffheapRatio and ExecutorPoisonSec (bind 
with default value when not existing)
    - erased MaxOffheapMb in job configuration and added ExecutorMemoryMb 
instead to compute size of max off-heap manually if needed
    
    **Minor changes to note:**
    - modified typos (poison from posion)
    - when changing test.java files which contain initialization of 
MemoryPoolAssigner, computed ExecutorMemoryMb using default MaxOffheapRatio
    - changed type of MaxOffheapRatio and ExecutorPoisonSec from double, int to 
Optional Double and Optioinal Integer, respectively
    
    **Tests for the changes:**
    - N/A
    
    **Other comments:**
    - N/A
    
    Closes #279
---
 .../java/org/apache/nemo/client/JobLauncher.java   | 29 +----------------
 .../java/org/apache/nemo/conf/DataPlaneConf.java   |  4 ---
 .../main/java/org/apache/nemo/conf/JobConf.java    | 36 ++++++++++++----------
 .../nemo/runtime/common/metric/TaskMetric.java     |  2 +-
 .../java/org/apache/nemo/driver/NemoContext.java   |  2 +-
 .../runtime/executor/data/MemoryPoolAssigner.java  |  5 ++-
 .../nemo/runtime/executor/data/BlockStoreTest.java | 13 +++++---
 .../nemo/runtime/executor/data/BlockTest.java      |  2 +-
 .../data/DirectByteBufferOutputStreamTest.java     |  2 +-
 .../executor/data/MemoryPoolAssignerTest.java      |  2 +-
 .../executor/datatransfer/DataTransferTest.java    |  3 +-
 .../apache/nemo/runtime/master/RuntimeMaster.java  | 25 +++++++++++----
 .../runtime/master/resource/ContainerManager.java  | 29 ++++++++++++++---
 .../master/resource/ResourceSpecification.java     | 18 ++++++++---
 14 files changed, 97 insertions(+), 75 deletions(-)

diff --git a/client/src/main/java/org/apache/nemo/client/JobLauncher.java 
b/client/src/main/java/org/apache/nemo/client/JobLauncher.java
index 76f4871..adafcd8 100644
--- a/client/src/main/java/org/apache/nemo/client/JobLauncher.java
+++ b/client/src/main/java/org/apache/nemo/client/JobLauncher.java
@@ -18,8 +18,6 @@
  */
 package org.apache.nemo.client;
 
-import com.fasterxml.jackson.core.TreeNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.protobuf.ByteString;
 import org.apache.commons.lang3.SerializationUtils;
@@ -149,8 +147,6 @@ public final class JobLauncher {
       + "{\"type\":\"Reserved\",\"memory_mb\":512,\"capacity\":5}]";
     final Configuration executorResourceConfig = getJSONConf(builtJobConf, 
JobConf.ExecutorJSONPath.class,
       JobConf.ExecutorJSONContents.class, defaultExecutorResourceConfig);
-    final Configuration offheapMemoryConfig = getMemoryConf(builtJobConf, 
executorResourceConfig,
-      JobConf.ExecutorJSONContents.class, JobConf.MaxOffheapRatio.class, 
JobConf.MaxOffheapMb.class);
     final Configuration bandwidthConfig = getJSONConf(builtJobConf, 
JobConf.BandwidthJSONPath.class,
       JobConf.BandwidthJSONContents.class, "");
     final Configuration clientConf = getClientConf();
@@ -158,8 +154,7 @@ public final class JobLauncher {
 
     // Merge Job and Driver Confs
     jobAndDriverConf = Configurations.merge(builtJobConf, driverConf, 
driverNcsConf, driverMessageConfig,
-      executorResourceConfig, bandwidthConfig, 
driverRPCServer.getListeningConfiguration(), schedulerConf,
-      offheapMemoryConfig);
+      executorResourceConfig, bandwidthConfig, 
driverRPCServer.getListeningConfiguration(), schedulerConf);
 
     // Get DeployMode Conf
     deployModeConf = Configurations.merge(getDeployModeConf(builtJobConf), 
clientConf);
@@ -483,28 +478,6 @@ public final class JobLauncher {
     }
   }
 
-  private static Configuration getMemoryConf(final Configuration jobConf,
-                                             final Configuration executorConf,
-                                             final Class<? extends 
Name<String>> contentsParameter,
-                                             final Class<? extends 
Name<Double>> offHeapRatio,
-                                             final Class<? extends 
Name<Integer>> maxOffHeapMb)
-    throws InjectionException {
-    final Injector injector = TANG.newInjector(Configurations.merge(jobConf, 
executorConf));
-    try {
-      final String contents = injector.getNamedInstance(contentsParameter);
-      final ObjectMapper objectMapper = new ObjectMapper();
-      final TreeNode jsonRootNode = objectMapper.readTree(contents);
-      final TreeNode resourceNode = jsonRootNode.get(0);
-      final int executorMemory = 
resourceNode.get("memory_mb").traverse().getIntValue();
-      final int offHeapMemory =  (int) (executorMemory * 
injector.getNamedInstance(offHeapRatio));
-      return TANG.newConfigurationBuilder()
-        .bindNamedParameter(maxOffHeapMb, String.valueOf(offHeapMemory))
-        .build();
-    } catch (final IOException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
   /**
    * Get the built job configuration.
    * It can be {@code null} if this method is not called by the process which 
called the main function of this class.
diff --git a/conf/src/main/java/org/apache/nemo/conf/DataPlaneConf.java 
b/conf/src/main/java/org/apache/nemo/conf/DataPlaneConf.java
index fe1d0df..fc80edc 100644
--- a/conf/src/main/java/org/apache/nemo/conf/DataPlaneConf.java
+++ b/conf/src/main/java/org/apache/nemo/conf/DataPlaneConf.java
@@ -37,7 +37,6 @@ public final class DataPlaneConf {
   private final int serverBackLog;
   private final int listenThreads;
   private final int workThreads;
-  private final int maxOffHeapMb;
   private final int chunkSizeKb;
 
   @Inject
@@ -49,7 +48,6 @@ public final class DataPlaneConf {
                         
@Parameter(JobConf.PartitionTransportServerBacklog.class) final int 
serverBackLog,
                         
@Parameter(JobConf.PartitionTransportServerNumListeningThreads.class) final int 
listenThreads,
                         
@Parameter(JobConf.PartitionTransportServerNumWorkingThreads.class) final int 
workThreads,
-                        @Parameter(JobConf.MaxOffheapMb.class) final int 
maxOffHeapMb,
                         @Parameter(JobConf.ChunkSizeKb.class) final int 
chunkSizeKb) {
     this.numIOThreads = numIOThreads;
     this.maxNumDownloads = maxNumDownloads;
@@ -59,7 +57,6 @@ public final class DataPlaneConf {
     this.serverBackLog = serverBackLog;
     this.listenThreads = listenThreads;
     this.workThreads = workThreads;
-    this.maxOffHeapMb = maxOffHeapMb;
     this.chunkSizeKb = chunkSizeKb;
   }
 
@@ -73,7 +70,6 @@ public final class DataPlaneConf {
       .bindNamedParameter(JobConf.PartitionTransportServerBacklog.class, 
Integer.toString(serverBackLog))
       
.bindNamedParameter(JobConf.PartitionTransportServerNumListeningThreads.class, 
Integer.toString(listenThreads))
       
.bindNamedParameter(JobConf.PartitionTransportServerNumWorkingThreads.class, 
Integer.toString(workThreads))
-      .bindNamedParameter(JobConf.MaxOffheapMb.class, 
Integer.toString(maxOffHeapMb))
       .bindNamedParameter(JobConf.ChunkSizeKb.class, 
Integer.toString(chunkSizeKb))
       .build();
   }
diff --git a/conf/src/main/java/org/apache/nemo/conf/JobConf.java 
b/conf/src/main/java/org/apache/nemo/conf/JobConf.java
index d12f191..b7ce273 100644
--- a/conf/src/main/java/org/apache/nemo/conf/JobConf.java
+++ b/conf/src/main/java/org/apache/nemo/conf/JobConf.java
@@ -194,11 +194,29 @@ public final class JobConf extends 
ConfigurationModuleBuilder {
   //////////////////////////////// Runtime Executor Configurations
 
   /**
+   * Maximum off-heap memory ratio to the total memory in the executor.
+   */
+  @NamedParameter(doc = "The maximum ratio of off-heap memory size to the 
total memory size.",
+    short_name = "max_offheap_ratio", default_value = "0.2")
+  public final class MaxOffheapRatio implements Name<Double> {
+  }
+
+  /**
+   * The size of total memory in the executor.
+   * (Max off-heap memory) = (executor memory) * (max off-heap ratio)
+   * We assume that the size of memory per executor is always given as input 
(therefore, no default value).
+   */
+  @NamedParameter(doc = "The size of total memory(sum of heap and off-heap 
memory) per executor",
+    short_name = "memory_mb")
+  public final class ExecutorMemoryMb implements Name<Integer> {
+  }
+
+  /**
    * Used for fault-injected tests.
    */
   @NamedParameter(doc = "Executor crashes after expected time, does not crash 
when -1",
     short_name = "executor_poison_sec", default_value = "-1")
-  public final class ExecutorPosionSec implements Name<Integer> {
+  public final class ExecutorPoisonSec implements Name<Integer> {
   }
 
   /**
@@ -300,22 +318,6 @@ public final class JobConf extends 
ConfigurationModuleBuilder {
   }
 
   /**
-   * Maximum off-heap memory ratio to the total memory in the executor.
-   */
-  @NamedParameter(doc = "The maximum ratio of off-heap memory size to the 
total memory size.",
-    short_name = "max_offheap_ratio", default_value = "0.2")
-  public final class MaxOffheapRatio implements Name<Double> {
-  }
-
-  /**
-   * Maximum off-heap memory size in the executor.
-   * This is set by the system according to the off-heap ratio.
-   */
-  @NamedParameter(doc = "The maximum off-heap memory that can be allocated")
-  public final class MaxOffheapMb implements Name<Integer> {
-  }
-
-  /**
    * MemoryChunk size in the memory pool.
    */
   @NamedParameter(doc = "The memory chunk size in the memory pool of the 
executor",
diff --git 
a/runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/TaskMetric.java
 
b/runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/TaskMetric.java
index 57833bb..d3cefcb 100644
--- 
a/runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/TaskMetric.java
+++ 
b/runtime/common/src/main/java/org/apache/nemo/runtime/common/metric/TaskMetric.java
@@ -123,7 +123,7 @@ public class TaskMetric implements 
StateMetric<TaskState.State> {
 
   @Override
   public final boolean processMetricMessage(final String metricField, final 
byte[] metricValue) {
-    LOG.debug("metric {} is just arrived!", metricField);
+    LOG.debug("metric {} has just arrived!", metricField);
     switch (metricField) {
       case "serializedReadBytes":
         setSerializedReadBytes(SerializationUtils.deserialize(metricValue));
diff --git 
a/runtime/driver/src/main/java/org/apache/nemo/driver/NemoContext.java 
b/runtime/driver/src/main/java/org/apache/nemo/driver/NemoContext.java
index 88c44ca..20c5c1e 100644
--- a/runtime/driver/src/main/java/org/apache/nemo/driver/NemoContext.java
+++ b/runtime/driver/src/main/java/org/apache/nemo/driver/NemoContext.java
@@ -48,7 +48,7 @@ public final class NemoContext {
 
   @Inject
   private NemoContext(final Executor executor,
-                      @Parameter(JobConf.ExecutorPosionSec.class) final int 
crashTimeSec,
+                      @Parameter(JobConf.ExecutorPoisonSec.class) final int 
crashTimeSec,
                       final Clock clock) {
     this.executor = executor; // To make Tang instantiate Executor
 
diff --git 
a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/MemoryPoolAssigner.java
 
b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/MemoryPoolAssigner.java
index 199072b..7224e51 100644
--- 
a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/MemoryPoolAssigner.java
+++ 
b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/MemoryPoolAssigner.java
@@ -47,8 +47,11 @@ public class MemoryPoolAssigner {
   private final MemoryPool memoryPool;
 
   @Inject
-  public MemoryPoolAssigner(@Parameter(JobConf.MaxOffheapMb.class) final int 
maxOffheapMb,
+  public MemoryPoolAssigner(@Parameter(JobConf.ExecutorMemoryMb.class) final 
int memory,
+                            @Parameter(JobConf.MaxOffheapRatio.class) final 
double maxOffheapRatio,
                             @Parameter(JobConf.ChunkSizeKb.class) final int 
chunkSizeKb) {
+
+    int maxOffheapMb = (int) (memory * maxOffheapRatio);
     if (chunkSizeKb < MIN_CHUNK_SIZE_KB) {
       throw new IllegalArgumentException("Chunk size too small. Minimum chunk 
size is 4KB");
     }
diff --git 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/BlockStoreTest.java
 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/BlockStoreTest.java
index b8a148a..83ec100 100644
--- 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/BlockStoreTest.java
+++ 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/BlockStoreTest.java
@@ -229,7 +229,8 @@ public final class BlockStoreTest {
   public void testMemoryStore() throws Exception {
     final Injector injector = Tang.Factory.getTang().newInjector();
     injector.bindVolatileInstance(SerializerManager.class, serializerManager);
-    injector.bindVolatileParameter(JobConf.MaxOffheapMb.class, 128);
+    injector.bindVolatileParameter(JobConf.ExecutorMemoryMb.class, 640);
+    injector.bindVolatileParameter(JobConf.MaxOffheapRatio.class, 0.2);
     final BlockStore memoryStore = injector.getInstance(MemoryStore.class);
     shuffle(memoryStore, memoryStore);
     concurrentRead(memoryStore, memoryStore);
@@ -245,7 +246,8 @@ public final class BlockStoreTest {
   public void testSerMemoryStore() throws Exception {
     final Injector injector = Tang.Factory.getTang().newInjector();
     injector.bindVolatileInstance(SerializerManager.class, serializerManager);
-    injector.bindVolatileParameter(JobConf.MaxOffheapMb.class, 128);
+    injector.bindVolatileParameter(JobConf.ExecutorMemoryMb.class, 640);
+    injector.bindVolatileParameter(JobConf.MaxOffheapRatio.class, 0.2);
     final BlockStore serMemoryStore = 
injector.getInstance(SerializedMemoryStore.class);
     shuffle(serMemoryStore, serMemoryStore);
     concurrentRead(serMemoryStore, serMemoryStore);
@@ -263,8 +265,8 @@ public final class BlockStoreTest {
     final Injector injector = Tang.Factory.getTang().newInjector();
     injector.bindVolatileParameter(JobConf.FileDirectory.class, 
TMP_FILE_DIRECTORY);
     injector.bindVolatileInstance(SerializerManager.class, serializerManager);
-    injector.bindVolatileParameter(JobConf.MaxOffheapMb.class, 128);
-
+    injector.bindVolatileParameter(JobConf.ExecutorMemoryMb.class, 640);
+    injector.bindVolatileParameter(JobConf.MaxOffheapRatio.class, 0.2);
     final BlockStore localFileStore = 
injector.getInstance(LocalFileStore.class);
     shuffle(localFileStore, localFileStore);
     concurrentRead(localFileStore, localFileStore);
@@ -300,7 +302,8 @@ public final class BlockStoreTest {
     injector.bindVolatileParameter(JobConf.JobId.class, "GFS test");
     injector.bindVolatileParameter(JobConf.ExecutorId.class, executorId);
     injector.bindVolatileInstance(SerializerManager.class, serializerManager);
-    injector.bindVolatileParameter(JobConf.MaxOffheapMb.class, 128);
+    injector.bindVolatileParameter(JobConf.ExecutorMemoryMb.class, 640);
+    injector.bindVolatileParameter(JobConf.MaxOffheapRatio.class, 0.2);
     return injector.getInstance(GlusterFileStore.class);
   }
 
diff --git 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/BlockTest.java
 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/BlockTest.java
index 67d1f5c..06ba015 100644
--- 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/BlockTest.java
+++ 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/BlockTest.java
@@ -53,7 +53,7 @@ public final class BlockTest {
   public void setUp() throws Exception {
     serializer = new Serializer<>(IntEncoderFactory.of(), 
IntDecoderFactory.of(), new ArrayList<>(), new ArrayList<>());
     testData = new HashMap<>();
-    memoryPoolAssigner = new MemoryPoolAssigner(1, 32);
+    memoryPoolAssigner = new MemoryPoolAssigner(5, 0.2, 32);
 
     final List<Integer> list1 = Collections.singletonList(1);
     final List<Integer> list2 = Arrays.asList(1, 2);
diff --git 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/DirectByteBufferOutputStreamTest.java
 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/DirectByteBufferOutputStreamTest.java
index 3bd5df3..cf7c4c3 100644
--- 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/DirectByteBufferOutputStreamTest.java
+++ 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/DirectByteBufferOutputStreamTest.java
@@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals;
  */
 public class DirectByteBufferOutputStreamTest {
   private DirectByteBufferOutputStream outputStream;
-  private static final MemoryPoolAssigner memoryPoolAssigner = new 
MemoryPoolAssigner(1, 32);
+  private static final MemoryPoolAssigner memoryPoolAssigner = new 
MemoryPoolAssigner(5, 0.2, 32);
 
   @Before
   public void setup() throws MemoryAllocationException {
diff --git 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/MemoryPoolAssignerTest.java
 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/MemoryPoolAssignerTest.java
index b351c44..c24ef74 100644
--- 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/MemoryPoolAssignerTest.java
+++ 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/data/MemoryPoolAssignerTest.java
@@ -42,7 +42,7 @@ public class MemoryPoolAssignerTest {
 
   @Before
   public void setUp() {
-    this.memoryPoolAssigner = new MemoryPoolAssigner(1, 32);
+    this.memoryPoolAssigner = new MemoryPoolAssigner(5, 0.2, 32);
   }
 
   @Test(expected = MemoryAllocationException.class)
diff --git 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/datatransfer/DataTransferTest.java
 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/datatransfer/DataTransferTest.java
index 65be287..f8f631b 100644
--- 
a/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/datatransfer/DataTransferTest.java
+++ 
b/runtime/executor/src/test/java/org/apache/nemo/runtime/executor/datatransfer/DataTransferTest.java
@@ -183,7 +183,8 @@ public final class DataTransferTest {
     final Configuration executorConfiguration = TANG.newConfigurationBuilder()
       .bindNamedParameter(JobConf.ExecutorId.class, executorId)
       .bindNamedParameter(MessageParameters.SenderId.class, executorId)
-      .bindNamedParameter(JobConf.MaxOffheapMb.class, "128")
+      .bindNamedParameter(JobConf.ExecutorMemoryMb.class, "640")
+      .bindNamedParameter(JobConf.MaxOffheapRatio.class, "0.2")
       .build();
     final Injector injector = 
nameClientInjector.forkInjector(executorConfiguration);
     injector.bindVolatileInstance(MessageEnvironment.class, 
messageEnvironment);
diff --git 
a/runtime/master/src/main/java/org/apache/nemo/runtime/master/RuntimeMaster.java
 
b/runtime/master/src/main/java/org/apache/nemo/runtime/master/RuntimeMaster.java
index ced25e4..45a9cf0 100644
--- 
a/runtime/master/src/main/java/org/apache/nemo/runtime/master/RuntimeMaster.java
+++ 
b/runtime/master/src/main/java/org/apache/nemo/runtime/master/RuntimeMaster.java
@@ -18,6 +18,7 @@
  */
 package org.apache.nemo.runtime.master;
 
+import com.fasterxml.jackson.core.JsonToken;
 import com.fasterxml.jackson.core.TreeNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.protobuf.ByteString;
@@ -59,10 +60,7 @@ import org.slf4j.LoggerFactory;
 import javax.inject.Inject;
 import java.io.Serializable;
 import java.nio.file.Paths;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -313,11 +311,26 @@ public final class RuntimeMaster {
           final TreeNode resourceNode = jsonRootNode.get(i);
           final String type = 
resourceNode.get("type").traverse().nextTextValue();
           final int memory = 
resourceNode.get("memory_mb").traverse().getIntValue();
+          final OptionalDouble maxOffheapRatio;
           final int capacity = 
resourceNode.get("capacity").traverse().getIntValue();
           final int executorNum = 
resourceNode.path("num").traverse().nextIntValue(1);
-          final int poisonSec = 
resourceNode.path("poison_sec").traverse().nextIntValue(-1);
+          final OptionalInt poisonSec;
+
+          if (resourceNode.path("max_offheap_ratio").traverse().nextToken() == 
JsonToken.VALUE_NUMBER_FLOAT) {
+            maxOffheapRatio = 
OptionalDouble.of(resourceNode.path("max_offheap_ratio").traverse().getDoubleValue());
+          } else {
+            maxOffheapRatio = OptionalDouble.empty();
+          }
+
+          if (resourceNode.path("poison_sec").traverse().nextToken() == 
JsonToken.VALUE_NUMBER_INT) {
+            poisonSec = 
OptionalInt.of(resourceNode.path("poison_sec").traverse().getIntValue());
+          } else {
+            poisonSec = OptionalInt.empty();
+          }
+
           resourceRequestCount.getAndAdd(executorNum);
-          containerManager.requestContainer(executorNum, new 
ResourceSpecification(type, capacity, memory, poisonSec));
+          containerManager.requestContainer(executorNum, new 
ResourceSpecification(type, capacity, memory,
+            maxOffheapRatio, poisonSec));
         }
         metricCountDownLatch = new CountDownLatch(resourceRequestCount.get());
       } catch (final Exception e) {
diff --git 
a/runtime/master/src/main/java/org/apache/nemo/runtime/master/resource/ContainerManager.java
 
b/runtime/master/src/main/java/org/apache/nemo/runtime/master/resource/ContainerManager.java
index 8ec14a6..40a2210 100644
--- 
a/runtime/master/src/main/java/org/apache/nemo/runtime/master/resource/ContainerManager.java
+++ 
b/runtime/master/src/main/java/org/apache/nemo/runtime/master/resource/ContainerManager.java
@@ -149,18 +149,39 @@ public final class ContainerManager {
     }
 
     final ResourceSpecification resourceSpecification = 
selectResourceSpecForContainer();
+    final List<Configuration> configurationsToMerge = new ArrayList<>();
+
     evaluatorIdToResourceSpec.put(allocatedContainer.getId(), 
resourceSpecification);
 
     LOG.info("Container type (" + resourceSpecification.getContainerType()
       + ") allocated, will be used for [" + executorId + "]");
     pendingContextIdToResourceSpec.put(executorId, resourceSpecification);
 
+    configurationsToMerge.add(executorConfiguration);
+
+    // ExecutorMemory handling
+    configurationsToMerge.add(Tang.Factory.getTang().newConfigurationBuilder()
+        .bindNamedParameter(JobConf.ExecutorMemoryMb.class, 
String.valueOf(resourceSpecification.getMemory()))
+        .build()
+    );
+
+    // MaxOffheapRatio handling
+    resourceSpecification.getMaxOffheapRatio().ifPresent(value ->
+      
configurationsToMerge.add(Tang.Factory.getTang().newConfigurationBuilder()
+        .bindNamedParameter(JobConf.MaxOffheapRatio.class, 
String.valueOf(value))
+        .build()
+      )
+    );
+
     // Poison handling
-    final Configuration poisonConfiguration = 
Tang.Factory.getTang().newConfigurationBuilder()
-      .bindNamedParameter(JobConf.ExecutorPosionSec.class, 
String.valueOf(resourceSpecification.getPoisonSec()))
-      .build();
+    resourceSpecification.getPoisonSec().ifPresent(value ->
+      
configurationsToMerge.add(Tang.Factory.getTang().newConfigurationBuilder()
+        .bindNamedParameter(JobConf.ExecutorPoisonSec.class, 
String.valueOf(value))
+        .build()
+      )
+    );
 
-    
allocatedContainer.submitContext(Configurations.merge(executorConfiguration, 
poisonConfiguration));
+    
allocatedContainer.submitContext(Configurations.merge(configurationsToMerge));
   }
 
   /**
diff --git 
a/runtime/master/src/main/java/org/apache/nemo/runtime/master/resource/ResourceSpecification.java
 
b/runtime/master/src/main/java/org/apache/nemo/runtime/master/resource/ResourceSpecification.java
index 6241165..f3f0e7e 100644
--- 
a/runtime/master/src/main/java/org/apache/nemo/runtime/master/resource/ResourceSpecification.java
+++ 
b/runtime/master/src/main/java/org/apache/nemo/runtime/master/resource/ResourceSpecification.java
@@ -20,6 +20,9 @@ package org.apache.nemo.runtime.master.resource;
 
 import org.apache.nemo.runtime.common.RuntimeIdManager;
 
+import java.util.OptionalDouble;
+import java.util.OptionalInt;
+
 /**
  * Represents the specifications of a resource.
  */
@@ -29,22 +32,25 @@ public final class ResourceSpecification {
   private final String containerType;
   private final int capacity;
   private final int memory;
-  private final int poisonSec; // -1 if this resources is not poisoned
+  private final OptionalDouble maxOffheapRatio;
+  private final OptionalInt poisonSec; // -1 if this resources is not poisoned
 
   public ResourceSpecification(final String containerType,
                                final int capacity,
                                final int memory) {
-    this(containerType, capacity, memory, -1);
+    this(containerType, capacity, memory, OptionalDouble.empty(), 
OptionalInt.empty());
   }
 
   public ResourceSpecification(final String containerType,
                                final int capacity,
                                final int memory,
-                               final int poisonSec) {
+                               final OptionalDouble maxOffheapRatio,
+                               final OptionalInt poisonSec) {
     this.resourceSpecId = RuntimeIdManager.generateResourceSpecId();
     this.containerType = containerType;
     this.capacity = capacity;
     this.memory = memory;
+    this.maxOffheapRatio = maxOffheapRatio;
     this.poisonSec = poisonSec;
   }
 
@@ -69,6 +75,10 @@ public final class ResourceSpecification {
     return memory;
   }
 
+  public OptionalDouble getMaxOffheapRatio() {
+    return maxOffheapRatio;
+  }
+
   public String getResourceSpecId() {
     return resourceSpecId;
   }
@@ -77,7 +87,7 @@ public final class ResourceSpecification {
    * @return -1   if this resource is not poisoned. (for all other normal 
cases)
    * &gt;= 0 the expected time to failure by poison. (for fault-handling tests)
    */
-  public int getPoisonSec() {
+  public OptionalInt getPoisonSec() {
     return poisonSec;
   }
 }

Reply via email to