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

Chris Riccomini commented on SAMZA-192:
---------------------------------------

The problem with both options is that they're YARN-specific, and the logic for 
logging container pid information should ideally live in the SamzaContainer so 
that we can see PID information whether we use YARN, Mesos, EC2, or just a 
regular old Java process.

The proposed solution on the StackOverflow link is to just use:

{code}
ManagementFactory.getRuntimeMXBean().getName()
{code}

It sounds like this code isn't guaranteed to log the PID--it's just guaranteed 
to log a unique identifier for the JVM, but in the case of linux, it logs the 
<pid>@<hostname>, which should do fine. I tend to favor this approach because 
it's not too invasive--it's just standard Java. Some of the other proposals in 
the StackOverflow discussion require third party libraries, which I'm hesitant 
to add for one small nice-to-have feature.

If we remove YARN from the equation, are you (or anyone else) aware of any 
other good ways to get PID information from a Java process?

Another approach, which is YARN-specific, but doesn't require modifying the 
SamzaContainer would be to log the PID information in the AM. I haven't dug 
into the AM RPC calls at all, but perhaps it gets PID information from the NM 
when a new container is allocated? If so, we should to be able to at least log 
the PID information in the AM's logs. This approach doesn't prevent us from 
also using the MXBean approach (or any other approach) in the SamzaContainer, 
either.

> Log container PID
> -----------------
>
>                 Key: SAMZA-192
>                 URL: https://issues.apache.org/jira/browse/SAMZA-192
>             Project: Samza
>          Issue Type: Improvement
>          Components: container
>            Reporter: Jakob Homan
>            Priority: Minor
>              Labels: newbie
>
> It would be nice if we logged the container PID at startup for easy reference 
> later on.  However, looks like Java may make this a bit difficult: 
> http://stackoverflow.com/questions/35842/how-can-a-java-program-get-its-own-process-id



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to