[ 
https://issues.apache.org/jira/browse/TWILL-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15631691#comment-15631691
 ] 

ASF GitHub Bot commented on TWILL-138:
--------------------------------------

Github user yaojiefeng commented on a diff in the pull request:

    https://github.com/apache/twill/pull/14#discussion_r86288445
  
    --- Diff: 
twill-yarn/src/main/java/org/apache/twill/internal/appmaster/RunningContainers.java
 ---
    @@ -575,18 +601,74 @@ private boolean removeContainerInfo(String 
containerId) {
         return false;
       }
     
    +  private Map<String, Map<String, LogEntry.Level>> 
copyLogLevels(Map<String, Map<String, LogEntry.Level>> originalMap) {
    +    Map<String, Map<String, LogEntry.Level>> result = new TreeMap<>();
    +    for (Map.Entry<String, Map<String, LogEntry.Level>> entry : 
originalMap.entrySet()) {
    +      Map<String, LogEntry.Level> value = new TreeMap<>();
    +      for (Map.Entry<String, LogEntry.Level> valueEntry : 
entry.getValue().entrySet()) {
    +        value.put(valueEntry.getKey(), valueEntry.getValue());
    +      }
    +      result.put(entry.getKey(), value);
    +    }
    +    return result;
    +  }
    +
    +  private void checkAndSetLogLevels(Message message, String runnableName) {
    +    if (message.getType() != Message.Type.SYSTEM
    +      || 
!SystemMessages.LOG_LEVEL.equals(message.getCommand().getCommand())) {
    +      return;
    +    }
    +
    +    Map<String, LogEntry.Level> runnableLogLevels = 
convertLogLevelValuesToLogEntry(message.getCommand().getOptions());
    +    if (!logLevels.containsKey(runnableName)) {
    +      logLevels.put(runnableName, runnableLogLevels);
    +    } else {
    +      logLevels.get(runnableName).putAll(runnableLogLevels);
    +    }
    +  }
    +
    +  private Location saveLogLevels() {
    --- End diff --
    
    We save the log levels to file because we have no way to know if there is 
message about log level change come before the launch of some containers(this 
can happen when we change instance count or restart the container). So when a 
message about log level change come, we will have it stored in the Map in 
`RunningContainers`. And if there is a container launch afterwards, we will 
check if there is update in the log levels, and localize it for the container 
if necessary.


> 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)

Reply via email to