> On Dec. 30, 2014, 9:36 a.m., Robert Levas wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java,
> >  line 410
> > <https://reviews.apache.org/r/29480/diff/1/?file=803370#file803370line410>
> >
> >     Isn't `clusterName` from line 405 relevant here? Looking at lines 
> > 421-423 `request.getClusterName()` could be null or empty.
> >     
> >     The logic seems to be a bit confusing.
> >     
> >     Maybe something like line 406 belongs inside the loop?
> 
> Dmytro Shkvyra wrote:
>     In this function we can update hostComponents only for one cluster.
>     We can add null or "" value to the clusterNames and clusterNames.size() 
> will be more than 1 and that will cause exception.
>     Root cause of issue is that UI can send requests with wrong predicates, 
> it caused empty requests parameter, so clusterNames set was empty, but we 
> already have cluster name in parameter "requestProperties".
>     Parameter "requestProperties" have cluster name if this functionality 
> have been called via REST API, but if this functionality called inside ambari 
> requestProperties will be empty.
>     So, First of all I try get cluster name from requestProperties if they 
> are empty I'll try get cluster name from requests.

It seems like this is what you are looking to do?

```
... 
for (ServiceComponentHostRequest request : requests) {
         validateServiceComponentHostRequest(request);
         
         String clusterName = request.getClusterName()
         
         if((clusterName == null) || clusterName.isEmpty) {
                clusterName = 
requestProperties.get(RequestOperationLevel.OPERATION_CLUSTER_ID);
         }
         
         // Do we throw an exception if clusterName is null or empty?
                 
         Cluster cluster = clusters.getCluster(clusterName);

         if (StringUtils.isEmpty(request.getServiceName())) {
        
request.setServiceName(getManagementController().findServiceName(cluster, 
request.getComponentName()));
     }

     ServiceComponent sc = getServiceComponent(
                clusterName, request.getServiceName(), 
request.getComponentName());

        logRequestInfo("Received a updateHostComponent request", request);

    if((clusterName != null && !clusterName.isEmpty()) { 
      clusterNames.add(clusterName);
        }
    
    ...    
```


- Robert


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/29480/#review66363
-----------------------------------------------------------


On Dec. 30, 2014, 6:01 a.m., Dmitro Lisnichenko wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/29480/
> -----------------------------------------------------------
> 
> (Updated Dec. 30, 2014, 6:01 a.m.)
> 
> 
> Review request for Ambari, Dmytro Sen, John Speidel, and Nate Cole.
> 
> 
> Bugs: AMBARI-8952
>     https://issues.apache.org/jira/browse/AMBARI-8952
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> STR:
> 
> 1. Deploy single-node cluster. Select only ZK on services page.
> 2. Add new host to cluster
> 
> Get 500 error. Did not face that when adding new host to 2-node cluster with 
> core services (HDFS, Yarn + MapReduce2, Ganglia, HBase, Hive (has 
> dependencies on Pig & Tez), Zookeeper, Ganglia.). So the issue may be 
> component-dependent.
> {code}
> 14:48:02,569  WARN [qtp2130180018-24] ServletHandler:514 - 
> /api/v1/clusters/cc/host_components
> java.util.NoSuchElementException
>         at java.util.HashMap$HashIterator.nextEntry(HashMap.java:925)
>         at java.util.HashMap$KeyIterator.next(HashMap.java:956)
>         at 
> org.apache.ambari.server.controller.internal.HostComponentResourceProvider.updateHostComponents(HostComponentResourceProvider.java:541)
>         at 
> org.apache.ambari.server.controller.internal.HostComponentResourceProvider$4.invoke(HostComponentResourceProvider.java:619)
>         at 
> org.apache.ambari.server.controller.internal.HostComponentResourceProvider$4.invoke(HostComponentResourceProvider.java:616)
>         at 
> org.apache.ambari.server.controller.internal.AbstractResourceProvider.modifyResources(AbstractResourceProvider.java:331)
>         at 
> org.apache.ambari.server.controller.internal.HostComponentResourceProvider.doUpdateResources(HostComponentResourceProvider.java:616)
>         at 
> org.apache.ambari.server.controller.internal.HostComponentResourceProvider.updateResources(HostComponentResourceProvider.java:259)
>         at 
> org.apache.ambari.server.controller.internal.ClusterControllerImpl.updateResources(ClusterControllerImpl.java:317)
>         at 
> org.apache.ambari.server.api.services.persistence.PersistenceManagerImpl.update(PersistenceManagerImpl.java:100)
>         at 
> org.apache.ambari.server.api.handlers.UpdateHandler.persist(UpdateHandler.java:42)
>         at 
> org.apache.ambari.server.api.handlers.BaseManagementHandler.handleRequest(BaseManagementHandler.java:72)
>         at 
> org.apache.ambari.server.api.services.BaseRequest.process(BaseRequest.java:135)
>         at 
> org.apache.ambari.server.api.services.BaseService.handleRequest(BaseService.java:103)
>         at 
> org.apache.ambari.server.api.services.BaseService.handleRequest(BaseService.java:72)
>         at 
> org.apache.ambari.server.api.services.HostComponentService.updateHostComponents(HostComponentService.java:183)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:606)
>         at 
> com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
>         at 
> com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatc
> hProvider.java:205)
>         at 
> com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
>         at 
> com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
>         at 
> com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
>         at 
> com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
>         at 
> com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
>         at 
> com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
>         at 
> com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
>         at 
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
>         at 
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
>         at 
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
>         at 
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
>         at 
> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
>         at 
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
>         at 
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>         at 
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1329)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
>         at 
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
>         at 
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>         at 
> org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>         at 
> org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
>         at 
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>         at 
> org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
> {code}
> 
> 
> Diffs
> -----
> 
>   
> ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
>  a6c95f5 
>   
> ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
>  f5521f9 
> 
> Diff: https://reviews.apache.org/r/29480/diff/
> 
> 
> Testing
> -------
> 
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Reactor Summary:
> [INFO] 
> [INFO] Ambari Views ...................................... SUCCESS [8.825s]
> [INFO] Ambari Server ..................................... SUCCESS 
> [31:56.554s]
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Total time: 32:07.709s
> [INFO] Finished at: Tue Dec 30 13:59:03 FET 2014
> [INFO] Final Memory: 30M/224M
> [INFO] 
> ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Dmitro Lisnichenko
> 
>

Reply via email to