Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-7704

JsonFactory can be created only once and used for every next request to create JsonGenerator inside JMXJsonServlet

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.24.0
    • 2.0.0-alpha
    • None
    • None
    • Reviewed
    • Reduce number of object created by JMXJsonServlet. (Devaraj K via Eric Yang)

    Description

      1. Currently JMXJsonServlet creates JsonFactory for every http request.
      Its not efficient.
      JsonFactory can be created only once and used for every next request to create JsonGenerator.

      2. Also following null check is not required.

       if (mBeanServer == null) {
              jg.writeStringField("result", "ERROR");
              jg.writeStringField("message", "No MBeanServer could be found");
              jg.close();
              LOG.error("No MBeanServer could be found.");
              response.setStatus(HttpServletResponse.SC_NOT_FOUND);
              return;
       }
      

      Because ManagementFactory.getPlatformMBeanServer(); will not return null.

      3. Move the following code to finally so that any exception should not cause skipping of close method on JsonGenerator

      jg.close();
      

      Attachments

        1. MAPREDUCE-3129.patch
          4 kB
          Devaraj Kavali
        2. HADOOP-7704.patch
          4 kB
          Devaraj Kavali

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            devaraj Devaraj Kavali
            devaraj Devaraj Kavali
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment