@Override public TwillRunResources deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Map<String, LogEntry.Level> logLevels = context.deserialize(jsonObj.get(LOG_LEVELS), new TypeToken<Map<String, LogEntry.Level>>() { }.getType()); int memoryMB = jsonObj.get(MEMORY_MB).getAsInt(); return new DefaultTwillRunResources( jsonObj.get(INSTANCE_ID).getAsInt(), jsonObj.get(CONTAINER_ID).getAsString(), jsonObj.get(VIRTUAL_CORES).getAsInt(), memoryMB, // For backward compatibility when a newer Twill client re-attached to running app started with older version. jsonObj.has(MAX_HEAP_MEMORY_MB) ? jsonObj.get(MAX_HEAP_MEMORY_MB).getAsInt() : memoryMB, jsonObj.get(HOST).getAsString(), jsonObj.has(DEBUG_PORT) ? jsonObj.get(DEBUG_PORT).getAsInt() : null, logLevels); } }
@Override @Deprecated @Nullable public Level getLogLevel() { return getLogLevels().get(Logger.ROOT_LOGGER_NAME); }
@Override public TwillRunResources deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Map<String, LogEntry.Level> logLevels = context.deserialize(jsonObj.get(LOG_LEVELS), new TypeToken<Map<String, LogEntry.Level>>() { }.getType()); int memoryMB = jsonObj.get(MEMORY_MB).getAsInt(); return new DefaultTwillRunResources( jsonObj.get(INSTANCE_ID).getAsInt(), jsonObj.get(CONTAINER_ID).getAsString(), jsonObj.get(VIRTUAL_CORES).getAsInt(), memoryMB, // For backward compatibility when a newer Twill client re-attached to running app started with older version. jsonObj.has(MAX_HEAP_MEMORY_MB) ? jsonObj.get(MAX_HEAP_MEMORY_MB).getAsInt() : memoryMB, jsonObj.get(HOST).getAsString(), jsonObj.has(DEBUG_PORT) ? jsonObj.get(DEBUG_PORT).getAsInt() : null, logLevels); } }
@Override @Deprecated @Nullable public Level getLogLevel() { return getLogLevels().get(Logger.ROOT_LOGGER_NAME); }
private DefaultTwillRunResources createResource(int seed) { DefaultTwillRunResources resource = new DefaultTwillRunResources(seed, "container_e04_1487533082952_0033_01_00000"+seed, 2, 8192, "container-host", 0, ImmutableMap.of(Logger.ROOT_LOGGER_NAME,LogEntry.Level.INFO)); return resource; }
private RunningContainers createRunningContainers(ContainerId appMasterContainerId, String appMasterHost) throws Exception { int containerMemoryMB = Integer.parseInt(System.getenv(EnvKeys.YARN_CONTAINER_MEMORY_MB)); // We can't get the -Xmx easily, so just recompute the -Xmx in the same way that the client does int maxHeapMemoryMB = Resources.computeMaxHeapSize(containerMemoryMB, twillRuntimeSpec.getAMReservedMemory(), twillRuntimeSpec.getAMMinHeapRatio()); TwillRunResources appMasterResources = new DefaultTwillRunResources( 0, appMasterContainerId.toString(), Integer.parseInt(System.getenv(EnvKeys.YARN_CONTAINER_VIRTUAL_CORES)), containerMemoryMB, maxHeapMemoryMB, appMasterHost, null); String appId = appMasterContainerId.getApplicationAttemptId().getApplicationId().toString(); return new RunningContainers(twillRuntimeSpec, appId, appMasterResources, zkClient, applicationLocation, twillSpec.getRunnables(), eventHandler); }
private RunningContainers createRunningContainers(ContainerId appMasterContainerId, String appMasterHost) throws Exception { int containerMemoryMB = Integer.parseInt(System.getenv(EnvKeys.YARN_CONTAINER_MEMORY_MB)); // We can't get the -Xmx easily, so just recompute the -Xmx in the same way that the client does int maxHeapMemoryMB = Resources.computeMaxHeapSize(containerMemoryMB, twillRuntimeSpec.getAMReservedMemory(), twillRuntimeSpec.getAMMinHeapRatio()); TwillRunResources appMasterResources = new DefaultTwillRunResources( 0, appMasterContainerId.toString(), Integer.parseInt(System.getenv(EnvKeys.YARN_CONTAINER_VIRTUAL_CORES)), containerMemoryMB, maxHeapMemoryMB, appMasterHost, null); String appId = appMasterContainerId.getApplicationAttemptId().getApplicationId().toString(); return new RunningContainers(twillRuntimeSpec, appId, appMasterResources, zkClient, applicationLocation, twillSpec.getRunnables(), eventHandler); }