Java Code Examples for org.apache.hadoop.http.HttpServer2#isInstrumentationAccessAllowed()

The following examples show how to use org.apache.hadoop.http.HttpServer2#isInstrumentationAccessAllowed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HddsConfServlet.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
      request, response)) {
    return;
  }

  String format = parseAcceptHeader(request);
  if (FORMAT_XML.equals(format)) {
    response.setContentType("text/xml; charset=utf-8");
  } else if (FORMAT_JSON.equals(format)) {
    response.setContentType("application/json; charset=utf-8");
  }

  String name = request.getParameter("name");
  Writer out = response.getWriter();
  String cmd = request.getParameter(COMMAND);

  processCommand(cmd, format, request, response, out, name);
  out.close();
}
 
Example 2
Source File: ConfServlet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
                                                 request, response)) {
    return;
  }

  String format = request.getParameter(FORMAT_PARAM);
  if (null == format) {
    format = FORMAT_XML;
  }

  if (FORMAT_XML.equals(format)) {
    response.setContentType("text/xml; charset=utf-8");
  } else if (FORMAT_JSON.equals(format)) {
    response.setContentType("application/json; charset=utf-8");
  }

  Writer out = response.getWriter();
  try {
    writeResponse(getConfFromContext(), out, format);
  } catch (BadFormatException bfe) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, bfe.getMessage());
  }
  out.close();
}
 
Example 3
Source File: ConfServlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
                                                 request, response)) {
    return;
  }

  String format = request.getParameter(FORMAT_PARAM);
  if (null == format) {
    format = FORMAT_XML;
  }

  if (FORMAT_XML.equals(format)) {
    response.setContentType("text/xml; charset=utf-8");
  } else if (FORMAT_JSON.equals(format)) {
    response.setContentType("application/json; charset=utf-8");
  }

  Writer out = response.getWriter();
  try {
    writeResponse(getConfFromContext(), out, format);
  } catch (BadFormatException bfe) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, bfe.getMessage());
  }
  out.close();
}
 
Example 4
Source File: JMXJsonServlet.java    From hadoop with Apache License 2.0 4 votes vote down vote up
protected boolean isInstrumentationAccessAllowed(HttpServletRequest request,
    HttpServletResponse response) throws IOException {
  return HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
      request, response);
}
 
Example 5
Source File: JMXJsonServlet.java    From big-c with Apache License 2.0 4 votes vote down vote up
protected boolean isInstrumentationAccessAllowed(HttpServletRequest request,
    HttpServletResponse response) throws IOException {
  return HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
      request, response);
}