Yiqun Lin created HDFS-10658:
--------------------------------

             Summary: Reduce JsonFactory instance allocation in 
StartupProgressServlet
                 Key: HDFS-10658
                 URL: https://issues.apache.org/jira/browse/HDFS-10658
             Project: Hadoop HDFS
          Issue Type: Bug
            Reporter: Yiqun Lin
            Assignee: Yiqun Lin


Now in class {{StartupProgressServlet}}, it will always create a new 
{{JsonFactory}} instance to create a JsonGenerator. The codes:
{code}
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    resp.setContentType("application/json; charset=UTF-8");
    StartupProgress prog = NameNodeHttpServer.getStartupProgressFromContext(
      getServletContext());
    StartupProgressView view = prog.createView();
    JsonGenerator json = new 
JsonFactory().createJsonGenerator(resp.getWriter());
    try {
      json.writeStartObject();
      json.writeNumberField(ELAPSED_TIME, view.getElapsedTime());
      json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete());
      json.writeArrayFieldStart(PHASES);
      ...
{code}
We can reuse the instance and reduce {{JsonFactory instance}} allocation.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org

Reply via email to