Github user srdo commented on a diff in the pull request:
https://github.com/apache/storm/pull/2113#discussion_r120446703
--- Diff:
storm-server/src/main/java/org/apache/storm/container/cgroup/CgroupManager.java
---
@@ -151,22 +161,40 @@ public void reserveResourcesForWorker(String
workerId, Map<String, Number> resou
}
}
- if (totalMem != null) {
- MemoryCore memCore = (MemoryCore)
workerGroup.getCores().get(SubSystemType.memory);
- try {
-
memCore.setPhysicalUsageLimit(Long.valueOf(totalMem.longValue() * 1024 * 1024));
- } catch (IOException e) {
- throw new RuntimeException("Cannot set
memory.limit_in_bytes! Exception: ", e);
+ if ((boolean)
this.conf.get(DaemonConfig.STORM_CGROUP_MEMORY_ENFORCEMENT_ENABLE)) {
+ if (totalMem != null) {
+ int cgroupMem =
+ (int)
+ (Math.ceil(
+ ObjectReader.getDouble(
+
this.conf.get(DaemonConfig.STORM_CGROUP_MEMORY_LIMIT_TOLERANCE_MARGIN_MB),
+ 0.0)));
+ long memLimit = Long.valueOf((totalMem.longValue() +
cgroupMem) * 1024 * 1024);
+ MemoryCore memCore = (MemoryCore)
workerGroup.getCores().get(SubSystemType.memory);
+ try {
+ memCore.setPhysicalUsageLimit(memLimit);
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot set
memory.limit_in_bytes! Exception: ", e);
+ }
+ // need to set memory.memsw.limit_in_bytes after setting
memory.limit_in_bytes or error
+ // might occur
+ try {
+ memCore.setWithSwapUsageLimit(memLimit);
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot set
memory.memsw.limit_in_bytes! Exception: ", e);
+ }
}
}
}
+ @Override
public void releaseResourcesForWorker(String workerId) {
CgroupCommon workerGroup = new CgroupCommon(workerId, hierarchy,
this.rootCgroup);
try {
Set<Integer> tasks = workerGroup.getTasks();
if (!tasks.isEmpty()) {
- throw new Exception("Cannot correctly showdown worker
CGroup " + workerId + "tasks " + tasks.toString() + " still running!");
+ throw new Exception("Cannot correctly showdown worker
CGroup " + workerId + "tasks " + tasks
--- End diff --
nit: showdown -> shutdown
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---