[
https://issues.apache.org/jira/browse/HADOOP-10085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13821442#comment-13821442
]
Steve Loughran commented on HADOOP-10085:
-----------------------------------------
I've been through all the hadoop-trunk code & looked at when {{addService()} is
called. Mostly its called in {{serviceInit()}} before a call to
{{super.serviceInit()}} -adding UNINITED services which get inited during the
loop through the children. {{ResourceManager}} is the busiest class here.
{{ContainerManagerImpl }}adds a service in its constructor which is mildly
hazardous as if that method were overridden in a test subclass then the
subclass would be in use before it had fully constructed. That doesn't impact
service states though.
now, some fun arises in calling {{addService()}} in your {{serviceInit()}}
operation, because although the run through to init the child services hasn't
started yet (i.e. the operations to move the children from UNINITED -> INITED,
the parent is already in the INITED state. A check to validate that you can add
an UNINITED service fails, because the parent is actually mid-init.
There's no easy solution here, so I propose
# don't implement any checks on service state when adding a child.
# if you do a state transition that isn't legal, you'll find out at the time.
# we make the new tests verify today's operation: you can insert children in
any state, but when the parent tries to enter any state other than stopped, if
there is a mismatch in versions a {{ServiceStateException}} gets thrown.
> 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
>
>
> 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#6144)