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

Daniel Templeton commented on YARN-5725:
----------------------------------------

Thanks for humoring me on refactoring the _if_.  In it's current form it's 
plain to see there are some issues.  What about something more like:

{code}
          Container container = context.getContainers().get(containerId);

          if (container != null) {
            String[] ipAndHost = containerExecutor.getIpAndHost(container);

            if ((ipAndHost != null) && (ipAndHost[0] != null) &&
                (ipAndHost[1] != null)) {
              container.setIpAndHost(ipAndHost);
              LOG.info(containerId + "'s ip = " + ipAndHost[0]
                  + ", and hostname = " + ipAndHost[1]);
            } else {
              LOG.info("Can not get both ip and hostname: "
                  + Arrays.toString(ipAndHost));
            }
          } else {
            LOG.info(containerId + " is missing. Not setting ip and "
                + "hostname");
          }
{code}

Notice that I changed your added log message to INFO level because it's not 
something the admin can or should do anything about.  I also moved the {{+}} 
for string catting to the beginning of the line, and I fixed the line 
continuation indentation.  (Sorry.  It's easier to give you fixed code than to 
explain how to fix it.)

Your log message in {{reportResourceUsage()}} should also be INFO.

In the test code, let's not do a compound conditional in a _for_ loop.  Either 
add an _if-break_ for the second condition or switch to a _while_.

> Test uncaught exception in 
> TestContainersMonitorResourceChange.testContainersResourceChange when setting 
> IP and host
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: YARN-5725
>                 URL: https://issues.apache.org/jira/browse/YARN-5725
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: nodemanager
>            Reporter: Miklos Szegedi
>            Assignee: Miklos Szegedi
>            Priority: Minor
>              Labels: oct16-easy
>         Attachments: YARN-5725.000.patch, YARN-5725.001.patch, 
> YARN-5725.002.patch, YARN-5725.003.patch, YARN-5725.004.patch, 
> YARN-5725.005.patch, YARN-5725.006.patch, YARN-5725.007.patch, 
> YARN-5725.008.patch, YARN-5725.009.patch
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> The issue is a warning but it prevents container monitor to continue
> 2016-10-12 14:38:23,280 WARN  [Container Monitor] 
> monitor.ContainersMonitorImpl (ContainersMonitorImpl.java:run(594)) - 
> Uncaught exception in ContainersMonitorImpl while monitoring resource of 
> container_123456_0001_01_000001
> java.lang.NullPointerException
>       at 
> org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl$MonitoringThread.run(ContainersMonitorImpl.java:455)
> 2016-10-12 14:38:23,281 WARN  [Container Monitor] 
> monitor.ContainersMonitorImpl (ContainersMonitorImpl.java:run(613)) - 
> org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl
>  is interrupted. Exiting.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org

Reply via email to