Uploaded image for project: 'Hadoop YARN'
  1. Hadoop YARN
  2. YARN-11367

[Federation] Fix DefaultRequestInterceptorREST Client NPE

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      YARN-8529. Add timeout to RouterWebServiceUtil#invokeRMWebService.

      This JIRA only considers the case of Create InterceptorChain, and initializes the client in the DefaultRequestInterceptorREST#init method

      @Override
      public void init(String user) {
        webAppAddress = WebAppUtils.getRMWebAppURLWithScheme(getConf());
        client = RouterWebServiceUtil.createJerseyClient(getConf());
      } 

      However, FederationInterceptorREST#createInterceptorForSubCluster will create DefaultRequestInterceptorREST of different SubClusters. This part does not initialize the Client, resulting in NPE when calling.

      private DefaultRequestInterceptorREST createInterceptorForSubCluster(
          SubClusterId subClusterId, String webAppAddress) {
      
        final Configuration conf = this.getConf();
      
        String interceptorClassName = conf.get(
            YarnConfiguration.ROUTER_WEBAPP_DEFAULT_INTERCEPTOR_CLASS,
            YarnConfiguration.DEFAULT_ROUTER_WEBAPP_DEFAULT_INTERCEPTOR_CLASS);
        DefaultRequestInterceptorREST interceptorInstance = null;
        try {
          Class<?> interceptorClass = conf.getClassByName(interceptorClassName);
          if (DefaultRequestInterceptorREST.class
              .isAssignableFrom(interceptorClass)) {
            interceptorInstance = (DefaultRequestInterceptorREST) ReflectionUtils
                .newInstance(interceptorClass, conf);
      
          } else {
            throw new YarnRuntimeException(
                "Class: " + interceptorClassName + " not instance of "
                    + DefaultRequestInterceptorREST.class.getCanonicalName());
          }
        } catch (ClassNotFoundException e) {
          throw new YarnRuntimeException(
              "Could not instantiate ApplicationMasterRequestInterceptor: "
                  + interceptorClassName,
              e);
        }
      
        String webAppAddresswithScheme =
            WebAppUtils.getHttpSchemePrefix(this.getConf()) + webAppAddress;
        interceptorInstance.setWebAppAddress(webAppAddresswithScheme);
        interceptorInstance.setSubClusterId(subClusterId);
        // Missing initialization DefaultRequestInterceptorREST#Client Code  
        interceptors.put(subClusterId, interceptorInstance);
        return interceptorInstance;
      } 

       

      Attachments

        Issue Links

          Activity

            People

              slfan1989 Shilun Fan
              slfan1989 Shilun Fan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: