APEX-101 #resolve store memory allocated in megabytes instead of bytes
Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/b82f9052 Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/b82f9052 Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/b82f9052 Branch: refs/heads/feature-module Commit: b82f90523f01019443220db7ceefa9f44c055e8e Parents: b57972b Author: David Yan <[email protected]> Authored: Wed Sep 9 18:18:29 2015 -0700 Committer: David Yan <[email protected]> Committed: Thu Sep 10 14:22:27 2015 -0700 ---------------------------------------------------------------------- .../com/datatorrent/stram/StreamingContainerManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/b82f9052/engine/src/main/java/com/datatorrent/stram/StreamingContainerManager.java ---------------------------------------------------------------------- diff --git a/engine/src/main/java/com/datatorrent/stram/StreamingContainerManager.java b/engine/src/main/java/com/datatorrent/stram/StreamingContainerManager.java index 7944a4b..41738f4 100644 --- a/engine/src/main/java/com/datatorrent/stram/StreamingContainerManager.java +++ b/engine/src/main/java/com/datatorrent/stram/StreamingContainerManager.java @@ -174,7 +174,7 @@ public class StreamingContainerManager implements PlanContext private long completeEndWindowStatsWindowId; private final ConcurrentHashMap<String, MovingAverageLong> rpcLatencies = new ConcurrentHashMap<String, MovingAverageLong>(); private final AtomicLong nodeToStramRequestIds = new AtomicLong(1); - private long allocatedMemoryBytes = 0; + private int allocatedMemoryMB = 0; private List<AppDataSource> appDataSources = null; private final Cache<Long, Object> commandResponse = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(); private long lastLatencyWarningTime; @@ -395,7 +395,7 @@ public class StreamingContainerManager implements PlanContext } if (nmHttpPort != null) { String nodeHttpAddress = nmHost + ":" + nmHttpPort; - if (allocatedMemoryBytes == 0) { + if (allocatedMemoryMB == 0) { String url = ConfigUtils.getSchemePrefix(conf) + nodeHttpAddress + "/ws/v1/node/containers/" + ci.id; WebServicesClient webServicesClient = new WebServicesClient(); try { @@ -403,7 +403,7 @@ public class StreamingContainerManager implements PlanContext JSONObject json = new JSONObject(content); int totalMemoryNeededMB = json.getJSONObject("container").getInt("totalMemoryNeededMB"); if (totalMemoryNeededMB > 0) { - allocatedMemoryBytes = totalMemoryNeededMB * 1024 * 1024; + allocatedMemoryMB = totalMemoryNeededMB; } else { LOG.warn("Could not determine the memory allocated for the streaming application master. Node manager is reporting {} MB from {}", totalMemoryNeededMB, url); } @@ -416,7 +416,7 @@ public class StreamingContainerManager implements PlanContext ci.rawContainerLogsUrl = ConfigUtils.getRawContainerLogsUrl(conf, nodeHttpAddress, plan.getLogicalPlan().getAttributes().get(LogicalPlan.APPLICATION_ID), ci.id); } } - ci.memoryMBAllocated = (int)(allocatedMemoryBytes / (1024 * 1024)); + ci.memoryMBAllocated = allocatedMemoryMB; ci.memoryMBFree = ((int)(Runtime.getRuntime().freeMemory() / (1024 * 1024))); ci.lastHeartbeat = -1; ci.startedTime = startTime;
