hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Loughran (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-10085) CompositeService should allow adding services while being inited
Date Wed, 06 Nov 2013 19:34:17 GMT

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

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

I would propose
# clone the list before doing the iteration -that way, changes in the list do not affect the
ongoing interation.
# simply add a check to addService() that the service must be in the same role as the service
is itself.

{code}
  protected void addService(Service service) {
    if (service.getServiceState() != getServiceState()) {
     throw new RuntimeException("Cannot add ... ")
   }
    if (LOG.isDebugEnabled()) {
      LOG.debug("Adding service " + service.getName());
    }
    synchronized (serviceList) {
      serviceList.add(service);
    }
  }
{code}

We could be more generous and allow you to add services later on in the lifecycle, making
the check {{service.getServiceState() != getServiceState()}}.

I actually think this may be an-unnoticed bug in the code today: I could add a service in
state UNINITED during my own code's init, 

{code}

  protected void serviceInit() throws Exception {
    super.serviceInit();
    addService(new CompositeService());  
  }
{code}

call start() on my service, it will try to start the service, which is in the wrong state.

> 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)

Mime
View raw message