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

Steve Loughran commented on HADOOP-10085:
-----------------------------------------

I'll rebuild it.

I looked at adding stricter checks but it broke things -some services were 
adding services in an incomplete state. Which is fine, because it will show up 
later

bq. It would have been nicer to have a check for the child being in at least 
the parent's state.
As start() on a STARTED service is a no-op, it's legal to add a started service 
to a service still in the inited state. Add an inited child while started 
-you'll need to start it yourself. It won't break anything though, as it's only 
transition is stop(), which must be valid from INITED anyway.

bq. Would it make sense to have the parent service enter INIT only after all 
its child services have been INITed? That way, if the parent is already in 
INIT, we can disallow adding a service in UNINITED state.

root service model MUST check for the valid transition before calling its 
execution operations -the whole YARN-117 work was to fix the situation where a 
lot of services were doing their init logic before super.init(), so could be 
called repeatedly before checking state, and weren't doing thread-safe 
operations either. 

the only way could address this is to rework the service model with extra 
transitional states (initing, starting, stopping), the way some service 
lifecycles do (such as 
[Guava|https://code.google.com/p/guava-libraries/wiki/ServiceExplained]. That 
gets to break everything as it is a major change in the service model.

bq. the current usage pattern of adding services followed by a call to 
super.serviceInit() will remain valid?

yes, and I went through the entire source tree looking at every single place 
the calls were being made to see what was going on. 

This is the lowest risk patch: it doesn't change any of the semantics of adding 
a service, merely guarantees there are  no re-entrancy problems. Anything more 
sophisticated breaks things.

> CompositeService should allow adding services while being inited
> ----------------------------------------------------------------
>
>                 Key: HADOOP-10085
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10085
>             Project: Hadoop Common
>          Issue Type: Improvement
>    Affects Versions: 2.2.0
>            Reporter: Karthik Kambatla
>            Assignee: Steve Loughran
>         Attachments: HADOOP-10085-002.patch, HADOOP-10085-003.patch, 
> HADOOP-10085-004.patch
>
>
> We can add services to a CompositeService. However, if we do that while 
> initing the CompositeService, it leads to a ConcurrentModificationException.
> It would be nice to allow adding services even during the init of 
> CompositeService.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to