[
https://issues.apache.org/jira/browse/HADOOP-10085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13816254#comment-13816254
]
Steve Loughran commented on HADOOP-10085:
-----------------------------------------
I'm just doing the tests for this and the fixes. Stopping the concurrency
condition is trivial (indeed, the javadocs imply I thought creating an
UnmodifiableList() around a service list did this. Moving to a clone is the
solution.
With that fix, you do get a stack trace after you add a service that is behind
the state of parent, in the specific case that the parent is in inited or
uninited
{code}
testAddUninitedSiblingInInit(org.apache.hadoop.service.TestCompositeService)
Time elapsed: 0.035 sec <<< ERROR!
org.apache.hadoop.service.ServiceStateException: BreakableService cannot enter
state STARTED from state NOTINITED
at
org.apache.hadoop.service.ServiceStateModel.checkStateTransition(ServiceStateModel.java:129)
at
org.apache.hadoop.service.ServiceStateModel.enterState(ServiceStateModel.java:111)
at
org.apache.hadoop.service.AbstractService.start(AbstractService.java:190)
at
org.apache.hadoop.service.CompositeService.serviceStart(CompositeService.java:126)
at
org.apache.hadoop.service.AbstractService.start(AbstractService.java:193)
at
org.apache.hadoop.service.TestCompositeService.testAddUninitedSiblingInInit(TestCompositeService.java:358)
{code}
You get a similar stack trace if any service adds a child to a composite that
is not in the current state -or in the one next (because it is not an error to
call start() from the started state -it's just a no-op.
{code}
Running org.apache.hadoop.service.TestCompositeService
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.184 sec <<<
FAILURE! - in org.apache.hadoop.service.TestCompositeService
testAddStartedChildBeforeInit(org.apache.hadoop.service.TestCompositeService)
Time elapsed: 0.037 sec <<< ERROR!
org.apache.hadoop.service.ServiceStateException: BreakableService cannot enter
state INITED from state STARTED
at
org.apache.hadoop.service.ServiceStateModel.checkStateTransition(ServiceStateModel.java:129)
at
org.apache.hadoop.service.ServiceStateModel.enterState(ServiceStateModel.java:111)
at
org.apache.hadoop.service.AbstractService.enterState(AbstractService.java:449)
at
org.apache.hadoop.service.AbstractService.init(AbstractService.java:160)
at
org.apache.hadoop.service.CompositeService.serviceInit(CompositeService.java:113)
at
org.apache.hadoop.service.AbstractService.init(AbstractService.java:163)
at
org.apache.hadoop.service.TestCompositeService.testAddStartedChildBeforeInit(TestCompositeService.java:371)
testAddStoppedChildBeforeInit(org.apache.hadoop.service.TestCompositeService)
Time elapsed: 0.036 sec <<< ERROR!
org.apache.hadoop.service.ServiceStateException: BreakableService cannot enter
state INITED from state STOPPED
at
org.apache.hadoop.service.ServiceStateModel.checkStateTransition(ServiceStateModel.java:129)
at
org.apache.hadoop.service.ServiceStateModel.enterState(ServiceStateModel.java:111)
at
org.apache.hadoop.service.AbstractService.enterState(AbstractService.java:449)
at
org.apache.hadoop.service.AbstractService.init(AbstractService.java:160)
at
org.apache.hadoop.service.CompositeService.serviceInit(CompositeService.java:113)
at
org.apache.hadoop.service.AbstractService.init(AbstractService.java:163)
at
org.apache.hadoop.service.TestCompositeService.testAddStoppedChildBeforeInit(TestCompositeService.java:384)
{code}
While we could have this inconsistent child problem picked up in the
{{addService()}} call -though there is a risk that someone may be adding
started services during the init phase -which is legitimate and harmless today,
but an error if a strict child state == parent state check was added.
> 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
>
> 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)