[ https://issues.apache.org/jira/browse/TWILL-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15664787#comment-15664787 ]
ASF GitHub Bot commented on TWILL-138: -------------------------------------- Github user chtyim commented on a diff in the pull request: https://github.com/apache/twill/pull/14#discussion_r87874799 --- Diff: twill-yarn/src/main/java/org/apache/twill/internal/appmaster/RunningContainers.java --- @@ -575,18 +597,63 @@ private boolean removeContainerInfo(String containerId) { return false; } + private void checkAndSetLogLevels(Message message, String runnableName) { + String command = message.getCommand().getCommand(); + if (message.getType() != Message.Type.SYSTEM || !SystemMessages.LOG_LEVEL.equals(command)) { + return; + } + + Map<String, LogEntry.Level> runnableLogLevels = copyAndConvertLogLevelsMap(message.getCommand().getOptions()); + if (!logLevels.containsKey(runnableName)) { + logLevels.put(runnableName, runnableLogLevels); + } else { + logLevels.get(runnableName).putAll(runnableLogLevels); + } + } + + private Location saveLogLevels() { + LOG.debug("save the log level file"); + try { + Gson gson = new GsonBuilder().serializeNulls().create(); + String jsonStr = gson.toJson(logLevels); + String fileName = Hashing.md5().hashString(jsonStr) + "." + Constants.Files.LOG_LEVELS; + Location location = applicationLocation.append(fileName); + if (!location.exists()) { + try (Writer writer = new OutputStreamWriter(location.getOutputStream(), Charsets.UTF_8)) { + gson.toJson(logLevels, new TypeToken<Map<String, Map<String, LogEntry.Level>>>() { }.getType(), writer); --- End diff -- Why need to encode again? You can just write the `jsonStr` to the file. > Runtime change of Application runnable log level > ------------------------------------------------ > > Key: TWILL-138 > URL: https://issues.apache.org/jira/browse/TWILL-138 > Project: Apache Twill > Issue Type: New Feature > Components: core > Reporter: Henry Saputra > > With TWILL-24 is supported for setting log level when starting the Twill > application, next enhancement is to able to send command to update the > aggregate log level for a particular runnable in a Twill application. -- This message was sent by Atlassian JIRA (v6.3.4#6332)