@Override public JsonElement serialize(ResourceReport src, Type typeOfSrc, JsonSerializationContext context) { JsonObject json = new JsonObject(); json.addProperty("appMasterId", src.getApplicationId()); json.add("appMasterResources", context.serialize(src.getAppMasterResources(), TwillRunResources.class)); json.add("runnableResources", context.serialize( src.getResources(), new TypeToken<Map<String, Collection<TwillRunResources>>>() { }.getType())); json.add("services", context.serialize( src.getServices(), new TypeToken<List<String>>() { }.getType())); return json; }
@Override public JsonElement serialize(ResourceReport src, Type typeOfSrc, JsonSerializationContext context) { JsonObject json = new JsonObject(); json.addProperty("appMasterId", src.getApplicationId()); json.add("appMasterResources", context.serialize(src.getAppMasterResources(), TwillRunResources.class)); json.add("runnableResources", context.serialize( src.getResources(), new TypeToken<Map<String, Collection<TwillRunResources>>>() { }.getType())); json.add("services", context.serialize( src.getServices(), new TypeToken<List<String>>() { }.getType())); return json; }
@Override public void reportResources() { for (TwillRunner.LiveInfo info : twillRunner.lookupLive()) { Map<String, String> metricContext = getMetricContext(info); if (metricContext == null) { continue; } // will have multiple controllers if there are multiple runs of the same application for (TwillController controller : info.getControllers()) { ResourceReport report = controller.getResourceReport(); if (report == null) { continue; } int memory = report.getAppMasterResources().getMemoryMB(); int vcores = report.getAppMasterResources().getVirtualCores(); Map<String, String> runContext = ImmutableMap.<String, String>builder() .putAll(metricContext) .put(Constants.Metrics.Tag.RUN_ID, controller.getRunId().getId()).build(); sendMetrics(runContext, 1, memory, vcores); } } reportYarnResources(); }
@Override public void reportResources() { for (TwillRunner.LiveInfo info : twillRunner.lookupLive()) { Map<String, String> metricContext = getMetricContext(info); if (metricContext == null) { continue; } // will have multiple controllers if there are multiple runs of the same application for (TwillController controller : info.getControllers()) { ResourceReport report = controller.getResourceReport(); if (report == null) { continue; } int memory = report.getAppMasterResources().getMemoryMB(); int vcores = report.getAppMasterResources().getVirtualCores(); Map<String, String> runContext = ImmutableMap.<String, String>builder() .putAll(metricContext) .put(Constants.Metrics.Tag.RUN_ID, controller.getRunId().getId()).build(); sendMetrics(runContext, 1, memory, vcores); } } reportYarnResources(); }
Assert.assertEquals(256, resourceReport.getAppMasterResources().getMemoryMB()); Assert.assertEquals(Resources.computeMaxHeapSize(256, Configs.Defaults.YARN_AM_RESERVED_MEMORY_MB, 0.65d), resourceReport.getAppMasterResources().getMaxHeapMemoryMB());